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