use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.
the class QueryTest method testMultipleConflictingQueries2.
@Test
public void testMultipleConflictingQueries2() {
Query queryA = StatzUtil.makeQuery("UUID", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", 100);
Query queryB = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", 100);
Query queryC = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", 200);
Query queryD = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", 500);
Query queryE = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", 100);
Query queryF = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "PIG", "value", 100);
List<Query> conflictingQueries = new ArrayList<>();
conflictingQueries.add(queryB);
conflictingQueries.add(queryC);
conflictingQueries.add(queryD);
conflictingQueries.add(queryE);
conflictingQueries.add(queryF);
Query nonConflictingQuery = queryA.resolveConflicts(conflictingQueries);
Assert.assertEquals(1000, nonConflictingQuery.getValue(), 0);
}
use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.
the class QueryTest method testConflictingQuery2.
// Same number of columns and UUIDs are the same, ignoring value column
@Test
public void testConflictingQuery2() {
Query queryA = StatzUtil.makeQuery("UUID", "3657b9cc-2518-4265-ad69-323e11286ce2", "value", 5);
Query queryB = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "value", 5498);
checkConflict(queryA, queryB, true);
}
use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.
the class QueryTest method testRobustnessResolveConflictingQueries.
// Queries are not conflicting, so cannot resolve.
@Test(expected = IllegalArgumentException.class)
public void testRobustnessResolveConflictingQueries() {
Query queryA = StatzUtil.makeQuery("UUID", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", 100);
Query queryB = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "Chicken", "value", -6);
queryA.resolveConflict(queryB).getValue();
}
use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.
the class PlayerInfoTest method testResolvePlayerInfo5.
// Test two conflicting (of same statType) and two non conflicting (of another statType, that conflict with each
// other).
@Test
public void testResolvePlayerInfo5() {
UUID uuid = UUID.fromString("3657b9cc-2518-4265-ad69-323e11286ce2");
PlayerStat statType = PlayerStat.ARROWS_SHOT;
PlayerStat statType2 = PlayerStat.KILLS_MOBS;
PlayerInfo playerInfo = new PlayerInfo(uuid);
PlayerInfo playerInfo2 = new PlayerInfo(uuid);
Query queryA = StatzUtil.makeQuery("UUID", uuid, "World", "worldName1", "value", 5);
Query queryB = StatzUtil.makeQuery("UUID", uuid, "World", "worldName1", "value", 6);
Query queryC = StatzUtil.makeQuery("UUID", uuid, "World", "worldName2", "value", 8);
Query queryD = StatzUtil.makeQuery("UUID", uuid, "World", "worldName2", "value", 45);
Query queryE = StatzUtil.makeQuery("UUID", uuid, "World", "worldName3", "value", 100);
playerInfo.addRow(statType, queryA);
playerInfo2.addRow(statType, queryB);
playerInfo2.addRow(statType2, queryC);
playerInfo.addRow(statType2, queryD);
playerInfo.addRow(statType, queryE);
PlayerInfo nonConflictingPlayerInfo = playerInfo.resolveConflicts(playerInfo2);
// Verify the number of rows
Assert.assertEquals(2, nonConflictingPlayerInfo.getNumberOfRows(statType));
Assert.assertEquals(1, nonConflictingPlayerInfo.getNumberOfRows(statType2));
// Verify the number of statistics stored.
Assert.assertEquals(2, nonConflictingPlayerInfo.getNumberOfStatistics());
// Verify that value is correct
Assert.assertEquals(111, nonConflictingPlayerInfo.getTotalValue(statType), 0);
Assert.assertEquals(53, nonConflictingPlayerInfo.getTotalValue(statType2), 0);
}
use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.
the class PlayerInfoTest method testResolvePlayerInfo2.
// Test with two conflicting and one non-conflicting query
@Test
public void testResolvePlayerInfo2() {
UUID uuid = UUID.fromString("3657b9cc-2518-4265-ad69-323e11286ce2");
PlayerStat statType = PlayerStat.ARROWS_SHOT;
PlayerInfo playerInfo = new PlayerInfo(uuid);
PlayerInfo playerInfo2 = new PlayerInfo(uuid);
Query queryA = StatzUtil.makeQuery("UUID", uuid, "World", "worldName1", "value", 5);
Query queryB = StatzUtil.makeQuery("UUID", uuid, "World", "worldName1", "value", 6);
Query queryC = StatzUtil.makeQuery("UUID", uuid, "World", "worldName2", "value", 8);
playerInfo.addRow(statType, queryA);
playerInfo2.addRow(statType, queryB);
playerInfo2.addRow(statType, queryC);
PlayerInfo nonConflictingPlayerInfo = playerInfo.resolveConflicts(playerInfo2);
// Verify that there is only 1 row
Assert.assertEquals(2, nonConflictingPlayerInfo.getNumberOfRows(statType));
// Verify that there is only 1 statistic stored
Assert.assertEquals(1, nonConflictingPlayerInfo.getNumberOfStatistics());
// Verify that value is correct
Assert.assertEquals(19, nonConflictingPlayerInfo.getTotalValue(statType), 0);
}
Aggregations