Resolves test failures
This commit is contained in:
parent
44a654a2e3
commit
054b1eaac6
@ -27,8 +27,9 @@ package com.iluwatar.model.view.controller;
|
||||
* Fatigue enumeration.
|
||||
*/
|
||||
public enum Fatigue {
|
||||
|
||||
ALERT("alert"), TIRED("tired"), SLEEPING("sleeping");
|
||||
ALERT("alert"),
|
||||
TIRED("tired"),
|
||||
SLEEPING("sleeping");
|
||||
|
||||
private final String title;
|
||||
|
||||
|
@ -27,8 +27,9 @@ package com.iluwatar.model.view.controller;
|
||||
* Health enumeration.
|
||||
*/
|
||||
public enum Health {
|
||||
|
||||
HEALTHY("healthy"), WOUNDED("wounded"), DEAD("dead");
|
||||
HEALTHY("healthy"),
|
||||
WOUNDED("wounded"),
|
||||
DEAD("dead");
|
||||
|
||||
private final String title;
|
||||
|
||||
|
@ -27,8 +27,9 @@ package com.iluwatar.model.view.controller;
|
||||
* Nourishment enumeration.
|
||||
*/
|
||||
public enum Nourishment {
|
||||
|
||||
SATURATED("saturated"), HUNGRY("hungry"), STARVING("starving");
|
||||
SATURATED("saturated"),
|
||||
HUNGRY("hungry"),
|
||||
STARVING("starving");
|
||||
|
||||
private final String title;
|
||||
|
||||
|
@ -39,13 +39,13 @@ public class GiantModelTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetHealth() {
|
||||
final var model = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.HUNGRY);
|
||||
final var model = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
assertEquals(Health.HEALTHY, model.getHealth());
|
||||
var messageFormat = "The giant looks %s, alert and saturated.";
|
||||
for (final var health : Health.values()) {
|
||||
model.setHealth(health);
|
||||
assertEquals(health, model.getHealth());
|
||||
assertEquals("The giant looks " + health.toString() + ", alert and saturated.", model
|
||||
.toString());
|
||||
assertEquals(String.format(messageFormat, health), model.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,13 +54,13 @@ public class GiantModelTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetFatigue() {
|
||||
final var model = new GiantModel(Health.WOUNDED, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
final var model = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
assertEquals(Fatigue.ALERT, model.getFatigue());
|
||||
var messageFormat = "The giant looks healthy, %s and saturated.";
|
||||
for (final var fatigue : Fatigue.values()) {
|
||||
model.setFatigue(fatigue);
|
||||
assertEquals(fatigue, model.getFatigue());
|
||||
assertEquals("The giant looks healthy, " + fatigue.toString() + " and saturated.", model
|
||||
.toString());
|
||||
assertEquals(String.format(messageFormat, fatigue), model.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,13 +69,13 @@ public class GiantModelTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetNourishment() {
|
||||
final var model = new GiantModel(Health.HEALTHY, Fatigue.TIRED, Nourishment.SATURATED);
|
||||
final var model = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
assertEquals(Nourishment.SATURATED, model.getNourishment());
|
||||
var messageFormat = "The giant looks healthy, alert and %s.";
|
||||
for (final var nourishment : Nourishment.values()) {
|
||||
model.setNourishment(nourishment);
|
||||
assertEquals(nourishment, model.getNourishment());
|
||||
assertEquals("The giant looks healthy, alert and " + nourishment.toString() + ".", model
|
||||
.toString());
|
||||
assertEquals(String.format(messageFormat, nourishment), model.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user