From 90025123e994319eeede498e5e092a249bf93ce3 Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 21:48:07 +0100 Subject: [PATCH] Added: Insert Item into Warehouse + Basic Test --- .../de/hs_fulda/ciip/projjpn/Warehouse.java | 15 +++++++++ .../hs_fulda/ciip/projjpn/WarehouseTest.java | 31 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Warehouse.java create mode 100644 projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Warehouse.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Warehouse.java new file mode 100644 index 0000000..3a13f09 --- /dev/null +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Warehouse.java @@ -0,0 +1,15 @@ +package de.hs_fulda.ciip.projjpn; + +import java.util.HashMap; + +public class Warehouse { + protected HashMap pool = new HashMap(); + + + + + public Item insertItem(Item item) { + return pool.putIfAbsent(item.getTitel(), item); + } + +} \ No newline at end of file diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java new file mode 100644 index 0000000..ef10f59 --- /dev/null +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java @@ -0,0 +1,31 @@ +package de.hs_fulda.ciip.projjpn; + +import junit.framework.TestCase; + +public class WarehouseTest extends TestCase { + /* + * public void test_fillWareHouseWithItems() { for (int i = 0; i < 10; i++) { + * + * } } + */ + + public void test_insertItemInWarehouse() { + // Given + Warehouse warehouse = new Warehouse(); + + String expectedTitel = "Logitec Maus"; + String expectedDescription = "Gaming Maus fuer Fortgeschrittene."; + int expectedQuantity = 10; + float expectedPrice = 69.69f; + + // When + Item expectedItem = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice); + assertNotNull(expectedItem); + warehouse.insertItem(expectedItem); + + Item gotItem = warehouse.pool.get(expectedTitel); + + // Then + assertEquals(expectedTitel, gotItem.getTitel()); + } +}