package be.arndep.commons.patterns;

import org.junit.Test;

import static org.junit.Assert.*;

public class AbstractHandlerTest {

    @Test
    public void testHandleRequest() throws Exception {
        //TODO: make unit test
    }
}
@@ -30,16 +30,41 @@
 terns;%0A%0A
+import org.junit.Before;%0A
 import o
@@ -153,104 +153,1784 @@
 t %7B%0A
-%0A    @Test%0A    public void testHandleRequest() throws Exception %7B%0A        //TODO: make unit test
+    private static enum KindNumber %7B%0A        ZERO,%0A        NEGATIVE,%0A        POSITIVE,%0A        UNDEFINED%0A    %7D%0A    private KindNumber kindNumber;%0A    private AbstractHandlerChain%3CInteger%3E handler;%0A%0A    @Before%0A    public void setUp() %7B%0A        kindNumber = KindNumber.UNDEFINED;%0A        handler = new AbstractHandlerChain%3CInteger%3E() %7B%0A            @Override%0A            protected boolean handleImpl(Integer request) %7B%0A                if (request == 0) %7B%0A                    kindNumber = KindNumber.ZERO;%0A                    return true;%0A                %7D%0A                return false;%0A            %7D%0A        %7D;%0A        handler%0A                .setSuccessor(new AbstractHandlerChain%3CInteger%3E() %7B%0A                    @Override%0A                    protected boolean handleImpl(Integer request) %7B%0A                        if (request %3C 0) %7B%0A                            kindNumber = KindNumber.NEGATIVE;%0A                            return true;%0A                        %7D%0A                        return false;%0A                    %7D%0A                %7D)%0A                .setSuccessor(new AbstractHandlerChain%3CInteger%3E() %7B%0A                    @Override%0A                    protected boolean handleImpl(Integer request) %7B%0A                        if (request %3E 0) %7B%0A                            kindNumber = KindNumber.POSITIVE;%0A                            return true;%0A                        %7D%0A                        return false;%0A                    %7D%0A                %7D);%0A    %7D%0A%0A    @Test%0A    public void testHandleRequest() throws Exception %7B%0A        handler.handle(0);%0A        assertEquals(KindNumber.ZERO, kindNumber);%0A%0A        handler.handle(1);%0A        assertEquals(KindNumber.POSITIVE, kindNumber);%0A%0A        handler.handle(-1);%0A        assertEquals(KindNumber.NEGATIVE, kindNumber);
 %0A   

add test for handler chain