Java 11 migration: patterns (remaining b-c) (#1081)
* Moves business-delegate pattern to java 11 * Moves bytecode pattern to java 11 * Moves caching pattern to java 11 * Moves callback pattern to java 11 * Moves chain pattern to java 11 * Moves circuit-breaker pattern to java 11 * Moves collection-pipeline pattern to java 11 * Moves command pattern to java 11 * Moves commander pattern to java 11 * Moves composite pattern to java 11 * Corrects test cases
This commit is contained in:
committed by
Ilkka Seppälä
parent
6ef840f3cf
commit
33ea7335b1
@ -25,15 +25,12 @@ package com.iluwatar.callback;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Tests that Callback example runs without errors.
|
||||
*/
|
||||
public class AppTest {
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
public void test() {
|
||||
App.main(new String[]{});
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,14 @@
|
||||
|
||||
package com.iluwatar.callback;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Add a field as a counter. Every time the callback method is called increment this field. Unit
|
||||
* test checks that the field is being incremented.
|
||||
*
|
||||
* <p>
|
||||
* Could be done with mock objects as well where the call method call is verified.
|
||||
*/
|
||||
public class CallbackTest {
|
||||
@ -41,17 +41,17 @@ public class CallbackTest {
|
||||
public void test() {
|
||||
Callback callback = () -> callingCount++;
|
||||
|
||||
Task task = new SimpleTask();
|
||||
var task = new SimpleTask();
|
||||
|
||||
assertEquals(new Integer(0), callingCount, "Initial calling count of 0");
|
||||
assertEquals(Integer.valueOf(0), callingCount, "Initial calling count of 0");
|
||||
|
||||
task.executeWith(callback);
|
||||
|
||||
assertEquals(new Integer(1), callingCount, "Callback called once");
|
||||
assertEquals(Integer.valueOf(1), callingCount, "Callback called once");
|
||||
|
||||
task.executeWith(callback);
|
||||
|
||||
assertEquals(new Integer(2), callingCount, "Callback called twice");
|
||||
assertEquals(Integer.valueOf(2), callingCount, "Callback called twice");
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user