package org.roklib.webapps.uridispatching.parameter;

import org.junit.Before;
import org.junit.Test;
import org.roklib.webapps.uridispatching.URIActionCommand;
import org.roklib.webapps.uridispatching.mapper.AbstractURIPathSegmentActionMapper;
import org.roklib.webapps.uridispatching.parameter.value.ParameterValue;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public abstract class AbstractURIParameterTest<V extends Serializable> {
    private AbstractURIParameter<V> testObj;

    public abstract AbstractURIParameter<V> getTestURIParameter();

    public abstract V getTestValue();

    public abstract V getDefaultValue();

    @Test
    public abstract void testGetSingleValueCount();

    @Test
    public abstract void testGetParameterNames();

    @Before
    public void setUp() {
        testObj = getTestURIParameter();
    }


    @Test
    public void testSetOptional() {
        testObj.setOptional(getDefaultValue());
        assertTrue(testObj.isOptional());
        testObj.setOptional(getDefaultValue());
        assertFalse(testObj.isOptional());
    }

    @SuppressWarnings("serial")
    private static class TURLParameter extends AbstractURIParameter<String> {
        boolean parameterized = false;

        public TURLParameter(String id) {
            super(id);
        }

        public boolean parameterized() {
            return parameterized;
        }

        @Override
        protected ParameterValue<String> consumeParametersImpl(Map<String, List<String>> parameters) {
            return null;
        }

        public URIActionCommand getErrorCommandIfInvalid() {
            return null;
        }

        public void parameterizeURIHandler(AbstractURIPathSegmentActionMapper handler) {
            parameterized = true;
        }

        public int getSingleValueCount() {
            return 1;
        }

        public List<String> getParameterNames() {
            return null;
        }
    }
}
@@ -739,24 +739,110 @@
 ltValue();%0A%0A
+    @Before%0A    public void setUp() %7B%0A        testObj = getTestURIParameter();%0A    %7D%0A%0A
     @Test%0A  
@@ -962,201 +962,67 @@
    @
-Before%0A    public void setUp() %7B%0A        testObj = getTestURIParameter();%0A    %7D%0A%0A%0A    @Test%0A    public void testSetOptional() %7B%0A        testObj.setOptional(getDefaultValue());%0A        assertTru
+Test%0A    public void testSetOptional() %7B%0A        assertFals
 e(te
@@ -1096,36 +1096,35 @@
 ;%0A        assert
-Fals
+Tru
 e(testObj.isOpti
@@ -1141,874 +1141,6 @@
    %7D
-%0A%0A    @SuppressWarnings(%22serial%22)%0A    private static class TURLParameter extends AbstractURIParameter%3CString%3E %7B%0A        boolean parameterized = false;%0A%0A        public TURLParameter(String id) %7B%0A            super(id);%0A        %7D%0A%0A        public boolean parameterized() %7B%0A            return parameterized;%0A        %7D%0A%0A        @Override%0A        protected ParameterValue%3CString%3E consumeParametersImpl(Map%3CString, List%3CString%3E%3E parameters) %7B%0A            return null;%0A        %7D%0A%0A        public URIActionCommand getErrorCommandIfInvalid() %7B%0A            return null;%0A        %7D%0A%0A        public void parameterizeURIHandler(AbstractURIPathSegmentActionMapper handler) %7B%0A            parameterized = true;%0A        %7D%0A%0A        public int getSingleValueCount() %7B%0A            return 1;%0A        %7D%0A%0A        public List%3CString%3E getParameterNames() %7B%0A            return null;%0A        %7D%0A    %7D
 %0A%7D

Fix test