package cz.senslog.connector.fetch.azure;

import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.fetch.api.ConnectorFetchProvider;
import cz.senslog.connector.fetch.api.ExecutableFetcher;
import org.junit.jupiter.api.Test;

import java.time.LocalDateTime;
import java.util.HashMap;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;

class ConnectorFetchAzureProviderTest {

    @Test
    void createFetcher_NewInstance_True() {

        DefaultConfig defaultConfig = new DefaultConfig("azure", any());
        defaultConfig.setProperty("startDate", LocalDateTime.MIN);
        defaultConfig.setProperty("limitPerSensor", 42);
        defaultConfig.setProperty("sensorInfoHost", new HashMap<String, Object>(){{
            put("domain", "http://test.com");
            put("path", "test");
        }});
        defaultConfig.setProperty("sensorDataHost", new HashMap<String, Object>(){{
            put("domain", "http://test.com");
            put("path", "test");
        }});
        defaultConfig.setProperty("authentication", new HashMap<String, Object>(){{
            put("username", "username");
            put("password", "password");
            put("refreshPeriodIfFail", 100);
            put("host", new HashMap<String, Object>(){{
                put("domain", "http://test.com");
                put("path", "test");
            }});
        }});

        defaultConfig.setProperty("allowedStation", new HashMap<String, Object>() {{
            put("unit_1", null);
        }});

        ConnectorFetchProvider provider = new ConnectorFetchAzureProvider();
        ExecutableFetcher fetcher = provider.createExecutableFetcher(defaultConfig);

        assertNotNull(fetcher);
        assertEquals(AzureFetcher.class, fetcher.getRawFetcher().getClass());
    }
}