Refactor PizzaUnitTest (#1527)

This commit is contained in:
Grzegorz Piwowarek 2017-03-28 22:45:46 +02:00 committed by GitHub
parent 17042f0420
commit 6e2dcfcf59
1 changed files with 6 additions and 7 deletions

View File

@ -1,14 +1,13 @@
package com.baeldung.enums; package com.baeldung.enums;
import static junit.framework.TestCase.assertTrue; import com.baeldung.enums.Pizza.PizzaStatusEnum;
import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import org.junit.Test; import static junit.framework.TestCase.assertTrue;
import com.baeldung.enums.Pizza.PizzaStatusEnum;
public class PizzaUnitTest { public class PizzaUnitTest {
@ -71,7 +70,7 @@ public class PizzaUnitTest {
} }
@Test @Test
public void givenPizaOrder_whenDelivered_thenPizzaGetsDeliveredAndStatusChanges() { public void whenDelivered_thenPizzaGetsDeliveredAndStatusChanges() {
Pizza pz = new Pizza(); Pizza pz = new Pizza();
pz.setStatus(Pizza.PizzaStatusEnum.READY); pz.setStatus(Pizza.PizzaStatusEnum.READY);
pz.deliver(); pz.deliver();
@ -79,14 +78,14 @@ public class PizzaUnitTest {
} }
@Test @Test
public void givenValidEnumValueAsString_whenConvertedIntoEnum_thenGetsConvertedCorrectly() { public void whenConvertedIntoEnum_thenGetsConvertedCorrectly() {
String pizzaEnumValue = "READY"; String pizzaEnumValue = "READY";
PizzaStatusEnum pizzaStatusEnum = PizzaStatusEnum.valueOf(pizzaEnumValue); PizzaStatusEnum pizzaStatusEnum = PizzaStatusEnum.valueOf(pizzaEnumValue);
assertTrue(pizzaStatusEnum == PizzaStatusEnum.READY); assertTrue(pizzaStatusEnum == PizzaStatusEnum.READY);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void givenInvalidEnumValueCaseWiseAsString_whenConvertedIntoEnum_thenThrowsException() { public void whenConvertedIntoEnum_thenThrowsException() {
String pizzaEnumValue = "rEAdY"; String pizzaEnumValue = "rEAdY";
PizzaStatusEnum pizzaStatusEnum = PizzaStatusEnum.valueOf(pizzaEnumValue); PizzaStatusEnum pizzaStatusEnum = PizzaStatusEnum.valueOf(pizzaEnumValue);
} }