Search in sources :

Example 21 with Query

use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.

the class QueryTest method testMultipleConflictingQueries3.

@Test
public void testMultipleConflictingQueries3() {
    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);
    List<Query> conflictingQueries = new ArrayList<>();
    conflictingQueries.add(queryB);
    conflictingQueries.add(queryC);
    conflictingQueries.add(queryD);
    conflictingQueries.add(queryE);
    Query nonConflictingQuery = queryA.resolveConflicts(conflictingQueries);
    Assert.assertEquals(400, nonConflictingQuery.getValue(), 0);
}
Also used : Query(me.staartvin.statz.database.datatype.Query) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 22 with Query

use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.

the class QueryTest method testRobustnessResolveConflictingQueries3.

// A query does not have value column
@Test(expected = IllegalArgumentException.class)
public void testRobustnessResolveConflictingQueries3() {
    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");
    PlayerInfo info = new PlayerInfo(UUID.fromString("3657b9cc-2518-4265-ad69-323e11286ce2"));
    List<Query> list = new ArrayList<>();
    list.add(queryA);
    list.add(queryB);
    info.setData(PlayerStat.KILLS_MOBS, list);
    info.setData(PlayerStat.ITEMS_DROPPED, list);
    queryA.resolveConflict(queryB).getValue();
}
Also used : Query(me.staartvin.statz.database.datatype.Query) PlayerInfo(me.staartvin.statz.datamanager.player.PlayerInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with Query

use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.

the class QueryTest method testNonConflictingQuery2.

// UUIDs are different
@Test
public void testNonConflictingQuery2() {
    Query queryA = StatzUtil.makeQuery("UUID", "3657b9cc-2518-4265-ad69-323e11286ce2", "World", "worldName1");
    Query queryB = StatzUtil.makeQuery("UUID", "c019cc4e-e9b9-4140-9cf5-07338a21659f", "World", "worldName1");
    checkConflict(queryA, queryB, false);
}
Also used : Query(me.staartvin.statz.database.datatype.Query) Test(org.junit.Test)

Example 24 with Query

use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.

the class QueryTest method testRobustnessAddValue2.

@Test(expected = NullPointerException.class)
public void testRobustnessAddValue2() {
    Query query = new Query();
    query.setValue("Existing-column", "Def value");
    query.addValue("Existing-column", null);
}
Also used : Query(me.staartvin.statz.database.datatype.Query) Test(org.junit.Test)

Example 25 with Query

use of me.staartvin.statz.database.datatype.Query in project Statz by Staartvin.

the class QueryTest method testRobustnessResolveConflictingQueries2.

// A query does not have value column
@Test(expected = IllegalArgumentException.class)
public void testRobustnessResolveConflictingQueries2() {
    Query queryA = StatzUtil.makeQuery("UUID", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW");
    Query queryB = StatzUtil.makeQuery("uuid", "3657b9cc-2518-4265-ad69-323e11286ce2", "mob", "COW", "value", -6);
    queryA.resolveConflict(queryB).getValue();
}
Also used : Query(me.staartvin.statz.database.datatype.Query) Test(org.junit.Test)

Aggregations

Query (me.staartvin.statz.database.datatype.Query)44 Test (org.junit.Test)25 PlayerInfo (me.staartvin.statz.datamanager.player.PlayerInfo)13 PlayerStat (me.staartvin.statz.datamanager.player.PlayerStat)11 ArrayList (java.util.ArrayList)8 UUID (java.util.UUID)6 RowRequirement (me.staartvin.statz.database.datatype.RowRequirement)4 HashMap (java.util.HashMap)2 Material (org.bukkit.Material)2 Player (org.bukkit.entity.Player)2 Inventory (org.bukkit.inventory.Inventory)2 ItemStack (org.bukkit.inventory.ItemStack)2 ItemMeta (org.bukkit.inventory.meta.ItemMeta)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1