|
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import cz.senslog.telemetry.TestPropertiesUtils;
|
|
import cz.senslog.telemetry.TestPropertiesUtils;
|
|
|
import cz.senslog.telemetry.app.PropertyConfig;
|
|
import cz.senslog.telemetry.app.PropertyConfig;
|
|
|
|
|
+import cz.senslog.telemetry.database.PagingRetrieve;
|
|
|
import cz.senslog.telemetry.database.domain.*;
|
|
import cz.senslog.telemetry.database.domain.*;
|
|
|
import cz.senslog.telemetry.database.repository.SensLogRepository;
|
|
import cz.senslog.telemetry.database.repository.SensLogRepository;
|
|
|
import cz.senslog.telemetry.server.HttpVertxServer;
|
|
import cz.senslog.telemetry.server.HttpVertxServer;
|
|
@@ -39,9 +40,7 @@ import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
|
|
|
import java.net.MalformedURLException;
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
import java.time.*;
|
|
import java.time.*;
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Properties;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
import static cz.senslog.telemetry.server.ws.ContentType.JSON;
|
|
import static cz.senslog.telemetry.server.ws.ContentType.JSON;
|
|
@@ -50,6 +49,7 @@ import static cz.senslog.telemetry.server.ws.OpenAPIHandlerTest.OpenAPIResponseT
|
|
|
import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
|
import static java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME;
|
|
import static java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME;
|
|
|
import static java.util.Collections.emptyList;
|
|
import static java.util.Collections.emptyList;
|
|
|
|
|
+import static java.util.stream.Collectors.toSet;
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
import static org.mockito.ArgumentMatchers.*;
|
|
import static org.mockito.ArgumentMatchers.*;
|
|
|
|
|
|
|
@@ -63,6 +63,9 @@ class OpenAPIHandlerTest {
|
|
|
|
|
|
|
|
private static OpenApi3 OPEN_API;
|
|
private static OpenApi3 OPEN_API;
|
|
|
|
|
|
|
|
|
|
+ private static Set<String> VISITED_TEST_NODES;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
enum OpenAPIResponseTyp {
|
|
enum OpenAPIResponseTyp {
|
|
|
SUCCESS ("200"), ERROR ("default")
|
|
SUCCESS ("200"), ERROR ("default")
|
|
|
;
|
|
;
|
|
@@ -97,10 +100,7 @@ class OpenAPIHandlerTest {
|
|
|
@BeforeAll
|
|
@BeforeAll
|
|
|
static void setUp() throws MalformedURLException, ResolutionException, ValidationException {
|
|
static void setUp() throws MalformedURLException, ResolutionException, ValidationException {
|
|
|
OPEN_API = new OpenApi3Parser().parse(new URL("file:src/main/resources/openAPISpec.yaml"), false);
|
|
OPEN_API = new OpenApi3Parser().parse(new URL("file:src/main/resources/openAPISpec.yaml"), false);
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @AfterAll
|
|
|
|
|
- static void tearDown() {
|
|
|
|
|
|
|
+ VISITED_TEST_NODES = new HashSet<>(OPEN_API.getPaths().size());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
@@ -128,10 +128,20 @@ class OpenAPIHandlerTest {
|
|
|
.hasSize(1);
|
|
.hasSize(1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @AfterAll
|
|
|
|
|
+ static void tearDown() {
|
|
|
|
|
+ if (OPEN_API.getPaths().size() != VISITED_TEST_NODES.size()) {
|
|
|
|
|
+ assertThat(VISITED_TEST_NODES).containsAll(OPEN_API.getPaths().values()
|
|
|
|
|
+ .stream().map(p -> p.getGet().getOperationId()).collect(toSet()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
@DisplayName("API Spec Test: infoGET")
|
|
@DisplayName("API Spec Test: infoGET")
|
|
|
void infoGET(Vertx vertx, VertxTestContext testContext) {
|
|
void infoGET(Vertx vertx, VertxTestContext testContext) {
|
|
|
Operation operation = OPEN_API.getOperationById("infoGET");
|
|
Operation operation = OPEN_API.getOperationById("infoGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/info")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/info")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap().add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap().add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
@@ -172,6 +182,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.allCampaigns()).thenReturn(dbFuture);
|
|
Mockito.when(repo.allCampaigns()).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("campaignsGET");
|
|
Operation operation = OPEN_API.getOperationById("campaignsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -207,6 +219,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findCampaignById(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findCampaignById(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("campaignIdGET");
|
|
Operation operation = OPEN_API.getOperationById("campaignIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -302,6 +316,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitsByCampaignId(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitsByCampaignId(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitsGET");
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -394,6 +410,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitByIdAndCampaignId(anyLong(), anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitByIdAndCampaignId(anyLong(), anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitIdGET");
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/1000")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/1000")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -491,6 +509,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findSensorsByCampaignIdAndUnitId(anyLong(), anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findSensorsByCampaignIdAndUnitId(anyLong(), anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitIdSensorsGET");
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitIdSensorsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/1000/sensors")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/1000/sensors")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -557,6 +577,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findSensorByCampaignIdAndUnitId(anyLong(), anyLong(), anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findSensorByCampaignIdAndUnitId(anyLong(), anyLong(), anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitIdSensorIdGET");
|
|
Operation operation = OPEN_API.getOperationById("campaignIdUnitIdSensorIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/1000/sensors/105")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/1000/sensors/105")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -631,6 +653,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.allUnits()).thenReturn(dbFuture);
|
|
Mockito.when(repo.allUnits()).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("unitsGET");
|
|
Operation operation = OPEN_API.getOperationById("unitsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -663,6 +687,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitById(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitById(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("unitIdGET");
|
|
Operation operation = OPEN_API.getOperationById("unitIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -736,6 +762,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findSensorsByUnitId(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findSensorsByUnitId(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("unitIdSensorsGET");
|
|
Operation operation = OPEN_API.getOperationById("unitIdSensorsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000/sensors")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000/sensors")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -809,6 +837,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findCampaignsByUnitId(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findCampaignsByUnitId(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("unitIdCampaignsGET");
|
|
Operation operation = OPEN_API.getOperationById("unitIdCampaignsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000/campaigns")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000/campaigns")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -899,6 +929,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findEntitiesByUnitId(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findEntitiesByUnitId(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("unitIdEntitiesGET");
|
|
Operation operation = OPEN_API.getOperationById("unitIdEntitiesGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000/entities")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/units/1000/entities")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -971,6 +1003,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.allSensors()).thenReturn(dbFuture);
|
|
Mockito.when(repo.allSensors()).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("sensorsGET");
|
|
Operation operation = OPEN_API.getOperationById("sensorsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/sensors")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/sensors")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1038,6 +1072,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findSensorById(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findSensorById(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("sensorIdGET");
|
|
Operation operation = OPEN_API.getOperationById("sensorIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/sensors/105")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/sensors/105")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1110,6 +1146,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitsBySensorId(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitsBySensorId(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("sensorIdUnitsGET");
|
|
Operation operation = OPEN_API.getOperationById("sensorIdUnitsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/sensors/105/units")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/sensors/105/units")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1182,6 +1220,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.allPhenomenons()).thenReturn(dbFuture);
|
|
Mockito.when(repo.allPhenomenons()).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("phenomenonsGET");
|
|
Operation operation = OPEN_API.getOperationById("phenomenonsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/phenomenons")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/phenomenons")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1248,6 +1288,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findPhenomenonById(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findPhenomenonById(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("phenomenonIdGET");
|
|
Operation operation = OPEN_API.getOperationById("phenomenonIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/phenomenons/1")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/phenomenons/1")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1320,6 +1362,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findSensorsByPhenomenonId(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findSensorsByPhenomenonId(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("phenomenonIdSensorsGET");
|
|
Operation operation = OPEN_API.getOperationById("phenomenonIdSensorsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/phenomenons/1/sensors")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/phenomenons/1/sensors")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1393,6 +1437,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.allEntities()).thenReturn(dbFuture);
|
|
Mockito.when(repo.allEntities()).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entitiesGET");
|
|
Operation operation = OPEN_API.getOperationById("entitiesGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1459,6 +1505,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findEntityById(anyInt())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findEntityById(anyInt())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1532,6 +1580,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitsByEntityId(anyInt(), any(), any())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitsByEntityId(anyInt(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitsGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1606,6 +1656,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitByIdAndEntityId(anyLong(), anyInt())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitByIdAndEntityId(anyLong(), anyInt())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1679,6 +1731,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findActionsByEntityIdAndUnitId(anyInt(), anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findActionsByEntityIdAndUnitId(anyInt(), anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdActionsGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdActionsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000/actions")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000/actions")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1752,6 +1806,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findActionsByEntityId(anyInt(), any(), any())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findActionsByEntityId(anyInt(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionsGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1826,6 +1882,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findActionByIdAndEntityId(anyInt(), anyInt())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findActionByIdAndEntityId(anyInt(), anyInt())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionIdGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1899,6 +1957,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitsByEntityIdAndActionId(anyInt(), anyInt())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitsByEntityIdAndActionId(anyInt(), anyInt())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionIdUnitsGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionIdUnitsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1/units")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1/units")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -1965,6 +2025,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findUnitByIdAndEntityIdAndActionId(anyLong(), anyInt(), anyInt())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findUnitByIdAndEntityIdAndActionId(anyLong(), anyInt(), anyInt())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionIdUnitIdGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdActionIdUnitIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1/units/1000")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1/units/1000")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -2032,6 +2094,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findActionByIdAndEntityIdAndUnitId(anyInt(), anyInt(), anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findActionByIdAndEntityIdAndUnitId(anyInt(), anyInt(), anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdActionIdGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdActionIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000/actions/1")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000/actions/1")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -2108,6 +2172,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findEventsByEntityIdAndUnitIdAndActionId(anyInt(), anyLong(), anyInt())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findEventsByEntityIdAndUnitIdAndActionId(anyInt(), anyLong(), anyInt())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdActionIdEventsGET");
|
|
Operation operation = OPEN_API.getOperationById("entityIdUnitIdActionIdEventsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000/actions/1/events")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/units/1000/actions/1/events")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -2199,6 +2265,8 @@ class OpenAPIHandlerTest {
|
|
|
Mockito.when(repo.findEventById(anyLong())).thenReturn(dbFuture);
|
|
Mockito.when(repo.findEventById(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
|
|
|
Operation operation = OPEN_API.getOperationById("eventIdGET");
|
|
Operation operation = OPEN_API.getOperationById("eventIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
RequestOptions reqOpt = new RequestOptions()
|
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/events/1")
|
|
.setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/events/1")
|
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
.setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
@@ -2269,4 +2337,537 @@ class OpenAPIHandlerTest {
|
|
|
testContext.completeNow();
|
|
testContext.completeNow();
|
|
|
})));
|
|
})));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitsAlertsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(List.of(
|
|
|
|
|
+ CampaignUnitAlert.of(1, 1, 10, "mock(message)", baseTimestamp, AlertStatus.CREATED),
|
|
|
|
|
+ CampaignUnitAlert.of(1, 1, 10, "mock(message)", baseTimestamp.plusHours(1), AlertStatus.CREATED)
|
|
|
|
|
+ )),
|
|
|
|
|
+ SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(emptyList()), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitsAlertsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitsAlertsGET")
|
|
|
|
|
+ void campaignIdUnitsAlertsGET_bySpec(Future<List<CampaignUnitAlert>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findAlertsByCampaignId(anyLong(), any(), any(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitsAlertsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/alerts")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> alertIdGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(
|
|
|
|
|
+ CampaignUnitAlert.of(1, 1, 10, "mock(message)", baseTimestamp, AlertStatus.CREATED)
|
|
|
|
|
+ ), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("alertIdGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: alertIdGET")
|
|
|
|
|
+ void alertIdGET_bySpec(Future<CampaignUnitAlert> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findAlertById(anyLong())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("alertIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/alerts/1")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitIdObservationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 2, List.of(
|
|
|
|
|
+ UnitTelemetry.of(1, 10, baseTimestamp, location, 0, JsonObject.of()),
|
|
|
|
|
+ UnitTelemetry.of(1, 10, baseTimestamp.plusMinutes(1), location, 0, JsonObject.of())
|
|
|
|
|
+ ))), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 0,emptyList())), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitIdObservationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitIdObservationsGET")
|
|
|
|
|
+ void campaignIdUnitIdObservationsGET_bySpec(Future<PagingRetrieve<List<UnitTelemetry>>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findObservationsByCampaignIdAndUnitIdWithPaging(anyLong(), anyLong(), any(), any(), anyInt(), anyInt(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitIdObservationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/10/observations")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitIdSensorIdObservationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 2, List.of(
|
|
|
|
|
+ SensorTelemetry.of(1, 10.0, baseTimestamp, location, 0),
|
|
|
|
|
+ SensorTelemetry.of(1, 10.0, baseTimestamp.plusMinutes(1), location, 0)
|
|
|
|
|
+ ))), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 0,emptyList())), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitIdSensorIdObservationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitIdSensorIdObservationsGET")
|
|
|
|
|
+ void campaignIdUnitIdSensorIdObservationsGET_bySpec(Future<PagingRetrieve<List<SensorTelemetry>>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findObservationsByCampaignIdAndUnitIdAndSensorIdWithPaging(anyLong(), anyLong(), anyLong(), any(), any(), anyInt(), anyInt(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitIdSensorIdObservationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/10/sensors/100/observations")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitsObservationsLocationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(List.of(
|
|
|
|
|
+ UnitLocation.of(1, baseTimestamp, location),
|
|
|
|
|
+ UnitLocation.of(1, baseTimestamp.plusHours(1), location)
|
|
|
|
|
+ )), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(emptyList()), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitsObservationsLocationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitsObservationsLocationsGET")
|
|
|
|
|
+ void campaignIdUnitsObservationsLocationsGET_bySpec(Future<List<UnitLocation>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findUnitsLocationsByCampaignId(anyLong(), anyInt(), any(), any(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitsObservationsLocationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/observations/locations?limitPerUnit=1")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> eventIdObservationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 2, List.of(
|
|
|
|
|
+ UnitTelemetry.of(1, 10, baseTimestamp, location, 0, JsonObject.of()),
|
|
|
|
|
+ UnitTelemetry.of(1, 10, baseTimestamp.plusHours(1), location, 0, JsonObject.of())
|
|
|
|
|
+ ))), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 0, emptyList())), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("eventIdObservationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: eventIdObservationsGET")
|
|
|
|
|
+ void eventIdObservationsGET_bySpec(Future<PagingRetrieve<List<UnitTelemetry>>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findObservationsByEventIdWithPaging(anyLong(), any(), any(), anyInt(), anyInt(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("eventIdObservationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/events/1/observations")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitsObservationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 2, List.of(
|
|
|
|
|
+ UnitTelemetry.of(1, 10, baseTimestamp, location, 0, JsonObject.of()),
|
|
|
|
|
+ UnitTelemetry.of(1, 10, baseTimestamp.plusHours(1), location, 0, JsonObject.of())
|
|
|
|
|
+ ))), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 0, emptyList())), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitsObservationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitsObservationsGET")
|
|
|
|
|
+ void campaignIdUnitsObservationsGET_bySpec(Future<PagingRetrieve<List<UnitTelemetry>>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findObservationsByCampaignIdWithPaging(anyLong(), any(), any(), anyInt(), anyInt(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitsObservationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/observations")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> eventIdAlertsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(List.of(
|
|
|
|
|
+ Alert.of(1, "mock(message)", baseTimestamp, AlertStatus.CREATED),
|
|
|
|
|
+ Alert.of(2, "mock(message)", baseTimestamp.plusHours(1), AlertStatus.CREATED)
|
|
|
|
|
+ )), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(emptyList()), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("eventIdAlertsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: eventIdAlertsGET")
|
|
|
|
|
+ void eventIdAlertsGET_bySpec(Future<List<Alert>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findAlertsByEventId(anyLong(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("eventIdAlertsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/events/1/alerts")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> eventIdLocationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 2, List.of(
|
|
|
|
|
+ UnitLocation.of(10, baseTimestamp, location),
|
|
|
|
|
+ UnitLocation.of(10, baseTimestamp.plusHours(1), location)
|
|
|
|
|
+ ))), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 0, emptyList())), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("eventIdLocationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: eventIdLocationsGET")
|
|
|
|
|
+ void eventIdLocationsGET_bySpec(Future<PagingRetrieve<List<UnitLocation>>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findLocationsByEventIdWithPaging(anyLong(), any(), any(), anyInt(), anyInt(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("eventIdLocationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/events/1/observations/locations")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> entityIdActionIdUnitIdAlertIdGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(
|
|
|
|
|
+ EventAlert.of(1, 1, 10, "mock(message)", baseTimestamp, AlertStatus.CREATED)
|
|
|
|
|
+ ), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("entityIdActionIdUnitIdAlertIdGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: entityIdActionIdUnitIdAlertIdGET")
|
|
|
|
|
+ void entityIdActionIdUnitIdAlertIdGET_bySpec(Future<EventAlert> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findAlertByIdAndEventId(anyLong(), anyLong())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("entityIdActionIdUnitIdAlertIdGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/events/1/alerts/1")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitIdAlertsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(List.of(
|
|
|
|
|
+ UnitAlert.of(1, 10, "mock(message)", baseTimestamp, AlertStatus.CREATED),
|
|
|
|
|
+ UnitAlert.of(2, 10, "mock(message)", baseTimestamp.plusHours(1), AlertStatus.CREATED)
|
|
|
|
|
+ )), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(emptyList()), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitIdAlertsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitIdAlertsGET")
|
|
|
|
|
+ void campaignIdUnitIdAlertsGET_bySpec(Future<List<UnitAlert>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findAlertsByCampaignIdAndUnitId(anyLong(), anyLong(), any(), any(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitIdAlertsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/10/alerts")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> entityIdActionIdUnitIdAlertsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(List.of(
|
|
|
|
|
+ Alert.of(1, "mock(message)", baseTimestamp, AlertStatus.CREATED),
|
|
|
|
|
+ Alert.of(2, "mock(message)", baseTimestamp.plusHours(1), AlertStatus.CREATED)
|
|
|
|
|
+ )), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(emptyList()), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("entityIdActionIdUnitIdAlertsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: entityIdActionIdUnitIdAlertsGET")
|
|
|
|
|
+ void entityIdActionIdUnitIdAlertsGET_bySpec(Future<List<Alert>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findAlertsByEntityIdAndActionIdAndUnitId(anyLong(), anyLong(), anyLong(), any(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("entityIdActionIdUnitIdAlertsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/entities/1/actions/1/units/10/alerts")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Stream<Arguments> campaignIdUnitIdLocationsGET_dataSource() {
|
|
|
|
|
+ OffsetDateTime baseTimestamp = OffsetDateTime.ofInstant(BASE_INSTANT_TIMESTAMP, ZoneOffset.UTC);
|
|
|
|
|
+ Location location = Location.of(10.5f, 10.f, 450f, 1);
|
|
|
|
|
+ return Stream.of(
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 2, List.of(
|
|
|
|
|
+ UnitLocation.of(10, baseTimestamp, location),
|
|
|
|
|
+ UnitLocation.of(10, baseTimestamp.plusMinutes(1), location)
|
|
|
|
|
+ ))), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.succeededFuture(new PagingRetrieve<>(false, 0, emptyList())), SUCCESS, JSON
|
|
|
|
|
+ ),
|
|
|
|
|
+ Arguments.of(
|
|
|
|
|
+ Future.failedFuture("Not found"), ERROR, JSON
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ParameterizedTest
|
|
|
|
|
+ @MethodSource("campaignIdUnitIdLocationsGET_dataSource")
|
|
|
|
|
+ @DisplayName("API Spec Test: campaignIdUnitIdLocationsGET")
|
|
|
|
|
+ void campaignIdUnitIdLocationsGET_bySpec(Future<PagingRetrieve<List<UnitLocation>>> dbFuture, OpenAPIResponseTyp responseTyp, ContentType contentType, Vertx vertx, VertxTestContext testContext) {
|
|
|
|
|
+
|
|
|
|
|
+ Mockito.when(repo.findLocationsByCampaignIdAndUnitIdWithPaging(anyLong(), anyLong(), any(), any(), anyInt(), anyInt(), any())).thenReturn(dbFuture);
|
|
|
|
|
+
|
|
|
|
|
+ Operation operation = OPEN_API.getOperationById("campaignIdUnitIdLocationsGET");
|
|
|
|
|
+ VISITED_TEST_NODES.add(operation.getOperationId());
|
|
|
|
|
+
|
|
|
|
|
+ RequestOptions reqOpt = new RequestOptions()
|
|
|
|
|
+ .setMethod(HttpMethod.GET).setPort(PORT).setHost(HOST).setURI("/campaigns/1/units/10/observations/locations")
|
|
|
|
|
+ .setHeaders(MultiMap.caseInsensitiveMultiMap()
|
|
|
|
|
+ .add(HttpHeaders.ACCEPT, JSON.contentType()));
|
|
|
|
|
+
|
|
|
|
|
+ vertx.createHttpClient().request(reqOpt)
|
|
|
|
|
+ .compose(req -> req.send().compose(HttpClientResponse::body))
|
|
|
|
|
+ .onComplete(testContext.succeeding(b -> testContext.verify(() -> {
|
|
|
|
|
+ validateAssert(b.toString(), operation, responseTyp, contentType);
|
|
|
|
|
+ testContext.completeNow();
|
|
|
|
|
+ })));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|