use of de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement in project FROST-Server by FraunhoferIOSB.
the class DeleteFilterTests method createEntities.
private static void createEntities() throws ServiceFailureException, URISyntaxException {
Thing thing = new Thing("Thing 1", "The first thing.");
THINGS.add(thing);
Location location = new Location("Location 1.0", "Location of Thing 1.", "application/vnd.geo+json", new Point(8, 51));
thing.getLocations().add(location);
service.create(thing);
Sensor sensor = new Sensor("Sensor 1", "The first sensor.", "text", "Some metadata.");
ObservedProperty obsProp = new ObservedProperty("Temperature", new URI("http://ucom.org/temperature"), "The temperature of the thing.");
{
Datastream datastream = new Datastream("Datastream 1", "The temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
datastream.setThing(thing);
datastream.setSensor(sensor);
datastream.setObservedProperty(obsProp);
service.create(datastream);
DATASTREAMS.add(datastream);
}
{
Datastream datastream = new Datastream("Datastream 2", "The alternate temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
datastream.setThing(thing);
datastream.setSensor(sensor);
datastream.setObservedProperty(obsProp);
service.create(datastream);
DATASTREAMS.add(datastream);
}
}
use of de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement in project FROST-Server by FraunhoferIOSB.
the class ResultTypesTests method createEntities.
private static void createEntities() throws ServiceFailureException, URISyntaxException {
Thing thing = new Thing("Thing 1", "The first thing.");
THINGS.add(thing);
Location location = new Location("Location 1.0", "Location of Thing 1.", "application/vnd.geo+json", new Point(8, 51));
thing.getLocations().add(location);
service.create(thing);
Sensor sensor = new Sensor("Sensor 1", "The first sensor.", "text", "Some metadata.");
ObservedProperty obsProp = new ObservedProperty("Temperature", new URI("http://ucom.org/temperature"), "The temperature of the thing.");
Datastream datastream = new Datastream("Datastream 1", "The temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
datastream.setThing(thing);
datastream.setSensor(sensor);
datastream.setObservedProperty(obsProp);
service.create(datastream);
DATASTREAMS.add(datastream);
}
use of de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement in project FROST-Server by FraunhoferIOSB.
the class AdditionalTests method testRecreateAutomaticFoi.
@Test
public void testRecreateAutomaticFoi() throws ServiceFailureException {
LOGGER.info(" testRecreateAutomaticFoi");
EntityUtils.deleteAll(service);
// Create two things
Location location1 = new Location("LocationThing1", "Location of Thing 1", "application/geo+json", new Point(8, 50));
service.create(location1);
Thing thing1 = new Thing("Thing 1", "The first thing.");
thing1.getLocations().add(location1.withOnlyId());
service.create(thing1);
Sensor sensor1 = new Sensor("Test Thermometre", "Test Sensor", "None", "-");
service.create(sensor1);
ObservedProperty obsProp1 = new ObservedProperty("Temperature", "http://example.org", "-");
service.create(obsProp1);
Datastream datastream1 = new Datastream("Ds 1, Thing 1", "The datastream of Thing 1", "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement", new UnitOfMeasurement("Degrees Celcius", "°C", "http://qudt.org/vocab/unit#DegreeCelsius"));
datastream1.setThing(thing1);
datastream1.setSensor(sensor1);
datastream1.setObservedProperty(obsProp1);
service.create(datastream1);
Observation obs1 = new Observation(1.0, datastream1);
service.create(obs1);
FeatureOfInterest foiGenerated1 = service.observations().find(obs1.getId()).getFeatureOfInterest();
Assert.assertNotNull(foiGenerated1);
service.delete(foiGenerated1);
Observation obs2 = new Observation(1.0, datastream1);
service.create(obs2);
FeatureOfInterest foiGenerated2 = service.observations().find(obs2.getId()).getFeatureOfInterest();
Assert.assertNotNull(foiGenerated2);
Assert.assertNotEquals(foiGenerated1, foiGenerated2);
}
use of de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement in project FROST-Server by FraunhoferIOSB.
the class AdditionalTests method testMultipleLocations.
/**
* Check the creation of a FoI on Observation creation, for Things that have
* multiple Locations, only one of which is a geoJson location.
*
* @throws ServiceFailureException If the service doesn't respond.
*/
@Test
public void testMultipleLocations() throws ServiceFailureException {
LOGGER.info(" testMultipleLocations");
EntityUtils.deleteAll(service);
Thing thing = new Thing("Thing 1", "The first thing.");
Location location1 = new Location("Location 1.0, Address", "The address of Thing 1.", "text/plain", "");
thing.getLocations().add(location1);
Location location2 = new Location("Location 1.0", "Location of Thing 1.", "application/geo+json", new Point(8, 51));
thing.getLocations().add(location2);
Location location3 = new Location("Location 1.0, Directions", "How to find Thing 1 in human language.", "text/plain", "");
thing.getLocations().add(location3);
service.create(thing);
THINGS.add(thing);
Sensor sensor = new Sensor("Sensor 1", "The first sensor.", "text", "Some metadata.");
ObservedProperty obsProp = new ObservedProperty("Temperature", "http://ucom.org/temperature", "The temperature of the thing.");
Datastream datastream = new Datastream("Datastream 1", "The temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
datastream.setSensor(sensor);
datastream.setObservedProperty(obsProp);
datastream.setThing(thing);
service.create(datastream);
DATASTREAMS.add(datastream);
ObservationDao doa = service.observations();
Observation observation = new Observation(1.0, DATASTREAMS.get(0));
doa.create(observation);
OBSERVATIONS.add(observation);
Observation found;
found = doa.find(observation.getId());
FeatureOfInterest featureOfInterest = found.getFeatureOfInterest();
Assert.assertNotNull("A FeatureOfInterest should have been generated, but got NULL.", featureOfInterest);
}
use of de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement in project FROST-Server by FraunhoferIOSB.
the class AdditionalTests method testPostInvalidPath.
/**
* Tests requests on paths like Things(x)/Datastreams(y)/Observations, where
* Datastream(y) exists, but is not part of the, also existing, Things(x).
*
* @throws ServiceFailureException If the service doesn't respond.
*/
@Test
public void testPostInvalidPath() throws ServiceFailureException {
LOGGER.info(" testPostInvalidPath");
EntityUtils.deleteAll(service);
// Create two things
Location location1 = new Location("LocationThing1", "Location of Thing 1", "application/geo+json", new Point(8, 50));
service.create(location1);
Thing thing1 = new Thing("Thing 1", "The first thing.");
thing1.getLocations().add(location1.withOnlyId());
service.create(thing1);
Thing thing2 = new Thing("Thing 2", "The second thing.");
thing2.getLocations().add(location1.withOnlyId());
service.create(thing2);
Sensor sensor1 = new Sensor("Test Thermometre", "Test Sensor", "None", "-");
service.create(sensor1);
ObservedProperty obsProp1 = new ObservedProperty("Temperature", "http://example.org", "-");
service.create(obsProp1);
Datastream datastream1 = new Datastream("Ds 1, Thing 1", "The datastream of Thing 1", "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement", new UnitOfMeasurement("Degrees Celcius", "°C", "http://qudt.org/vocab/unit#DegreeCelsius"));
datastream1.setThing(thing1);
datastream1.setSensor(sensor1);
datastream1.setObservedProperty(obsProp1);
service.create(datastream1);
Observation obs1 = new Observation(1.0, datastream1);
service.create(obs1);
testGet(thing1, datastream1, thing2);
// PUT tests
String urlObsGood = serverSettings.getServiceUrl(version) + "/Things(" + thing1.getId().getUrl() + ")" + "/Datastreams(" + datastream1.getId().getUrl() + ")" + "/Observations(" + obs1.getId().getUrl() + ")";
String urlObsBad = serverSettings.getServiceUrl(version) + "/Things(" + thing2.getId().getUrl() + ")" + "/Datastreams(" + datastream1.getId().getUrl() + ")" + "/Observations(" + obs1.getId().getUrl() + ")";
testPut(urlObsGood, urlObsBad);
testPatch(urlObsGood, urlObsBad);
testDelete(urlObsBad, urlObsGood);
}
Aggregations