From a3b16658752ed0af17132f5ea8e453e775f9ad28 Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 17:28:11 +0100 Subject: [PATCH] Extended: test_buildCompleteItem() by validDescription Test --- .../src/main/java/de/hs_fulda/ciip/projjpn/Item.java | 12 ++++++++++++ .../test/java/de/hs_fulda/ciip/projjpn/ItemTest.java | 11 +++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java index d9828ef..6b9c5f1 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java @@ -24,6 +24,10 @@ public class Item { return availability > 0; } + public float getCurrentStock() { + return availability; + } + public void updateAvailability(int newAmount) { availability = newAmount; } @@ -35,4 +39,12 @@ public class Item { public float getCurrentPrice() { return price; } + + public String getTitel() { + return this.productTitle; + } + + public String getDescription() { + return this.description; + } } diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java index 2a94571..6b2f0b2 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java @@ -51,8 +51,15 @@ public class ItemTest extends TestCase { String expectedDescription = "Gaming Maus fuer Fortgeschrittene."; int expectedQuantity = 10; float expectedPrice = 69.99f; - Item item = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice); - assertNotNull(item); + // When + Item itemNotNull = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice); + + // Then + assertNotNull(itemNotNull); + + // When + boolean validDescription = itemNotNull.getDescription().equals(expectedDescription); + assertTrue(validDescription); } }