|
@@ -7,10 +7,7 @@ import cz.senslog.common.http.HttpClient;
|
|
|
import cz.senslog.common.http.HttpRequest;
|
|
import cz.senslog.common.http.HttpRequest;
|
|
|
import cz.senslog.common.http.HttpResponse;
|
|
import cz.senslog.common.http.HttpResponse;
|
|
|
import cz.senslog.connector.model.converter.FieldClimateModelSenslogV1ModelConverter;
|
|
import cz.senslog.connector.model.converter.FieldClimateModelSenslogV1ModelConverter;
|
|
|
-import cz.senslog.connector.model.fieldclimate.FieldClimateModel;
|
|
|
|
|
-import cz.senslog.connector.model.fieldclimate.SensorDataInfo;
|
|
|
|
|
-import cz.senslog.connector.model.fieldclimate.StationData;
|
|
|
|
|
-import cz.senslog.connector.model.fieldclimate.StationInfo;
|
|
|
|
|
|
|
+import cz.senslog.connector.model.fieldclimate.*;
|
|
|
import cz.senslog.connector.model.v1.SenslogV1Model;
|
|
import cz.senslog.connector.model.v1.SenslogV1Model;
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
@@ -73,11 +70,12 @@ class FieldClimateFetcherTest {
|
|
|
}});
|
|
}});
|
|
|
}});
|
|
}});
|
|
|
|
|
|
|
|
- fcDConfig.setProperty("blockedStations", new ArrayList<String>(){{
|
|
|
|
|
- add("#123");
|
|
|
|
|
- add("#456");
|
|
|
|
|
- }});
|
|
|
|
|
|
|
+ Map<String, List<Integer>> allowedStation = new HashMap<>();
|
|
|
|
|
+ List<Integer> allowedSensor = new ArrayList<>();
|
|
|
|
|
+ allowedSensor.add((int)SensorType.HC_AIR_TEMPERATURE.getCode());
|
|
|
|
|
+ allowedStation.put("original_name", allowedSensor);
|
|
|
|
|
|
|
|
|
|
+ fcDConfig.setProperty("allowedStation", allowedStation);
|
|
|
fcDConfig.setProperty("timeZone", "Europe/Riga");
|
|
fcDConfig.setProperty("timeZone", "Europe/Riga");
|
|
|
|
|
|
|
|
fcDConfig.setProperty("startDate", startDate);
|
|
fcDConfig.setProperty("startDate", startDate);
|
|
@@ -335,7 +333,7 @@ class FieldClimateFetcherTest {
|
|
|
SensorDataInfo dataInfo = new SensorDataInfo();
|
|
SensorDataInfo dataInfo = new SensorDataInfo();
|
|
|
dataInfo.setName("sensorName");
|
|
dataInfo.setName("sensorName");
|
|
|
dataInfo.setCh(1L);
|
|
dataInfo.setCh(1L);
|
|
|
- dataInfo.setCode(2L);
|
|
|
|
|
|
|
+ dataInfo.setCode(SensorType.HC_AIR_TEMPERATURE.getCode());
|
|
|
dataInfo.setMac("mac");
|
|
dataInfo.setMac("mac");
|
|
|
dataInfo.setSerial("serial");
|
|
dataInfo.setSerial("serial");
|
|
|
Map<String, Integer> aggrMap = new HashMap<>();
|
|
Map<String, Integer> aggrMap = new HashMap<>();
|
|
@@ -360,9 +358,6 @@ class FieldClimateFetcherTest {
|
|
|
|
|
|
|
|
FieldClimateModel model = fetcher.fetch(Optional.empty());
|
|
FieldClimateModel model = fetcher.fetch(Optional.empty());
|
|
|
|
|
|
|
|
- assertEquals(startDate.plusHours(1), model.getFrom().toLocalDateTime());
|
|
|
|
|
- assertEquals(startDate.plusHours(2), model.getTo().toLocalDateTime());
|
|
|
|
|
-
|
|
|
|
|
assertEquals(1, model.getStations().size());
|
|
assertEquals(1, model.getStations().size());
|
|
|
|
|
|
|
|
StationData stationData = model.getStations().get(0);
|
|
StationData stationData = model.getStations().get(0);
|
|
@@ -407,6 +402,12 @@ class FieldClimateFetcherTest {
|
|
|
StationData data = new StationData();
|
|
StationData data = new StationData();
|
|
|
data.setId(stationName);
|
|
data.setId(stationName);
|
|
|
SensorDataInfo dataInfo = new SensorDataInfo();
|
|
SensorDataInfo dataInfo = new SensorDataInfo();
|
|
|
|
|
+ dataInfo.setName("sensorName");
|
|
|
|
|
+ dataInfo.setCh(1L);
|
|
|
|
|
+ dataInfo.setCode(SensorType.HC_AIR_TEMPERATURE.getCode());
|
|
|
|
|
+ Map<String, Integer> aggrMap = new HashMap<>();
|
|
|
|
|
+ aggrMap.put("avg", 1);
|
|
|
|
|
+ dataInfo.setAggr(aggrMap);
|
|
|
Map<String, String> dataMap = new HashMap<>();
|
|
Map<String, String> dataMap = new HashMap<>();
|
|
|
dataMap.put("date", startDate.plusHours(1).format(ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
dataMap.put("date", startDate.plusHours(1).format(ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
data.setSensors(singletonList(dataInfo));
|
|
data.setSensors(singletonList(dataInfo));
|
|
@@ -422,14 +423,6 @@ class FieldClimateFetcherTest {
|
|
|
fetcher.init();
|
|
fetcher.init();
|
|
|
|
|
|
|
|
FieldClimateModel model1 = fetcher.fetch(Optional.empty());
|
|
FieldClimateModel model1 = fetcher.fetch(Optional.empty());
|
|
|
- assertEquals(startDate, model1.getFrom().toLocalDateTime());
|
|
|
|
|
- assertEquals(startDate.plusHours(config.getPeriod()), model1.getTo().toLocalDateTime());
|
|
|
|
|
-
|
|
|
|
|
- FieldClimateModel model2 = fetcher.fetch(Optional.empty());
|
|
|
|
|
- assertEquals(startDate.plusHours(config.getPeriod()), model2.getFrom().toLocalDateTime());
|
|
|
|
|
- assertEquals(startDate.plusHours(2*config.getPeriod()), model2.getTo().toLocalDateTime());
|
|
|
|
|
-
|
|
|
|
|
- FieldClimateModel model3 = fetcher.fetch(Optional.empty());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -457,7 +450,7 @@ class FieldClimateFetcherTest {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
*/
|
|
|
-
|
|
|
|
|
|
|
+/*
|
|
|
@Test
|
|
@Test
|
|
|
void fetch() throws Exception {
|
|
void fetch() throws Exception {
|
|
|
|
|
|
|
@@ -519,7 +512,7 @@ class FieldClimateFetcherTest {
|
|
|
System.out.println(senslogV1Model);
|
|
System.out.println(senslogV1Model);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+*/
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
private void saveToCSV(FieldClimateModel model) throws IOException {
|
|
private void saveToCSV(FieldClimateModel model) throws IOException {
|