Skip to content

Commit

Permalink
More test fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
asvitkine committed Jul 12, 2023
1 parent a2d3fb2 commit 8c78dda
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ void defendingFirstStrikeWithSneakAttackAllowed() {
givenBattleStateBuilder()
.gameData(
givenGameData()
.withCaptureUnitsOnEnteringTerritory(false)
.withSubRetreatBeforeBattle(false)
.withDefendingSuicideAndMunitionUnitsDoNotFire(false)
.withAlliedAirIndependent(true)
Expand Down Expand Up @@ -1621,6 +1622,7 @@ void defendingFirstStrikeCanSubmergeIfSubmersibleSubs() {
givenBattleStateBuilder()
.gameData(
givenGameData()
.withCaptureUnitsOnEnteringTerritory(false)
.withSubRetreatBeforeBattle(false)
.withDefendingSuicideAndMunitionUnitsDoNotFire(false)
.withAlliedAirIndependent(true)
Expand Down Expand Up @@ -2013,6 +2015,7 @@ void partialAmphibiousAttackCanNotWithdrawIfHasAllAmphibious() {
givenBattleStateBuilder()
.gameData(
givenGameData()
.withCaptureUnitsOnEnteringTerritory(false)
.withSubRetreatBeforeBattle(false)
.withWW2V2(false)
.withAlliedAirIndependent(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import games.strategy.engine.data.GameData;
import games.strategy.engine.data.GamePlayer;
import games.strategy.engine.data.Unit;
import games.strategy.engine.data.UnitType;
import games.strategy.triplea.attachments.UnitAttachment;
import games.strategy.triplea.delegate.battle.steps.fire.FiringGroup;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand All @@ -40,6 +42,16 @@ class FiringGroupSplitterGeneralTest {
@Mock GamePlayer attacker;
@Mock GamePlayer defender;

@BeforeEach
void setUp() {
final GameData gameData = new GameData();

lenient().when(attacker.getName()).thenReturn("attacker");
lenient().when(attacker.getData()).thenReturn(gameData);
lenient().when(defender.getName()).thenReturn("defender");
lenient().when(defender.getData()).thenReturn(gameData);
}

@Test
void oneFiringUnitVsOneTargetableUnitMakesOneFiringGroup() {
final Unit targetUnit = givenAnyUnit();
Expand Down Expand Up @@ -216,14 +228,6 @@ void doNotExcludeUnitsOfAlliesIfAlliedAirIndependentIsFalseButItIsDefense() {
assertThat(firingGroups.get(0).getFiringUnits(), contains(fireUnit, fireUnit2));
assertThat(firingGroups.get(0).getTargetUnits(), contains(targetUnit));
assertThat(firingGroups.get(0).isSuicideOnHit(), is(false));

verify(
fireUnit,
never()
.description(
"Units on defense with AlliedAirIndependent == false"
+ "should never call getOwner"))
.getOwner();
}

@Test
Expand Down

0 comments on commit 8c78dda

Please sign in to comment.