Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiDatastream Extension tests #28

Closed
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
<spec-version>1.0</spec-version>
</properties>

<repositories>
<repository>
<id>bintray-fraunhoferiosb-Maven</id>
<name>bintray</name>
<url>http://dl.bintray.com/fraunhoferiosb/Maven</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.opengis.cite.teamengine</groupId>
Expand All @@ -76,7 +84,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<version>20171018</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand All @@ -87,6 +95,11 @@
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>de.fraunhofer.iosb.ilt</groupId>
<artifactId>SensorThingsClient</artifactId>
<version>0.14</version>
</dependency>
</dependencies>

<build>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/org/opengis/cite/sta10/SuiteFixtureListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void processSuiteParameters(ISuite suite) {

String iutParam = params.get(TestRunArg.IUT.toString());

String response = checkServiceRootUri(iutParam);
if(!response.equals("")){
String response = checkServiceRootUri(iutParam, params);
if (!response.equals("")) {
throw new IllegalArgumentException(
response);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ void registerClientComponent(ISuite suite) {
* @param rootUri The root URL for the service under test
* @return If the root URL of the service is not compliant to SensorThings API, it will return the reason it is not compliant. Otherwise it returns empty String.
*/
private String checkServiceRootUri(String rootUri) {
private String checkServiceRootUri(String rootUri, Map<String, String> params) {
rootUri = rootUri.trim();
if(rootUri.lastIndexOf('/')==rootUri.length()-1){
rootUri = rootUri.substring(0,rootUri.length()-1);
Expand Down Expand Up @@ -181,56 +181,55 @@ private String checkServiceRootUri(String rootUri) {
if(!nameUrl.equals(rootUri + "/Things") ){
return "The URL for Things in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("Things");
addedLinks.put(name, true);
break;
case "Locations":
if(!nameUrl.equals(rootUri + "/Locations")) {
return "The URL for Locations in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("Locations");
addedLinks.put(name, true);
break;
case "HistoricalLocations":
if(!nameUrl.equals(rootUri + "/HistoricalLocations")) {
return "The URL for HistoricalLocations in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("HistoricalLocations");
addedLinks.put(name, true);
break;
case "Datastreams":
if(!nameUrl.equals(rootUri + "/Datastreams")) {
return "The URL for Datastreams in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("Datastreams");
addedLinks.put(name, true);
break;
case "MultiDatastreams":
if (!nameUrl.equals(rootUri + "/MultiDatastreams")) {
return "The URL for Datastreams in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.put(name, true);
params.put("hasMultiDatastream", "true");
break;
case "Sensors":
if(!nameUrl.equals(rootUri + "/Sensors")) {
return "The URL for Sensors in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("Sensors");
addedLinks.put(name, true);
break;
case "Observations":
if(!nameUrl.equals(rootUri + "/Observations")) {
return "The URL for Observations in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("Observations");
addedLinks.put(name, true);
break;
case "ObservedProperties":
if(!nameUrl.equals(rootUri + "/ObservedProperties")) {
return "The URL for ObservedProperties in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("ObservedProperties");
addedLinks.put(name, true);
break;
case "FeaturesOfInterest":
if(!nameUrl.equals(rootUri + "/FeaturesOfInterest")) {
return "The URL for FeaturesOfInterest in Service Root URI is not compliant to SensorThings API.";
}
addedLinks.remove("FeaturesOfInterest");
addedLinks.put(name, true);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package org.opengis.cite.sta10.multiDatastreamExtension;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* List of entity types in SensorThings API.
*/
public enum EntityTypeMds {
THING("Thing", "Things"),
LOCATION("Location", "Locations"),
SENSOR("Sensor", "Sensors"),
OBSERVED_PROPERTY("ObservedProperty", "ObservedProperties"),
OBSERVATION("Observation", "Observations"),
DATASTREAM("Datastream", "Datastreams"),
MULTI_DATASTREAM("MultiDatastream", "MultiDatastreams"),
FEATURE_OF_INTEREST("FeatureOfInterest", "FeaturesOfInterest"),
HISTORICAL_LOCATION("HistoricalLocation", "HistoricalLocations");
public final String singular;
public final String plural;
private final List<String> properties = new ArrayList<>();
private final List<String> relations = new ArrayList<>();

private static final Map<String, EntityTypeMds> NAMES_MAP = new HashMap<>();
private static final Set<String> NAMES_PLURAL = new HashSet<>();

static {
THING.addProperties("name", "description");
THING.addRelations(DATASTREAM.plural, MULTI_DATASTREAM.plural, HISTORICAL_LOCATION.plural, LOCATION.plural);

LOCATION.addProperties("name", "description", "encodingType", "location");
LOCATION.addRelations(HISTORICAL_LOCATION.plural, THING.plural);

SENSOR.addProperties("name", "description", "encodingType", "metadata");
SENSOR.addRelations(DATASTREAM.plural, MULTI_DATASTREAM.plural);

OBSERVED_PROPERTY.addProperties("name", "definition", "description");
OBSERVED_PROPERTY.addRelations(DATASTREAM.plural, MULTI_DATASTREAM.plural);

OBSERVATION.addProperties("phenomenonTime", "result", "resultTime");
OBSERVATION.addRelations(DATASTREAM.singular, MULTI_DATASTREAM.singular, FEATURE_OF_INTEREST.singular);

DATASTREAM.addProperties("name", "description", "unitOfMeasurement", "observationType");
DATASTREAM.addRelations(THING.singular, SENSOR.singular, OBSERVED_PROPERTY.singular, OBSERVATION.plural);

MULTI_DATASTREAM.addProperties("name", "description", "unitOfMeasurements", "observationType", "multiObservationDataTypes");
MULTI_DATASTREAM.addRelations(THING.singular, SENSOR.singular, OBSERVED_PROPERTY.plural, OBSERVATION.plural);

FEATURE_OF_INTEREST.addProperties("name", "description", "encodingType", "feature");
FEATURE_OF_INTEREST.addRelations(OBSERVATION.plural);

HISTORICAL_LOCATION.addProperties("time");
HISTORICAL_LOCATION.addRelations(THING.singular, LOCATION.plural);

for (EntityTypeMds entityType : EntityTypeMds.values()) {
NAMES_MAP.put(entityType.singular, entityType);
NAMES_MAP.put(entityType.plural, entityType);
NAMES_PLURAL.add(entityType.plural);
}
}

public static EntityTypeMds getForRelation(String relation) {
EntityTypeMds entityType = NAMES_MAP.get(relation);
if (entityType == null) {
throw new IllegalArgumentException("Unknown relation: " + relation);
}
return entityType;
}

public static boolean isPlural(String relation) {
return NAMES_PLURAL.contains(relation);
}

private EntityTypeMds(String singular, String plural) {
this.singular = singular;
this.plural = plural;
}

public String getRootEntitySet() {
return plural;
}

public List<String> getRelations() {
return Collections.unmodifiableList(relations);
}

public List<String> getProperties() {
return Collections.unmodifiableList(properties);
}

private void addProperties(String... properties) {
this.properties.addAll(Arrays.asList(properties));
}

private void addRelations(String... relations) {
this.relations.addAll(Arrays.asList(relations));
}

}
Loading