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