Reformat business-delegate, callback, chain, command, composite, dao, decorator & dependency-injection patterns.

This commit is contained in:
Ankur Kaushal
2015-11-01 18:48:43 -05:00
parent 3af06a3a3a
commit 449340bd2b
54 changed files with 698 additions and 700 deletions

View File

@ -5,35 +5,35 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* 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.
* 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.
*
* Could be done with mock objects as well where the call method call is verified.
*/
public class AppTest {
private Integer callingCount = 0;
private Integer callingCount = 0;
@Test
public void test() {
Callback callback = new Callback() {
@Override
public void call() {
callingCount++;
}
};
@Test
public void test() {
Callback callback = new Callback() {
@Override
public void call() {
callingCount++;
}
};
Task task = new SimpleTask();
Task task = new SimpleTask();
assertEquals("Initial calling count of 0", new Integer(0), callingCount);
assertEquals("Initial calling count of 0", new Integer(0), callingCount);
task.executeWith(callback);
task.executeWith(callback);
assertEquals("Callback called once", new Integer(1), callingCount);
assertEquals("Callback called once", new Integer(1), callingCount);
task.executeWith(callback);
task.executeWith(callback);
assertEquals("Callback called twice", new Integer(2), callingCount);
assertEquals("Callback called twice", new Integer(2), callingCount);
}
}
}