From 7904c710265a03b918e52f394e8df38470a8638d Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Sun, 17 Mar 2019 21:05:19 +0300 Subject: [PATCH] test SQLStore --- .../api/store/DailyRespectTaskMapper.xml | 4 ++-- .../api/store/PlayerStatsMapper.xml | 4 ++-- .../api/store/PlayersInCagesMapper.xml | 6 ++--- .../ru/prisonlife/api/store/config.xml | 12 +++++++--- .../ru/prisonlife/api/store/SQLStoreTest.java | 24 +++++++++++++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 src/test/java/ru/prisonlife/api/store/SQLStoreTest.java diff --git a/src/main/resources/ru/prisonlife/api/store/DailyRespectTaskMapper.xml b/src/main/resources/ru/prisonlife/api/store/DailyRespectTaskMapper.xml index 3ba164d..6d0b541 100644 --- a/src/main/resources/ru/prisonlife/api/store/DailyRespectTaskMapper.xml +++ b/src/main/resources/ru/prisonlife/api/store/DailyRespectTaskMapper.xml @@ -2,7 +2,7 @@ - + @@ -16,7 +16,7 @@ VALUES (#{name}, #{uuid}, #{cooldown}) - + UPDATE daily_respect_task SET COOLDOWN = #{cooldownRespect} WHERE UUID = #{uuid}; diff --git a/src/main/resources/ru/prisonlife/api/store/PlayerStatsMapper.xml b/src/main/resources/ru/prisonlife/api/store/PlayerStatsMapper.xml index 79a9a0f..85ed322 100644 --- a/src/main/resources/ru/prisonlife/api/store/PlayerStatsMapper.xml +++ b/src/main/resources/ru/prisonlife/api/store/PlayerStatsMapper.xml @@ -2,7 +2,7 @@ - + @@ -32,7 +32,7 @@ VALUES (#{name}, #{uuid}, 1, 0, 'NONE', 0, 0, 0, 0, 0, 0, 0, 0, 0) - + UPDATE player_stats SET WALLET = #{wallet}, FACTION = #{faction}, diff --git a/src/main/resources/ru/prisonlife/api/store/PlayersInCagesMapper.xml b/src/main/resources/ru/prisonlife/api/store/PlayersInCagesMapper.xml index 082d764..42d7dc7 100644 --- a/src/main/resources/ru/prisonlife/api/store/PlayersInCagesMapper.xml +++ b/src/main/resources/ru/prisonlife/api/store/PlayersInCagesMapper.xml @@ -2,14 +2,14 @@ - + - SELECT * FROM players_in_cages WHERE UUID = #{id} @@ -17,7 +17,7 @@ SELECT TIME_IN_CAGE FROM players_in_cages WHERE UUID = #{id} - + INSERT INTO players_in_cages (NAME, UUID, TIME_IN_CAGE, BLOCKS_LEFT) VALUES (#{name}, #{uuid}, #{timeInCage}, #{blocksLeft}) diff --git a/src/main/resources/ru/prisonlife/api/store/config.xml b/src/main/resources/ru/prisonlife/api/store/config.xml index c0ace7b..ebf567a 100644 --- a/src/main/resources/ru/prisonlife/api/store/config.xml +++ b/src/main/resources/ru/prisonlife/api/store/config.xml @@ -2,6 +2,12 @@ + + + + + + @@ -15,9 +21,9 @@ - - - + + + \ No newline at end of file diff --git a/src/test/java/ru/prisonlife/api/store/SQLStoreTest.java b/src/test/java/ru/prisonlife/api/store/SQLStoreTest.java new file mode 100644 index 0000000..c011e34 --- /dev/null +++ b/src/test/java/ru/prisonlife/api/store/SQLStoreTest.java @@ -0,0 +1,24 @@ +package ru.prisonlife.api.store; + +import org.apache.ibatis.session.SqlSession; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SQLStoreTest { + + @Test + public void testCreate() { + SQLStore sqlStore = new SQLStore( + "jdbc:h2:mem:testDb", + "sa", + "" + ); + + assertNotNull(sqlStore); + + try (SqlSession sqlSession = sqlStore.openSession()) { + assertNotNull(sqlSession); + } + } +} \ No newline at end of file