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