package cz.senslog.connector.push.rest.senslog.v1;

import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.model.config.HostConfig;
import cz.senslog.connector.tools.exception.PropertyNotFoundException;
import org.junit.jupiter.api.Test;

import java.util.HashMap;

import static cz.senslog.connector.tools.json.BasicJson.jsonToObject;
import static org.junit.jupiter.api.Assertions.*;

class SenslogV1ConfigTest {


    @Test
    void newConfig_Full_True() {

        DefaultConfig defaultConfig = new DefaultConfig("senslog", null);
        defaultConfig.setProperty("host", new HashMap<String, String>(){{
            put("baseUrl", "http://test.com");
        }});

        SenslogV1Config config = new SenslogV1Config(defaultConfig);


        assertNotNull(config);
        assertEquals("http://test.com", config.getBaseUrl());
    }

    @Test
    void newConfig_EmptyHost_Exception() {

        DefaultConfig defaultConfig = new DefaultConfig("senslog", null);

        PropertyNotFoundException exception = assertThrows(PropertyNotFoundException.class, () -> new SenslogV1Config(defaultConfig));

        assertEquals("Property 'senslog.host' does not exist.", exception.getMessage());
    }
}