Skip to content

Commit

Permalink
Merge pull request #4059 from AaronGullickson/fix-more-tests
Browse files Browse the repository at this point in the history
Fix unit tests on Large Craft Bays
  • Loading branch information
AaronGullickson authored May 8, 2024
2 parents 9a22cd6 + dee1877 commit bc0e140
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ public void checkWeaponBayOnlyWeaponRemovedTest() {

int location = SmallCraft.LOC_HULL;
int equipmentNum = 42;
Mounted mounted = mock(Mounted.class);
WeaponMounted mounted = mock(WeaponMounted.class);
when(mounted.getLocation()).thenReturn(location);
doAnswer(inv -> {
when(mounted.isDestroyed()).thenReturn(true);
Expand All @@ -1449,8 +1449,7 @@ public void checkWeaponBayOnlyWeaponRemovedTest() {
when(weaponBay.getLocation()).thenReturn(location);
when(weaponBay.getType()).thenReturn(bayWeaponType);
List<WeaponMounted> bayWeapons = new ArrayList<>();
//bayWeapons.addElement(33);
bayWeapons.add(weaponBay);
bayWeapons.add(mounted);
when(weaponBay.getBayWeapons()).thenReturn(bayWeapons);
doReturn(weaponBay).when(entity).getEquipment(eq(bayEqNum));
doReturn(bayEqNum).when(entity).getEquipmentNum(eq(weaponBay));
Expand Down Expand Up @@ -1518,7 +1517,7 @@ public void checkWeaponBayWeaponRemovedOthersOkayTest() {

int location = SmallCraft.LOC_HULL;
int equipmentNum = 42;
Mounted mounted = mock(Mounted.class);
WeaponMounted mounted = mock(WeaponMounted.class);
when(mounted.getLocation()).thenReturn(location);
doAnswer(inv -> {
when(mounted.isDestroyed()).thenReturn(true);
Expand All @@ -1538,7 +1537,7 @@ public void checkWeaponBayWeaponRemovedOthersOkayTest() {
when(weaponBay.getType()).thenReturn(bayWeaponType);
List<WeaponMounted> bayWeapons = new ArrayList<>();
bayWeapons.add(otherMounted);
bayWeapons.add(weaponBay);
bayWeapons.add(mounted);
when(weaponBay.getBayWeapons()).thenReturn(bayWeapons);
doReturn(weaponBay).when(entity).getEquipment(eq(bayEqNum));
doReturn(bayEqNum).when(entity).getEquipmentNum(eq(weaponBay));
Expand Down Expand Up @@ -1606,7 +1605,7 @@ public void checkWeaponBayWeaponRemovedOthersDestroyedTest() {

int location = SmallCraft.LOC_HULL;
int equipmentNum = 42;
Mounted mounted = mock(Mounted.class);
WeaponMounted mounted = mock(WeaponMounted.class);
when(mounted.getLocation()).thenReturn(location);
doAnswer(inv -> {
when(mounted.isDestroyed()).thenReturn(true);
Expand All @@ -1627,7 +1626,7 @@ public void checkWeaponBayWeaponRemovedOthersDestroyedTest() {
when(weaponBay.getType()).thenReturn(bayWeaponType);
List<WeaponMounted> bayWeapons = new ArrayList<>();
bayWeapons.add(otherMounted);
bayWeapons.add(weaponBay);
bayWeapons.add(mounted);
when(weaponBay.getBayWeapons()).thenReturn(bayWeapons);
doReturn(weaponBay).when(entity).getEquipment(eq(bayEqNum));
doReturn(bayEqNum).when(entity).getEquipmentNum(eq(weaponBay));
Expand Down Expand Up @@ -1695,7 +1694,7 @@ public void checkWeaponBayUpdateConditionFromPartGoodWeaponTest() {

int location = SmallCraft.LOC_HULL;
int equipmentNum = 42;
Mounted mounted = mock(Mounted.class);
WeaponMounted mounted = mock(WeaponMounted.class);
when(mounted.getLocation()).thenReturn(location);
doReturn(mounted).when(entity).getEquipment(eq(equipmentNum));

Expand All @@ -1711,7 +1710,7 @@ public void checkWeaponBayUpdateConditionFromPartGoodWeaponTest() {
when(weaponBay.getType()).thenReturn(bayWeaponType);
List<WeaponMounted> bayWeapons = new ArrayList<>();
bayWeapons.add(otherMounted);
bayWeapons.add(weaponBay);
bayWeapons.add(mounted);
when(weaponBay.getBayWeapons()).thenReturn(bayWeapons);
doReturn(weaponBay).when(entity).getEquipment(eq(bayEqNum));
doReturn(bayEqNum).when(entity).getEquipmentNum(eq(weaponBay));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public void getBayReturnsBayMatchingEqNum() {
when(bay.getBayAmmo()).thenReturn(bayAmmo);
when(entity.getEquipment(bayNum)).thenReturn((Mounted) bay);

ammoBin.setUnit(unit);

// Set the bay as if we're in deserialization code
ammoBin.setBay(bayNum);

ammoBin.setUnit(unit);

assertEquals(bay, ammoBin.getBay());
}

Expand Down Expand Up @@ -276,6 +276,7 @@ public void getBayFallsBackToMatchingWeaponBayIfNoBayEquipment() {
weaponBays.add(wrongWeaponBay);
weaponBays.add(weaponBay);
when(entity.getWeaponBayList()).thenReturn(weaponBays);
when(entity.whichBay(equipmentNum)).thenReturn((WeaponMounted) weaponBay);

// Add the ammo bin to the unit without setting up a bay
ammoBin.setUnit(unit);
Expand Down

0 comments on commit bc0e140

Please sign in to comment.