mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-23 14:00:42 +00:00
Lightweight Locker (#578)
* object registration adjustments for players and avatars and lockers (especially lockers) * refactored locker container * modifications to fields and method names for guid-related files; SpecificNumberSource created * locker item display; proper item insertion into locker-space and searchability of that locker-space * proper item removal from locker-space, including swap-items on other insertion tasks * comments and tests; adjusted avatar/player registrations; allowed for restriction in the SpecificNumberSource; renamed CataloguedInventory to LocallyRegisteredInventory, and made internal object registration work * accommodations for RequestDestroy, to allow the locker's Clear button to work; modification of expectation for resolving projectiles through ValidObject
This commit is contained in:
parent
8245d3ff1e
commit
7626c8e6c9
55 changed files with 1743 additions and 948 deletions
|
|
@ -5,6 +5,7 @@ import net.psforever.objects.GlobalDefinitions._
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.avatar.{Avatar, BattleRank, Implant}
|
||||
import net.psforever.objects.definition.ImplantDefinition
|
||||
import net.psforever.objects.locker.LockerEquipment
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, ImplantType, PlanetSideEmpire}
|
||||
import org.specs2.mutable._
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import net.psforever.objects.avatar.Avatar
|
|||
import net.psforever.objects.definition._
|
||||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.inventory.InventoryTile
|
||||
import net.psforever.objects.locker.{LockerContainer, LockerEquipment}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
import net.psforever.objects.vehicles.UtilityType
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import net.psforever.objects._
|
|||
import net.psforever.objects.ballistics._
|
||||
import net.psforever.objects.equipment.JammableUnit
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.damage.Damageable
|
||||
import net.psforever.objects.serverobject.generator.{Generator, GeneratorControl}
|
||||
import net.psforever.objects.serverobject.implantmech.{ImplantTerminalMech, ImplantTerminalMechControl}
|
||||
|
|
@ -242,7 +242,7 @@ essentially, treat them more as generic entities whose object types are damageab
|
|||
see specific object type tests in relation to what those object types does above and beyond that during damage
|
||||
*/
|
||||
class DamageableEntityDamageTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ class DamageableEntityDamageTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableEntityDestroyedTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -387,7 +387,7 @@ class DamageableEntityDestroyedTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableEntityNotDestroyTwice extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -458,7 +458,7 @@ class DamageableEntityNotDestroyTwice extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableAmenityTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ class DamageableAmenityTest extends ActorTest {
|
|||
|
||||
class DamageableMountableDamageTest extends ActorTest {
|
||||
//TODO this test with not send HitHint packets because LivePlayers is not being allocated for the players in the zone
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ class DamageableMountableDamageTest extends ActorTest {
|
|||
|
||||
class DamageableMountableDestroyTest extends ActorTest {
|
||||
//TODO this test with not send HitHint packets because LivePlayers is not being allocated for the players in the zone
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -730,7 +730,7 @@ class DamageableMountableDestroyTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableWeaponTurretDamageTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -823,7 +823,7 @@ class DamageableWeaponTurretDamageTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableWeaponTurretJammerTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -918,7 +918,7 @@ class DamageableWeaponTurretJammerTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableWeaponTurretDestructionTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -1069,7 +1069,7 @@ class DamageableWeaponTurretDestructionTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableVehicleDamageTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -1174,7 +1174,7 @@ class DamageableVehicleDamageTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableVehicleDamageMountedTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -1315,7 +1315,7 @@ class DamageableVehicleDamageMountedTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableVehicleJammeringMountedTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -1428,7 +1428,7 @@ class DamageableVehicleJammeringMountedTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableVehicleDestroyTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -1531,7 +1531,7 @@ class DamageableVehicleDestroyTest extends ActorTest {
|
|||
}
|
||||
|
||||
class DamageableVehicleDestroyMountedTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import base.ActorTest
|
|||
import net.psforever.objects.ballistics._
|
||||
import net.psforever.objects.ce.DeployedItem
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.mount.Mountable
|
||||
import net.psforever.objects.vital.Vitality
|
||||
import net.psforever.objects.zones.{Zone, ZoneMap}
|
||||
|
|
@ -300,7 +300,7 @@ class ShieldGeneratorDeployableTest extends Specification {
|
|||
}
|
||||
|
||||
class ExplosiveDeployableJammerTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -398,7 +398,7 @@ class ExplosiveDeployableJammerTest extends ActorTest {
|
|||
}
|
||||
|
||||
class ExplosiveDeployableJammerExplodeTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -508,7 +508,7 @@ class ExplosiveDeployableJammerExplodeTest extends ActorTest {
|
|||
}
|
||||
|
||||
class ExplosiveDeployableDestructionTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import net.psforever.objects.avatar.Avatar
|
|||
import net.psforever.objects.{Default, GlobalDefinitions, Player, Tool}
|
||||
import net.psforever.objects.definition.ToolDefinition
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.serverobject.mount.Mountable
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
|
|
@ -182,7 +182,7 @@ class FacilityTurretControl4Test extends ActorTest {
|
|||
}
|
||||
|
||||
class FacilityTurretControlRestorationTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import net.psforever.objects.avatar.Avatar
|
|||
import net.psforever.objects.ballistics._
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Tool}
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.serverobject.generator.{Generator, GeneratorControl}
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
|
|
@ -46,7 +46,7 @@ class GeneratorControlConstructTest extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlDamageTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -128,7 +128,7 @@ class GeneratorControlDamageTest extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlCriticalTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -218,7 +218,7 @@ class GeneratorControlCriticalTest extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlDestroyedTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -341,7 +341,7 @@ class GeneratorControlKillsTest extends ActorTest {
|
|||
but its SOI information can be loaded with the players manually
|
||||
the players need something to catch the die message
|
||||
*/
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -478,7 +478,7 @@ class GeneratorControlKillsTest extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlNotDestroyTwice extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -561,7 +561,7 @@ class GeneratorControlNotDestroyTwice extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlNotDamageIfExplodingTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -655,7 +655,7 @@ class GeneratorControlNotDamageIfExplodingTest extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlNotRepairIfExplodingTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -753,7 +753,7 @@ class GeneratorControlNotRepairIfExplodingTest extends ActorTest {
|
|||
}
|
||||
|
||||
class GeneratorControlRepairPastRestorePoint extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(5))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(5))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ package objects
|
|||
|
||||
import net.psforever.objects.{AmmoBox, SimpleItem, Tool}
|
||||
import net.psforever.objects.definition.SimpleItemDefinition
|
||||
import net.psforever.objects.inventory.{GridInventory, InventoryDisarrayException, InventoryItem, InventoryTile}
|
||||
import net.psforever.objects.inventory._
|
||||
import net.psforever.objects.GlobalDefinitions.{bullet_9mm, suppressor}
|
||||
import net.psforever.types.PlanetSideGUID
|
||||
import org.specs2.mutable._
|
||||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import scala.util.{Success, Failure}
|
||||
import scala.util.{Failure, Success}
|
||||
|
||||
class InventoryTest extends Specification {
|
||||
val bullet9mmBox1 = AmmoBox(bullet_9mm)
|
||||
|
|
@ -522,6 +522,168 @@ class InventoryTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"LocallyRegisteredInventory" should {
|
||||
"construct" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15))
|
||||
obj.TotalCapacity mustEqual 1
|
||||
obj.Capacity mustEqual 1
|
||||
}
|
||||
|
||||
"insert (and register) item" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15))
|
||||
obj.Resize(9, 6)
|
||||
obj.Size mustEqual 0
|
||||
val item = AmmoBox(bullet_9mm)
|
||||
item.HasGUID mustEqual false
|
||||
obj.CheckCollisions(2, item) mustEqual Success(Nil)
|
||||
obj += 2 -> item
|
||||
obj.Size mustEqual 1
|
||||
obj.hasItem(PlanetSideGUID(15)).contains(item) mustEqual true
|
||||
item.HasGUID mustEqual true
|
||||
item.GUID mustEqual PlanetSideGUID(15)
|
||||
}
|
||||
|
||||
"insert (and register) complex item" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15, 16))
|
||||
obj.Resize(9, 6)
|
||||
obj.Size mustEqual 0
|
||||
val item = Tool(suppressor)
|
||||
item.HasGUID mustEqual false
|
||||
item.AmmoSlot.Box.HasGUID mustEqual false
|
||||
obj.CheckCollisions(2, item) mustEqual Success(Nil)
|
||||
obj += 2 -> item
|
||||
obj.Size mustEqual 1
|
||||
item.HasGUID mustEqual true
|
||||
item.AmmoSlot.Box.HasGUID mustEqual true
|
||||
}
|
||||
|
||||
"not insert item if already registered" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15))
|
||||
obj.Resize(9, 6)
|
||||
obj.Size mustEqual 0
|
||||
val item = AmmoBox(bullet_9mm)
|
||||
item.GUID = PlanetSideGUID(10) //artificially register
|
||||
item.HasGUID mustEqual true
|
||||
|
||||
obj.CheckCollisions(2, item) mustEqual Success(Nil) //insert should be possible
|
||||
obj += 2 -> item
|
||||
obj.Size mustEqual 0
|
||||
obj.hasItem(PlanetSideGUID(15)).isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"not insert (or register) item if no (more) GUID's are available" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15))
|
||||
obj.Resize(9, 6)
|
||||
val item1 = AmmoBox(bullet_9mm)
|
||||
val item2 = AmmoBox(bullet_9mm)
|
||||
item1.HasGUID mustEqual false
|
||||
item2.HasGUID mustEqual false
|
||||
|
||||
obj.CheckCollisions(2, item1) mustEqual Success(Nil) //insert should be possible
|
||||
obj += 2 -> item1
|
||||
obj.Size mustEqual 1
|
||||
obj.hasItem(PlanetSideGUID(15)).contains(item1) mustEqual true
|
||||
item1.HasGUID mustEqual true
|
||||
item1.GUID mustEqual PlanetSideGUID(15)
|
||||
|
||||
obj.CheckCollisions(5, item2) mustEqual Success(Nil) //insert should be possible
|
||||
obj += 5 -> item2
|
||||
obj.Size mustEqual 1
|
||||
item2.HasGUID mustEqual false
|
||||
}
|
||||
|
||||
"not insert (or register) complex item if no (more) GUID's are available" in {
|
||||
val item = Tool(suppressor)
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15))
|
||||
obj.Resize(9, 6)
|
||||
obj.Size mustEqual 0
|
||||
item.HasGUID mustEqual false
|
||||
item.AmmoSlot.Box.HasGUID mustEqual false
|
||||
|
||||
obj.CheckCollisions(2, item) mustEqual Success(Nil) //insert should be possible
|
||||
obj += 2 -> item
|
||||
obj.Size mustEqual 0
|
||||
item.HasGUID mustEqual false
|
||||
item.AmmoSlot.Box.HasGUID mustEqual false
|
||||
}
|
||||
|
||||
"insert (and register) multiple items" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15, 17))
|
||||
obj.Resize(9, 6)
|
||||
val item1 = AmmoBox(bullet_9mm)
|
||||
val item2 = AmmoBox(bullet_9mm)
|
||||
item1.HasGUID mustEqual false
|
||||
item2.HasGUID mustEqual false
|
||||
|
||||
obj.CheckCollisions(2, item1) mustEqual Success(Nil) //insert should be possible
|
||||
obj += 2 -> item1
|
||||
obj.Size mustEqual 1
|
||||
item1.HasGUID mustEqual true
|
||||
|
||||
obj.CheckCollisions(5, item2) mustEqual Success(Nil) //insert should be possible
|
||||
obj += 5 -> item2
|
||||
obj.Size mustEqual 2
|
||||
item2.HasGUID mustEqual true
|
||||
}
|
||||
|
||||
"clear (and unregister) all items" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15, 17))
|
||||
obj.Resize(9, 6)
|
||||
val item1 = AmmoBox(bullet_9mm)
|
||||
val item2 = AmmoBox(bullet_9mm)
|
||||
obj += 2 -> item1
|
||||
obj += 5 -> item2
|
||||
obj.Size mustEqual 2
|
||||
item1.HasGUID mustEqual true
|
||||
item2.HasGUID mustEqual true
|
||||
|
||||
obj.Clear()
|
||||
obj.Size mustEqual 0
|
||||
item1.HasGUID mustEqual false
|
||||
item2.HasGUID mustEqual false
|
||||
}
|
||||
|
||||
"remove (and unregister) item" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15, 17))
|
||||
obj.Resize(9, 6)
|
||||
val item1 = AmmoBox(bullet_9mm)
|
||||
val item2 = AmmoBox(bullet_9mm)
|
||||
obj += 2 -> item1
|
||||
obj += 5 -> item2
|
||||
obj.Size mustEqual 2
|
||||
item1.HasGUID mustEqual true
|
||||
item2.HasGUID mustEqual true
|
||||
|
||||
obj -= 2
|
||||
obj.Size mustEqual 1
|
||||
item1.HasGUID mustEqual false
|
||||
item2.HasGUID mustEqual true
|
||||
|
||||
obj -= 5
|
||||
obj.Size mustEqual 0
|
||||
item1.HasGUID mustEqual false
|
||||
item2.HasGUID mustEqual false
|
||||
}
|
||||
}
|
||||
|
||||
"remove (and unregister) complex item" in {
|
||||
val obj: LocallyRegisteredInventory = new LocallyRegisteredInventory(List(15, 17))
|
||||
obj.Resize(9, 6)
|
||||
val item = Tool(suppressor)
|
||||
item.HasGUID mustEqual false
|
||||
item.AmmoSlot.Box.HasGUID mustEqual false
|
||||
obj.CheckCollisions(2, item) mustEqual Success(Nil)
|
||||
obj += 2 -> item
|
||||
obj.Size mustEqual 1
|
||||
item.HasGUID mustEqual true
|
||||
item.AmmoSlot.Box.HasGUID mustEqual true
|
||||
|
||||
obj -= 2
|
||||
obj.Size mustEqual 0
|
||||
item.HasGUID mustEqual false
|
||||
item.AmmoSlot.Box.HasGUID mustEqual false
|
||||
}
|
||||
|
||||
"InventoryEquiupmentSlot" should {
|
||||
"insert, collide, insert" in {
|
||||
val obj: GridInventory = GridInventory(7, 7)
|
||||
|
|
|
|||
24
src/test/scala/objects/LocalTest.scala
Normal file
24
src/test/scala/objects/LocalTest.scala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package objects
|
||||
|
||||
import net.psforever.objects.{LocalLockerItem, LocalProjectile}
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class LocalTest extends Specification {
|
||||
"LocalProjectile" should {
|
||||
"construct" in {
|
||||
val obj = new LocalProjectile() //since they're just placeholders, they only need to construct
|
||||
obj.Definition.ObjectId mustEqual 0
|
||||
obj.Definition.Name mustEqual "projectile"
|
||||
}
|
||||
}
|
||||
|
||||
"LocalLockerItem" should {
|
||||
"construct" in {
|
||||
val obj = new LocalLockerItem() //since they're just placeholders, they only need to construct
|
||||
obj.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
obj.Definition.ObjectId mustEqual 0
|
||||
obj.Definition.Name mustEqual "locker-equipment"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import base.ActorTest
|
|||
import net.psforever.objects.avatar.{Avatar, PlayerControl}
|
||||
import net.psforever.objects.ballistics._
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.vital.Vitality
|
||||
import net.psforever.objects.zones.{Zone, ZoneMap}
|
||||
import net.psforever.objects._
|
||||
|
|
@ -20,7 +20,7 @@ import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
|
|||
import scala.concurrent.duration._
|
||||
|
||||
class PlayerControlHealTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -106,7 +106,7 @@ class PlayerControlHealTest extends ActorTest {
|
|||
}
|
||||
|
||||
class PlayerControlHealSelfTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -181,7 +181,7 @@ class PlayerControlHealSelfTest extends ActorTest {
|
|||
}
|
||||
|
||||
class PlayerControlRepairTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -277,7 +277,7 @@ class PlayerControlRepairTest extends ActorTest {
|
|||
}
|
||||
|
||||
class PlayerControlRepairSelfTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -352,7 +352,7 @@ class PlayerControlRepairSelfTest extends ActorTest {
|
|||
}
|
||||
|
||||
class PlayerControlDamageTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -449,7 +449,7 @@ class PlayerControlDamageTest extends ActorTest {
|
|||
}
|
||||
|
||||
class PlayerControlDeathStandingTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -575,7 +575,7 @@ class PlayerControlDeathStandingTest extends ActorTest {
|
|||
}
|
||||
|
||||
class PlayerControlDeathSeatedTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(15))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(15))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import net.psforever.objects._
|
|||
import net.psforever.objects.avatar.Avatar
|
||||
import net.psforever.objects.definition.{SimpleItemDefinition, SpecialExoSuitDefinition}
|
||||
import net.psforever.objects.equipment.EquipmentSize
|
||||
import net.psforever.objects.locker.LockerEquipment
|
||||
import net.psforever.types.{PlanetSideGUID, _}
|
||||
import org.specs2.mutable._
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,7 @@ class ProjectileTest extends Specification {
|
|||
val player = Player(Avatar(0, "TestCharacter", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val fury = Vehicle(GlobalDefinitions.fury)
|
||||
|
||||
"LocalProjectile" should {
|
||||
"construct" in {
|
||||
val obj = new LocalProjectile() //since they're just placeholders, they only need to construct
|
||||
obj.Definition.ObjectId mustEqual 0
|
||||
obj.Definition.Name mustEqual "projectile"
|
||||
}
|
||||
|
||||
"Range" should {
|
||||
"local projectile range" in {
|
||||
Projectile.baseUID < Projectile.rangeUID mustEqual true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import base.ActorTest
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.avatar.Avatar
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.serverobject.generator.{Generator, GeneratorControl}
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
|
|
@ -28,7 +28,7 @@ essentially, treat it more as a generic entity whose object type is repairable
|
|||
see GeneratorTest in relation to what the generator does above and beyond that during repair
|
||||
*/
|
||||
class RepairableEntityRepairTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ class RepairableEntityRepairTest extends ActorTest {
|
|||
}
|
||||
|
||||
class RepairableEntityNotRepairTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ class RepairableEntityNotRepairTest extends ActorTest {
|
|||
}
|
||||
|
||||
class RepairableAmenityTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ class RepairableAmenityTest extends ActorTest {
|
|||
}
|
||||
|
||||
class RepairableTurretWeapon extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -323,7 +323,7 @@ class RepairableTurretWeapon extends ActorTest {
|
|||
}
|
||||
|
||||
class RepairableVehicleRepair extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
@ -396,7 +396,7 @@ class RepairableVehicleRestoration extends ActorTest {
|
|||
/*
|
||||
no messages are dispatched, in this case, because most vehicles are flagged to not be repairable if destroyed
|
||||
*/
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import akka.testkit.TestProbe
|
|||
import base.ActorTest
|
||||
import net.psforever.actors.zone.{BuildingActor, ZoneActor}
|
||||
import net.psforever.objects.guid.{NumberPoolHub, TaskResolver}
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.CommonMessages
|
||||
import net.psforever.objects.{GlobalDefinitions, Ntu, Player, Vehicle}
|
||||
import net.psforever.objects.serverobject.resourcesilo.{ResourceSilo, ResourceSiloControl, ResourceSiloDefinition}
|
||||
|
|
@ -94,7 +94,7 @@ class ResourceSiloControlStartupTest extends ActorTest {
|
|||
}
|
||||
|
||||
class ResourceSiloControlUseTest extends ActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val map = new ZoneMap("test")
|
||||
val zone = new Zone("test", map, 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.{Actor, ActorContext, Props}
|
||||
import base.ActorTest
|
||||
import akka.actor.ActorContext
|
||||
import base.FreedContextActorTest
|
||||
import net.psforever.objects.GlobalDefinitions
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.serverobject.ServerObjectBuilder
|
||||
|
|
@ -11,361 +11,223 @@ import net.psforever.objects.serverobject.terminals.ProximityTerminal
|
|||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.types.{PlanetSideGUID, Vector3}
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
class BuildingBuilderTest extends ActorTest {
|
||||
class BuildingBuilderTest extends FreedContextActorTest {
|
||||
"Building object" should {
|
||||
"build" in {
|
||||
val structure: (String, Int, Int, Zone, ActorContext) => Building = Building.Structure(StructureType.Building)
|
||||
val actor = system.actorOf(
|
||||
Props(classOf[ServerObjectBuilderTest.BuildingTestActor], structure, "Building", 10, 10, Zone.Nowhere),
|
||||
"building"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Building])
|
||||
assert(reply.asInstanceOf[Building].MapId == 10)
|
||||
assert(reply.asInstanceOf[Building].Zone == Zone.Nowhere)
|
||||
val building = FoundationBuilder(structure).Build("building", 10, 10, Zone.Nowhere)(context)
|
||||
assert(building ne null)
|
||||
assert(building.isInstanceOf[Building])
|
||||
assert(building.MapId == 10)
|
||||
assert(building.Zone == Zone.Nowhere)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WarpGateBuilderTest extends ActorTest {
|
||||
class WarpGateBuilderTest extends FreedContextActorTest {
|
||||
"WarpGate object" should {
|
||||
"build" in {
|
||||
val structure: (String, Int, Int, Zone, ActorContext) => Building = WarpGate.Structure
|
||||
val actor = system.actorOf(
|
||||
Props(classOf[ServerObjectBuilderTest.BuildingTestActor], structure, "wgate", 10, 10, Zone.Nowhere),
|
||||
"wgate"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Building])
|
||||
assert(reply.asInstanceOf[Building].MapId == 10)
|
||||
assert(reply.asInstanceOf[Building].Zone == Zone.Nowhere)
|
||||
val building = FoundationBuilder(structure).Build("wgate", 10, 10, Zone.Nowhere)(context)
|
||||
assert(building ne null)
|
||||
assert(building.isInstanceOf[WarpGate])
|
||||
assert(building.MapId == 10)
|
||||
assert(building.Zone == Zone.Nowhere)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DoorObjectBuilderTest1 extends ActorTest {
|
||||
class DoorObjectBuilderTest1 extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
"Door object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(classOf[ServerObjectBuilderTest.BuilderTestActor], ServerObjectBuilder(1, Door.Constructor), hub),
|
||||
"door"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Door])
|
||||
assert(reply.asInstanceOf[Door].HasGUID)
|
||||
assert(reply.asInstanceOf[Door].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, Door.Constructor).Build(context, hub)
|
||||
assert(obj.isInstanceOf[Door])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DoorObjectBuilderTest2 extends ActorTest {
|
||||
class DoorObjectBuilderTest2 extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
"Door object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, Door.Constructor(Vector3(1, 2, 3))),
|
||||
hub
|
||||
),
|
||||
"door"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Door])
|
||||
assert(reply.asInstanceOf[Door].Position == Vector3(1, 2, 3))
|
||||
assert(reply.asInstanceOf[Door].HasGUID)
|
||||
assert(reply.asInstanceOf[Door].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, Door.Constructor(Vector3(1, 2, 3))).Build(context, hub)
|
||||
assert(obj.isInstanceOf[Door])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
assert(obj.Position == Vector3(1, 2, 3))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IFFLockObjectBuilderTest extends ActorTest {
|
||||
class IFFLockObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.locks.IFFLock
|
||||
"IFFLock object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, IFFLock.Constructor(Vector3(0f, 0f, 0f), Vector3(0f, 0f, 0f))),
|
||||
hub
|
||||
),
|
||||
"lock"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[IFFLock])
|
||||
assert(reply.asInstanceOf[IFFLock].HasGUID)
|
||||
assert(reply.asInstanceOf[IFFLock].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, IFFLock.Constructor(Vector3(1f, 1f, 1f), Vector3(2f, 2f, 2f))).Build(context, hub)
|
||||
assert(obj.isInstanceOf[IFFLock])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj.Position == Vector3(1,1,1))
|
||||
assert(obj.Outwards == Vector3(0.034899496f, 0.99939084f, 0.0f))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ImplantTerminalMechObjectBuilderTest extends ActorTest {
|
||||
class ImplantTerminalMechObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.implantmech.ImplantTerminalMech
|
||||
"Implant terminal mech object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, ImplantTerminalMech.Constructor(Vector3.Zero)),
|
||||
hub
|
||||
),
|
||||
"mech"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[ImplantTerminalMech])
|
||||
assert(reply.asInstanceOf[ImplantTerminalMech].HasGUID)
|
||||
assert(reply.asInstanceOf[ImplantTerminalMech].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, ImplantTerminalMech.Constructor(Vector3.Zero)).Build(context, hub)
|
||||
assert(obj.isInstanceOf[ImplantTerminalMech])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TerminalObjectBuilderTest extends ActorTest {
|
||||
class TerminalObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.GlobalDefinitions.order_terminal
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
"Terminal object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, Terminal.Constructor(Vector3(1.1f, 2.2f, 3.3f), order_terminal)),
|
||||
hub
|
||||
),
|
||||
"term"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal])
|
||||
assert(reply.asInstanceOf[Terminal].HasGUID)
|
||||
assert(reply.asInstanceOf[Terminal].GUID == PlanetSideGUID(1))
|
||||
assert(reply.asInstanceOf[Terminal].Position == Vector3(1.1f, 2.2f, 3.3f))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, Terminal.Constructor(Vector3(1.1f, 2.2f, 3.3f), order_terminal)).Build(context, hub)
|
||||
assert(obj.isInstanceOf[Terminal])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj.Position == Vector3(1.1f, 2.2f, 3.3f))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProximityTerminalObjectBuilderTest extends ActorTest {
|
||||
class ProximityTerminalObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.GlobalDefinitions.medical_terminal
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
"Terminal object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, ProximityTerminal.Constructor(medical_terminal)),
|
||||
hub
|
||||
),
|
||||
"term"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal])
|
||||
assert(reply.asInstanceOf[Terminal].HasGUID)
|
||||
assert(reply.asInstanceOf[Terminal].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, ProximityTerminal.Constructor(medical_terminal)).Build(context, hub)
|
||||
assert(obj.isInstanceOf[Terminal])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnPadObjectBuilderTest extends ActorTest {
|
||||
class VehicleSpawnPadObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.pad.VehicleSpawnPad
|
||||
"Vehicle spawn pad object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(
|
||||
1,
|
||||
VehicleSpawnPad
|
||||
.Constructor(Vector3(1.1f, 2.2f, 3.3f), GlobalDefinitions.mb_pad_creation, Vector3(4.4f, 5.5f, 6.6f))
|
||||
),
|
||||
hub
|
||||
),
|
||||
"pad"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[VehicleSpawnPad])
|
||||
assert(reply.asInstanceOf[VehicleSpawnPad].HasGUID)
|
||||
assert(reply.asInstanceOf[VehicleSpawnPad].GUID == PlanetSideGUID(1))
|
||||
assert(reply.asInstanceOf[VehicleSpawnPad].Position == Vector3(1.1f, 2.2f, 3.3f))
|
||||
assert(reply.asInstanceOf[VehicleSpawnPad].Orientation == Vector3(4.4f, 5.5f, 6.6f))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1,
|
||||
VehicleSpawnPad.Constructor(
|
||||
Vector3(1.1f, 2.2f, 3.3f), GlobalDefinitions.mb_pad_creation, Vector3(4.4f, 5.5f, 6.6f)
|
||||
)
|
||||
).Build(context, hub)
|
||||
assert(obj.isInstanceOf[VehicleSpawnPad])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj.Position == Vector3(1.1f, 2.2f, 3.3f))
|
||||
assert(obj.Orientation == Vector3(4.4f, 5.5f, 6.6f))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LocalProjectileBuilderTest extends ActorTest {
|
||||
class LocalProjectileBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.LocalProjectile
|
||||
"Local projectile object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, LocalProjectile.Constructor),
|
||||
hub
|
||||
),
|
||||
"locker"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[LocalProjectile])
|
||||
assert(reply.asInstanceOf[LocalProjectile].HasGUID)
|
||||
assert(reply.asInstanceOf[LocalProjectile].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, LocalProjectile.Constructor).Build(context, hub)
|
||||
assert(obj.isInstanceOf[LocalProjectile])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LockerObjectBuilderTest extends ActorTest {
|
||||
class LockerObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.mblocker.Locker
|
||||
"Locker object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(classOf[ServerObjectBuilderTest.BuilderTestActor], ServerObjectBuilder(1, Locker.Constructor), hub),
|
||||
"locker"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[Locker])
|
||||
assert(reply.asInstanceOf[Locker].HasGUID)
|
||||
assert(reply.asInstanceOf[Locker].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, Locker.Constructor).Build(context, hub)
|
||||
assert(obj.isInstanceOf[Locker])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ResourceSiloObjectBuilderTest extends ActorTest {
|
||||
class ResourceSiloObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.resourcesilo.ResourceSilo
|
||||
"Resource silo object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, ResourceSilo.Constructor(Vector3(0f, 0f, 0f))),
|
||||
hub
|
||||
),
|
||||
"resource-silo"
|
||||
)
|
||||
actor ! "startup"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[ResourceSilo])
|
||||
assert(reply.asInstanceOf[ResourceSilo].HasGUID)
|
||||
assert(reply.asInstanceOf[ResourceSilo].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, ResourceSilo.Constructor(Vector3(1f, 1f, 1f))).Build(context, hub)
|
||||
assert(obj.isInstanceOf[ResourceSilo])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj.Position == Vector3(1,1,1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SpawnTubeObjectBuilderTest extends ActorTest {
|
||||
class SpawnTubeObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
"Spawn tube object" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, SpawnTube.Constructor(Vector3(3980.4062f, 4267.3047f, 257.5625f), Vector3(0, 0, 90))),
|
||||
hub
|
||||
),
|
||||
"spawn-tube"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[SpawnTube])
|
||||
assert(reply.asInstanceOf[SpawnTube].HasGUID)
|
||||
assert(reply.asInstanceOf[SpawnTube].GUID == PlanetSideGUID(1))
|
||||
assert(reply.asInstanceOf[SpawnTube].Position == Vector3(3980.4062f, 4267.3047f, 257.5625f))
|
||||
assert(reply.asInstanceOf[SpawnTube].Orientation == Vector3(0, 0, 90))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(
|
||||
1,
|
||||
SpawnTube.Constructor(Vector3(3980.4062f, 4267.3047f, 257.5625f), Vector3(0, 0, 90))
|
||||
).Build(context, hub)
|
||||
assert(obj.isInstanceOf[SpawnTube])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj.Position == Vector3(3980.4062f, 4267.3047f, 257.5625f))
|
||||
assert(obj.Orientation == Vector3(0, 0, 90))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FacilityTurretObjectBuilderTest extends ActorTest {
|
||||
class FacilityTurretObjectBuilderTest extends FreedContextActorTest {
|
||||
import net.psforever.objects.GlobalDefinitions.manned_turret
|
||||
import net.psforever.objects.serverobject.turret.FacilityTurret
|
||||
"FacilityTurretObjectBuilder" should {
|
||||
"build" in {
|
||||
val hub = ServerObjectBuilderTest.NumberPoolHub
|
||||
val actor = system.actorOf(
|
||||
Props(
|
||||
classOf[ServerObjectBuilderTest.BuilderTestActor],
|
||||
ServerObjectBuilder(1, FacilityTurret.Constructor(manned_turret)),
|
||||
hub
|
||||
),
|
||||
"manned-turret"
|
||||
)
|
||||
actor ! "!"
|
||||
|
||||
val reply = receiveOne(Duration.create(1000, "ms"))
|
||||
assert(reply.isInstanceOf[FacilityTurret])
|
||||
assert(reply.asInstanceOf[FacilityTurret].HasGUID)
|
||||
assert(reply.asInstanceOf[FacilityTurret].GUID == PlanetSideGUID(1))
|
||||
assert(reply == hub(1).get)
|
||||
val obj = ServerObjectBuilder(1, FacilityTurret.Constructor(manned_turret)).Build(context, hub)
|
||||
assert(obj.isInstanceOf[FacilityTurret])
|
||||
assert(obj.HasGUID)
|
||||
assert(obj.GUID == PlanetSideGUID(1))
|
||||
assert(obj == hub(1).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object ServerObjectBuilderTest {
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
def NumberPoolHub: NumberPoolHub = {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(2))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(2))
|
||||
obj
|
||||
}
|
||||
|
||||
class BuilderTestActor(builder: ServerObjectBuilder[_], hub: NumberPoolHub) extends Actor {
|
||||
def receive: Receive = {
|
||||
case _ =>
|
||||
sender() ! builder.Build(context, hub)
|
||||
}
|
||||
}
|
||||
|
||||
class BuildingTestActor(
|
||||
structure_con: (String, Int, Int, Zone, ActorContext) => Building,
|
||||
name: String,
|
||||
building_guid: Int,
|
||||
map_id: Int,
|
||||
zone: Zone
|
||||
) extends Actor {
|
||||
def receive: Receive = {
|
||||
case _ =>
|
||||
sender() ! FoundationBuilder(structure_con).Build(name, building_guid, map_id, zone)(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import base.{ActorTest, FreedContextActorTest}
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.definition.{SeatDefinition, VehicleDefinition}
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.mount.Mountable
|
||||
import net.psforever.objects.vehicles._
|
||||
import net.psforever.objects.vital.VehicleShieldCharge
|
||||
|
|
@ -408,7 +408,7 @@ class VehicleControlPrepareForDeletionPassengerTest extends ActorTest {
|
|||
|
||||
class VehicleControlPrepareForDeletionMountedInTest extends FreedContextActorTest {
|
||||
ServiceManager.boot
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
GUID(guid)
|
||||
|
||||
|
|
@ -534,7 +534,7 @@ class VehicleControlPrepareForDeletionMountedInTest extends FreedContextActorTes
|
|||
}
|
||||
|
||||
class VehicleControlPrepareForDeletionMountedCargoTest extends FreedContextActorTest {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
ServiceManager.boot
|
||||
val zone = new Zone("test", new ZoneMap("test"), 0) {
|
||||
GUID(guid)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import base.ActorTest
|
|||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
import net.psforever.objects._
|
||||
|
|
@ -104,7 +104,7 @@ class ZoneTest extends Specification {
|
|||
|
||||
"can have its unique identifier system changed if no objects were added to it" in {
|
||||
val zone = new Zone("home3", map13, 13)
|
||||
val guid1: NumberPoolHub = new NumberPoolHub(new LimitedNumberSource(100))
|
||||
val guid1: NumberPoolHub = new NumberPoolHub(new MaxNumberSource(100))
|
||||
zone.GUID(guid1) mustEqual true
|
||||
zone.AddPool("pool1", (0 to 50).toList)
|
||||
zone.AddPool("pool2", (51 to 75).toList)
|
||||
|
|
@ -114,7 +114,7 @@ class ZoneTest extends Specification {
|
|||
registration.isSuccess mustEqual true
|
||||
guid1.WhichPool(obj).contains("pool2") mustEqual true
|
||||
|
||||
zone.GUID(new NumberPoolHub(new LimitedNumberSource(150))) mustEqual false
|
||||
zone.GUID(new NumberPoolHub(new MaxNumberSource(150))) mustEqual false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ class ZoneActorTest extends ActorTest {
|
|||
"Zone" should {
|
||||
"refuse new number pools after the Actor is started" in {
|
||||
val zone = new Zone("test", new ZoneMap("map6"), 1) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(new NumberPoolHub(new LimitedNumberSource(40150)))
|
||||
zone.GUID(new NumberPoolHub(new MaxNumberSource(40150)))
|
||||
zone.actor = system.spawn(ZoneActor(zone), "test-add-pool-actor-init")
|
||||
expectNoMessage(Duration.create(500, "ms"))
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ class ZoneActorTest extends ActorTest {
|
|||
"refuse to remove number pools after the Actor is started" in {
|
||||
val zone = new Zone("test", new ZoneMap("map6"), 1) { override def SetupNumberPools() = {} }
|
||||
|
||||
zone.GUID(new NumberPoolHub(new LimitedNumberSource(10)))
|
||||
zone.GUID(new NumberPoolHub(new MaxNumberSource(10)))
|
||||
zone.AddPool("test", 1 to 2)
|
||||
zone.actor = system.spawn(ZoneActor(zone), "test-remove-pool-actor-init")
|
||||
expectNoMessage(Duration.create(300, "ms"))
|
||||
|
|
@ -482,7 +482,7 @@ class ZonePopulationTest extends ActorTest {
|
|||
|
||||
class ZoneGroundDropItemTest extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
hub.register(item, 10)
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(hub)
|
||||
|
|
@ -507,7 +507,7 @@ class ZoneGroundDropItemTest extends ActorTest {
|
|||
|
||||
class ZoneGroundCanNotDropItem1Test extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
//hub.register(item, 10) //!important
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(hub)
|
||||
|
|
@ -532,7 +532,7 @@ class ZoneGroundCanNotDropItem1Test extends ActorTest {
|
|||
|
||||
class ZoneGroundCanNotDropItem2Test extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
hub.register(item, 10) //!important
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
//zone.GUID(hub) //!important
|
||||
|
|
@ -557,7 +557,7 @@ class ZoneGroundCanNotDropItem2Test extends ActorTest {
|
|||
|
||||
class ZoneGroundCanNotDropItem3Test extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
hub.register(item, 10) //!important
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(hub) //!important
|
||||
|
|
@ -590,7 +590,7 @@ class ZoneGroundCanNotDropItem3Test extends ActorTest {
|
|||
|
||||
class ZoneGroundPickupItemTest extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
hub.register(item, 10)
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(hub)
|
||||
|
|
@ -618,7 +618,7 @@ class ZoneGroundPickupItemTest extends ActorTest {
|
|||
|
||||
class ZoneGroundCanNotPickupItemTest extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
hub.register(item, 10)
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(hub) //still registered to this zone
|
||||
|
|
@ -642,7 +642,7 @@ class ZoneGroundCanNotPickupItemTest extends ActorTest {
|
|||
|
||||
class ZoneGroundRemoveItemTest extends ActorTest {
|
||||
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(20))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
||||
hub.register(item, 10)
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
||||
zone.GUID(hub) //still registered to this zone
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import base.ActorTest
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.avatar.Avatar
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import net.psforever.objects.locker.LockerEquipment
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire}
|
||||
|
||||
class GUIDTaskRegisterAvatarTest extends ActorTest {
|
||||
|
|
@ -26,7 +27,7 @@ class GUIDTaskRegisterAvatarTest extends ActorTest {
|
|||
assert(!obj_wep_ammo.HasGUID)
|
||||
assert(!obj_inv_ammo.HasGUID)
|
||||
assert(!obj_locker.HasGUID)
|
||||
assert(!obj_locker_ammo.HasGUID)
|
||||
assert(obj_locker_ammo.HasGUID)
|
||||
taskResolver ! TaskResolver.GiveTask(
|
||||
new GUIDTaskTest.RegisterTestTask(probe.ref),
|
||||
List(GUIDTask.RegisterAvatar(obj)(uns))
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import base.ActorTest
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.avatar.Avatar
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import net.psforever.objects.locker.LockerEquipment
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire}
|
||||
|
||||
class GUIDTaskRegisterPlayerTest extends ActorTest {
|
||||
|
|
@ -26,7 +27,7 @@ class GUIDTaskRegisterPlayerTest extends ActorTest {
|
|||
assert(!obj_wep_ammo.HasGUID)
|
||||
assert(!obj_inv_ammo.HasGUID)
|
||||
assert(!obj_locker.HasGUID)
|
||||
assert(!obj_locker_ammo.HasGUID)
|
||||
assert(obj_locker_ammo.HasGUID)
|
||||
taskResolver ! TaskResolver.GiveTask(
|
||||
new GUIDTaskTest.RegisterTestTask(probe.ref),
|
||||
List(GUIDTask.RegisterPlayer(obj)(uns))
|
||||
|
|
@ -37,6 +38,6 @@ class GUIDTaskRegisterPlayerTest extends ActorTest {
|
|||
assert(obj_wep_ammo.HasGUID)
|
||||
assert(obj_inv_ammo.HasGUID)
|
||||
assert(!obj_locker.HasGUID)
|
||||
assert(!obj_locker_ammo.HasGUID)
|
||||
assert(obj_locker_ammo.HasGUID)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import akka.testkit.TestProbe
|
|||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
import net.psforever.objects.guid.actor.{NumberPoolActor, UniqueNumberSystem}
|
||||
import net.psforever.objects.guid.selector.RandomSelector
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.guid.{NumberPoolHub, Task, TaskResolver}
|
||||
|
||||
object GUIDTaskTest {
|
||||
|
|
@ -26,7 +26,7 @@ object GUIDTaskTest {
|
|||
import akka.routing.RandomPool
|
||||
import akka.testkit.TestProbe
|
||||
|
||||
val guid: NumberPoolHub = new NumberPoolHub(new LimitedNumberSource(110))
|
||||
val guid: NumberPoolHub = new NumberPoolHub(new MaxNumberSource(110))
|
||||
guid.AddPool("dynamic", (1 to 100).toList).Selector = new RandomSelector //TODO name is hardcoded for now
|
||||
val uns = system.actorOf(
|
||||
RandomPool(25).props(Props(classOf[UniqueNumberSystem], guid, GUIDTaskTest.AllocateNumberPoolActors(guid))),
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import base.ActorTest
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.avatar.Avatar
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import net.psforever.objects.locker.LockerEquipment
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire}
|
||||
|
||||
class GUIDTaskUnregisterAvatarTest extends ActorTest {
|
||||
|
|
@ -43,6 +44,6 @@ class GUIDTaskUnregisterAvatarTest extends ActorTest {
|
|||
assert(!obj_wep_ammo.HasGUID)
|
||||
assert(!obj_inv_ammo.HasGUID)
|
||||
assert(!obj_locker.HasGUID)
|
||||
assert(!obj_locker_ammo.HasGUID)
|
||||
assert(obj_locker_ammo.HasGUID)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import base.ActorTest
|
|||
import net.psforever.objects._
|
||||
import net.psforever.objects.avatar.Avatar
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import net.psforever.objects.locker.LockerEquipment
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire}
|
||||
|
||||
class GUIDTaskUnregisterPlayerTest extends ActorTest {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ package objects.number
|
|||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.selector.RandomSelector
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.types.PlanetSideGUID
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
|
|
@ -20,17 +20,17 @@ class NumberPoolHubTest extends Specification {
|
|||
|
||||
"NumberPoolHub" should {
|
||||
"construct" in {
|
||||
new NumberPoolHub(new LimitedNumberSource(51))
|
||||
new NumberPoolHub(new MaxNumberSource(51))
|
||||
ok
|
||||
}
|
||||
|
||||
"get a pool" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.GetPool("generic").isDefined mustEqual true //default pool
|
||||
}
|
||||
|
||||
"add a pool" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.Numbers.isEmpty mustEqual true
|
||||
obj.AddPool("fibonacci", numberList)
|
||||
obj.Numbers.toSet.equals(numberList.toSet) mustEqual true
|
||||
|
|
@ -40,7 +40,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"enumerate the content of all pools" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.AddPool("fibonacci1", numberList1)
|
||||
obj.AddPool("fibonacci2", numberList2)
|
||||
numberSet1.intersect(obj.Numbers.toSet) mustEqual numberSet1
|
||||
|
|
@ -49,7 +49,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"remove a pool" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.Numbers.isEmpty mustEqual true
|
||||
obj.AddPool("fibonacci", numberList)
|
||||
obj.Numbers.toSet.equals(numberList.toSet) mustEqual true
|
||||
|
|
@ -59,19 +59,19 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"block removing the default 'generic' pool" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.RemovePool("generic") must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"block adding pools that use already-included numbers" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.AddPool("fibonacci1", numberList)
|
||||
val numberList4 = 3 :: 7 :: 21 :: 34 :: 45 :: Nil
|
||||
obj.AddPool("fibonacci2", numberList4) must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"enumerate only the content of all current pools" in {
|
||||
val obj = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val obj = new NumberPoolHub(new MaxNumberSource(51))
|
||||
obj.AddPool("fibonacci1", numberList1)
|
||||
obj.AddPool("fibonacci2", numberList2)
|
||||
numberSet1.intersect(obj.Numbers.toSet) mustEqual numberSet1
|
||||
|
|
@ -82,7 +82,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"register an object to a pool" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList)
|
||||
val obj = new EntityTestClass()
|
||||
obj.GUID must throwA[Exception]
|
||||
|
|
@ -95,7 +95,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"lookup a registered object" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList)
|
||||
val obj = new EntityTestClass()
|
||||
hub.register(obj, "fibonacci") match {
|
||||
|
|
@ -108,14 +108,14 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"lookup the pool of a(n unassigned) number" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci1", numberList1)
|
||||
hub.AddPool("fibonacci2", numberList2)
|
||||
hub.WhichPool(13).contains("fibonacci2") mustEqual true
|
||||
}
|
||||
|
||||
"lookup the pool of a registered object" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList1)
|
||||
val obj = new EntityTestClass()
|
||||
hub.register(obj, "fibonacci")
|
||||
|
|
@ -123,7 +123,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"register an object to a specific, unused number; it is assigned to pool 'generic'" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList1)
|
||||
val obj = new EntityTestClass()
|
||||
obj.GUID must throwA[Exception]
|
||||
|
|
@ -137,7 +137,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"register an object to a specific, pooled number (list 1)" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
val src = new MaxNumberSource(51)
|
||||
val hub = new NumberPoolHub(src)
|
||||
hub.AddPool("fibonacci", numberList)
|
||||
val obj = new EntityTestClass()
|
||||
|
|
@ -146,14 +146,14 @@ class NumberPoolHubTest extends Specification {
|
|||
case Success(number) =>
|
||||
obj.GUID mustEqual PlanetSideGUID(number)
|
||||
hub.WhichPool(obj).contains("fibonacci") mustEqual true
|
||||
src.Available(5).isEmpty mustEqual true
|
||||
src.getAvailable(5).isEmpty mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"register an object to a specific, pooled number (list 2)" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
val src = new MaxNumberSource(51)
|
||||
val hub = new NumberPoolHub(src)
|
||||
hub.AddPool("fibonacci", numberList2)
|
||||
val obj = new EntityTestClass()
|
||||
|
|
@ -162,21 +162,21 @@ class NumberPoolHubTest extends Specification {
|
|||
case Success(number) =>
|
||||
obj.GUID mustEqual PlanetSideGUID(number)
|
||||
hub.WhichPool(obj).contains("fibonacci") mustEqual true
|
||||
src.Available(13).isEmpty mustEqual true
|
||||
src.getAvailable(13).isEmpty mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"register an object without extra specifications; it is assigned to pool 'generic'" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
val obj = new EntityTestClass()
|
||||
hub.register(obj)
|
||||
hub.WhichPool(obj).contains("generic") mustEqual true
|
||||
}
|
||||
|
||||
"unregister an object" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList)
|
||||
val obj = new EntityTestClass()
|
||||
obj.HasGUID mustEqual false
|
||||
|
|
@ -190,7 +190,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"not register an object to a different pool" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci1", numberList1)
|
||||
hub.AddPool("fibonacci2", numberList2)
|
||||
val obj = new EntityTestClass()
|
||||
|
|
@ -200,17 +200,17 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"fail to unregister an object that is not registered to this hub" in {
|
||||
val hub1 = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub2 = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub1 = new NumberPoolHub(new MaxNumberSource(51))
|
||||
val hub2 = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub1.AddPool("fibonacci", numberList)
|
||||
hub2.AddPool("fibonacci", numberList)
|
||||
val obj = new EntityTestClass()
|
||||
hub1.register(obj, "fibonacci")
|
||||
hub2.unregister(obj) must throwA[Exception]
|
||||
hub2.unregister(obj).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"pre-register a specific, unused number" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.register(13) match {
|
||||
case Success(_) =>
|
||||
ok
|
||||
|
|
@ -220,7 +220,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"pre-register a specific, pooled number" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList)
|
||||
hub.register(13) match {
|
||||
case Success(key) =>
|
||||
|
|
@ -231,7 +231,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"pre-register a number from a known pool" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList).Selector = new RandomSelector
|
||||
hub.register("fibonacci") match {
|
||||
case Success(key) =>
|
||||
|
|
@ -242,7 +242,7 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"unregister a number" in {
|
||||
val hub = new NumberPoolHub(new LimitedNumberSource(51))
|
||||
val hub = new NumberPoolHub(new MaxNumberSource(51))
|
||||
hub.AddPool("fibonacci", numberList).Selector = new RandomSelector //leave this tagged on
|
||||
val obj = new EntityTestClass()
|
||||
hub.register(13) match {
|
||||
|
|
@ -263,48 +263,48 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"not affect the hidden restricted pool by adding a new pool" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
src.Restrict(4)
|
||||
src.Restrict(8) //in fibonacci
|
||||
src.Restrict(10)
|
||||
src.Restrict(12)
|
||||
val src = new MaxNumberSource(51)
|
||||
src.restrictNumber(4)
|
||||
src.restrictNumber(8) //in fibonacci
|
||||
src.restrictNumber(10)
|
||||
src.restrictNumber(12)
|
||||
val hub = new NumberPoolHub(src)
|
||||
hub.AddPool("fibonacci", numberList) must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"not register an object to a number belonging to the restricted pool" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
src.Restrict(4)
|
||||
val src = new MaxNumberSource(51)
|
||||
src.restrictNumber(4)
|
||||
val hub = new NumberPoolHub(src)
|
||||
val obj = new EntityTestClass()
|
||||
hub.register(obj, 4).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"not register an object to the restricted pool directly" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
// src.Restrict(4)
|
||||
val src = new MaxNumberSource(51)
|
||||
// src.restrictNumber(4)
|
||||
val hub = new NumberPoolHub(src)
|
||||
val obj = new EntityTestClass()
|
||||
hub.register(obj, "").isFailure mustEqual true //the empty string represents the restricted pool
|
||||
}
|
||||
|
||||
"not register a number belonging to the restricted pool" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
src.Restrict(4)
|
||||
val src = new MaxNumberSource(51)
|
||||
src.restrictNumber(4)
|
||||
val hub = new NumberPoolHub(src)
|
||||
hub.register(4).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"not unregister a number belonging to the restricted pool" in {
|
||||
val src = new LimitedNumberSource(51)
|
||||
src.Restrict(4)
|
||||
val src = new MaxNumberSource(51)
|
||||
src.restrictNumber(4)
|
||||
val hub = new NumberPoolHub(src)
|
||||
hub.unregister(4).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"identity an object that is registered to it" in {
|
||||
val hub1 = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val hub2 = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val hub1 = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val hub2 = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val obj1 = new EntityTestClass()
|
||||
val obj2 = new EntityTestClass()
|
||||
hub1.register(obj1)
|
||||
|
|
@ -317,15 +317,15 @@ class NumberPoolHubTest extends Specification {
|
|||
}
|
||||
|
||||
"identity a number that is registered to it" in {
|
||||
val src1 = new LimitedNumberSource(5)
|
||||
val src1 = new MaxNumberSource(5)
|
||||
val hub1 = new NumberPoolHub(src1)
|
||||
val src2 = new LimitedNumberSource(10)
|
||||
src2.Restrict(0)
|
||||
src2.Restrict(1)
|
||||
src2.Restrict(2)
|
||||
src2.Restrict(3)
|
||||
src2.Restrict(4)
|
||||
src2.Restrict(5)
|
||||
val src2 = new MaxNumberSource(10)
|
||||
src2.restrictNumber(0)
|
||||
src2.restrictNumber(1)
|
||||
src2.restrictNumber(2)
|
||||
src2.restrictNumber(3)
|
||||
src2.restrictNumber(4)
|
||||
src2.restrictNumber(5)
|
||||
val hub2 = new NumberPoolHub(src2)
|
||||
val obj1 = new EntityTestClass()
|
||||
val obj2 = new EntityTestClass()
|
||||
|
|
|
|||
|
|
@ -10,62 +10,71 @@ class NumberSourceTest extends Specification {
|
|||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
private class TestClass extends IdentifiableEntity
|
||||
|
||||
"LimitedNumberSource" should {
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
"MaxNumberSource" should {
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
"construct" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
obj.Size mustEqual 26
|
||||
obj.CountAvailable mustEqual 26
|
||||
obj.CountUsed mustEqual 0
|
||||
val obj = MaxNumberSource(25)
|
||||
obj.size mustEqual 26
|
||||
obj.countAvailable mustEqual 26
|
||||
obj.countUsed mustEqual 0
|
||||
}
|
||||
|
||||
"get a number" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
"construct failure (negative max value)" in {
|
||||
MaxNumberSource(-1) must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"get any number (failure)" in {
|
||||
val obj = MaxNumberSource(25)
|
||||
obj.getAvailable(number = 50).isDefined mustEqual false
|
||||
}
|
||||
|
||||
"get a valid number" in {
|
||||
val obj = MaxNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
obj.Size mustEqual 26
|
||||
obj.CountAvailable mustEqual 25
|
||||
obj.CountUsed mustEqual 1
|
||||
obj.size mustEqual 26
|
||||
obj.countAvailable mustEqual 25
|
||||
obj.countUsed mustEqual 1
|
||||
}
|
||||
|
||||
"assign the number" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
val obj = MaxNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.Object = new TestClass()
|
||||
ok
|
||||
}
|
||||
|
||||
"return a number (unused)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
val obj = MaxNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 5
|
||||
obj.CountUsed mustEqual 1
|
||||
val ret = obj.Return(result.get)
|
||||
obj.countUsed mustEqual 1
|
||||
val ret = obj.returnNumber(result.get)
|
||||
ret.isEmpty mustEqual true
|
||||
obj.CountUsed mustEqual 0
|
||||
obj.countUsed mustEqual 0
|
||||
}
|
||||
|
||||
"return a number (assigned)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Object = test
|
||||
obj.CountUsed mustEqual 1
|
||||
val ret = obj.Return(result.get)
|
||||
obj.countUsed mustEqual 1
|
||||
val ret = obj.returnNumber(result.get)
|
||||
ret.contains(test) mustEqual true
|
||||
obj.CountUsed mustEqual 0
|
||||
obj.countUsed mustEqual 0
|
||||
}
|
||||
|
||||
"restrict a number (unassigned)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.Restrict(5)
|
||||
val obj = MaxNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.restrictNumber(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
|
|
@ -73,10 +82,10 @@ class NumberSourceTest extends Specification {
|
|||
}
|
||||
|
||||
"restrict a number (assigned + multiple assignments)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test1 = new TestClass()
|
||||
val test2 = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.Restrict(5)
|
||||
val result: Option[LoanedKey] = obj.restrictNumber(5)
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
|
|
@ -89,108 +98,309 @@ class NumberSourceTest extends Specification {
|
|||
}
|
||||
|
||||
"return a restricted number (correctly fail)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.Restrict(5)
|
||||
val result: Option[LoanedKey] = obj.restrictNumber(5)
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result.get.Object = test
|
||||
|
||||
obj.Return(5)
|
||||
val result2: Option[SecureKey] = obj.Get(5)
|
||||
obj.returnNumber(5)
|
||||
val result2: Option[SecureKey] = obj.get(5)
|
||||
result2.get.GUID mustEqual 5
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result2.get.Object.contains(test) mustEqual true
|
||||
}
|
||||
|
||||
"return a secure key" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test = new TestClass()
|
||||
|
||||
val result1: Option[LoanedKey] = obj.Available(5)
|
||||
val result1: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result1.get.Object = test
|
||||
test.GUID mustEqual PlanetSideGUID(5)
|
||||
|
||||
val result2: Option[SecureKey] = obj.Get(5)
|
||||
obj.Return(result2.get).contains(test) mustEqual true
|
||||
val result2: Option[SecureKey] = obj.get(5)
|
||||
obj.returnNumber(result2.get).contains(test) mustEqual true
|
||||
}
|
||||
|
||||
"restrict a previously-assigned number" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test = new TestClass()
|
||||
val result1: Option[LoanedKey] = obj.Available(5)
|
||||
val result1: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result1.isDefined mustEqual true
|
||||
result1.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result1.get.Object = test
|
||||
val result2: Option[LoanedKey] = obj.Restrict(5)
|
||||
val result2: Option[LoanedKey] = obj.restrictNumber(5)
|
||||
result2.isDefined mustEqual true
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result2.get.Object.contains(test) mustEqual true
|
||||
}
|
||||
|
||||
"check a number (not previously gotten)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result2: Option[SecureKey] = obj.Get(5)
|
||||
val obj = MaxNumberSource(25)
|
||||
val result2: Option[SecureKey] = obj.get(5)
|
||||
result2.get.GUID mustEqual 5
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Available
|
||||
result2.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"check a number (previously gotten)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
val obj = MaxNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
val result2: Option[SecureKey] = obj.Get(5)
|
||||
val result2: Option[SecureKey] = obj.get(5)
|
||||
result2.get.GUID mustEqual 5
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result2.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"check a number (assigned)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
val obj = MaxNumberSource(25)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 5
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object = new TestClass()
|
||||
val result2: Option[SecureKey] = obj.Get(5)
|
||||
val result2: Option[SecureKey] = obj.get(5)
|
||||
result2.get.GUID mustEqual 5
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result2.get.Object mustEqual result.get.Object
|
||||
}
|
||||
|
||||
"check a number (assigned and returned)" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.Available(5)
|
||||
val result: Option[LoanedKey] = obj.getAvailable(5)
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object = test
|
||||
val result2: Option[SecureKey] = obj.Get(5)
|
||||
val result2: Option[SecureKey] = obj.get(5)
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result2.get.Object.get mustEqual test
|
||||
obj.Return(5).contains(test) mustEqual true
|
||||
val result3: Option[SecureKey] = obj.Get(5)
|
||||
obj.returnNumber(5).contains(test) mustEqual true
|
||||
val result3: Option[SecureKey] = obj.get(5)
|
||||
result3.get.Policy mustEqual AvailabilityPolicy.Available
|
||||
result3.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"clear" in {
|
||||
val obj = LimitedNumberSource(25)
|
||||
val obj = MaxNumberSource(25)
|
||||
val test1 = new TestClass()
|
||||
val test2 = new TestClass()
|
||||
val test3 = new TestClass()
|
||||
obj.Available(5) //no assignment
|
||||
obj.Available(10).get.Object = test1
|
||||
obj.Available(15).get.Object = test2
|
||||
obj.Restrict(15)
|
||||
obj.Restrict(20).get.Object = test3
|
||||
obj.CountUsed mustEqual 4
|
||||
obj.getAvailable(5) //no assignment
|
||||
obj.getAvailable(10).get.Object = test1
|
||||
obj.getAvailable(15).get.Object = test2
|
||||
obj.restrictNumber(15)
|
||||
obj.restrictNumber(20).get.Object = test3
|
||||
obj.countUsed mustEqual 4
|
||||
|
||||
val list: List[IdentifiableEntity] = obj.Clear()
|
||||
obj.CountUsed mustEqual 0
|
||||
val list: List[IdentifiableEntity] = obj.clear()
|
||||
obj.countUsed mustEqual 0
|
||||
list.size mustEqual 3
|
||||
list.count(obj => obj == test1) mustEqual 1
|
||||
list.count(obj => obj == test2) mustEqual 1
|
||||
list.count(obj => obj == test3) mustEqual 1
|
||||
}
|
||||
}
|
||||
|
||||
"SpecificNumberSource" should {
|
||||
import net.psforever.objects.guid.source.SpecificNumberSource
|
||||
"construct" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
obj.size mustEqual 1
|
||||
obj.countAvailable mustEqual 1
|
||||
obj.countUsed mustEqual 0
|
||||
}
|
||||
|
||||
"construct failure (no values)" in {
|
||||
SpecificNumberSource(List()) must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"construct failure (at least one value is negative)" in {
|
||||
SpecificNumberSource(List(0, 1, -1, 2, 3)) must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"get any number (failure)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
obj.getAvailable(number = 5).isDefined mustEqual false
|
||||
}
|
||||
|
||||
"get specific number (success)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result: Option[LoanedKey] = obj.getAvailable(25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
obj.size mustEqual 1
|
||||
obj.countAvailable mustEqual 0
|
||||
obj.countUsed mustEqual 1
|
||||
}
|
||||
|
||||
"assign the number" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.Object = new TestClass()
|
||||
ok
|
||||
}
|
||||
|
||||
"return a number (unused)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 25
|
||||
obj.countUsed mustEqual 1
|
||||
val ret = obj.returnNumber(result.get)
|
||||
ret.isEmpty mustEqual true
|
||||
obj.countUsed mustEqual 0
|
||||
}
|
||||
|
||||
"return a number (assigned)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val test = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Object = test
|
||||
obj.countUsed mustEqual 1
|
||||
val ret = obj.returnNumber(result.get)
|
||||
ret.contains(test) mustEqual true
|
||||
obj.countUsed mustEqual 0
|
||||
}
|
||||
|
||||
"restrict a number (unassigned)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result: Option[LoanedKey] = obj.restrictNumber(number = 25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"restrict a number (assigned + multiple assignments)" in {
|
||||
val obj = SpecificNumberSource(List(25, 26))
|
||||
val test1 = new TestClass()
|
||||
val test2 = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.restrictNumber(number = 25)
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
result.get.Object = None //assignment 1
|
||||
result.get.Object.isEmpty mustEqual true //still unassigned
|
||||
result.get.Object = test1 //assignment 2
|
||||
result.get.Object.contains(test1) mustEqual true
|
||||
result.get.Object = test2 //assignment 3
|
||||
result.get.Object.contains(test1) mustEqual true //same as above
|
||||
}
|
||||
|
||||
"return a restricted number (correctly fail)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val test = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.restrictNumber(number = 25)
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result.get.Object = test
|
||||
|
||||
obj.returnNumber(number = 25)
|
||||
val result2: Option[SecureKey] = obj.get(25)
|
||||
result2.get.GUID mustEqual 25
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result2.get.Object.contains(test) mustEqual true
|
||||
}
|
||||
|
||||
"return a secure key" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val test = new TestClass()
|
||||
|
||||
val result1: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result1.get.Object = test
|
||||
test.GUID mustEqual PlanetSideGUID(25)
|
||||
|
||||
val result2: Option[SecureKey] = obj.get(25)
|
||||
obj.returnNumber(result2.get).contains(test) mustEqual true
|
||||
}
|
||||
|
||||
"restrict a previously-assigned number" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val test = new TestClass()
|
||||
val result1: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result1.isDefined mustEqual true
|
||||
result1.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result1.get.Object = test
|
||||
val result2: Option[LoanedKey] = obj.restrictNumber(number = 25)
|
||||
result2.isDefined mustEqual true
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Restricted
|
||||
result2.get.Object.contains(test) mustEqual true
|
||||
}
|
||||
|
||||
"check a number (not previously gotten)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result2: Option[SecureKey] = obj.get(25)
|
||||
result2.get.GUID mustEqual 25
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Available
|
||||
result2.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"check a number (previously gotten)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object.isEmpty mustEqual true
|
||||
val result2: Option[SecureKey] = obj.get(25)
|
||||
result2.get.GUID mustEqual 25
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result2.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"check a number (assigned)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val result: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result.isDefined mustEqual true
|
||||
result.get.GUID mustEqual 25
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object = new TestClass()
|
||||
val result2: Option[SecureKey] = obj.get(25)
|
||||
result2.get.GUID mustEqual 25
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result2.get.Object mustEqual result.get.Object
|
||||
}
|
||||
|
||||
"check a number (assigned and returned)" in {
|
||||
val obj = SpecificNumberSource(List(25))
|
||||
val test = new TestClass()
|
||||
val result: Option[LoanedKey] = obj.getAvailable(number = 25)
|
||||
result.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result.get.Object = test
|
||||
val result2: Option[SecureKey] = obj.get(25)
|
||||
result2.get.Policy mustEqual AvailabilityPolicy.Leased
|
||||
result2.get.Object.get mustEqual test
|
||||
obj.returnNumber(number = 25).contains(test) mustEqual true
|
||||
val result3: Option[SecureKey] = obj.get(25)
|
||||
result3.get.Policy mustEqual AvailabilityPolicy.Available
|
||||
result3.get.Object.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"clear" in {
|
||||
val obj = SpecificNumberSource(List(25, 26, 27, 28, 29, 30))
|
||||
val test1 = new TestClass()
|
||||
val test2 = new TestClass()
|
||||
val test3 = new TestClass()
|
||||
obj.getAvailable(25) //no assignment
|
||||
obj.getAvailable(26).get.Object = test1
|
||||
obj.getAvailable(28).get.Object = test2
|
||||
obj.restrictNumber(28)
|
||||
obj.restrictNumber(30).get.Object = test3
|
||||
obj.countUsed mustEqual 4
|
||||
|
||||
val list: List[IdentifiableEntity] = obj.clear()
|
||||
obj.countUsed mustEqual 0
|
||||
list.size mustEqual 3
|
||||
list.count(obj => obj == test1) mustEqual 1
|
||||
list.count(obj => obj == test2) mustEqual 1
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import net.psforever.objects.entity.IdentifiableEntity
|
|||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.actor.{NumberPoolActor, Register, UniqueNumberSystem, Unregister}
|
||||
import net.psforever.objects.guid.selector.RandomSelector
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.types.PlanetSideGUID
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
|
@ -15,7 +15,7 @@ import scala.util.{Failure, Success}
|
|||
|
||||
class AllocateNumberPoolActors extends ActorTest {
|
||||
"AllocateNumberPoolActors" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList)
|
||||
guid.AddPool("pool2", (3001 to 4000).toList)
|
||||
|
|
@ -32,7 +32,7 @@ class AllocateNumberPoolActors extends ActorTest {
|
|||
class UniqueNumberSystemTest extends ActorTest() {
|
||||
"UniqueNumberSystem" should {
|
||||
"constructor" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList)
|
||||
guid.AddPool("pool2", (3001 to 4000).toList)
|
||||
|
|
@ -51,7 +51,7 @@ class UniqueNumberSystemTest1 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Register (success)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
val pool1 = (1001 to 2000).toList
|
||||
val pool2 = (3001 to 4000).toList
|
||||
|
|
@ -63,7 +63,7 @@ class UniqueNumberSystemTest1 extends ActorTest() {
|
|||
Props(classOf[UniqueNumberSystem], guid, UniqueNumberSystemTest.AllocateNumberPoolActors(guid)),
|
||||
"uns"
|
||||
)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
//pool1
|
||||
for (_ <- 1 to 100) {
|
||||
val testObj = new EntityTestClass()
|
||||
|
|
@ -88,7 +88,7 @@ class UniqueNumberSystemTest1 extends ActorTest() {
|
|||
assert(msg.isInstanceOf[Success[_]])
|
||||
assert(pool3.contains(testObj.GUID.guid))
|
||||
}
|
||||
assert(src.CountUsed == 300)
|
||||
assert(src.countUsed == 300)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ class UniqueNumberSystemTest2 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Register (success; already registered)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -109,20 +109,20 @@ class UniqueNumberSystemTest2 extends ActorTest() {
|
|||
)
|
||||
val testObj = new EntityTestClass()
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
|
||||
uns ! Register(testObj, "pool1")
|
||||
val msg1 = receiveOne(Duration.create(500, "ms"))
|
||||
assert(msg1.isInstanceOf[Success[_]])
|
||||
assert(testObj.HasGUID)
|
||||
assert(src.CountUsed == 1)
|
||||
assert(src.countUsed == 1)
|
||||
|
||||
val id = testObj.GUID.guid
|
||||
uns ! Register(testObj, "pool2") //different pool; makes no difference
|
||||
val msg2 = receiveOne(Duration.create(500, "ms"))
|
||||
assert(msg2.isInstanceOf[Success[_]])
|
||||
assert(testObj.HasGUID)
|
||||
assert(src.CountUsed == 1)
|
||||
assert(src.countUsed == 1)
|
||||
assert(testObj.GUID.guid == id) //unchanged
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ class UniqueNumberSystemTest3 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Register (failure; no pool)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -145,13 +145,13 @@ class UniqueNumberSystemTest3 extends ActorTest() {
|
|||
)
|
||||
val testObj = new EntityTestClass()
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
|
||||
uns ! Register(testObj, "pool4")
|
||||
val msg1 = receiveOne(Duration.create(500, "ms"))
|
||||
assert(msg1.isInstanceOf[Failure[_]])
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ class UniqueNumberSystemTest4 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Register (failure; empty pool)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -190,7 +190,7 @@ class UniqueNumberSystemTest5 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Unregister (success)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
val pool2 = (3001 to 4000).toList
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
|
|
@ -202,20 +202,20 @@ class UniqueNumberSystemTest5 extends ActorTest() {
|
|||
)
|
||||
val testObj = new EntityTestClass()
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
|
||||
uns ! Register(testObj, "pool2")
|
||||
val msg1 = receiveOne(Duration.create(2000, "ms"))
|
||||
assert(msg1.isInstanceOf[Success[_]])
|
||||
assert(testObj.HasGUID)
|
||||
assert(pool2.contains(testObj.GUID.guid))
|
||||
assert(src.CountUsed == 1)
|
||||
assert(src.countUsed == 1)
|
||||
|
||||
uns ! Unregister(testObj)
|
||||
val msg2 = receiveOne(Duration.create(2000, "ms"))
|
||||
assert(msg2.isInstanceOf[Success[_]])
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ class UniqueNumberSystemTest6 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Unregister (success; object not registered at all)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -236,13 +236,13 @@ class UniqueNumberSystemTest6 extends ActorTest() {
|
|||
)
|
||||
val testObj = new EntityTestClass()
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
|
||||
uns ! Unregister(testObj)
|
||||
val msg1 = receiveOne(Duration.create(500, "ms"))
|
||||
assert(msg1.isInstanceOf[Success[_]])
|
||||
assert(!testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ class UniqueNumberSystemTest7 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Unregister (failure; number not in system)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -264,13 +264,13 @@ class UniqueNumberSystemTest7 extends ActorTest() {
|
|||
val testObj = new EntityTestClass()
|
||||
testObj.GUID = PlanetSideGUID(6001) //fake registering; number too high
|
||||
assert(testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
|
||||
uns ! Unregister(testObj)
|
||||
val msg1 = receiveOne(Duration.create(500, "ms"))
|
||||
assert(msg1.isInstanceOf[Failure[_]])
|
||||
assert(testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ class UniqueNumberSystemTest8 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Unregister (failure; object is not registered to that number)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -292,13 +292,13 @@ class UniqueNumberSystemTest8 extends ActorTest() {
|
|||
val testObj = new EntityTestClass()
|
||||
testObj.GUID = PlanetSideGUID(3500) //fake registering
|
||||
assert(testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
|
||||
uns ! Unregister(testObj)
|
||||
val msg1 = receiveOne(Duration.create(500, "ms"))
|
||||
assert(msg1.isInstanceOf[Failure[_]])
|
||||
assert(testObj.HasGUID)
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ class UniqueNumberSystemTest9 extends ActorTest() {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"Failures (manually walking the failure cases)" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(6000)
|
||||
val src: MaxNumberSource = MaxNumberSource(6000)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (1001 to 2000).toList).Selector = new RandomSelector
|
||||
guid.AddPool("pool2", (3001 to 4000).toList).Selector = new RandomSelector
|
||||
|
|
@ -345,7 +345,7 @@ class UniqueNumberSystemTestA extends ActorTest {
|
|||
|
||||
"UniqueNumberSystem" should {
|
||||
"remain consistent between registrations" in {
|
||||
val src: LimitedNumberSource = LimitedNumberSource(10)
|
||||
val src: MaxNumberSource = MaxNumberSource(10)
|
||||
val guid: NumberPoolHub = new NumberPoolHub(src)
|
||||
guid.AddPool("pool1", (0 until 10).toList).Selector = new RandomSelector
|
||||
val uns = system.actorOf(
|
||||
|
|
@ -354,9 +354,9 @@ class UniqueNumberSystemTestA extends ActorTest {
|
|||
)
|
||||
expectNoMessage(Duration.create(200, "ms"))
|
||||
|
||||
assert(src.CountUsed == 0)
|
||||
assert(src.countUsed == 0)
|
||||
(0 to 4).foreach(i => { assert(guid.register(new EntityTestClass(), i).isSuccess) })
|
||||
assert(src.CountUsed == 5)
|
||||
assert(src.countUsed == 5)
|
||||
|
||||
(0 to 5).foreach(_ => { uns ! Register(new EntityTestClass(), "pool1") })
|
||||
assert(receiveOne(200 milliseconds).isInstanceOf[Success[_]]) //6th
|
||||
|
|
@ -365,7 +365,7 @@ class UniqueNumberSystemTestA extends ActorTest {
|
|||
assert(receiveOne(200 milliseconds).isInstanceOf[Success[_]]) //9th
|
||||
assert(receiveOne(200 milliseconds).isInstanceOf[Success[_]]) //10th
|
||||
assert(receiveOne(200 milliseconds).isInstanceOf[Failure[_]]) //no more
|
||||
assert(src.CountUsed == 10)
|
||||
assert(src.countUsed == 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import net.psforever.objects.avatar.Avatar
|
|||
import net.psforever.objects.{Default, GlobalDefinitions, Player}
|
||||
import net.psforever.objects.definition.SeatDefinition
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.objects.guid.source.MaxNumberSource
|
||||
import net.psforever.objects.serverobject.mount.Mountable
|
||||
import net.psforever.objects.serverobject.implantmech.{ImplantTerminalMech, ImplantTerminalMechControl}
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
|
|
@ -162,7 +162,7 @@ class ImplantTerminalMechControl5Test extends ActorTest {
|
|||
|
||||
object ImplantTerminalMechTest {
|
||||
def SetUpAgents(faction: PlanetSideEmpire.Value)(implicit system: ActorSystem): (Player, ImplantTerminalMech) = {
|
||||
val guid = new NumberPoolHub(new LimitedNumberSource(10))
|
||||
val guid = new NumberPoolHub(new MaxNumberSource(10))
|
||||
val map = new ZoneMap("test")
|
||||
val zone = new Zone("test", map, 0) {
|
||||
override def SetupNumberPools() = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue