package net.ssehub.kernel_haven.config;

import static net.ssehub.kernel_haven.config.Setting.Type.BOOLEAN;

import java.util.Properties;

import org.junit.Assert;
import org.junit.Test;

import net.ssehub.kernel_haven.SetUpException;

/**
 * Tests the {@link Configuration}.
 * @author El-Sharkawy
 *
 */
public class ConfigurationTest {

    /**
     * Tests that Boolean config values are handled correctly by the {@link Configuration}.
     * @throws SetUpException Must not occur, is not tested by this test.
     */
    @Test
    public void testBooleanValues() throws SetUpException {
        Setting<Boolean> falseValue = new Setting<>("value.false", BOOLEAN, false, "false", "");
        Setting<Boolean> trueValue = new Setting<>("value.true", BOOLEAN, false, "true", "");
        
        Configuration config = new Configuration(new Properties());
        config.registerSetting(falseValue);
        config.registerSetting(trueValue);
        
        boolean value = config.getValue(falseValue);
        Assert.assertFalse("False value is treated as true", value);
        
        value = config.getValue(trueValue);
        Assert.assertTrue("True value is treated as false", value);
    }
}

@@ -776,32 +776,240 @@
 %22, %22%22);%0A        
+Setting%3CBoolean%3E overwriteableValue = new Setting%3C%3E(%22value.x%22, BOOLEAN, false, %22true%22, %22%22);%0A        %0A        Properties prop = new Properties();%0A        prop.setProperty(overwriteableValue.getKey(), %22false%22);
 %0A        Configu
@@ -1042,32 +1042,20 @@
 uration(
-new Properties()
+prop
 );%0A     
@@ -1128,32 +1128,84 @@
 ing(trueValue);%0A
+        config.registerSetting(overwriteableValue);%0A
         %0A       
@@ -1364,32 +1364,32 @@
 lue(trueValue);%0A
-
         Assert.a
@@ -1436,20 +1436,151 @@
 e%22, value);%0A
+        %0A        value = config.getValue(overwriteableValue);%0A        Assert.assertFalse(%22False value is treated as true%22, value);%0A
     %7D%0A%7D%0A

Test case for the configuration