adder.startSum("foo");
assertThat(adder.getSum("foo")).isNotEmpty();
}
+
+ @Test
+ @DisplayName("A sum can be ended, if it does exist")
+ public void testCanEndIfSumExists()
+ {
+ AdderBusinessLogic adder = new AdderBusinessLogic();
+ adder.startSum("foo");
+ assertThatNoException().isThrownBy(() -> adder.endSum("foo"));
+ }
+
+ @Test
+ @DisplayName("An existing Sum returns a non-null value, if ended")
+ public void testEndSumReturnsNonNullValueIfSumExists()
+ {
+ AdderBusinessLogic adder = new AdderBusinessLogic();
+ adder.startSum("foo");
+ assertThat(adder.endSum("foo")).isNotNull();
+ }
+
+ @Test
+ @DisplayName("An existing Sum returns a non-negative value, if ended")
+ public void testEndSumReturnsNonNegativeValueIfSumExists()
+ {
+ AdderBusinessLogic adder = new AdderBusinessLogic();
+ adder.startSum("foo");
+ assertThat(adder.endSum("foo")).isNotNegative();
+ }
+
+ @Test
+ @DisplayName("Ending a non-existing sum, causes an IllegalStateException")
+ public void testEndSumCausesExceptionIfNotExists()
+ {
+ AdderBusinessLogic adder = new AdderBusinessLogic();
+ assertThatIllegalStateException().isThrownBy(() -> adder.endSum("foo"));
+ }
}