package cz.senslog.connector.fetch.senslog.telemetry;

import cz.senslog.connector.fetch.api.ExecutableFetcher;
import cz.senslog.connector.model.api.GeoJsonModel;
import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.tools.http.HttpClient;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collections;

class SensLogTelemetryFetcherTest {

    @Test
    void onlineTest() throws Exception {

        DefaultConfig defaultConfig = new DefaultConfig("", null);
//        defaultConfig.setProperty("startAt", "now");
        defaultConfig.setProperty("startAt", "2024-12-01T10:09:00+00:00"); // 2024-12-01T10:09:34.589Z
        defaultConfig.setProperty("bearerToken", "#123");
        defaultConfig.setProperty("limit", 100);
        defaultConfig.setProperty("interval", 1);

//        defaultConfig.setProperty("baseUrl", "http://127.0.0.1:8085");
//        defaultConfig.setProperty("campaignId", 3);
//        defaultConfig.setProperty("actionId", 9);
//        defaultConfig.setProperty("entityId", 3);
//        defaultConfig.setProperty("allowedStations", Arrays.asList(1000L));


        defaultConfig.setProperty("baseUrl", "https://theros.wirelessinfo.cz/");
        defaultConfig.setProperty("campaignId", 4);
        defaultConfig.setProperty("actionId", 1);
        defaultConfig.setProperty("entityId", 1);
        defaultConfig.setProperty("allowedStations", Arrays.asList(1305167563014004L, 1305167563048283L));


        SensLogTelemetryConfig config = new SensLogTelemetryConfig(defaultConfig);
        SensLogTelemetryFetcher fetcher = new SensLogTelemetryFetcher(config, HttpClient.newHttpSSLClient());
        ExecutableFetcher<GeoJsonModel> executor = ExecutableFetcher.create(fetcher);

        fetcher.init();
        for (int i = 0; i < 10; i++) {
            executor.execute();
        }
    }
}