-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
255 additions
and
89 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
src/main/java/pl/uj/io/cuteanimals/action/MessageAction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/test/java/pl/uj/io/cuteanimals/action/InvestigateActionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package pl.uj.io.cuteanimals.action; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import pl.uj.io.cuteanimals.model.GameState; | ||
import pl.uj.io.cuteanimals.model.Player; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class InvestigateActionTest { | ||
@Mock private Player player; | ||
private InvestigateAction investigateAction; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
investigateAction = new InvestigateAction("Message"); | ||
} | ||
|
||
@Test | ||
void actionBodyShouldReturnInfoMessage() { | ||
when(player.getCurrentGameState()).thenReturn(GameState.EXPLORATION); | ||
assertThat(investigateAction.execute(player).getMessage()).isEqualTo("Message"); | ||
} | ||
|
||
@Test | ||
void actionShouldBeAvailableOnlyInExploration() { | ||
assertThat(investigateAction.getAcceptableStates()) | ||
.isEqualTo(List.of(GameState.EXPLORATION)); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/java/pl/uj/io/cuteanimals/action/ShowAbilitiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package pl.uj.io.cuteanimals.action; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import pl.uj.io.cuteanimals.action.ability.Focus; | ||
import pl.uj.io.cuteanimals.model.GameState; | ||
import pl.uj.io.cuteanimals.model.Player; | ||
import pl.uj.io.cuteanimals.model.interfaces.IAction; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ShowAbilitiesTest { | ||
@Mock private Player player; | ||
private ShowAbilities showAbilities; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
showAbilities = new ShowAbilities(); | ||
} | ||
|
||
@Test | ||
void actionBodyShouldReturnInfoMessage() { | ||
var skills = new HashMap<String, IAction>(); | ||
skills.put("focus", new Focus()); | ||
when(player.getCurrentGameState()).thenReturn(GameState.EXPLORATION); | ||
when(player.getAbilities()).thenReturn(skills); | ||
|
||
var out = showAbilities.execute(player).getMessage(); | ||
assertThat(out).isNotBlank(); | ||
assertThat(out).contains("focus"); | ||
} | ||
|
||
@Test | ||
void actionShouldBeAvailableOnlyInExplorationAndFight() { | ||
assertThat(showAbilities.getAcceptableStates()) | ||
.isEqualTo(List.of(GameState.EXPLORATION, GameState.FIGHT)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/java/pl/uj/io/cuteanimals/action/ShowArmorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package pl.uj.io.cuteanimals.action; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import pl.uj.io.cuteanimals.model.GameState; | ||
import pl.uj.io.cuteanimals.model.Player; | ||
import pl.uj.io.cuteanimals.model.PlayerBackpack; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ShowArmorTest { | ||
@Mock private Player player; | ||
private ShowArmor showArmor; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
showArmor = new ShowArmor(); | ||
} | ||
|
||
@Test | ||
void actionBodyShouldReturnInfoMessage() { | ||
var bp = mock(PlayerBackpack.class); | ||
when(player.getCurrentGameState()).thenReturn(GameState.EXPLORATION); | ||
when(player.getArmor()).thenReturn(bp); | ||
showArmor.execute(player); | ||
var thisVariableIsHereToSilenceFalsePositiveWarningReportedBySpotBugs = | ||
verify(bp).showItems(); | ||
assertThat(thisVariableIsHereToSilenceFalsePositiveWarningReportedBySpotBugs) | ||
.isNull(); // silence spotbugs | ||
} | ||
|
||
@Test | ||
void actionShouldBeAvailableOnlyInExploration() { | ||
assertThat(showArmor.getAcceptableStates()) | ||
.isEqualTo(List.of(GameState.EXPLORATION, GameState.FIGHT)); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/test/java/pl/uj/io/cuteanimals/action/ShowBackpackTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package pl.uj.io.cuteanimals.action; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import pl.uj.io.cuteanimals.model.GameState; | ||
import pl.uj.io.cuteanimals.model.Player; | ||
import pl.uj.io.cuteanimals.model.PlayerBackpack; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ShowBackpackTest { | ||
@Mock private Player player; | ||
private ShowBackpack showBackpack; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
showBackpack = new ShowBackpack(); | ||
} | ||
|
||
@Test | ||
void actionBodyShouldReturnInfoMessage() { | ||
when(player.getCurrentGameState()).thenReturn(GameState.EXPLORATION); | ||
var playerBackpack = mock(PlayerBackpack.class); | ||
when(player.getEquipment()).thenReturn(playerBackpack); | ||
|
||
assertThat(showBackpack.execute(player).getMessage()).isNotBlank(); | ||
var thisVariableIsHereToSilenceFalsePositiveWarningReportedBySpotBugs = | ||
verify(playerBackpack).showItems(); | ||
var thisOneToo = verify(playerBackpack).getRemainingCapacity(); | ||
assertThat(thisVariableIsHereToSilenceFalsePositisveWarningReportedBySpotBugs) | ||
.isNull(); // silence spotbugs | ||
assertThat(thisOneToo).isNotNull(); // silence spotbugs | ||
} | ||
|
||
@Test | ||
void actionShouldBeAvailableOnlyInExplorationAndFight() { | ||
assertThat(showBackpack.getAcceptableStates()) | ||
.isEqualTo(List.of(GameState.EXPLORATION, GameState.FIGHT)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/java/pl/uj/io/cuteanimals/action/ShowStatsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package pl.uj.io.cuteanimals.action; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import pl.uj.io.cuteanimals.model.GameState; | ||
import pl.uj.io.cuteanimals.model.Player; | ||
import pl.uj.io.cuteanimals.model.entity.Attributes; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ShowStatsTest { | ||
@Mock private Player player; | ||
private ShowStats showStats; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
showStats = new ShowStats(); | ||
} | ||
|
||
@Test | ||
void actionBodyShouldReturnInfoMessage() { | ||
when(player.getCurrentGameState()).thenReturn(GameState.EXPLORATION); | ||
when(player.getAttributes()).thenReturn(new Attributes(1, 1, 1, 1, 1, 1)); | ||
|
||
assertThat(showStats.execute(player).getMessage()).isNotBlank(); | ||
var thisVariableIsHereToSilenceFalsePositiveWarningReportedBySpotBugs = | ||
verify(player).getAttributes(); | ||
assertThat(thisVariableIsHereToSilenceFalsePositiveWarningReportedBySpotBugs) | ||
.isNull(); // silence spotbugs | ||
} | ||
|
||
@Test | ||
void actionShouldBeAvailableOnlyInExploration() { | ||
assertThat(showStats.getAcceptableStates()) | ||
.isEqualTo(List.of(GameState.EXPLORATION, GameState.FIGHT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.