fix: Fehlerhafte Erwartung korrigiert
[demos/kafka/training] / src / test / java / de / juplo / kafka / AdderBusinessLogicTest.java
index 0325c63..63447e3 100644 (file)
@@ -59,6 +59,16 @@ public class AdderBusinessLogicTest
     assertThatNoException().isThrownBy(() -> adder.endSum("foo"));
   }
 
+  @Test
+  @DisplayName("An existing sum is removed, if ended")
+  public void testEndSumRemovesSumIfSumExists()
+  {
+    AdderBusinessLogic adder = new AdderBusinessLogic();
+    adder.startSum("foo");
+    adder.endSum("foo");
+    assertThat(adder.getSum("foo")).isEmpty();
+  }
+
   @Test
   @DisplayName("An existing Sum returns a non-null value, if ended")
   public void testEndSumReturnsNonNullValueIfSumExists()
@@ -112,13 +122,14 @@ public class AdderBusinessLogicTest
     assertThatIllegalArgumentException().isThrownBy(() -> adder.addToSum("foo", value));
   }
 
-  @Test
+  @ParameterizedTest(name = "{index}: Adding {0}")
   @DisplayName("Can add a positive value to an existing sum")
-  public void testAddSumWithPositiveValuePossibleIfSumExists()
+  @ValueSource(ints = { 1, 3, 6, 66, 7, 9 })
+  public void testAddSumWithPositiveValuePossibleIfSumExists(int value)
   {
     AdderBusinessLogic adder = new AdderBusinessLogic();
     adder.startSum("foo");
-    assertThatIllegalArgumentException().isThrownBy(() -> adder.addToSum("foo", -1));
+    assertThatNoException().isThrownBy(() -> adder.addToSum("foo", value));
   }
 
   @ParameterizedTest(name = "{index}: Summing up {0}")