package org.roklib.webapps.uridispatching.parameter.value;

import org.junit.Before;
import org.junit.Test;
import org.roklib.webapps.uridispatching.parameter.SingleIntegerURIParameter;
import org.roklib.webapps.uridispatching.parameter.SingleStringURIParameter;

import java.util.Optional;

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;

/**
 * @author Roland Krüger
 */
public class ConsumedParameterValuesTest {

    private ConsumedParameterValues values;
    private SingleStringURIParameter stringParameter;
    private SingleIntegerURIParameter integerParameter;

    @Before
    public void setUp() {
        values = new ConsumedParameterValues();
        stringParameter = new SingleStringURIParameter("text");
        integerParameter = new SingleIntegerURIParameter("number");
    }

    @Test
    public void returns_empty_optional_for_unknown_mapper_name() {
        assertThat(values.getValueFor("unknown", stringParameter), equalTo(Optional.empty()));
    }

    @Test
    public void returns_empty_optional_for_unavailable_parameter() {
        values.setValueFor("first", stringParameter, "test");
        assertThat(values.getValueFor("first", integerParameter), equalTo(Optional.empty()));
    }

    @Test
    public void getValueFor_returns_correct_value() {
        values.setValueFor("first", stringParameter, "test");
        values.setValueFor("second", integerParameter, 17);

        assertThat(values.getValueFor("first", stringParameter).get().getValue(), equalTo("test"));
        assertThat(values.getValueFor("second", integerParameter).get().getValue(), equalTo(17));
    }

    @Test(expected = NullPointerException.class)
    public void getValueFor_mapper_name_null_not_allowed() {
        values.getValueFor(null, stringParameter);
    }

    @Test(expected = NullPointerException.class)
    public void getValueFor_parameter_null_not_allowed() {
        values.getValueFor("first", null);
    }

    @Test(expected = NullPointerException.class)
    public void setValueFor_mapper_name_null_not_allowed() {
        values.setValueFor(null, stringParameter, "");
    }

    @Test(expected = NullPointerException.class)
    public void setValueFor_parameter_null_not_allowed() {
        values.setValueFor("first", null, "");
    }
}

@@ -538,24 +538,86 @@
 meter string
+TextParameter;%0A    private SingleStringURIParameter stringName
 Parameter;%0A 
@@ -768,24 +768,28 @@
       string
+Text
 Parameter = 
@@ -822,24 +822,92 @@
 er(%22text%22);%0A
+        stringNameParameter = new SingleStringURIParameter(%22name%22);%0A
         inte
@@ -1093,32 +1093,36 @@
 unknown%22, string
+Text
 Parameter), equa
@@ -1265,32 +1265,36 @@
 (%22first%22, string
+Text
 Parameter, %22test
@@ -1496,32 +1496,36 @@
 (%22first%22, string
+Text
 Parameter, %22test
@@ -1514,34 +1514,110 @@
 xtParameter, %22te
-st
+xtValue%22);%0A        values.setValueFor(%22first%22, stringNameParameter, %22nameValue
 %22);%0A        valu
@@ -1710,32 +1710,36 @@
 (%22first%22, string
+Text
 Parameter).get()
@@ -1762,18 +1762,132 @@
 alTo(%22te
-st
+xtValue%22));%0A        assertThat(values.getValueFor(%22first%22, stringNameParameter).get().getValue(), equalTo(%22nameValue
 %22));%0A   
@@ -2129,32 +2129,36 @@
 For(null, string
+Text
 Parameter);%0A    
@@ -2467,16 +2467,20 @@
 , string
+Text
 Paramete

Add second string parameter to tests