package cz.senslog.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 static org.junit.jupiter.api.Assertions.*;

class SensLogTelemetryFetcherTest {

    @Test
    void onlineTest() throws Exception {

        DefaultConfig defaultConfig = new DefaultConfig("", null);
        defaultConfig.setProperty("baseUrl", "https://theros.wirelessinfo.cz/");
        defaultConfig.setProperty("startAt", "2023-08-25T00:00:00+00:00");
        defaultConfig.setProperty("bearerToken", "#123");
        defaultConfig.setProperty("campaignId", 2);
        defaultConfig.setProperty("limit", 10);
        defaultConfig.setProperty("interval", 12);

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

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