mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
🔨 update tests, add static import
This commit is contained in:
parent
5f64e3fb2e
commit
4c7e41537d
@ -8,8 +8,9 @@ import com.gildedrose.items.NormalItem;
|
||||
import com.gildedrose.main.Item;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import static java.util.stream.Stream.of;
|
||||
|
||||
public class ItemFactory {
|
||||
|
||||
@ -26,9 +27,9 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
private static Map<String, ItemType> getItems(Item item) {
|
||||
return Stream.of(new NormalItem(item), new AgedBrieItem(item), new LegendaryItem(item),
|
||||
new BackstagePassItem(item), new ConjuredItem(item))
|
||||
.collect(Collectors.toMap(ItemType::getName, itemType -> itemType));
|
||||
return of(new NormalItem(item), new AgedBrieItem(item), new LegendaryItem(item),
|
||||
new BackstagePassItem(item), new ConjuredItem(item))
|
||||
.collect(toMap(ItemType::getName, itemType -> itemType));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,21 +5,20 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static com.gildedrose.items.AgedBrieItem.AGED_BRIE;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
class ItemClassTest {
|
||||
|
||||
private final Item item = new Item(AGED_BRIE, 5, 20);
|
||||
private final Item item = new Item("foo", 5, 20);
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void testItemSuccess() {
|
||||
assertEquals(AGED_BRIE, item.name);
|
||||
assertEquals("foo", item.name);
|
||||
assertEquals(5, item.sellIn);
|
||||
assertEquals(20, item.quality);
|
||||
assertEquals("Aged Brie, 5, 20", item.toString());
|
||||
assertEquals("foo, 5, 20", item.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user