use of de.fraunhofer.iosb.ilt.sta.model.Observation in project FROST-Server by FraunhoferIOSB.
the class DeleteFilterTests method createObservation.
private void createObservation(double result, Datastream ds, TimeObject pt, ZonedDateTime rt, Interval vt) throws ServiceFailureException {
Observation o = new Observation(result, ds);
o.setPhenomenonTime(pt);
o.setResultTime(rt);
o.setValidTime(vt);
service.create(o);
OBSERVATIONS.add(o);
}
use of de.fraunhofer.iosb.ilt.sta.model.Observation in project FROST-Server by FraunhoferIOSB.
the class ResultTypesTests method testStringResult.
/**
* Tests if String result values are stored and retrieved correctly.
*
* @throws ServiceFailureException if the service connection fails.
*/
@Test
public void testStringResult() throws ServiceFailureException {
LOGGER.info(" testStringResult");
ObservationDao doa = service.observations();
Observation b1 = new Observation("fourty two", DATASTREAMS.get(0));
doa.create(b1);
OBSERVATIONS.add(b1);
Observation found;
found = doa.find(b1.getId());
String message = "Expected result to be a String.";
Assert.assertEquals(message, b1.getResult(), found.getResult());
}
use of de.fraunhofer.iosb.ilt.sta.model.Observation in project FROST-Server by FraunhoferIOSB.
the class ResultTypesTests method testResultQualityArray.
/**
* Tests if resultQuality can have arbitrary json.
*
* @throws ServiceFailureException if the service connection fails.
*/
@Test
public void testResultQualityArray() throws ServiceFailureException, IOException {
LOGGER.info(" testResultQualityArray");
ObservationDao doa = service.observations();
Observation o1 = new Observation(1.0, DATASTREAMS.get(0));
ObjectMapper mapper = ObjectMapperFactory.get();
String resultQualityString = "[\n" + " {\n" + " \"nameOfMeasure\": \"DQ_Status\",\n" + " \"DQ_Result\": {\n" + " \"code\": \"http://id.eaufrance.fr/nsa/446#2\",\n" + " \"label\": \"Niveau 1\",\n" + " \"comment\": \"Donnée contrôlée niveau 1 (données contrôlées)\"\n" + " }\n" + " },\n" + " {\n" + " \"nameOfMeasure\": \"DQ_Qualification\",\n" + " \"DQ_Result\": {\n" + " \"code\": \"http://id.eaufrance.fr/nsa/414#1\",\n" + " \"label\": \"Correcte\",\n" + " \"comment\": \"Correcte\"\n" + " }\n" + " }\n" + "\n" + "]";
o1.setResultQuality(mapper.readTree(resultQualityString));
doa.create(o1);
OBSERVATIONS.add(o1);
Observation found;
found = doa.find(o1.getId());
String message = "resultQuality not stored correctly.";
Assert.assertEquals(message, o1.getResultQuality(), mapper.valueToTree(found.getResultQuality()));
}
use of de.fraunhofer.iosb.ilt.sta.model.Observation in project FROST-Server by FraunhoferIOSB.
the class ResultTypesTests method testNumericResult.
/**
* Tests if Numeric result values are stored and retrieved correctly.
*
* @throws ServiceFailureException if the service connection fails.
*/
@Test
public void testNumericResult() throws ServiceFailureException {
LOGGER.info(" testNumericResult");
ObservationDao doa = service.observations();
Observation b1 = new Observation(1, DATASTREAMS.get(0));
doa.create(b1);
OBSERVATIONS.add(b1);
Observation found;
found = doa.find(b1.getId());
String message = "Expected result to be a Number.";
Assert.assertEquals(message, b1.getResult(), found.getResult());
Observation b2 = new Observation(BigDecimal.valueOf(1.23), DATASTREAMS.get(0));
doa.create(b2);
OBSERVATIONS.add(b2);
found = doa.find(b2.getId());
message = "Expected result to be a Number.";
Assert.assertEquals(message, b2.getResult(), found.getResult());
}
use of de.fraunhofer.iosb.ilt.sta.model.Observation in project FROST-Server by FraunhoferIOSB.
the class ResultTypesTests method testResultQualityObject.
/**
* Tests if resultQuality can have arbitrary json.
*
* @throws ServiceFailureException if the service connection fails.
*/
@Test
public void testResultQualityObject() throws ServiceFailureException, IOException {
LOGGER.info(" testResultQualityObject");
ObservationDao doa = service.observations();
Observation o1 = new Observation(1.0, DATASTREAMS.get(0));
ObjectMapper mapper = ObjectMapperFactory.get();
String resultQualityString = "" + "{\"DQ_Status\":{" + " \"code\": \"http://id.eaufrance.fr/nsa/446#2\"," + " \"label\": \"Niveau 1\",\n" + " \"comment\": \"Donnée contrôlée niveau 1 (données contrôlées)\"" + "}}";
o1.setResultQuality(mapper.readTree(resultQualityString));
doa.create(o1);
OBSERVATIONS.add(o1);
Observation found;
found = doa.find(o1.getId());
String message = "resultQuality not stored correctly.";
Assert.assertEquals(message, o1.getResultQuality(), mapper.valueToTree(found.getResultQuality()));
}
Aggregations