package cz.senslog.connector.fetch.alapans;

import cz.senslog.connector.fetch.api.ExecutableFetcher;
import cz.senslog.connector.model.alapans.AlapansModel;
import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.model.converter.AlapansModelSenslogV1ModelConverter;
import cz.senslog.connector.model.v1.SenslogV1Model;
import org.junit.jupiter.api.Test;

import java.util.HashMap;

import static org.junit.jupiter.api.Assertions.*;

class AlapansFetcherTest {

    @Test
    void online_fetch() {
        DefaultConfig defaultConfig = new DefaultConfig("", null);

        defaultConfig.setProperty("baseUrl", "https://gca44347dc41d4c-alapansdw.adb.eu-paris-1.oraclecloudapps.com/ords/alapans/sensors/date");
        defaultConfig.setProperty("timeZone", "Europe/Riga");
        defaultConfig.setProperty("startDate", "2023-05-29");
        defaultConfig.setProperty("newDataExecutionTime", "06:30:00");
        defaultConfig.setProperty("period", 1);
        defaultConfig.setProperty("sessionProxy", new HashMap<String, Object>() {{
            put("baseUrl", "https://sensor.lesprojekt.cz/senslog15/");
            put("user", "vestiena");
            put("group", "vestiena");
            put("senslogAuth", new HashMap<String, Object>() {{
                put("username", "vestiena");
                put("password", "potato");
            }});
        }});

        ExecutableFetcher<AlapansModel> fetcher = new ConnectorFetchAlapansProvider()
                .createExecutableFetcher(defaultConfig);

        AlapansModelSenslogV1ModelConverter converter = new AlapansModelSenslogV1ModelConverter();


        System.out.println(converter.convert(fetcher.execute()).getObservations().size());
        System.out.println(converter.convert(fetcher.execute()).getObservations().size());
        System.out.println(converter.convert(fetcher.execute()).getObservations().size());
        System.out.println(converter.convert(fetcher.execute()).getObservations().size());
        System.out.println(converter.convert(fetcher.execute()).getObservations().size());
    }
}