|
|
@@ -5,18 +5,19 @@ import org.junit.jupiter.api.Tag;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.net.URISyntaxException;
|
|
|
+import java.net.URL;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import static io.connector.module.afarcloud.OGCSensorThingsAssertions.*;
|
|
|
import static java.nio.file.Files.readAllBytes;
|
|
|
import static java.nio.file.Paths.get;
|
|
|
+import static java.util.Objects.requireNonNull;
|
|
|
|
|
|
@Tag(TestType.INTEGRATION)
|
|
|
class OGCSensorThingsOfflineIntegrationTest {
|
|
|
|
|
|
- private static final String RESOURCES_DIR = "src/test/resources";
|
|
|
-
|
|
|
private static final Map<String, String> DEFAULT_PROPERTIES;
|
|
|
|
|
|
static {
|
|
|
@@ -25,56 +26,66 @@ class OGCSensorThingsOfflineIntegrationTest {
|
|
|
DEFAULT_PROPERTIES.put("multiSensorId", "10002222");
|
|
|
}
|
|
|
|
|
|
+ private String readResourceFile(String relativePath) throws IOException {
|
|
|
+ try {
|
|
|
+ URL url = getClass().getClassLoader().getResource(relativePath);
|
|
|
+ byte[] bytes = readAllBytes(get(requireNonNull(url).toURI()));
|
|
|
+ return new String(bytes);
|
|
|
+ } catch (URISyntaxException e) {
|
|
|
+ throw new IOException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void things() throws IOException {
|
|
|
- String jsonAFCAllSensors = new String(readAllBytes(get(RESOURCES_DIR,"afc/getAllSensors.json")));
|
|
|
- String jsonOGCThings = new String(readAllBytes(get(RESOURCES_DIR,"ogc/things.json")));
|
|
|
+ String jsonAFCAllSensors = readResourceFile("afc/getAllSensors.json");
|
|
|
+ String jsonOGCThings = readResourceFile("ogc/things.json");
|
|
|
assertThings(jsonAFCAllSensors, jsonOGCThings, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void sensor() throws IOException {
|
|
|
- String jsonAFCSensor = new String(readAllBytes(get(RESOURCES_DIR, "afc/getSensor.json")));
|
|
|
- String jsonOGCDataStream = new String(readAllBytes(get(RESOURCES_DIR,"ogc/sensor.json")));
|
|
|
+ String jsonAFCSensor = readResourceFile("afc/getSensor.json");
|
|
|
+ String jsonOGCDataStream = readResourceFile("ogc/sensor.json");
|
|
|
assertSensor(jsonAFCSensor, jsonOGCDataStream, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void dataStreams() throws IOException {
|
|
|
- String jsonAFCSensor = new String(readAllBytes(get(RESOURCES_DIR, "afc/getSensor.json")));
|
|
|
- String jsonAFCData = new String(readAllBytes(get(RESOURCES_DIR, "afc/getObservationsBySensor.json")));
|
|
|
- String jsonOGC = new String(readAllBytes(get(RESOURCES_DIR,"ogc/datastreams.json")));
|
|
|
+ String jsonAFCSensor = readResourceFile("afc/getSensor.json");
|
|
|
+ String jsonAFCData = readResourceFile("afc/getObservationsBySensor.json");
|
|
|
+ String jsonOGC = readResourceFile("ogc/datastreams.json");
|
|
|
assertDataStream(jsonAFCSensor, jsonAFCData, jsonOGC, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void observationProperty() throws IOException {
|
|
|
- String jsonAFCSensor = new String(readAllBytes(get(RESOURCES_DIR, "afc/getSensor.json")));
|
|
|
- String jsonAFCData = new String(readAllBytes(get(RESOURCES_DIR, "afc/getObservationsBySensor.json")));
|
|
|
- String jsonOGC = new String(readAllBytes(get(RESOURCES_DIR,"ogc/observationProperty.json")));
|
|
|
+ String jsonAFCSensor = readResourceFile("afc/getSensor.json");
|
|
|
+ String jsonAFCData = readResourceFile("afc/getObservationsBySensor.json");
|
|
|
+ String jsonOGC = readResourceFile("ogc/observationProperty.json");
|
|
|
assertObservedProperty(jsonAFCSensor, jsonAFCData, jsonOGC, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void observations() throws IOException {
|
|
|
- String jsonAFCData = new String(readAllBytes(get(RESOURCES_DIR, "afc/getObservationsBySensor.json")));
|
|
|
- String jsonOGC = new String(readAllBytes(get(RESOURCES_DIR,"ogc/observations.json")));
|
|
|
+ String jsonAFCData = readResourceFile("afc/getObservationsBySensor.json");
|
|
|
+ String jsonOGC = readResourceFile("ogc/observations.json");
|
|
|
assertObservation(jsonAFCData, jsonOGC, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void locations() throws IOException {
|
|
|
- String jsonAFCSensor = new String(readAllBytes(get(RESOURCES_DIR, "afc/getSensor.json")));
|
|
|
- String jsonAFCData = new String(readAllBytes(get(RESOURCES_DIR, "afc/getObservationsBySensor.json")));
|
|
|
- String jsonOGC = new String(readAllBytes(get(RESOURCES_DIR,"ogc/locations.json")));
|
|
|
+ String jsonAFCSensor = readResourceFile("afc/getSensor.json");
|
|
|
+ String jsonAFCData = readResourceFile("afc/getObservationsBySensor.json");
|
|
|
+ String jsonOGC = readResourceFile("ogc/locations.json");
|
|
|
assertLocations(jsonAFCSensor, jsonAFCData, jsonOGC, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void historicalLocations() throws IOException {
|
|
|
- String jsonAFCSensor = new String(readAllBytes(get(RESOURCES_DIR, "afc/getSensor.json")));
|
|
|
- String jsonAFCData = new String(readAllBytes(get(RESOURCES_DIR, "afc/getObservationsBySensor.json")));
|
|
|
- String jsonOGC = new String(readAllBytes(get(RESOURCES_DIR,"ogc/historicalLocations.json")));
|
|
|
+ String jsonAFCSensor = readResourceFile("afc/getSensor.json");
|
|
|
+ String jsonAFCData = readResourceFile("afc/getObservationsBySensor.json");
|
|
|
+ String jsonOGC = readResourceFile("ogc/historicalLocations.json");
|
|
|
assertHistoricalLocation(jsonAFCSensor, jsonAFCData, jsonOGC, DEFAULT_PROPERTIES);
|
|
|
}
|
|
|
}
|