test SQLStore
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="DailyRespectTask">
|
<mapper namespace="DailyRespectTask">
|
||||||
|
|
||||||
<resultMap id = "result" type = "DailyRespectTask">
|
<resultMap id="result" type="DailyRespectTaskEntity">
|
||||||
<result property = "uuid" column = "UUID"/>
|
<result property = "uuid" column = "UUID"/>
|
||||||
<result property = "cooldownRespect" column = "COOLDOWN"/>
|
<result property = "cooldownRespect" column = "COOLDOWN"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
VALUES (#{name}, #{uuid}, #{cooldown})
|
VALUES (#{name}, #{uuid}, #{cooldown})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="update" parameterType="DailyRespectTask">
|
<update id="update" parameterType="DailyRespectTaskEntity">
|
||||||
UPDATE daily_respect_task
|
UPDATE daily_respect_task
|
||||||
SET COOLDOWN = #{cooldownRespect}
|
SET COOLDOWN = #{cooldownRespect}
|
||||||
WHERE UUID = #{uuid};
|
WHERE UUID = #{uuid};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="PlayerStats">
|
<mapper namespace="PlayerStats">
|
||||||
|
|
||||||
<resultMap id = "result" type = "PlayerStats">
|
<resultMap id="result" type="PlayerStatsEntity">
|
||||||
<result property = "uuid" column = "UUID"/>
|
<result property = "uuid" column = "UUID"/>
|
||||||
<result property = "wallet" column = "WALLET"/>
|
<result property = "wallet" column = "WALLET"/>
|
||||||
<result property = "faction" column = "FACTION"/>
|
<result property = "faction" column = "FACTION"/>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
VALUES (#{name}, #{uuid}, 1, 0, 'NONE', 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
VALUES (#{name}, #{uuid}, 1, 0, 'NONE', 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="update" parameterType="PlayerStats">
|
<update id="update" parameterType="PlayerStatsEntity">
|
||||||
UPDATE player_stats
|
UPDATE player_stats
|
||||||
SET WALLET = #{wallet},
|
SET WALLET = #{wallet},
|
||||||
FACTION = #{faction},
|
FACTION = #{faction},
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="PlayersInCages">
|
<mapper namespace="PlayersInCages">
|
||||||
|
|
||||||
<resultMap id = "result" type = "PlayersInCages">
|
<resultMap id="result" type="PlayersInCagesEntity">
|
||||||
<result property = "name" column = "NAME"/>
|
<result property = "name" column = "NAME"/>
|
||||||
<result property = "uuid" column = "UUID"/>
|
<result property = "uuid" column = "UUID"/>
|
||||||
<result property = "timeInCage" column = "TIME_IN_CAGE"/>
|
<result property = "timeInCage" column = "TIME_IN_CAGE"/>
|
||||||
<result property = "blocksLeft" column = "BLOCKS_LEFT"/>
|
<result property = "blocksLeft" column = "BLOCKS_LEFT"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectOne" parameterType="String" resultMap="PlayersInCages">
|
<select id="selectOne" parameterType="String" resultMap="result">
|
||||||
SELECT * FROM players_in_cages WHERE UUID = #{id}
|
SELECT * FROM players_in_cages WHERE UUID = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
SELECT TIME_IN_CAGE FROM players_in_cages WHERE UUID = #{id}
|
SELECT TIME_IN_CAGE FROM players_in_cages WHERE UUID = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="register" parameterType="PlayersInCages">
|
<insert id="register" parameterType="PlayersInCagesEntity">
|
||||||
INSERT INTO players_in_cages (NAME, UUID, TIME_IN_CAGE, BLOCKS_LEFT)
|
INSERT INTO players_in_cages (NAME, UUID, TIME_IN_CAGE, BLOCKS_LEFT)
|
||||||
VALUES (#{name}, #{uuid}, #{timeInCage}, #{blocksLeft})
|
VALUES (#{name}, #{uuid}, #{timeInCage}, #{blocksLeft})
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
|
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
<configuration>
|
<configuration>
|
||||||
|
|
||||||
|
<typeAliases>
|
||||||
|
<typeAlias alias="PlayerStatsEntity" type="ru.prisonlife.api.store.PlayerStatsEntity"/>
|
||||||
|
<typeAlias alias="DailyRespectTaskEntity" type="ru.prisonlife.api.store.DailyRespectTaskEntity"/>
|
||||||
|
<typeAlias alias="PlayersInCagesEntity" type="ru.prisonlife.api.store.PlayersInCagesEntity"/>
|
||||||
|
</typeAliases>
|
||||||
|
|
||||||
<environments default="main">
|
<environments default="main">
|
||||||
<environment id="main">
|
<environment id="main">
|
||||||
<transactionManager type="JDBC"/>
|
<transactionManager type="JDBC"/>
|
||||||
@@ -15,9 +21,9 @@
|
|||||||
</environments>
|
</environments>
|
||||||
|
|
||||||
<mappers>
|
<mappers>
|
||||||
<mapper resource = "PlayerStatsMapper.xml"/>
|
<mapper resource = "ru/prisonlife/api/store/PlayerStatsMapper.xml"/>
|
||||||
<mapper resource = "DailyRespectTaskMapper.xml"/>
|
<mapper resource = "ru/prisonlife/api/store/DailyRespectTaskMapper.xml"/>
|
||||||
<mapper resource = "PlayersInCagesMapper.xml"/>
|
<mapper resource = "ru/prisonlife/api/store/PlayersInCagesMapper.xml"/>
|
||||||
</mappers>
|
</mappers>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
24
src/test/java/ru/prisonlife/api/store/SQLStoreTest.java
Normal file
24
src/test/java/ru/prisonlife/api/store/SQLStoreTest.java
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user