package cz.senslog.connector.model.converter;

import cz.senslog.connector.model.afarcloud.AFarCloudModel;
import cz.senslog.connector.model.v1.*;
import cz.senslog.connector.model.v1.Record;
import org.junit.jupiter.api.Test;

import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


class SenslogV1ModelAFarCloudModelConverterTest {

    @Test
    void convert() {

        ZonedDateTime now = ZonedDateTime.now();

        Map<Long, UnitInfo> unitInfos = new HashMap<>();
        UnitInfo unitInfo = new UnitInfo();
        unitInfo.setUnitId(42L);
        unitInfo.setDescription("description");
        unitInfo.setHolderId(0);
        unitInfos.put(unitInfo.getUnitId(), unitInfo);

        SensorInfo sensorInfo = new SensorInfo();
        sensorInfo.setSensorId(10L);
        sensorInfo.setPhenomenon(new SensorInfo.Phenomenon());
        sensorInfo.getPhenomenon().setPhenomenonName("<phenomenon_name");
        sensorInfo.getPhenomenon().setUnit("%");
        List<SensorInfo> sensorInfos = new ArrayList<>();
        sensorInfos.add(sensorInfo);
        unitInfo.setSensors(sensorInfos);

        List<Record> observations = new ArrayList<>();
        Observation observation = new Observation();
        observation.setUnitId(unitInfo.getUnitId());
        observation.setSensorId(sensorInfo.getSensorId());
        observation.setValue(10F);
        observation.setTime(now.toOffsetDateTime());
        observations.add(observation);

        SenslogV1Model senslogV1Model = new SenslogV1Model(unitInfos, observations, OffsetDateTime.MIN, OffsetDateTime.MAX);

        SenslogV1ModelAFarCloudModelConverter converter = new SenslogV1ModelAFarCloudModelConverter();

        AFarCloudModel aFarCloudModel = converter.convert(senslogV1Model);


    }
}