package cz.senslog.connector.fetch.fofr;

import cz.senslog.connector.model.config.DefaultConfig;
import cz.senslog.connector.tools.http.HttpClient;
import cz.senslog.connector.tools.util.DateTrunc;
import org.junit.jupiter.api.Test;

import java.util.*;

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

class FofrFetcherTest {

    @Test
    void fetch() throws Exception {

        DefaultConfig defaultConfig = new DefaultConfig("fofr", null);
        defaultConfig.setProperty("orderStatesUrl", "https://objednavky.fofrcz.cz/stavy/fofr/xml");
            defaultConfig.setProperty("warehouseLocationsUrl", "https://objednavky.fofrcz.cz/seznam-dep/json");
        defaultConfig.setProperty("parcelTrackingUrl", "https://objednavky.fofrcz.cz/procedure/track_and_trace_sledovani_zasilek.php");
        defaultConfig.setProperty("parcelInfoUrl", "https://objednavky.fofrcz.cz/zasilka-info/%d/%d/json");
        defaultConfig.setProperty("activeOrdersUrl", "http://172.17.0.1:8085/integration/tracking/all");
        defaultConfig.setProperty("deliveryStatus", 6);

        defaultConfig.setProperty("missingWarehouses", Collections.singletonList(
                new HashMap<String, Object>() {{
                    put("code", "CB");
                    put("location", Arrays.asList(49.4854338, 16.6436640));
                }}
        ));

        FofrConfig config = new FofrConfig(defaultConfig);

        FofrFetcher fofrFetcher = new FofrFetcher(config, HttpClient.newHttpClient());

        fofrFetcher.init();
        fofrFetcher.fetch(Optional.empty());
    }
}