/*******************************************************************************
 * Copyright (c) 2011, 2016 Eurotech and/or its affiliates and others
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Eurotech - initial API and implementation
 *
 *******************************************************************************/
package org.eclipse.kapua.commons.setting;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class AbstractKapuaSettingTest {

    @Test
    public void shouldReadPathFromEnv() {
        // When
        String path = new TestSetting().property("PATH");

        // Then
        assertThat(path).isNotEmpty();
    }

    @Test
    public void shouldReadEnvUsingDotNotation() {
        // Given
        System.setProperty("FOO_BAR_BAZ", "qux");

        // When
        String path = new TestSetting().property("foo.bar.baz");

        // Then
        assertThat(path).isEqualTo("qux");
    }

    static class TestSetting extends AbstractKapuaSetting {

        String property(String key) {
            return config.getString(key);
        }

        protected TestSetting() {
            super("test.properties");
        }

    }

}

@@ -104,9 +104,9 @@
  201
-6
+7
  Eur
@@ -464,16 +464,32 @@
 ation%0A *
+     Red Hat Inc
 %0A ******
@@ -727,24 +727,331 @@
 tingTest %7B%0A%0A
+    private static class TestSettingKey implements SettingKey %7B%0A%0A        private String key;%0A%0A        @SuppressWarnings(%22unused%22)%0A        public TestSettingKey(String key) %7B%0A            this.key = key;%0A        %7D%0A%0A        @Override%0A        public String key() %7B%0A            return this.key;%0A        %7D%0A    %7D%0A%0A
     @Test%0A  
@@ -1499,24 +1499,24 @@
 x%22);%0A    %7D%0A%0A
-
     static c
@@ -1560,16 +1560,32 @@
 aSetting
+%3CTestSettingKey%3E
  %7B%0A%0A    

Fix warning about missing type parameter