mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-09-12 22:45:18 -04:00
+9
-1
@@ -46,7 +46,11 @@ sourceSets {
|
||||
}
|
||||
test {
|
||||
dependencies {
|
||||
testImplementation(group="junit", name="junit", version="4.13.2")
|
||||
val junit5Version = "5.8.1"
|
||||
testImplementation(group="org.junit.jupiter", name="junit-jupiter-api", version= junit5Version)
|
||||
testRuntimeOnly(group="org.junit.jupiter", name="junit-jupiter-engine", version= junit5Version)
|
||||
testImplementation(group="org.junit.jupiter", name="junit-jupiter-params", version= junit5Version)
|
||||
|
||||
testImplementation(group="org.mockito", name="mockito-core", version="3.8.0")
|
||||
}
|
||||
}
|
||||
@@ -97,3 +101,7 @@ tasks.create<JavaExec>("runDebug") {
|
||||
classpath = sourceSets.main.get().runtimeClasspath
|
||||
mainClass.set("com.projectswg.holocore.ProjectSWG")
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
+1
-1
Submodule pswgcommon updated: b31910d730...8a516676d7
+4
-4
@@ -36,8 +36,8 @@ import com.projectswg.holocore.resources.support.objects.swg.custom.AIObject
|
||||
import com.projectswg.holocore.resources.support.objects.swg.tangible.OptionFlag
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class TestEnemyProcessor: TestRunnerNoIntents() {
|
||||
|
||||
@@ -129,8 +129,8 @@ class TestEnemyProcessor: TestRunnerNoIntents() {
|
||||
|
||||
private fun testAttackable(player: CreatureObject, npc: CreatureObject, playerFaction: FactionLoader.Faction, npcFaction: FactionLoader.Faction, playerAttackable: Boolean, npcAttackable: Boolean) {
|
||||
player.faction = playerFaction; npc.faction = npcFaction
|
||||
Assert.assertEquals("${player.faction} ${if (playerAttackable) "is not" else "is"} able to attack ${npc.faction}", playerAttackable, EnemyProcessor.isAttackable(player, npc))
|
||||
Assert.assertEquals("${npc.faction} ${if (npcAttackable) "is not" else "is"} able to attack ${player.faction}", npcAttackable, EnemyProcessor.isAttackable(npc, player))
|
||||
assertEquals(playerAttackable, EnemyProcessor.isAttackable(player, npc), "${player.faction} ${if (playerAttackable) "is not" else "is"} able to attack ${npc.faction}")
|
||||
assertEquals(npcAttackable, EnemyProcessor.isAttackable(npc, player), "${npc.faction} ${if (npcAttackable) "is not" else "is"} able to attack ${player.faction}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -2,12 +2,12 @@ package com.projectswg.holocore.resources.gameplay.conversation.requirements;
|
||||
|
||||
import com.projectswg.holocore.resources.support.global.player.Player;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.player.PlayerObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ActiveQuestRequirementTest {
|
||||
private PlayerObject playerObject;
|
||||
private String questName;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
player = mock(Player.class);
|
||||
playerObject = mock(PlayerObject.class);
|
||||
|
||||
+20
-20
@@ -28,8 +28,8 @@ package com.projectswg.holocore.resources.gameplay.crafting.resource.raw;
|
||||
|
||||
import com.projectswg.holocore.resources.gameplay.crafting.resource.raw.RawResource.RawResourceBuilder;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestRawResource extends TestRunnerNoIntents {
|
||||
|
||||
@@ -45,15 +45,15 @@ public class TestRawResource extends TestRunnerNoIntents {
|
||||
.setRecycled(false)
|
||||
.setCrateTemplate("")
|
||||
.build();
|
||||
Assert.assertEquals("resource/resource_names", resource.getName().getFile());
|
||||
Assert.assertEquals("resource_name", resource.getName().getKey());
|
||||
Assert.assertNull(resource.getParent());
|
||||
Assert.assertEquals(15, resource.getMinPools());
|
||||
Assert.assertEquals(30, resource.getMaxPools());
|
||||
Assert.assertEquals(45, resource.getMinTypes());
|
||||
Assert.assertEquals(60, resource.getMaxTypes());
|
||||
Assert.assertEquals("", resource.getCrateTemplate());
|
||||
Assert.assertFalse(resource.isRecycled());
|
||||
assertEquals("resource/resource_names", resource.getName().getFile());
|
||||
assertEquals("resource_name", resource.getName().getKey());
|
||||
assertNull(resource.getParent());
|
||||
assertEquals(15, resource.getMinPools());
|
||||
assertEquals(30, resource.getMaxPools());
|
||||
assertEquals(45, resource.getMinTypes());
|
||||
assertEquals(60, resource.getMaxTypes());
|
||||
assertEquals("", resource.getCrateTemplate());
|
||||
assertFalse(resource.isRecycled());
|
||||
|
||||
RawResource child = new RawResourceBuilder(2)
|
||||
.setName("child_name")
|
||||
@@ -65,15 +65,15 @@ public class TestRawResource extends TestRunnerNoIntents {
|
||||
.setRecycled(true)
|
||||
.setCrateTemplate("")
|
||||
.build();
|
||||
Assert.assertEquals("resource/resource_names", child.getName().getFile());
|
||||
Assert.assertEquals("child_name", child.getName().getKey());
|
||||
Assert.assertEquals(resource, child.getParent());
|
||||
Assert.assertEquals(5, child.getMinPools());
|
||||
Assert.assertEquals(6, child.getMaxPools());
|
||||
Assert.assertEquals(7, child.getMinTypes());
|
||||
Assert.assertEquals(8, child.getMaxTypes());
|
||||
Assert.assertEquals("", child.getCrateTemplate());
|
||||
Assert.assertTrue(child.isRecycled());
|
||||
assertEquals("resource/resource_names", child.getName().getFile());
|
||||
assertEquals("child_name", child.getName().getKey());
|
||||
assertEquals(resource, child.getParent());
|
||||
assertEquals(5, child.getMinPools());
|
||||
assertEquals(6, child.getMaxPools());
|
||||
assertEquals(7, child.getMinTypes());
|
||||
assertEquals(8, child.getMaxTypes());
|
||||
assertEquals("", child.getCrateTemplate());
|
||||
assertTrue(child.isRecycled());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -27,8 +27,8 @@
|
||||
package com.projectswg.holocore.resources.gameplay.crafting.resource.raw;
|
||||
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestRawResourceContainer extends TestRunnerNoIntents {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TestRawResourceContainer extends TestRunnerNoIntents {
|
||||
public void testResourcesLoad() {
|
||||
RawResourceContainer loader = new RawResourceContainer();
|
||||
loader.loadResources();
|
||||
Assert.assertEquals(845, loader.getResources().size());
|
||||
assertEquals(845, loader.getResources().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-12
@@ -8,11 +8,10 @@ import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureOb
|
||||
import com.projectswg.holocore.resources.support.objects.swg.player.PlayerObject;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericPlayer;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestActivePlayerPredicate {
|
||||
|
||||
@@ -26,7 +25,7 @@ public class TestActivePlayerPredicate {
|
||||
private CreatureObject creatureObject;
|
||||
private PlayerObject playerObject;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
player = new GenericPlayer();
|
||||
creatureObject = new GenericCreatureObject(1);
|
||||
@@ -40,7 +39,7 @@ public class TestActivePlayerPredicate {
|
||||
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertFalse("AFK players should not be determined active", actual);
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,7 +48,7 @@ public class TestActivePlayerPredicate {
|
||||
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertFalse("LD players should not be determined active", actual);
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +57,7 @@ public class TestActivePlayerPredicate {
|
||||
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertFalse("Incapacitated players should not be determined active", actual);
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +66,7 @@ public class TestActivePlayerPredicate {
|
||||
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertFalse("Dead players should not be determined active", actual);
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,7 +75,7 @@ public class TestActivePlayerPredicate {
|
||||
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertFalse("Cloaked players should not be determined active", actual);
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,13 +86,13 @@ public class TestActivePlayerPredicate {
|
||||
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertFalse("Players inside private cells should not be determined active", actual);
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActive() {
|
||||
boolean actual = predicate.test(player);
|
||||
|
||||
assertTrue("Active player should not be determined inactive", actual);
|
||||
assertTrue(actual);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -33,8 +33,8 @@ import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,9 +43,9 @@ public class TestTravelHelper extends TestRunnerNoIntents {
|
||||
@Test
|
||||
public void testTravelGroups() {
|
||||
TravelHelper helper = new TravelHelper();
|
||||
Assert.assertNotNull(helper.getTravelGroup(SpecificObject.SO_TRANSPORT_SHUTTLE.getTemplate()));
|
||||
Assert.assertNotNull(helper.getTravelGroup(SpecificObject.SO_TRANSPORT_STARPORT.getTemplate()));
|
||||
Assert.assertNotNull(helper.getTravelGroup(SpecificObject.SO_TRANSPORT_STARPORT_THEED.getTemplate()));
|
||||
assertNotNull(helper.getTravelGroup(SpecificObject.SO_TRANSPORT_SHUTTLE.getTemplate()));
|
||||
assertNotNull(helper.getTravelGroup(SpecificObject.SO_TRANSPORT_STARPORT.getTemplate()));
|
||||
assertNotNull(helper.getTravelGroup(SpecificObject.SO_TRANSPORT_STARPORT_THEED.getTemplate()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,15 +58,15 @@ public class TestTravelHelper extends TestRunnerNoIntents {
|
||||
};
|
||||
TravelHelper helper = new TravelHelper();
|
||||
for (Terrain terrain : terrains) {
|
||||
Assert.assertEquals(100, helper.getTravelFee(terrain, terrain));
|
||||
assertEquals(100, helper.getTravelFee(terrain, terrain));
|
||||
}
|
||||
Assert.assertEquals(1250, helper.getTravelFee(Terrain.DATHOMIR, Terrain.CORELLIA));
|
||||
Assert.assertEquals(2000, helper.getTravelFee(Terrain.CORELLIA, Terrain.DATHOMIR));
|
||||
Assert.assertEquals(4000, helper.getTravelFee(Terrain.NABOO, Terrain.ENDOR));
|
||||
Assert.assertEquals(500, helper.getTravelFee(Terrain.TATOOINE, Terrain.NABOO));
|
||||
Assert.assertFalse(helper.isValidRoute(Terrain.TATOOINE, Terrain.YAVIN4));
|
||||
Assert.assertTrue(helper.isValidRoute(Terrain.TATOOINE, Terrain.LOK));
|
||||
Assert.assertTrue(helper.isValidRoute(Terrain.TATOOINE, Terrain.NABOO));
|
||||
assertEquals(1250, helper.getTravelFee(Terrain.DATHOMIR, Terrain.CORELLIA));
|
||||
assertEquals(2000, helper.getTravelFee(Terrain.CORELLIA, Terrain.DATHOMIR));
|
||||
assertEquals(4000, helper.getTravelFee(Terrain.NABOO, Terrain.ENDOR));
|
||||
assertEquals(500, helper.getTravelFee(Terrain.TATOOINE, Terrain.NABOO));
|
||||
assertFalse(helper.isValidRoute(Terrain.TATOOINE, Terrain.YAVIN4));
|
||||
assertTrue(helper.isValidRoute(Terrain.TATOOINE, Terrain.LOK));
|
||||
assertTrue(helper.isValidRoute(Terrain.TATOOINE, Terrain.NABOO));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,15 +80,15 @@ public class TestTravelHelper extends TestRunnerNoIntents {
|
||||
helper.addTravelPoint(outOfRange);
|
||||
GenericCreatureObject creature = new GenericCreatureObject(1);
|
||||
creature.setPosition(Terrain.TATOOINE, 75, 0, 75);
|
||||
Assert.assertEquals(starport, helper.getNearestTravelPoint(creature));
|
||||
assertEquals(starport, helper.getNearestTravelPoint(creature));
|
||||
creature.setPosition(Terrain.TATOOINE, 25, 0, 25);
|
||||
Assert.assertEquals(starport, helper.getNearestTravelPoint(creature));
|
||||
assertEquals(starport, helper.getNearestTravelPoint(creature));
|
||||
creature.setPosition(Terrain.TATOOINE, 500, 0, 500);
|
||||
Assert.assertEquals(starport, helper.getNearestTravelPoint(creature));
|
||||
assertEquals(starport, helper.getNearestTravelPoint(creature));
|
||||
creature.setPosition(Terrain.TATOOINE, -25, 0, -25);
|
||||
Assert.assertEquals(shuttleport, helper.getNearestTravelPoint(creature));
|
||||
assertEquals(shuttleport, helper.getNearestTravelPoint(creature));
|
||||
creature.setPosition(Terrain.TATOOINE, -75, 0, -75);
|
||||
Assert.assertEquals(shuttleport, helper.getNearestTravelPoint(creature));
|
||||
assertEquals(shuttleport, helper.getNearestTravelPoint(creature));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,10 +97,10 @@ public class TestTravelHelper extends TestRunnerNoIntents {
|
||||
GenericCreatureObject creature = new GenericCreatureObject(1);
|
||||
creature.setPosition(Terrain.TATOOINE, 3500, 5, -4800);
|
||||
List<TravelPoint> destinations = helper.getAvailableTravelPoints(creature, Terrain.YAVIN4);
|
||||
Assert.assertEquals(0, destinations.size());
|
||||
assertEquals(0, destinations.size());
|
||||
destinations = helper.getAvailableTravelPoints(creature, Terrain.LOK);
|
||||
Assert.assertEquals(1, destinations.size());
|
||||
Assert.assertEquals("Nym's Stronghold" , destinations.get(0).getName());
|
||||
assertEquals(1, destinations.size());
|
||||
assertEquals("Nym's Stronghold" , destinations.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,12 +109,12 @@ public class TestTravelHelper extends TestRunnerNoIntents {
|
||||
GenericCreatureObject creature = new GenericCreatureObject(1);
|
||||
creature.setPosition(Terrain.CORELLIA, -75, 0, -4723);
|
||||
List<TravelPoint> destinations = helper.getAvailableTravelPoints(creature, Terrain.YAVIN4);
|
||||
Assert.assertEquals(3, destinations.size());
|
||||
Assert.assertEquals("Imperial Base", destinations.get(0).getName());
|
||||
Assert.assertEquals("Labor Outpost", destinations.get(1).getName());
|
||||
Assert.assertEquals("Mining Outpost", destinations.get(2).getName());
|
||||
assertEquals(3, destinations.size());
|
||||
assertEquals("Imperial Base", destinations.get(0).getName());
|
||||
assertEquals("Labor Outpost", destinations.get(1).getName());
|
||||
assertEquals("Mining Outpost", destinations.get(2).getName());
|
||||
destinations = helper.getAvailableTravelPoints(creature, Terrain.LOK);
|
||||
Assert.assertEquals(0, destinations.size());
|
||||
assertEquals(0, destinations.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,10 +125,10 @@ public class TestTravelHelper extends TestRunnerNoIntents {
|
||||
TravelPoint imperialBase = helper.getDestinationPoint(Terrain.YAVIN4, "Imperial Base");
|
||||
TravelPoint coronet = helper.getDestinationPoint(Terrain.CORELLIA, "Coronet Starport");
|
||||
helper.grantTicket(imperialBase, coronet, creature);
|
||||
Assert.assertEquals(imperialBase, helper.getNearestTravelPoint(creature));
|
||||
Assert.assertEquals(1, creature.getSlottedObject("inventory").getContainedObjects().size());
|
||||
assertEquals(imperialBase, helper.getNearestTravelPoint(creature));
|
||||
assertEquals(1, creature.getSlottedObject("inventory").getContainedObjects().size());
|
||||
List<TangibleObject> tickets = helper.getTickets(creature);
|
||||
Assert.assertEquals(1, tickets.size());
|
||||
assertEquals(1, tickets.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -29,11 +29,11 @@ package com.projectswg.holocore.resources.support.data.collections;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestSWGBitSet extends TestRunnerNoIntents {
|
||||
|
||||
@@ -68,12 +68,12 @@ public class TestSWGBitSet extends TestRunnerNoIntents {
|
||||
|
||||
flag.decode(buffer);
|
||||
|
||||
assertTrue("Flag 1 should be set", flag.get(1));
|
||||
assertTrue("Flag 4 should be set", flag.get(4));
|
||||
assertTrue("Flag 8 should be set", flag.get(8));
|
||||
assertTrue("Flag 16 should be set", flag.get(16));
|
||||
assertTrue("Flag 32 should be set", flag.get(32));
|
||||
assertFalse("Flag 64 should be not set", flag.get(64));
|
||||
assertTrue(flag.get(1));
|
||||
assertTrue(flag.get(4));
|
||||
assertTrue(flag.get(8));
|
||||
assertTrue(flag.get(16));
|
||||
assertTrue(flag.get(32));
|
||||
assertFalse(flag.get(64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,7 +83,7 @@ public class TestSWGBitSet extends TestRunnerNoIntents {
|
||||
flag.set(4);
|
||||
flag.set(8);
|
||||
|
||||
assertEquals("Two flags should fill 10 bytes", 10, flag.getLength());
|
||||
assertEquals(10, flag.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+12
-12
@@ -29,8 +29,8 @@ package com.projectswg.holocore.resources.support.data.collections;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.BitSet;
|
||||
@@ -46,14 +46,14 @@ public class TestSWGFlag extends TestRunnerNoIntents {
|
||||
flag.set(64);
|
||||
flag.set(96);
|
||||
int [] ints = flag.toList();
|
||||
Assert.assertEquals(4, ints.length);
|
||||
Assert.assertEquals((1<<4)+(1<<1), ints[0]);
|
||||
Assert.assertEquals(1, ints[1]);
|
||||
Assert.assertEquals(1, ints[2]);
|
||||
Assert.assertEquals(1, ints[3]);
|
||||
assertEquals(4, ints.length);
|
||||
assertEquals((1<<4)+(1<<1), ints[0]);
|
||||
assertEquals(1, ints[1]);
|
||||
assertEquals(1, ints[2]);
|
||||
assertEquals(1, ints[3]);
|
||||
SWGFlag decoded = new SWGFlag(3, 16);
|
||||
decoded.decode(NetBuffer.wrap(flag.encode()));
|
||||
Assert.assertArrayEquals(flag.encode(), decoded.encode());
|
||||
assertArrayEquals(flag.encode(), decoded.encode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,13 +62,13 @@ public class TestSWGFlag extends TestRunnerNoIntents {
|
||||
SWGFlag flag = new SWGFlag(3, 16);
|
||||
|
||||
encoded = flag.encode();
|
||||
Assert.assertEquals(4, encoded.length);
|
||||
assertEquals(4, encoded.length);
|
||||
|
||||
flag.set(1);
|
||||
encoded = flag.encode();
|
||||
Assert.assertEquals(8, encoded.length);
|
||||
Assert.assertEquals(1, encoded[0]);
|
||||
Assert.assertEquals(2, encoded[4]);
|
||||
assertEquals(8, encoded.length);
|
||||
assertEquals(1, encoded[0]);
|
||||
assertEquals(2, encoded[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-12
@@ -29,8 +29,8 @@ package com.projectswg.holocore.resources.support.data.collections;
|
||||
|
||||
import com.projectswg.common.network.NetBuffer;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -48,13 +48,13 @@ public class TestSWGList extends TestRunnerNoIntents {
|
||||
SWGList<String> swgList = SWGList.Companion.createAsciiList(3, 6);
|
||||
swgList.addAll(List.of(strings));
|
||||
|
||||
Assert.assertEquals(size, swgList.size());
|
||||
Assert.assertArrayEquals(strings, swgList.toArray());
|
||||
assertEquals(size, swgList.size());
|
||||
assertArrayEquals(strings, swgList.toArray());
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
Collections.addAll(list, strings);
|
||||
|
||||
Assert.assertArrayEquals(swgList.toArray(), list.toArray());
|
||||
assertArrayEquals(swgList.toArray(), list.toArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,14 +68,14 @@ public class TestSWGList extends TestRunnerNoIntents {
|
||||
SWGList<String> swgList = SWGList.Companion.createAsciiList(3, 6);
|
||||
swgList.addAll(strings);
|
||||
|
||||
Assert.assertEquals(size, swgList.getUpdateCount());
|
||||
Assert.assertEquals(strings, swgList);
|
||||
assertEquals(size, swgList.getUpdateCount());
|
||||
assertEquals(strings, swgList);
|
||||
for (ListIterator<String> it = swgList.listIterator(); it.hasNext(); ) {
|
||||
String str = it.next();
|
||||
it.set(str.replace('t', 'j'));
|
||||
}
|
||||
Assert.assertEquals(strings.stream().map(str -> str.replace('t', 'j')).collect(Collectors.toList()), swgList);
|
||||
Assert.assertEquals(size*2, swgList.getUpdateCount());
|
||||
assertEquals(strings.stream().map(str -> str.replace('t', 'j')).collect(Collectors.toList()), swgList);
|
||||
assertEquals(size*2, swgList.getUpdateCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,11 +93,11 @@ public class TestSWGList extends TestRunnerNoIntents {
|
||||
SWGList<String> swgList = SWGList.Companion.createAsciiList(3, 6);
|
||||
Collections.addAll(swgList, strings);
|
||||
byte [] encoded = swgList.encode();
|
||||
Assert.assertArrayEquals(expected.array(), encoded);
|
||||
Assert.assertEquals(encoded.length, swgList.getLength());
|
||||
assertArrayEquals(expected.array(), encoded);
|
||||
assertEquals(encoded.length, swgList.getLength());
|
||||
|
||||
SWGList<String> decodedList = SWGList.Companion.createAsciiList(3, 6);
|
||||
decodedList.decode(NetBuffer.wrap(encoded));
|
||||
Assert.assertEquals(swgList, decodedList);
|
||||
assertEquals(swgList, decodedList);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -29,8 +29,8 @@ package com.projectswg.holocore.resources.support.data.common;
|
||||
import com.projectswg.common.data.location.Point3D;
|
||||
import com.projectswg.common.data.location.Quaternion;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestPoint3D extends TestRunnerNoIntents {
|
||||
|
||||
@@ -39,15 +39,15 @@ public class TestPoint3D extends TestRunnerNoIntents {
|
||||
Point3D p = new Point3D(0, 0, 1);
|
||||
Quaternion q = new Quaternion(0, 1, 0, 0);
|
||||
p.rotateAround(0, 0, 0, q);
|
||||
Assert.assertEquals(0, p.getX(), 1E-7);
|
||||
Assert.assertEquals(0, p.getY(), 1E-7);
|
||||
Assert.assertEquals(-1, p.getZ(), 1E-7);
|
||||
assertEquals(0, p.getX(), 1E-7);
|
||||
assertEquals(0, p.getY(), 1E-7);
|
||||
assertEquals(-1, p.getZ(), 1E-7);
|
||||
p.set(0, 0, 1);
|
||||
q.setHeading(45);
|
||||
p.rotateAround(0, 0, 0, q);
|
||||
Assert.assertEquals(Math.sqrt(2)/2, p.getX(), 1E-7);
|
||||
Assert.assertEquals(0, p.getY(), 1E-7);
|
||||
Assert.assertEquals(Math.sqrt(2)/2, p.getZ(), 1E-7);
|
||||
assertEquals(Math.sqrt(2)/2, p.getX(), 1E-7);
|
||||
assertEquals(0, p.getY(), 1E-7);
|
||||
assertEquals(Math.sqrt(2)/2, p.getZ(), 1E-7);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -28,8 +28,8 @@ package com.projectswg.holocore.resources.support.data.common;
|
||||
|
||||
import com.projectswg.common.data.location.Quaternion;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestQuaternion extends TestRunnerNoIntents {
|
||||
|
||||
@@ -50,10 +50,10 @@ public class TestQuaternion extends TestRunnerNoIntents {
|
||||
q2.setHeading(heading2);
|
||||
Quaternion ret = new Quaternion(q1);
|
||||
ret.rotateByQuaternion(q2);
|
||||
Assert.assertEquals(x, ret.getX(), 1E-7);
|
||||
Assert.assertEquals(y, ret.getY(), 1E-7);
|
||||
Assert.assertEquals(z, ret.getZ(), 1E-7);
|
||||
Assert.assertEquals(w, ret.getW(), 1E-7);
|
||||
// Assert.assertEquals((heading1+heading2+360)%360, (ret.getHeading()+360)%360, 1E-7);
|
||||
assertEquals(x, ret.getX(), 1E-7);
|
||||
assertEquals(y, ret.getY(), 1E-7);
|
||||
assertEquals(z, ret.getZ(), 1E-7);
|
||||
assertEquals(w, ret.getW(), 1E-7);
|
||||
// assertEquals((heading1+heading2+360)%360, (ret.getHeading()+360)%360, 1E-7);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,9 +28,9 @@ package com.projectswg.holocore.resources.support.data.common;
|
||||
|
||||
import com.projectswg.common.data.WeatherType;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class TestWeatherType extends TestRunnerNoIntents {
|
||||
|
||||
|
||||
+8
-8
@@ -2,17 +2,17 @@ package com.projectswg.holocore.resources.support.data.location;
|
||||
|
||||
import com.projectswg.common.data.location.Location;
|
||||
import com.projectswg.common.data.location.Terrain;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class TestClosestLocationReducer {
|
||||
|
||||
private ClosestLocationReducer reducer;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Location base = Location.builder()
|
||||
.setTerrain(Terrain.TATOOINE)
|
||||
@@ -41,7 +41,7 @@ public class TestClosestLocationReducer {
|
||||
|
||||
Location reduced = reducer.apply(loc1, loc2);
|
||||
|
||||
assertNull("Null should be the result when reducing locations not located on the same planet as the base location", reduced);
|
||||
assertNull(reduced, "Null should be the result when reducing locations not located on the same planet as the base location");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class TestClosestLocationReducer {
|
||||
|
||||
Location reduced = reducer.apply(closest, farthest);
|
||||
|
||||
assertEquals("The location closest to the base location should be the reduced location", closest, reduced);
|
||||
assertEquals(closest, reduced, "The location closest to the base location should be the reduced location");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public class TestClosestLocationReducer {
|
||||
|
||||
Location reduced = reducer.apply(closestDifferentPlanet, farthestSamePlanet);
|
||||
|
||||
assertEquals("The location on the same planet should be picked even if it's furthest away from the X Y Z coordinates", farthestSamePlanet, reduced);
|
||||
assertEquals(farthestSamePlanet, reduced, "The location on the same planet should be picked even if it's furthest away from the X Y Z coordinates");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-21
@@ -1,31 +1,16 @@
|
||||
package com.projectswg.holocore.resources.support.data.namegen;
|
||||
|
||||
import com.projectswg.common.data.encodables.tangible.Race;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestSWGNameGenerator {
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Race> input() {
|
||||
return Arrays.asList(Race.values());
|
||||
}
|
||||
|
||||
@Parameterized.Parameter
|
||||
public Race race;
|
||||
|
||||
/**
|
||||
* Verifies that we can generate names for all races without encountering an error
|
||||
*/
|
||||
@Test
|
||||
public void testCanGenerate() {
|
||||
@ParameterizedTest
|
||||
@EnumSource(Race.class)
|
||||
public void canGenerateNamesForAllRacesWithoutError(Race race) {
|
||||
SWGNameGenerator generator = new SWGNameGenerator();
|
||||
|
||||
assertNotEquals("Should be able to generate non-empty name for race " + race.getSpecies(), "", generator.generateName(race));
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.projectswg.holocore.resources.support.data.server_info.loader
|
||||
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MappingTemplateLoaderTest {
|
||||
|
||||
|
||||
+9
-7
@@ -1,19 +1,19 @@
|
||||
package com.projectswg.holocore.resources.support.data.server_info.loader;
|
||||
|
||||
import com.projectswg.common.data.location.Terrain;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestDynamicSpawnLoader {
|
||||
|
||||
private DynamicSpawnLoader loader;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
loader = new DynamicSpawnLoader();
|
||||
loader.load(); // We just expect this to not throw an exception
|
||||
@@ -23,13 +23,15 @@ public class TestDynamicSpawnLoader {
|
||||
public void testGetSpawnInfosNullTerrain() {
|
||||
Collection<DynamicSpawnLoader.DynamicSpawnInfo> output = loader.getSpawnInfos(null);
|
||||
|
||||
assertEquals("Unknown terrain should result in an empty list of dynamic spawns", 0, output.size());
|
||||
assertEquals(0, output.size(), "Unknown terrain should result in an empty list of dynamic spawns");
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test
|
||||
public void testGetSpawnInfosUnmodifiable() {
|
||||
Collection<DynamicSpawnLoader.DynamicSpawnInfo> output = loader.getSpawnInfos(Terrain.TATOOINE); // Hopefully we have spawns on Tatooine
|
||||
|
||||
output.add(null); // Adding something to an unmodifiable collection should throw an exception
|
||||
assertThrows(UnsupportedOperationException.class, () -> {
|
||||
output.add(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+7
-18
@@ -2,24 +2,17 @@ package com.projectswg.holocore.resources.support.data.server_info.loader;
|
||||
|
||||
import com.projectswg.common.data.location.Location;
|
||||
import com.projectswg.common.data.location.Terrain;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestNoSpawnZoneLoader {
|
||||
|
||||
@Parameterized.Parameter
|
||||
public Input input;
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Input> parameters() {
|
||||
Location mosEisleyLocation = Location.builder()
|
||||
.setTerrain(Terrain.TATOOINE)
|
||||
@@ -41,16 +34,12 @@ public class TestNoSpawnZoneLoader {
|
||||
);
|
||||
}
|
||||
|
||||
private NoSpawnZoneLoader loader;
|
||||
private final NoSpawnZoneLoader loader = new NoSpawnZoneLoader();
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
loader = new NoSpawnZoneLoader();
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
public void testIsInNoSpawnZone(Input input) throws IOException {
|
||||
loader.load(); // We just expect this to not throw an exception
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInNoSpawnZone() {
|
||||
boolean actual = loader.isInNoSpawnZone(input.getLocation());
|
||||
boolean expected = input.isNoBuildZone();
|
||||
|
||||
|
||||
+12
-12
@@ -1,9 +1,8 @@
|
||||
package com.projectswg.holocore.resources.support.data.server_info.loader;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.runners.Enclosed;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@@ -11,17 +10,17 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@RunWith(Enclosed.class)
|
||||
public class TestQuestLoader {
|
||||
|
||||
public static class TestQuestInfo {
|
||||
@Nested
|
||||
public class TestQuestInfo {
|
||||
|
||||
private static QuestLoader.QuestListInfo questInfo;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws IOException {
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
QuestLoader questLoader = new QuestLoader();
|
||||
questLoader.load(); // May throw an exception
|
||||
|
||||
@@ -75,12 +74,13 @@ public class TestQuestLoader {
|
||||
|
||||
}
|
||||
|
||||
public static class TestQuestTask {
|
||||
@Nested
|
||||
public class TestQuestTask {
|
||||
|
||||
private static List<QuestLoader.QuestTaskInfo> taskListInfos;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws IOException {
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
QuestLoader questLoader = new QuestLoader();
|
||||
|
||||
taskListInfos = questLoader.getTaskListInfos("quest/purvis_kill_warriors");
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.projectswg.holocore.resources.support.data.server_info.loader;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
+4
-4
@@ -1,18 +1,18 @@
|
||||
package com.projectswg.holocore.resources.support.data.server_info.loader.conversation.requirements;
|
||||
|
||||
import com.projectswg.holocore.resources.gameplay.conversation.requirements.ActiveQuestRequirement;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class ActiveQuestRequirementParserTest {
|
||||
|
||||
private ActiveQuestRequirementParser parser;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
parser = new ActiveQuestRequirementParser();
|
||||
}
|
||||
|
||||
+4
-4
@@ -10,15 +10,15 @@ import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleOb
|
||||
import com.projectswg.holocore.services.gameplay.player.experience.skills.SkillService
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class EquipArmorTest : TestRunnerSimulatedWorld() {
|
||||
|
||||
private val transferItemCallback = TransferItemCallback()
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
registerService(SkillService())
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ import com.projectswg.holocore.resources.support.objects.swg.SWGObject
|
||||
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class EquipClothingTest : TestRunnerSimulatedWorld() {
|
||||
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ import com.projectswg.holocore.resources.support.objects.swg.SWGObject
|
||||
import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class EquipWeaponTest : TestRunnerSimulatedWorld() {
|
||||
|
||||
|
||||
+3
-3
@@ -28,8 +28,8 @@
|
||||
package com.projectswg.holocore.resources.support.global.network;
|
||||
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -55,7 +55,7 @@ public class TestLittleEndianDataOutputStream extends TestRunnerNoIntents {
|
||||
le.writeLong(1024);
|
||||
le.writeFloat(1.25f);
|
||||
le.writeDouble(1.75);
|
||||
Assert.assertArrayEquals(bb.array(), baos.toByteArray());
|
||||
assertArrayEquals(bb.array(), baos.toByteArray());
|
||||
le.close();
|
||||
}
|
||||
|
||||
|
||||
+18
-18
@@ -29,8 +29,8 @@ package com.projectswg.holocore.resources.support.global.network;
|
||||
|
||||
import com.projectswg.common.network.NetBufferStream;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TestNetBufferStream extends TestRunnerNoIntents {
|
||||
for (int i = 0; i < 10; i++)
|
||||
stream.write(generateTestString(i));
|
||||
for (int i = 0; i < 10; i++)
|
||||
Assert.assertEquals(getTestString(i), stream.getAscii());
|
||||
assertEquals(getTestString(i), stream.getAscii());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,12 @@ public class TestNetBufferStream extends TestRunnerNoIntents {
|
||||
for (int i = 0; i < 10; i++)
|
||||
stream.write(generateTestString(i));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Assert.assertEquals(getTestString(i), stream.getAscii());
|
||||
assertEquals(getTestString(i), stream.getAscii());
|
||||
if (i == 4) {
|
||||
int rem = stream.remaining();
|
||||
stream.compact();
|
||||
Assert.assertEquals(0, stream.position());
|
||||
Assert.assertEquals(rem, stream.remaining());
|
||||
assertEquals(0, stream.position());
|
||||
assertEquals(rem, stream.remaining());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,11 +86,11 @@ public class TestNetBufferStream extends TestRunnerNoIntents {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
stream.write(generateTestString(i));
|
||||
if (i % 2 == 1) {
|
||||
Assert.assertEquals(getTestString(i-1), stream.getAscii());
|
||||
Assert.assertEquals(getTestString(i), stream.getAscii());
|
||||
assertEquals(getTestString(i-1), stream.getAscii());
|
||||
assertEquals(getTestString(i), stream.getAscii());
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(0, stream.remaining());
|
||||
assertEquals(0, stream.remaining());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,15 +100,15 @@ public class TestNetBufferStream extends TestRunnerNoIntents {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
stream.write(generateTestString(i));
|
||||
if (i % 2 == 1) {
|
||||
Assert.assertEquals(getTestString(i-1), stream.getAscii());
|
||||
Assert.assertEquals(getTestString(i), stream.getAscii());
|
||||
assertEquals(getTestString(i-1), stream.getAscii());
|
||||
assertEquals(getTestString(i), stream.getAscii());
|
||||
int rem = stream.remaining();
|
||||
stream.compact();
|
||||
Assert.assertEquals(0, stream.position());
|
||||
Assert.assertEquals(rem, stream.remaining());
|
||||
assertEquals(0, stream.position());
|
||||
assertEquals(rem, stream.remaining());
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(0, stream.remaining());
|
||||
assertEquals(0, stream.remaining());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,15 +118,15 @@ public class TestNetBufferStream extends TestRunnerNoIntents {
|
||||
for (int i = 0; i < 10; i++)
|
||||
stream.write(generateTestString(i));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Assert.assertEquals(getTestString(i), stream.getAscii());
|
||||
assertEquals(getTestString(i), stream.getAscii());
|
||||
if (i == 4)
|
||||
stream.mark();
|
||||
}
|
||||
Assert.assertEquals(0, stream.remaining());
|
||||
assertEquals(0, stream.remaining());
|
||||
stream.rewind();
|
||||
Assert.assertEquals(5*(2+getTestString(0).length()), stream.remaining());
|
||||
assertEquals(5*(2+getTestString(0).length()), stream.remaining());
|
||||
for (int i = 5; i < 10; i++)
|
||||
Assert.assertEquals(getTestString(i), stream.getAscii());
|
||||
assertEquals(getTestString(i), stream.getAscii());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -31,8 +31,8 @@ import com.projectswg.holocore.resources.support.objects.swg.player.PlayerObject
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericPlayer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestZoneRequester extends TestRunnerNoIntents {
|
||||
|
||||
@@ -40,16 +40,16 @@ public class TestZoneRequester extends TestRunnerNoIntents {
|
||||
public void testNullCreatureObject() {
|
||||
ZoneRequester zr = new ZoneRequester();
|
||||
GenericPlayer player = new GenericPlayer();
|
||||
Assert.assertFalse(zr.onZoneRequested(null, player, 0));
|
||||
Assert.assertNotNull(player.getNextPacket(ErrorMessage.class));
|
||||
assertFalse(zr.onZoneRequested(null, player, 0));
|
||||
assertNotNull(player.getNextPacket(ErrorMessage.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidCreatureObject() {
|
||||
ZoneRequester zr = new ZoneRequester();
|
||||
GenericPlayer player = new GenericPlayer();
|
||||
Assert.assertFalse(zr.onZoneRequested(new PlayerObject(1), player, 0));
|
||||
Assert.assertNotNull(player.getNextPacket(ErrorMessage.class));
|
||||
assertFalse(zr.onZoneRequested(new PlayerObject(1), player, 0));
|
||||
assertNotNull(player.getNextPacket(ErrorMessage.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,8 +58,8 @@ public class TestZoneRequester extends TestRunnerNoIntents {
|
||||
GenericCreatureObject creature = new GenericCreatureObject(getUniqueId());
|
||||
GenericPlayer player = creature.getOwner();
|
||||
creature.getSlottedObject("ghost").systemMove(null);
|
||||
Assert.assertFalse(zr.onZoneRequested(creature, player, creature.getObjectId()));
|
||||
Assert.assertNotNull(player.getNextPacket(ErrorMessage.class));
|
||||
assertFalse(zr.onZoneRequested(creature, player, creature.getObjectId()));
|
||||
assertNotNull(player.getNextPacket(ErrorMessage.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,8 +68,8 @@ public class TestZoneRequester extends TestRunnerNoIntents {
|
||||
GenericCreatureObject creature = new GenericCreatureObject(getUniqueId());
|
||||
GenericPlayer player = creature.getOwner();
|
||||
creature.setOwner(null);
|
||||
Assert.assertTrue(zr.onZoneRequested(creature, player, creature.getObjectId()));
|
||||
Assert.assertNull(player.getNextPacket(ErrorMessage.class));
|
||||
assertTrue(zr.onZoneRequested(creature, player, creature.getObjectId()));
|
||||
assertNull(player.getNextPacket(ErrorMessage.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-13
@@ -36,8 +36,8 @@ import com.projectswg.holocore.resources.support.objects.swg.cell.Portal;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -51,9 +51,9 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
NavigationPoint src = NavigationPoint.at(null, Location.builder().setPosition(0, 0, 0).build(), 0);
|
||||
NavigationPoint dst = NavigationPoint.at(null, Location.builder().setPosition(0, 0, 10).build(), 0);
|
||||
|
||||
Assert.assertEquals(10, src.distanceTo(dst), 1E-7);
|
||||
Assert.assertEquals(10, dst.distanceTo(src), 1E-7);
|
||||
Assert.assertEquals(5, src.distanceTo(null, Location.builder().setPosition(5, 0, 0).build()), 1E-7);
|
||||
assertEquals(10, src.distanceTo(dst), 1E-7);
|
||||
assertEquals(10, dst.distanceTo(src), 1E-7);
|
||||
assertEquals(5, src.distanceTo(null, Location.builder().setPosition(5, 0, 0).build()), 1E-7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,7 +62,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
Location end = location(10, 0, 0);
|
||||
List<NavigationPoint> route = from(null, start, end);
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(null, start, end, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(null, start, end, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
route.addAll(from(null, start, worldPortal));
|
||||
route.addAll(from(buio.getCellByNumber(1), portal, end));
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(null, start, buio.getCellByNumber(1), end, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(null, start, buio.getCellByNumber(1), end, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,7 +100,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
route.addAll(from(buio.getCellByNumber(1), end, portal));
|
||||
route.addAll(from(null, worldPortal, start));
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(buio.getCellByNumber(1), end, null, start, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(buio.getCellByNumber(1), end, null, start, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +121,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
route.addAll(from(buio.getCellByNumber(1), portal1, portal2));
|
||||
route.addAll(from(buio.getCellByNumber(2), portal2, end));
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(null, start, buio.getCellByNumber(2), end, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(null, start, buio.getCellByNumber(2), end, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +144,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
route.addAll(from(buio.getCellByNumber(2), portal2, portal3));
|
||||
route.addAll(from(buio.getCellByNumber(3), portal3, end));
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(null, start, buio.getCellByNumber(3), end, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(null, start, buio.getCellByNumber(3), end, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,7 +165,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
route.addAll(from(buio.getCellByNumber(1), portal2, portal1));
|
||||
route.addAll(from(null, worldPortal, start));
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(buio.getCellByNumber(2), end, null, start, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(buio.getCellByNumber(2), end, null, start, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -183,7 +183,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
route.addAll(from(buio.getCellByNumber(1), start, portal));
|
||||
route.addAll(from(buio.getCellByNumber(2), portal, end));
|
||||
|
||||
Assert.assertEquals(route, NavigationPoint.from(buio.getCellByNumber(1), start, buio.getCellByNumber(2), end, SPEED));
|
||||
assertEquals(route, NavigationPoint.from(buio.getCellByNumber(1), start, buio.getCellByNumber(2), end, SPEED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,7 +196,7 @@ public class TestNavigationPoint extends TestRunnerNoIntents {
|
||||
Location start = location(5, 0, 5);
|
||||
Location end = location(-5, 0, -5);
|
||||
|
||||
Assert.assertEquals(from(buio.getCellByNumber(1), start, end), NavigationPoint.from(buio.getCellByNumber(1), start, buio.getCellByNumber(1), end, SPEED));
|
||||
assertEquals(from(buio.getCellByNumber(1), start, end), NavigationPoint.from(buio.getCellByNumber(1), start, buio.getCellByNumber(1), end, SPEED));
|
||||
}
|
||||
|
||||
private static List<NavigationPoint> from(@Nullable SWGObject parent, @NotNull Location source, @NotNull Location destination) {
|
||||
|
||||
+4
-4
@@ -32,13 +32,13 @@ import com.projectswg.holocore.resources.support.objects.swg.player.PlayerObject
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestObjectAware extends TestRunnerNoIntents {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TestObjectAware extends TestRunnerNoIntents {
|
||||
private SWGObject creature1;
|
||||
private SWGObject creature2;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void initialize() {
|
||||
tangible1 = new GenericTangibleObject(1);
|
||||
tangible2 = new GenericTangibleObject(2);
|
||||
|
||||
+20
-20
@@ -39,15 +39,15 @@ import com.projectswg.holocore.resources.support.objects.swg.waypoint.WaypointOb
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestObjectAwareness extends TestRunnerNoIntents {
|
||||
|
||||
@@ -131,10 +131,10 @@ public class TestObjectAwareness extends TestRunnerNoIntents {
|
||||
initialize();
|
||||
player.setHasOwner(false);
|
||||
|
||||
Assert.assertTrue(player.isPlayer());
|
||||
Assert.assertFalse(player.isLoggedInPlayer());
|
||||
Assert.assertTrue(testPlayer.isPlayer());
|
||||
Assert.assertTrue(testPlayer.isLoggedInPlayer());
|
||||
assertTrue(player.isPlayer());
|
||||
assertFalse(player.isLoggedInPlayer());
|
||||
assertTrue(testPlayer.isPlayer());
|
||||
assertTrue(testPlayer.isLoggedInPlayer());
|
||||
|
||||
// Shouldn't be aware of anything else because it's a logged out player
|
||||
for (TestLocation loc : TestLocation.values()) {
|
||||
@@ -143,10 +143,10 @@ public class TestObjectAwareness extends TestRunnerNoIntents {
|
||||
}
|
||||
|
||||
player.setHasOwner(true);
|
||||
Assert.assertTrue(player.isPlayer());
|
||||
Assert.assertTrue(player.isLoggedInPlayer());
|
||||
Assert.assertTrue(testPlayer.isPlayer());
|
||||
Assert.assertTrue(testPlayer.isLoggedInPlayer());
|
||||
assertTrue(player.isPlayer());
|
||||
assertTrue(player.isLoggedInPlayer());
|
||||
assertTrue(testPlayer.isPlayer());
|
||||
assertTrue(testPlayer.isLoggedInPlayer());
|
||||
|
||||
for (TestLocation loc : TestLocation.values()) {
|
||||
try {
|
||||
@@ -163,15 +163,15 @@ public class TestObjectAwareness extends TestRunnerNoIntents {
|
||||
|
||||
move(TestLocation.BSSI);
|
||||
|
||||
Assert.assertTrue(player.getAware().contains(testNpc));
|
||||
assertTrue(player.getAware().contains(testNpc));
|
||||
testNpc.systemMove(testCell2);
|
||||
update(testNpc);
|
||||
assertFalse(player.getAware().contains(testNpc));
|
||||
|
||||
testNpc.systemMove(testCell1);
|
||||
Assert.assertTrue(testNpc.isVisible(player));
|
||||
assertTrue(testNpc.isVisible(player));
|
||||
update(testNpc);
|
||||
Assert.assertTrue(player.getAware().contains(testNpc));
|
||||
assertTrue(player.getAware().contains(testNpc));
|
||||
|
||||
{
|
||||
SWGPacket packet;
|
||||
@@ -183,7 +183,7 @@ public class TestObjectAwareness extends TestRunnerNoIntents {
|
||||
|
||||
testNpc.systemMove(testCell1);
|
||||
update(testNpc);
|
||||
Assert.assertNull(player.getOwner().getNextPacket());
|
||||
assertNull(player.getOwner().getNextPacket());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,16 +234,16 @@ public class TestObjectAwareness extends TestRunnerNoIntents {
|
||||
|
||||
// Ensure it doesn't contain the unexpected
|
||||
for (SWGObject a : awareActual) {
|
||||
assertTrue("Baselines were supposed to be sent: " + a, player.getOwner() == null || player.isBaselinesSent(a));
|
||||
assertTrue(player.getOwner() == null || player.isBaselinesSent(a), "Baselines were supposed to be sent: " + a);
|
||||
if (a.getParent() != null)
|
||||
continue;
|
||||
assertTrue("Not supposed to be aware of object: " + a, awareExpected.contains(a));
|
||||
assertTrue(awareExpected.contains(a), "Not supposed to be aware of object: " + a);
|
||||
}
|
||||
|
||||
// Ensure it contains the expected
|
||||
for (SWGObject a : awareExpected) {
|
||||
assertTrue("Baselines were supposed to be sent: " + a, player.getOwner() == null || player.isBaselinesSent(a));
|
||||
assertTrue("Supposed to be aware of object: " + a, awareActual.contains(a));
|
||||
assertTrue(player.getOwner() == null || player.isBaselinesSent(a), "Baselines were supposed to be sent: " + a);
|
||||
assertTrue(awareActual.contains(a), "Supposed to be aware of object: " + a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -31,10 +31,10 @@ import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleOb
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestContainerPermissions extends TestRunnerNoIntents {
|
||||
|
||||
|
||||
+5
-5
@@ -30,10 +30,10 @@ package com.projectswg.holocore.resources.support.objects.permissions;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestReadOnlyPermissions {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TestReadOnlyPermissions {
|
||||
|
||||
boolean movable = permissions.canMove(creature, container);
|
||||
|
||||
assertTrue("An exempt object should be able to move an object with read-only permissions", movable);
|
||||
assertTrue(movable);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,6 +56,6 @@ public class TestReadOnlyPermissions {
|
||||
|
||||
boolean movable = permissions.canMove(creature, container);
|
||||
|
||||
assertFalse("Only exempted objects should be able to move an object with read-only permissions", movable);
|
||||
assertFalse(movable);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -8,13 +8,13 @@ import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureOb
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericPlayer;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestTuneCrystalRadial {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TestTuneCrystalRadial {
|
||||
private GenericPlayer player;
|
||||
private SWGObject crystal;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
radial = new TuneCrystalRadial();
|
||||
player = new GenericPlayer();
|
||||
@@ -34,30 +34,30 @@ public class TestTuneCrystalRadial {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotCrystal() {
|
||||
public void youShouldNotBeAbleToTuneObjectsThatAreNotLightsaberCrystals() {
|
||||
player.getCreatureObject().addSkill("jedi"); // Only Jedi can tune crystals
|
||||
List<RadialOption> options = new ArrayList<>();
|
||||
crystal.setGameObjectType(GameObjectType.GOT_CLOTHING_JACKET); // Let's change the object type to something different
|
||||
|
||||
radial.getOptions(options, player, crystal);
|
||||
|
||||
assertTrue("You should not be able to tune objects that are not lightsaber crystals", options.isEmpty());
|
||||
assertTrue(options.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrystalUntuned() {
|
||||
public void untunedCrystalsShouldHaveTheTuneRadialOptionForJedi() {
|
||||
player.getCreatureObject().addSkill("jedi"); // Only Jedi can tune crystals
|
||||
List<RadialOption> options = new ArrayList<>();
|
||||
radial.getOptions(options, player, crystal);
|
||||
|
||||
assertEquals("Untuned crystals should have one radial option", 1, options.size());
|
||||
assertEquals(1, options.size());
|
||||
|
||||
RadialOption radialOption = options.get(0);
|
||||
assertEquals("Untuned crystals should present the option of tuning them", "@jedi_spam:tune_crystal", radialOption.getLabel());
|
||||
assertEquals("@jedi_spam:tune_crystal", radialOption.getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrystalAlreadyTuned() {
|
||||
public void tunedCrystalShouldHaveNoOptions() {
|
||||
player.getCreatureObject().addSkill("jedi"); // Only Jedi can tune crystals
|
||||
List<RadialOption> options = new ArrayList<>();
|
||||
|
||||
@@ -66,16 +66,16 @@ public class TestTuneCrystalRadial {
|
||||
|
||||
radial.getOptions(options, player, crystal);
|
||||
|
||||
assertTrue("Tuned crystals should have no options", options.isEmpty());
|
||||
assertTrue(options.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotJedi() {
|
||||
public void onlyJediCanTuneCrystals() {
|
||||
player.getCreatureObject().addSkill("swg_dev"); // Something that's not Jedi - doesn't really matter what
|
||||
List<RadialOption> options = new ArrayList<>();
|
||||
|
||||
radial.getOptions(options, player, crystal);
|
||||
|
||||
assertTrue("Only Jedi should be able to tune crystals", options.isEmpty());
|
||||
assertTrue(options.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ package com.projectswg.holocore.resources.support.objects.swg
|
||||
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.MovementModifierContainer
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.MovementModifierIdentifier
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class MovementModifierContainerTest {
|
||||
@Test
|
||||
|
||||
+10
-10
@@ -34,8 +34,8 @@ import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureOb
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObjectAwareness
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
@@ -57,7 +57,7 @@ class TestCreatureObjectAwareness: TestRunnerNoIntents() {
|
||||
val stack = LinkedList<SWGObject>()
|
||||
|
||||
// Don't lose any objects
|
||||
Assert.assertEquals(HashSet(awareness), HashSet(create))
|
||||
assertEquals(HashSet(awareness), HashSet(create))
|
||||
|
||||
// Verify that all bundled objects are next to their parent
|
||||
for (obj in create) {
|
||||
@@ -69,8 +69,8 @@ class TestCreatureObjectAwareness: TestRunnerNoIntents() {
|
||||
if (!obj.isBundledWithin(parent, creature) && stack.peekLast() == parent)
|
||||
stack.pollLast()
|
||||
if (obj.isBundledWithin(parent, creature)) {
|
||||
Assert.assertFalse(obj.toString(), stack.isEmpty())
|
||||
Assert.assertEquals(obj.toString(), parent, stack.last)
|
||||
assertFalse(stack.isEmpty(), obj.toString())
|
||||
assertEquals(parent, stack.last, obj.toString())
|
||||
}
|
||||
stack.add(obj)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class TestCreatureObjectAwareness: TestRunnerNoIntents() {
|
||||
val flushData = CreatureObjectAwareness.FlushAwarenessData(creature)
|
||||
val create = flushData.buildCreate(HashSet(), LinkedHashSet(awareness))
|
||||
val destroy = flushData.buildDestroy(HashSet(create), HashSet())
|
||||
Assert.assertEquals(setOf(creature, building1, building2), HashSet(destroy))
|
||||
assertEquals(setOf(creature, building1, building2), HashSet(destroy))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,16 +99,16 @@ class TestCreatureObjectAwareness: TestRunnerNoIntents() {
|
||||
creature.setAware(AwarenessType.OBJECT, awareness)
|
||||
creatureObjectAwareness.flush(creature.owner ?: throw AssertionError("owner is not defined for creature"))
|
||||
for (obj in awareness) {
|
||||
Assert.assertTrue("Should be aware of $obj", creatureObjectAwareness.isAware(obj))
|
||||
assertTrue(creatureObjectAwareness.isAware(obj), "Should be aware of $obj")
|
||||
}
|
||||
|
||||
creature.setAware(AwarenessType.OBJECT, getRecursiveInfo(creature, listOf(creature)))
|
||||
creatureObjectAwareness.flush(creature.owner ?: throw AssertionError("owner is not defined for creature"))
|
||||
for (obj in getRecursiveInfo(creature, listOf(creature))) {
|
||||
Assert.assertTrue("Should be aware of $obj", creatureObjectAwareness.isAware(obj))
|
||||
assertTrue(creatureObjectAwareness.isAware(obj), "Should be aware of $obj")
|
||||
}
|
||||
for (obj in getRecursiveInfo(creature, listOf(building1, building2))) {
|
||||
Assert.assertFalse("Should not be aware of $obj", creatureObjectAwareness.isAware(obj))
|
||||
assertFalse(creatureObjectAwareness.isAware(obj), "Should not be aware of $obj")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class TestCreatureObjectAwareness: TestRunnerNoIntents() {
|
||||
val building = BuildingObject(id)
|
||||
building.template = "object/building/player/shared_player_house_tatooine_small_style_01.iff"
|
||||
building.populateCells()
|
||||
Assert.assertEquals(3, building.cells.size)
|
||||
assertEquals(3, building.cells.size)
|
||||
building.initializeBuilding()
|
||||
return building
|
||||
}
|
||||
|
||||
+48
-42
@@ -33,8 +33,8 @@ import com.projectswg.holocore.resources.support.objects.swg.building.BuildingOb
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -62,16 +62,16 @@ public class TestSWGObject extends TestRunnerNoIntents {
|
||||
b.systemMove(buio.getCellByNumber(3));
|
||||
a.setPosition(-5.97, 0.64, 1); // Center of portal
|
||||
b.setPosition(-5.97, 0.64, -1);
|
||||
Assert.assertTrue(a.isLineOfSight(b));
|
||||
Assert.assertTrue(b.isLineOfSight(a));
|
||||
assertTrue(a.isLineOfSight(b));
|
||||
assertTrue(b.isLineOfSight(a));
|
||||
a.setPosition(-7.20, 0.64, 1); // Edge of portal
|
||||
b.setPosition(-7.20, 0.64, -1);
|
||||
Assert.assertTrue(a.isLineOfSight(b));
|
||||
Assert.assertTrue(b.isLineOfSight(a));
|
||||
assertTrue(a.isLineOfSight(b));
|
||||
assertTrue(b.isLineOfSight(a));
|
||||
a.setPosition(-10, 0.64, 1); // Far beyond portal's view
|
||||
b.setPosition(-7.20, 0.64, -1);
|
||||
Assert.assertFalse(a.isLineOfSight(b));
|
||||
Assert.assertFalse(b.isLineOfSight(a));
|
||||
assertFalse(a.isLineOfSight(b));
|
||||
assertFalse(b.isLineOfSight(a));
|
||||
|
||||
// Testing portal null-5
|
||||
a.systemMove(null);
|
||||
@@ -79,18 +79,18 @@ public class TestSWGObject extends TestRunnerNoIntents {
|
||||
// Center of portal
|
||||
a.setLocation(Location.builder().setTerrain(Terrain.TATOOINE).setPosition(1, 0.63, 7.5).translateLocation(buio.getLocation()).build());
|
||||
b.setPosition(1, 0.63, 5.5);
|
||||
Assert.assertTrue(a.isLineOfSight(b));
|
||||
Assert.assertTrue(b.isLineOfSight(a));
|
||||
assertTrue(a.isLineOfSight(b));
|
||||
assertTrue(b.isLineOfSight(a));
|
||||
// Edge of portal
|
||||
a.setLocation(Location.builder().setTerrain(Terrain.TATOOINE).setPosition(2, 0.63, 7.5).translateLocation(buio.getLocation()).build());
|
||||
b.setPosition(2, 0.63, 5.5);
|
||||
Assert.assertTrue(a.isLineOfSight(b));
|
||||
Assert.assertTrue(b.isLineOfSight(a));
|
||||
assertTrue(a.isLineOfSight(b));
|
||||
assertTrue(b.isLineOfSight(a));
|
||||
// Just beyond portal's view
|
||||
a.setLocation(Location.builder().setTerrain(Terrain.TATOOINE).setPosition(3, 0.63, 7.5).translateLocation(buio.getLocation()).build());
|
||||
b.setPosition(2, 0.63, 5.5);
|
||||
Assert.assertFalse(a.isLineOfSight(b));
|
||||
Assert.assertFalse(b.isLineOfSight(a));
|
||||
assertFalse(a.isLineOfSight(b));
|
||||
assertFalse(b.isLineOfSight(a));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,14 +103,14 @@ public class TestSWGObject extends TestRunnerNoIntents {
|
||||
parent.setLocation(worldLocation);
|
||||
child.setPosition(0, 0, 0);
|
||||
|
||||
Assert.assertEquals(worldLocation, parent.getWorldLocation());
|
||||
Assert.assertEquals(worldLocation, parent.getLocation());
|
||||
Assert.assertEquals(worldLocation, child.getWorldLocation());
|
||||
Assert.assertEquals(new Location(0, 0, 0, Terrain.NABOO), child.getLocation());
|
||||
assertEquals(worldLocation, parent.getWorldLocation());
|
||||
assertEquals(worldLocation, parent.getLocation());
|
||||
assertEquals(worldLocation, child.getWorldLocation());
|
||||
assertEquals(new Location(0, 0, 0, Terrain.NABOO), child.getLocation());
|
||||
|
||||
child.setPosition(5, 5, 5);
|
||||
Assert.assertEquals(new Location(20, 22, 24, Terrain.NABOO), child.getWorldLocation());
|
||||
Assert.assertEquals(new Location(5, 5, 5, Terrain.NABOO), child.getLocation());
|
||||
assertEquals(new Location(20, 22, 24, Terrain.NABOO), child.getWorldLocation());
|
||||
assertEquals(new Location(5, 5, 5, Terrain.NABOO), child.getLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,46 +119,52 @@ public class TestSWGObject extends TestRunnerNoIntents {
|
||||
SWGObject child = new GenericTangibleObject(2);
|
||||
parent.setTerrain(Terrain.ADVENTURE1);
|
||||
|
||||
Assert.assertEquals(Terrain.ADVENTURE1, parent.getTerrain());
|
||||
Assert.assertEquals(Terrain.GONE, child.getTerrain());
|
||||
assertEquals(Terrain.ADVENTURE1, parent.getTerrain());
|
||||
assertEquals(Terrain.GONE, child.getTerrain());
|
||||
|
||||
child.moveToContainer(parent);
|
||||
Assert.assertEquals(Terrain.ADVENTURE1, parent.getTerrain());
|
||||
Assert.assertEquals(Terrain.ADVENTURE1, child.getTerrain());
|
||||
assertEquals(Terrain.ADVENTURE1, parent.getTerrain());
|
||||
assertEquals(Terrain.ADVENTURE1, child.getTerrain());
|
||||
|
||||
parent.setTerrain(Terrain.TATOOINE);
|
||||
Assert.assertEquals(Terrain.TATOOINE, parent.getTerrain());
|
||||
Assert.assertEquals(Terrain.TATOOINE, child.getTerrain());
|
||||
assertEquals(Terrain.TATOOINE, parent.getTerrain());
|
||||
assertEquals(Terrain.TATOOINE, child.getTerrain());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testChildTerrainInvalidParent1() {
|
||||
SWGObject parent = new GenericCreatureObject(1);
|
||||
SWGObject child = new GenericTangibleObject(2);
|
||||
parent.setTerrain(Terrain.ADVENTURE1);
|
||||
child.moveToContainer(parent);
|
||||
|
||||
child.setTerrain(Terrain.TATOOINE);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
child.setTerrain(Terrain.TATOOINE);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testChildTerrainInvalidParent2() {
|
||||
SWGObject parent = new GenericCreatureObject(1);
|
||||
SWGObject child = new GenericTangibleObject(2);
|
||||
parent.setTerrain(Terrain.ADVENTURE1);
|
||||
child.moveToContainer(parent);
|
||||
|
||||
child.setPosition(Terrain.CORELLIA, 0, 0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
child.setPosition(Terrain.CORELLIA, 0, 0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testChildTerrainInvalidParent3() {
|
||||
SWGObject parent = new GenericCreatureObject(1);
|
||||
SWGObject child = new GenericTangibleObject(2);
|
||||
parent.setTerrain(Terrain.ADVENTURE1);
|
||||
child.moveToContainer(parent);
|
||||
|
||||
child.setLocation(new Location(0, 0, 0, Terrain.NABOO));
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
child.setLocation(new Location(0, 0, 0, Terrain.NABOO));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,26 +175,26 @@ public class TestSWGObject extends TestRunnerNoIntents {
|
||||
child.setArrangement(List.of(List.of("inventory"), List.of("inventory", "datapad")));
|
||||
|
||||
parent.setSlots(List.of("inventory"));
|
||||
Assert.assertEquals(4, parent.getArrangementId(child));
|
||||
assertEquals(4, parent.getArrangementId(child));
|
||||
|
||||
parent.setSlots(List.of("inventory", "datapad"));
|
||||
Assert.assertEquals(4, parent.getArrangementId(child));
|
||||
assertEquals(4, parent.getArrangementId(child));
|
||||
|
||||
parent.removeObject(parent.getDatapad());
|
||||
|
||||
parent.setSlots(List.of("inventory"));
|
||||
Assert.assertEquals(4, parent.getArrangementId(child));
|
||||
assertEquals(4, parent.getArrangementId(child));
|
||||
|
||||
parent.setSlots(List.of("inventory", "datapad"));
|
||||
Assert.assertEquals(4, parent.getArrangementId(child));
|
||||
assertEquals(4, parent.getArrangementId(child));
|
||||
|
||||
child.setArrangement(List.of(List.of("inventory", "datapad")));
|
||||
|
||||
parent.setSlots(List.of("inventory"));
|
||||
Assert.assertEquals(-1, parent.getArrangementId(child));
|
||||
assertEquals(-1, parent.getArrangementId(child));
|
||||
|
||||
parent.setSlots(List.of("inventory", "datapad"));
|
||||
Assert.assertEquals(4, parent.getArrangementId(child));
|
||||
assertEquals(4, parent.getArrangementId(child));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -206,12 +212,12 @@ public class TestSWGObject extends TestRunnerNoIntents {
|
||||
ring1.moveToContainer(parent);
|
||||
ring2.moveToContainer(parent);
|
||||
|
||||
Assert.assertEquals("Should be able to equip a ring when slot is unoccupied", parent, ring1.getParent());
|
||||
Assert.assertEquals("Should be able to equip a second ring when a similar slot is unoccupied", parent, ring2.getParent());
|
||||
assertEquals(parent, ring1.getParent(), "Should be able to equip a ring when slot is unoccupied");
|
||||
assertEquals(parent, ring2.getParent(), "Should be able to equip a second ring when a similar slot is unoccupied");
|
||||
|
||||
ring3.moveToContainer(parent);
|
||||
|
||||
Assert.assertEquals("Ring 3 should have been equipped", parent, ring3.getParent());
|
||||
Assert.assertNotEquals("Ring 1 should have been unequipped", ring1.getParent(), parent);
|
||||
assertEquals(parent, ring3.getParent(), "Ring 3 should have been equipped");
|
||||
assertNotEquals(ring1.getParent(), parent, "Ring 1 should have been unequipped");
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -40,8 +40,8 @@ import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleOb
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import org.bson.Document;
|
||||
import org.bson.types.Binary;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -58,15 +58,15 @@ public class TestSWGPersistence {
|
||||
assertContains((Map<String, Object>) e.getValue(), (Map<String, Object>) actual.get(e.getKey()));
|
||||
} else if (actual.get(e.getKey()) instanceof Collection) {
|
||||
if (!(e.getValue() instanceof Collection))
|
||||
Assert.fail("expected value is not a collection for key: " + e.getKey());
|
||||
fail("expected value is not a collection for key: " + e.getKey());
|
||||
if (!(actual.get(e.getKey()) instanceof Collection))
|
||||
Assert.fail("actual value is not a collection for key: " + e.getKey());
|
||||
fail("actual value is not a collection for key: " + e.getKey());
|
||||
Collection<Object> expectedCollection = (Collection<Object>) e.getValue();
|
||||
Collection<Object> actualCollection = (Collection<Object>) actual.get(e.getKey());
|
||||
Assert.assertEquals("Key: '"+e.getKey()+"' Size mismatch.", expectedCollection.size(), actualCollection.size());
|
||||
Assert.assertTrue("Key: '"+e.getKey()+"' Expected <"+expectedCollection+"> but was <"+actualCollection+">", actualCollection.containsAll(expectedCollection));
|
||||
assertEquals(expectedCollection.size(), actualCollection.size(), "Key: '"+e.getKey()+"' Size mismatch.");
|
||||
assertTrue(actualCollection.containsAll(expectedCollection), "Key: '"+e.getKey()+"' Expected <"+expectedCollection+"> but was <"+actualCollection+">");
|
||||
} else {
|
||||
Assert.assertEquals("Key: '" + e.getKey() + "'", e.getValue(), actual.get(e.getKey()));
|
||||
assertEquals(e.getValue(), actual.get(e.getKey()), "Key: '" + e.getKey() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class TestSWGPersistence {
|
||||
SWGObject gen = SWGObjectFactory.create(new MongoData(saved));
|
||||
Document saved2 = SWGObjectFactory.save(gen, new MongoData()).toDocument();
|
||||
assertContains(expected, saved2);
|
||||
Assert.assertEquals(saved, saved2);
|
||||
assertEquals(saved, saved2);
|
||||
}
|
||||
|
||||
private void testSWGObject(SWGObject obj) {
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
package com.projectswg.holocore.resources.support.objects.swg.custom;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class IncapSafetyTimerTest {
|
||||
|
||||
|
||||
+12
-15
@@ -1,18 +1,15 @@
|
||||
package com.projectswg.holocore.resources.support.objects.swg.weapon;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestWeaponType {
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Input> parameters() {
|
||||
return Arrays.asList(
|
||||
// Melee, not lightsabers
|
||||
@@ -37,27 +34,27 @@ public class TestWeaponType {
|
||||
);
|
||||
}
|
||||
|
||||
@Parameterized.Parameter
|
||||
public Input input;
|
||||
|
||||
@Test
|
||||
public void testMelee() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
public void testMelee(Input input) {
|
||||
boolean expectMelee = input.isExpectMelee();
|
||||
WeaponType type = input.getType();
|
||||
|
||||
assertEquals(expectMelee, type.isMelee());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLightsaber() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
public void testLightsaber(Input input) {
|
||||
boolean expectLightsaber = input.isExpectLightSaber();
|
||||
WeaponType type = input.getType();
|
||||
|
||||
assertEquals(expectLightsaber, type.isLightsaber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRanged() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
public void testRanged(Input input) {
|
||||
boolean expectRanged = input.isExpectRanged();
|
||||
WeaponType type = input.getType();
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ package com.projectswg.holocore.resources.support.objects.swg.weapon;
|
||||
|
||||
import com.projectswg.holocore.resources.support.objects.ObjectCreator;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class WeaponObjectTest {
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ import com.projectswg.holocore.services.support.global.commands.CommandQueueServ
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.resources.GenericPlayer
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class AttackCostTest : TestRunnerSimulatedWorld() {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
registerService(CommandQueueService())
|
||||
registerService(CommandExecutionService())
|
||||
|
||||
@@ -17,13 +17,13 @@ import com.projectswg.holocore.services.support.global.commands.CommandQueueServ
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import com.projectswg.holocore.test.resources.GenericPlayer
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class FactionPvpTest : TestRunnerSimulatedWorld() {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
registerService(CommandQueueService())
|
||||
registerService(CommandExecutionService())
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ package com.projectswg.holocore.services.gameplay.combat.buffs
|
||||
|
||||
import com.projectswg.holocore.resources.support.global.commands.callbacks.BurstRunCmdCallback
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class BurstRunTest {
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package com.projectswg.holocore.services.gameplay.combat.command;
|
||||
|
||||
import com.projectswg.common.data.location.Location;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestCombatCommandAttack {
|
||||
@Test
|
||||
|
||||
+9
-15
@@ -9,27 +9,20 @@ import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject
|
||||
import com.projectswg.holocore.services.gameplay.combat.buffs.BuffService;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSynchronousIntents;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestCombatCommandBuffNpcs extends TestRunnerSynchronousIntents {
|
||||
|
||||
private CreatureObject source;
|
||||
private CreatureObject target;
|
||||
|
||||
@Parameterized.Parameter
|
||||
public Input input;
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Input> input() {
|
||||
long group1 = 1234;
|
||||
long group2 = 4321;
|
||||
@@ -44,8 +37,7 @@ public class TestCombatCommandBuffNpcs extends TestRunnerSynchronousIntents {
|
||||
);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
public void setup(Input input) {
|
||||
source = new GenericCreatureObject(1, "Player", true);
|
||||
source.setFaction(ServerData.INSTANCE.getFactions().getFaction("neutral"));
|
||||
source.setGroupId(input.getPlayerGroupId());
|
||||
@@ -67,8 +59,10 @@ public class TestCombatCommandBuffNpcs extends TestRunnerSynchronousIntents {
|
||||
registerService(new BuffService());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReceiveBuff() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("input")
|
||||
public void testReceiveBuff(Input input) {
|
||||
setup(input);
|
||||
String targetBuffName = "hemorrhage"; // Important that the buff actually exists
|
||||
Command command = Command.builder()
|
||||
.withName(targetBuffName)
|
||||
@@ -87,7 +81,7 @@ public class TestCombatCommandBuffNpcs extends TestRunnerSynchronousIntents {
|
||||
boolean expected = input.isExpected();
|
||||
String caseName = input.getCaseName();
|
||||
|
||||
assertEquals(caseName, expected, target.hasBuff(targetBuffName));
|
||||
assertEquals(expected, target.hasBuff(targetBuffName), caseName);
|
||||
}
|
||||
|
||||
private static class Input {
|
||||
|
||||
+10
-17
@@ -10,24 +10,19 @@ import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject
|
||||
import com.projectswg.holocore.services.gameplay.combat.buffs.BuffService;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSynchronousIntents;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestCombatCommandBuffPlayers extends TestRunnerSynchronousIntents {
|
||||
|
||||
private CreatureObject source;
|
||||
private CreatureObject target;
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Input> data() {
|
||||
return Arrays.asList(
|
||||
// Neutral cases
|
||||
@@ -63,11 +58,7 @@ public class TestCombatCommandBuffPlayers extends TestRunnerSynchronousIntents {
|
||||
);
|
||||
}
|
||||
|
||||
@Parameterized.Parameter // first data value (0) is default
|
||||
public Input input;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
public void setup(Input input) {
|
||||
source = new GenericCreatureObject(1, "Source Creature");
|
||||
FactionLoader.Faction sourceFaction = ServerData.INSTANCE.getFactions().getFaction(input.getSourceFactionName());
|
||||
source.setFaction(sourceFaction);
|
||||
@@ -87,8 +78,10 @@ public class TestCombatCommandBuffPlayers extends TestRunnerSynchronousIntents {
|
||||
registerService(new BuffService());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReceiveBuff() {
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void testReceiveBuff(Input input) {
|
||||
setup(input);
|
||||
String targetBuffName = "hemorrhage"; // Important that the buff actually exists
|
||||
Command command = Command.builder()
|
||||
.withName(targetBuffName)
|
||||
@@ -105,9 +98,9 @@ public class TestCombatCommandBuffPlayers extends TestRunnerSynchronousIntents {
|
||||
waitForIntents(); // Let's give the BuffService a chance to process the BuffIntent
|
||||
|
||||
if (input.isExpected()) {
|
||||
assertTrue("Source should be allowed to buff target", target.hasBuff(targetBuffName));
|
||||
assertTrue(target.hasBuff(targetBuffName), "Source should be allowed to buff target");
|
||||
} else {
|
||||
assertTrue("Source should have buffed themselves and not target due to factional restrictions", source.hasBuff(targetBuffName));
|
||||
assertTrue(source.hasBuff(targetBuffName), "Source should have buffed themselves and not target due to factional restrictions");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.projectswg.holocore.services.gameplay.player.experience;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class CombatLevelCalculatorTest {
|
||||
private final CombatLevel combatLevel1 = new CombatLevel(1, 500, 0);
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.projectswg.holocore.services.gameplay.player.experience;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class CombatXpCalculatorTest {
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.projectswg.holocore.services.gameplay.player.experience;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class HealthAddedCalculatorTest {
|
||||
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.projectswg.holocore.services.gameplay.player.experience;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class SdbCombatLevelRepositoryTest {
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.projectswg.holocore.services.gameplay.player.experience;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class SdbCombatXpMultiplierRepositoryTest {
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.projectswg.holocore.services.gameplay.training;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TrainingTest {
|
||||
|
||||
private SkillsSdbSkillRepository skillRepository;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
skillRepository = new SkillsSdbSkillRepository();
|
||||
}
|
||||
|
||||
+21
-20
@@ -41,9 +41,10 @@ import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -64,8 +65,8 @@ public class TestPlayerMountService extends TestRunnerSimulatedWorld {
|
||||
|
||||
// PCD [object/intangible/vehicle/shared_speederbike_swoop_pcd.iff] should be in the datapad
|
||||
Collection<SWGObject> datapadData = creature.getDatapad().getContainedObjects();
|
||||
Assert.assertEquals(1, datapadData.size());
|
||||
Assert.assertEquals("object/intangible/vehicle/shared_speederbike_swoop_pcd.iff", datapadData.iterator().next().getTemplate());
|
||||
assertEquals(1, datapadData.size());
|
||||
assertEquals("object/intangible/vehicle/shared_speederbike_swoop_pcd.iff", datapadData.iterator().next().getTemplate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,7 +92,7 @@ public class TestPlayerMountService extends TestRunnerSimulatedWorld {
|
||||
assertCorrectDismount(creature, vehicle, friend);
|
||||
|
||||
// Vehicle [object/mobile/vehicle/shared_speederbike_swoop.iff] should now be in the world alongside the player, and aware of eachother
|
||||
Assert.assertEquals(creature.getLocation(), vehicle.getLocation());
|
||||
assertEquals(creature.getLocation(), vehicle.getLocation());
|
||||
|
||||
broadcastAndWait(new PetDeviceStoreIntent(creature, pcd));
|
||||
updateAwareness();
|
||||
@@ -135,7 +136,7 @@ public class TestPlayerMountService extends TestRunnerSimulatedWorld {
|
||||
assertCorrectDismount(creature, vehicle, friend);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void enableLogging() {
|
||||
Log.addWrapper(new ConsoleLogWrapper());
|
||||
}
|
||||
@@ -154,28 +155,28 @@ public class TestPlayerMountService extends TestRunnerSimulatedWorld {
|
||||
}
|
||||
|
||||
private void assertCorrectStored(CreatureObject creature, CreatureObject vehicle, SWGObject ... awareness) {
|
||||
Assert.assertNull(creature.getParent());
|
||||
assertNull(creature.getParent());
|
||||
|
||||
Assert.assertTrue(creature.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
Assert.assertFalse(vehicle.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
Assert.assertFalse(creature.getAware(AwarenessType.SELF).contains(vehicle));
|
||||
Assert.assertFalse(vehicle.getAware(AwarenessType.SELF).contains(creature));
|
||||
assertTrue(creature.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
assertFalse(vehicle.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
assertFalse(creature.getAware(AwarenessType.SELF).contains(vehicle));
|
||||
assertFalse(vehicle.getAware(AwarenessType.SELF).contains(creature));
|
||||
}
|
||||
|
||||
private void assertCorrectMount(CreatureObject creature, CreatureObject vehicle, SWGObject ... awareness) {
|
||||
Assert.assertEquals(vehicle, creature.getParent());
|
||||
Assert.assertNull(vehicle.getParent());
|
||||
Assert.assertTrue(creature.isObserveWithParent());
|
||||
assertEquals(vehicle, creature.getParent());
|
||||
assertNull(vehicle.getParent());
|
||||
assertTrue(creature.isObserveWithParent());
|
||||
|
||||
Assert.assertTrue(creature.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
assertTrue(creature.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
}
|
||||
|
||||
private void assertCorrectDismount(CreatureObject creature, CreatureObject vehicle, SWGObject ... awareness) {
|
||||
Assert.assertNull(creature.getParent());
|
||||
Assert.assertNull(vehicle.getParent());
|
||||
Assert.assertTrue(creature.isObserveWithParent());
|
||||
assertNull(creature.getParent());
|
||||
assertNull(vehicle.getParent());
|
||||
assertTrue(creature.isObserveWithParent());
|
||||
|
||||
Assert.assertTrue(creature.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
assertTrue(creature.getAware(AwarenessType.OBJECT).containsAll(List.of(awareness)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -30,18 +30,18 @@ package com.projectswg.holocore.services.support.npc.ai
|
||||
import com.projectswg.common.data.location.Location
|
||||
import com.projectswg.holocore.resources.support.npc.ai.NavigationOffset
|
||||
import com.projectswg.holocore.test.runners.TestRunnerNoIntents
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.math.sqrt
|
||||
|
||||
class TestAIMovementService: TestRunnerNoIntents() {
|
||||
|
||||
@Test
|
||||
fun testOffsetLocation() {
|
||||
Assert.assertEquals("NORTH", 0.0, headingTo(0.0, 1.0), 1E-7)
|
||||
Assert.assertEquals("EAST", 270.0, headingTo(1.0, 0.0), 1E-7)
|
||||
Assert.assertEquals("SOUTH", 180.0, headingTo(0.0, -1.0), 1E-7)
|
||||
Assert.assertEquals("WEST", 90.0, headingTo(-1.0, 0.0), 1E-7)
|
||||
assertEquals(0.0, headingTo(0.0, 1.0), 1E-7, "NORTH")
|
||||
assertEquals(270.0, headingTo(1.0, 0.0), 1E-7, "EAST")
|
||||
assertEquals(180.0, headingTo(0.0, -1.0), 1E-7, "SOUTH")
|
||||
assertEquals(90.0, headingTo(-1.0, 0.0), 1E-7, "WEST")
|
||||
|
||||
testOffset(headingTo(0.0, 1.0), 1.0, 1.0)
|
||||
testOffset(headingTo(-1.0, 0.0), -1.0, 1.0)
|
||||
@@ -58,8 +58,8 @@ class TestAIMovementService: TestRunnerNoIntents() {
|
||||
private fun testOffset(heading: Double, tx: Double, tz: Double) {
|
||||
val startLocation = Location.builder().setPosition(0.0, 0.0, 0.0).build()
|
||||
val endLocation = AIMovementService.offsetLocation(startLocation, heading, NavigationOffset(1.0, 1.0))
|
||||
Assert.assertEquals("X", tx, endLocation.x, 1E-7)
|
||||
Assert.assertEquals("Z", tz, endLocation.z, 1E-7)
|
||||
assertEquals(tx, endLocation.x, 1E-7, "X")
|
||||
assertEquals(tz, endLocation.z, 1E-7, "Z")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-19
@@ -40,13 +40,13 @@ import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleOb
|
||||
import com.projectswg.holocore.test.runners.TestRunnerSimulatedWorld;
|
||||
import com.projectswg.holocore.test.resources.GenericCreatureObject;
|
||||
import com.projectswg.holocore.test.resources.GenericTangibleObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestRadialService extends TestRunnerSimulatedWorld {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void initServices() {
|
||||
registerService(new RadialService());
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class TestRadialService extends TestRunnerSimulatedWorld {
|
||||
sendRequest(creature, tangible, RadialItem.ITEM_USE, RadialItem.ITEM_DESTROY);
|
||||
|
||||
ObjectMenuResponse response = creature.getOwner().getNextPacket(ObjectMenuResponse.class);
|
||||
Assert.assertNull(response);
|
||||
assertNull(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,12 +72,12 @@ public class TestRadialService extends TestRunnerSimulatedWorld {
|
||||
sendRequest(creature, tangible, RadialItem.ITEM_USE, RadialItem.ITEM_DESTROY);
|
||||
|
||||
ObjectMenuResponse response = creature.getOwner().getNextPacket(ObjectMenuResponse.class);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(creature.getObjectId(), response.getRequestorId());
|
||||
Assert.assertEquals(tangible.getObjectId(), response.getTargetId());
|
||||
Assert.assertEquals(2, response.getOptions().size());
|
||||
Assert.assertEquals(RadialItem.ITEM_USE, response.getOptions().get(0).getType());
|
||||
Assert.assertEquals(RadialItem.ITEM_DESTROY, response.getOptions().get(1).getType());
|
||||
assertNotNull(response);
|
||||
assertEquals(creature.getObjectId(), response.getRequestorId());
|
||||
assertEquals(tangible.getObjectId(), response.getTargetId());
|
||||
assertEquals(2, response.getOptions().size());
|
||||
assertEquals(RadialItem.ITEM_USE, response.getOptions().get(0).getType());
|
||||
assertEquals(RadialItem.ITEM_DESTROY, response.getOptions().get(1).getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,16 +90,16 @@ public class TestRadialService extends TestRunnerSimulatedWorld {
|
||||
sendRequest(creature, dead, RadialItem.LOOT_ALL, RadialItem.EXAMINE);
|
||||
|
||||
ObjectMenuResponse response = creature.getOwner().getNextPacket(ObjectMenuResponse.class);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(creature.getObjectId(), response.getRequestorId());
|
||||
Assert.assertEquals(dead.getObjectId(), response.getTargetId());
|
||||
assertNotNull(response);
|
||||
assertEquals(creature.getObjectId(), response.getRequestorId());
|
||||
assertEquals(dead.getObjectId(), response.getTargetId());
|
||||
|
||||
Assert.assertEquals(2, response.getOptions().size());
|
||||
Assert.assertEquals(RadialItem.LOOT_ALL, response.getOptions().get(0).getType());
|
||||
Assert.assertEquals(RadialItem.EXAMINE, response.getOptions().get(1).getType());
|
||||
assertEquals(2, response.getOptions().size());
|
||||
assertEquals(RadialItem.LOOT_ALL, response.getOptions().get(0).getType());
|
||||
assertEquals(RadialItem.EXAMINE, response.getOptions().get(1).getType());
|
||||
|
||||
Assert.assertEquals(1, response.getOptions().get(0).getChildren().size());
|
||||
Assert.assertEquals(RadialItem.LOOT, response.getOptions().get(0).getChildren().get(0).getType());
|
||||
assertEquals(1, response.getOptions().get(0).getChildren().size());
|
||||
assertEquals(RadialItem.LOOT, response.getOptions().get(0).getChildren().get(0).getType());
|
||||
}
|
||||
|
||||
private void sendRequest(CreatureObject source, SWGObject target, RadialItem ... items) {
|
||||
|
||||
@@ -52,7 +52,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class GenericPlayer extends Player {
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ package com.projectswg.holocore.test.runners;
|
||||
import com.projectswg.holocore.resources.support.objects.ObjectCreator;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
public abstract class TestRunner {
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void initializeStatic() {
|
||||
Log.clearWrappers();
|
||||
Log.addWrapper(new ConsoleLogWrapper());
|
||||
|
||||
@@ -28,19 +28,19 @@
|
||||
package com.projectswg.holocore.test.runners;
|
||||
|
||||
import me.joshlarson.jlcommon.control.IntentManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
public abstract class TestRunnerNoIntents extends TestRunner {
|
||||
|
||||
private static final IntentManager INTENT_MANAGER = new IntentManager(0);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void initializeIntents() {
|
||||
IntentManager.setInstance(INTENT_MANAGER);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void terminateIntents() {
|
||||
IntentManager.setInstance(null);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ package com.projectswg.holocore.test.runners;
|
||||
import com.projectswg.holocore.services.support.global.zone.CharacterLookupService;
|
||||
import com.projectswg.holocore.services.support.objects.SimulatedObjectStorage;
|
||||
import com.projectswg.holocore.services.support.objects.awareness.AwarenessService;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
public abstract class TestRunnerSimulatedWorld extends TestRunnerSynchronousIntents {
|
||||
|
||||
private AwarenessService awareness;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public final void setupSimulatedServices() {
|
||||
registerService(new CharacterLookupService());
|
||||
registerService(new SimulatedObjectStorage());
|
||||
|
||||
+4
-4
@@ -33,8 +33,8 @@ import me.joshlarson.jlcommon.concurrency.Delay;
|
||||
import me.joshlarson.jlcommon.control.Intent;
|
||||
import me.joshlarson.jlcommon.control.IntentManager;
|
||||
import me.joshlarson.jlcommon.control.ServiceBase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -45,13 +45,13 @@ public abstract class TestRunnerSynchronousIntents extends TestRunner {
|
||||
private final Collection<ServiceBase> instantiatedServices = new ArrayList<>();
|
||||
private IntentManager intentManager = null;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public final void setupSynchronous() {
|
||||
intentManager = new IntentManager(1);
|
||||
IntentManager.setInstance(intentManager);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public final void cleanupServices() {
|
||||
for (ServiceBase service : instantiatedServices) {
|
||||
service.setIntentManager(null);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.projectswg.holocore.utilities;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class TestSdbGenerator {
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
@@ -16,14 +16,14 @@ public class TestSdbGenerator {
|
||||
private StringWriter stringWriter;
|
||||
private SdbGenerator generator;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
stringWriter = new StringWriter();
|
||||
generator = new SdbGenerator(new BufferedWriter(stringWriter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteColumnLine() throws IOException {
|
||||
public void columnNamesRetainOrder() throws IOException {
|
||||
String col1 = "col1";
|
||||
String col2 = "col2";
|
||||
String separator = "\t";
|
||||
@@ -34,11 +34,11 @@ public class TestSdbGenerator {
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
String expected = col1 + separator + col2;
|
||||
|
||||
assertEquals("Column names should be written in the given order, separated by a TAB", expected, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineStringType() throws IOException {
|
||||
public void canWriteString() throws IOException {
|
||||
String cell = "cell";
|
||||
|
||||
generator.writeLine(cell);
|
||||
@@ -46,11 +46,11 @@ public class TestSdbGenerator {
|
||||
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
|
||||
assertEquals("String data type should be supported", cell, result);
|
||||
assertEquals(cell, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineIntegerType() throws IOException {
|
||||
public void canWriteInt() throws IOException {
|
||||
int cell = 1234;
|
||||
|
||||
generator.writeLine(cell);
|
||||
@@ -59,22 +59,22 @@ public class TestSdbGenerator {
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
String expected = String.valueOf(cell);
|
||||
|
||||
assertEquals("int data type should be supported", expected, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineNullType() throws IOException {
|
||||
public void nullIsWrittenAsEmptyString() throws IOException {
|
||||
generator.writeLine(new Object[]{null});
|
||||
generator.close();
|
||||
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
String expected = "";
|
||||
|
||||
assertEquals("null should be written as an empty string", expected, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineCollectionTypeMultipleValues() throws IOException {
|
||||
public void multipleValuesInCollection() throws IOException {
|
||||
String valSeparator = ";";
|
||||
String val1 = "1";
|
||||
String val2 = "2";
|
||||
@@ -90,11 +90,11 @@ public class TestSdbGenerator {
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
String expected = val1 + valSeparator + val2;
|
||||
|
||||
assertEquals("Multiple values in a Collection should be supported", expected, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineCollectionTypeSingleValue() throws IOException {
|
||||
public void singleValueInCollection() throws IOException {
|
||||
String val = "1";
|
||||
|
||||
Collection<String> collection = Collections.singletonList(val);
|
||||
@@ -104,11 +104,11 @@ public class TestSdbGenerator {
|
||||
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
|
||||
assertEquals("Single value in a Collection should be supported", val, result);
|
||||
assertEquals(val, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineCollectionOfCollections() throws IOException {
|
||||
public void collectionOfCollections() throws IOException {
|
||||
String val1 = "1";
|
||||
String val2 = "2";
|
||||
String val3 = "3";
|
||||
@@ -126,11 +126,11 @@ public class TestSdbGenerator {
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
String expected = val1 + valSeparator + val2 + valSeparator + val3 + valSeparator + val4;
|
||||
|
||||
assertEquals("Collections of collections should be supported", expected, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteRowLineMapTypeSingleValue() throws IOException {
|
||||
public void multipleValuesInMap() throws IOException {
|
||||
String k1 = "k1";
|
||||
String k2 = "k2";
|
||||
String v1 = "v1";
|
||||
@@ -149,7 +149,7 @@ public class TestSdbGenerator {
|
||||
String result = stringWriter.toString().replace(LINE_SEPARATOR, "");
|
||||
String expected = k1 + pairSeparator + v1 + entrySeparator + k2 + pairSeparator + v2;
|
||||
|
||||
assertEquals("Single value in a Collection should be supported", expected, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user