Search in sources :

Example 1 with Observation

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);
}
Also used : Observation(de.fraunhofer.iosb.ilt.sta.model.Observation)

Example 2 with Observation

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());
}
Also used : ObservationDao(de.fraunhofer.iosb.ilt.sta.dao.ObservationDao) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) Test(org.junit.Test)

Example 3 with Observation

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()));
}
Also used : ObservationDao(de.fraunhofer.iosb.ilt.sta.dao.ObservationDao) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with Observation

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());
}
Also used : ObservationDao(de.fraunhofer.iosb.ilt.sta.dao.ObservationDao) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) Test(org.junit.Test)

Example 5 with Observation

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()));
}
Also used : ObservationDao(de.fraunhofer.iosb.ilt.sta.dao.ObservationDao) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

Observation (de.fraunhofer.iosb.ilt.sta.model.Observation)47 Test (org.junit.Test)18 Datastream (de.fraunhofer.iosb.ilt.sta.model.Datastream)14 Point (org.geojson.Point)14 FeatureOfInterest (de.fraunhofer.iosb.ilt.sta.model.FeatureOfInterest)12 Location (de.fraunhofer.iosb.ilt.sta.model.Location)11 ObservationDao (de.fraunhofer.iosb.ilt.sta.dao.ObservationDao)9 ServiceFailureException (de.fraunhofer.iosb.ilt.sta.ServiceFailureException)8 TimeObject (de.fraunhofer.iosb.ilt.sta.model.TimeObject)8 MultiDatastream (de.fraunhofer.iosb.ilt.sta.model.MultiDatastream)7 ObservedProperty (de.fraunhofer.iosb.ilt.sta.model.ObservedProperty)7 Sensor (de.fraunhofer.iosb.ilt.sta.model.Sensor)7 Thing (de.fraunhofer.iosb.ilt.sta.model.Thing)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 UnitOfMeasurement (de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement)6 ArrayList (java.util.ArrayList)6 Id (de.fraunhofer.iosb.ilt.sta.model.Id)5 Instant (java.time.Instant)5 HashMap (java.util.HashMap)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4