summaryrefslogtreecommitdiffstats
path: root/so-monitoring/so-monitoring-service/src
diff options
context:
space:
mode:
authorAndrei_Barcovschi <andrei.barcovschi@ericsson.com>2019-03-06 12:45:45 +0000
committerAndrei Barcovschi <andrei.barcovschi@ericsson.com>2019-03-06 15:27:47 +0000
commit42dd47e5c8431cafee7b949122672d422e100ae3 (patch)
tree39a01be9fbe9b25838d803970162e0ff867703f3 /so-monitoring/so-monitoring-service/src
parent91426ec9f221e288ea3f54fa62030e6f17420b90 (diff)
Fix for So Mon UI search result
Change-Id: Ifa65f415e47fd3ef95a48c5299b04f1038148421 Issue-ID: SO-1507 Signed-off-by: Andrei_Barcovschi <andrei.barcovschi@ericsson.com>
Diffstat (limited to 'so-monitoring/so-monitoring-service/src')
-rw-r--r--so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java67
-rw-r--r--so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java86
-rw-r--r--so-monitoring/so-monitoring-service/src/test/resources/application-test.yaml9
-rw-r--r--so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json161
4 files changed, 292 insertions, 31 deletions
diff --git a/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java
new file mode 100644
index 0000000000..aef8234228
--- /dev/null
+++ b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.rest.api;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.UUID;
+
+/**
+ * @author andrei.barcovschi@ericsson.com
+ *
+ */
+public class Constants {
+
+ public static final String PROCRESS_DEF_ID = "AFRFLOW:1:c6eea1b7-9722-11e8-8caf-022ac9304eeb";
+
+ public static final String EMPTY_ARRAY_RESPONSE = "[]";
+
+ public static final String PROCESS_INSTACE_ID = "5956a99d-9736-11e8-8caf-022ac9304eeb";
+
+ public static final String EMPTY_STRING = "";
+
+ public static final String SOURCE_TEST_FOLDER = "src/test/resources/camundaResponses/";
+
+ public static final Path PROCESS_DEF_RESPONSE_JSON_FILE = Paths.get(SOURCE_TEST_FOLDER + "processDefinition.json");
+
+ public static final Path ACTIVITY_INSTANCE_RESPONSE_JSON_FILE =
+ Paths.get(SOURCE_TEST_FOLDER + "activityInstance.json");
+
+ public static final Path PROCESS_INSTANCE_VARIABLES_RESPONSE_JSON_FILE =
+ Paths.get(SOURCE_TEST_FOLDER + "processInstanceVariables.json");
+
+ public static final Path PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
+ Paths.get(SOURCE_TEST_FOLDER + "processInstance.json");
+
+ public static final Path SINGLE_PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
+ Paths.get(SOURCE_TEST_FOLDER + "singleprocessInstance.json");
+
+ public static final Path SEARCH_RESULT_RESPONSE_JSON_FILE =
+ Paths.get("src/test/resources/databaseResponses/searchResult.json");
+
+ public static final String ID = UUID.randomUUID().toString();
+
+ public static final long END_TIME_IN_MS = 1546351200000l;
+
+ public static final long START_TIME_IN_MS = 1546346700000l;
+
+ private Constants() {}
+
+}
diff --git a/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java
index ca2a88d4a8..3ca184ebaa 100644
--- a/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java
+++ b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java
@@ -23,6 +23,20 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.CAMUNDA_REST_TEMPLATE;
+import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.DATABASE_REST_TEMPLATE;
+import static org.onap.so.monitoring.rest.api.Constants.ACTIVITY_INSTANCE_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.EMPTY_ARRAY_RESPONSE;
+import static org.onap.so.monitoring.rest.api.Constants.EMPTY_STRING;
+import static org.onap.so.monitoring.rest.api.Constants.END_TIME_IN_MS;
+import static org.onap.so.monitoring.rest.api.Constants.ID;
+import static org.onap.so.monitoring.rest.api.Constants.PROCCESS_INSTANCE_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.PROCESS_DEF_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.PROCESS_INSTACE_ID;
+import static org.onap.so.monitoring.rest.api.Constants.PROCESS_INSTANCE_VARIABLES_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.PROCRESS_DEF_ID;
+import static org.onap.so.monitoring.rest.api.Constants.SEARCH_RESULT_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.SINGLE_PROCCESS_INSTANCE_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.START_TIME_IN_MS;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@@ -31,9 +45,10 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
-import java.util.UUID;
+import java.util.Map;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@@ -42,11 +57,13 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider;
+import org.onap.so.monitoring.configuration.database.DatabaseUrlProvider;
import org.onap.so.monitoring.model.ActivityInstanceDetail;
import org.onap.so.monitoring.model.ProcessDefinitionDetail;
import org.onap.so.monitoring.model.ProcessInstanceDetail;
import org.onap.so.monitoring.model.ProcessInstanceIdDetail;
import org.onap.so.monitoring.model.ProcessInstanceVariableDetail;
+import org.onap.so.monitoring.model.SoInfraRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
@@ -57,56 +74,39 @@ import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-
/**
- * @author waqas.ikram@ericsson.com
+ * @author waqas.ikram@ericsson.com, andrei.barcovschi@ericsson.com
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test")
@SpringBootTest
public class SoMonitoringControllerTest {
- private static final String PROCRESS_DEF_ID = "AFRFLOW:1:c6eea1b7-9722-11e8-8caf-022ac9304eeb";
-
- private static final String EMPTY_ARRAY_RESPONSE = "[]";
-
- private static final String PROCESS_INSTACE_ID = "5956a99d-9736-11e8-8caf-022ac9304eeb";
-
- private static final String EMPTY_STRING = "";
-
- private static final String SOURCE_TEST_FOLDER = "src/test/resources/camundaResponses/";
-
- private static final Path PROCESS_DEF_RESPONSE_JSON_FILE = Paths.get(SOURCE_TEST_FOLDER + "processDefinition.json");
-
- private static final Path ACTIVITY_INSTANCE_RESPONSE_JSON_FILE =
- Paths.get(SOURCE_TEST_FOLDER + "activityInstance.json");
-
- private static final Path PROCESS_INSTANCE_VARIABLES_RESPONSE_JSON_FILE =
- Paths.get(SOURCE_TEST_FOLDER + "processInstanceVariables.json");
-
- private static final Path PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
- Paths.get(SOURCE_TEST_FOLDER + "processInstance.json");
-
- private static final Path SINGLE_PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
- Paths.get(SOURCE_TEST_FOLDER + "singleprocessInstance.json");
-
- private static final String ID = UUID.randomUUID().toString();
-
@Autowired
@Qualifier(CAMUNDA_REST_TEMPLATE)
private RestTemplate restTemplate;
@Autowired
+ @Qualifier(DATABASE_REST_TEMPLATE)
+ private RestTemplate dataBaseRestTemplate;
+
+ @Autowired
private CamundaRestUrlProvider urlProvider;
+ @Autowired
+ private DatabaseUrlProvider databaseUrlProvider;
+
private MockRestServiceServer camundaMockServer;
+ private MockRestServiceServer databaseMockServer;
+
@Autowired
private SoMonitoringController objUnderTest;
@Before
public void setUp() throws Exception {
camundaMockServer = MockRestServiceServer.bindTo(restTemplate).build();
+ databaseMockServer = MockRestServiceServer.bindTo(dataBaseRestTemplate).build();
}
@Test
@@ -339,7 +339,7 @@ public class SoMonitoringControllerTest {
final List<ProcessInstanceVariableDetail> actual = (List<ProcessInstanceVariableDetail>) response.getEntity();
assertEquals(230, actual.size());
- ProcessInstanceVariableDetail variableDetail = actual.get(0);
+ final ProcessInstanceVariableDetail variableDetail = actual.get(0);
assertEquals("serviceType", variableDetail.getName());
assertEquals("String", variableDetail.getType());
assertEquals("PNFSERVICE", variableDetail.getValue());
@@ -393,6 +393,30 @@ public class SoMonitoringControllerTest {
}
+ @Test
+ public void test_GetInfraActiveRequests_SuccessResponseWithSoInfraRequestList() throws Exception {
+ final String jsonString = getJsonResponse(SEARCH_RESULT_RESPONSE_JSON_FILE);
+ this.databaseMockServer
+ .expect(requestTo(databaseUrlProvider.getSearchUrl(START_TIME_IN_MS, END_TIME_IN_MS, null)))
+ .andRespond(withSuccess(jsonString, MediaType.APPLICATION_JSON));
+
+ final Response response =
+ objUnderTest.getInfraActiveRequests(Collections.emptyMap(), START_TIME_IN_MS, END_TIME_IN_MS, null);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ @SuppressWarnings("unchecked")
+ final List<SoInfraRequest> actual = (List<SoInfraRequest>) response.getEntity();
+ assertEquals(3, actual.size());
+
+ final Map<String, SoInfraRequest> actualRequests = new HashMap<>();
+ for (final SoInfraRequest soInfraRequest : actual) {
+ actualRequests.put(soInfraRequest.getRequestId(), soInfraRequest);
+ }
+ final SoInfraRequest infraRequest = actualRequests.get("9383dc81-7a6c-4673-8082-650d50a82a1a");
+ assertNull(infraRequest.getEndTime());
+ assertEquals("IN_PROGRESS", infraRequest.getRequestStatus());
+ }
+
private String getJsonResponse(final Path path) throws IOException {
return new String(Files.readAllBytes(path));
}
diff --git a/so-monitoring/so-monitoring-service/src/test/resources/application-test.yaml b/so-monitoring/so-monitoring-service/src/test/resources/application-test.yaml
index 857266d3e6..8d930fe17f 100644
--- a/so-monitoring/so-monitoring-service/src/test/resources/application-test.yaml
+++ b/so-monitoring/so-monitoring-service/src/test/resources/application-test.yaml
@@ -13,3 +13,12 @@ camunda:
url: http://localhost:8080/engine-rest/engine/
engine: default
auth: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==
+
+mso:
+ database:
+ rest:
+ api:
+ url: http://localhost:8083/infraActiveRequests/
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+
+ \ No newline at end of file
diff --git a/so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json b/so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json
new file mode 100644
index 0000000000..90c27efcbd
--- /dev/null
+++ b/so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json
@@ -0,0 +1,161 @@
+[
+ {
+ "requestId": "a5294d37-21db-4e3a-ae04-57412adcb4ac",
+ "clientRequestId": null,
+ "action": "createInstance",
+ "requestStatus": "COMPLETE",
+ "statusMessage": null,
+ "rollbackStatusMessage": null,
+ "flowStatus": null,
+ "retryStatusMessage": null,
+ "progress": null,
+ "startTime": 1546346700000,
+ "endTime": 1546347000000,
+ "source": null,
+ "vnfId": null,
+ "vnfName": null,
+ "vnfType": null,
+ "serviceType": null,
+ "aicNodeClli": null,
+ "tenantId": null,
+ "provStatus": null,
+ "vnfParams": null,
+ "vnfOutputs": null,
+ "requestBody": null,
+ "responseBody": null,
+ "lastModifiedBy": null,
+ "modifyTime": null,
+ "requestType": null,
+ "volumeGroupId": null,
+ "volumeGroupName": null,
+ "vfModuleId": null,
+ "vfModuleName": null,
+ "vfModuleModelName": null,
+ "aaiServiceId": null,
+ "aicCloudRegion": null,
+ "callBackUrl": null,
+ "correlator": null,
+ "serviceInstanceId": "f7712652-b516-4925-a243-64550d26fd84",
+ "serviceInstanceName": "ShouldReturnInSearchQuery_1",
+ "requestScope": null,
+ "requestAction": null,
+ "networkId": null,
+ "networkName": null,
+ "networkType": null,
+ "requestorId": null,
+ "configurationId": null,
+ "configurationName": null,
+ "operationalEnvId": null,
+ "operationalEnvName": null,
+ "instanceGroupId": null,
+ "instanceGroupName": null,
+ "requestUrl": null,
+ "requestURI": "a5294d37-21db-4e3a-ae04-57412adcb4ac"
+ },
+ {
+ "requestId": "9383dc81-7a6c-4673-8082-650d50a82a1a",
+ "clientRequestId": null,
+ "action": "createInstance",
+ "requestStatus": "IN_PROGRESS",
+ "statusMessage": null,
+ "rollbackStatusMessage": null,
+ "flowStatus": null,
+ "retryStatusMessage": null,
+ "progress": null,
+ "startTime": 1546347300000,
+ "endTime": null,
+ "source": null,
+ "vnfId": null,
+ "vnfName": null,
+ "vnfType": null,
+ "serviceType": null,
+ "aicNodeClli": null,
+ "tenantId": null,
+ "provStatus": null,
+ "vnfParams": null,
+ "vnfOutputs": null,
+ "requestBody": null,
+ "responseBody": null,
+ "lastModifiedBy": null,
+ "modifyTime": null,
+ "requestType": null,
+ "volumeGroupId": null,
+ "volumeGroupName": null,
+ "vfModuleId": null,
+ "vfModuleName": null,
+ "vfModuleModelName": null,
+ "aaiServiceId": null,
+ "aicCloudRegion": null,
+ "callBackUrl": null,
+ "correlator": null,
+ "serviceInstanceId": "f7712652-b516-4925-a243-64550d26fd84",
+ "serviceInstanceName": "ShouldReturnInSearchQuery_2",
+ "requestScope": null,
+ "requestAction": null,
+ "networkId": null,
+ "networkName": null,
+ "networkType": null,
+ "requestorId": null,
+ "configurationId": null,
+ "configurationName": null,
+ "operationalEnvId": null,
+ "operationalEnvName": null,
+ "instanceGroupId": null,
+ "instanceGroupName": null,
+ "requestUrl": null,
+ "requestURI": "9383dc81-7a6c-4673-8082-650d50a82a1a"
+ },
+ {
+ "requestId": "a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f",
+ "clientRequestId": null,
+ "action": "activateInstance",
+ "requestStatus": "FAILED",
+ "statusMessage": null,
+ "rollbackStatusMessage": null,
+ "flowStatus": null,
+ "retryStatusMessage": null,
+ "progress": null,
+ "startTime": 1546347600000,
+ "endTime": 1546351200000,
+ "source": null,
+ "vnfId": null,
+ "vnfName": null,
+ "vnfType": null,
+ "serviceType": null,
+ "aicNodeClli": null,
+ "tenantId": null,
+ "provStatus": null,
+ "vnfParams": null,
+ "vnfOutputs": null,
+ "requestBody": null,
+ "responseBody": null,
+ "lastModifiedBy": null,
+ "modifyTime": null,
+ "requestType": null,
+ "volumeGroupId": null,
+ "volumeGroupName": null,
+ "vfModuleId": null,
+ "vfModuleName": null,
+ "vfModuleModelName": null,
+ "aaiServiceId": null,
+ "aicCloudRegion": null,
+ "callBackUrl": null,
+ "correlator": null,
+ "serviceInstanceId": "f7712652-b516-4925-a243-64550d26fd84",
+ "serviceInstanceName": "ShouldReturnInSearchQuery_3",
+ "requestScope": null,
+ "requestAction": null,
+ "networkId": null,
+ "networkName": null,
+ "networkType": null,
+ "requestorId": null,
+ "configurationId": null,
+ "configurationName": null,
+ "operationalEnvId": null,
+ "operationalEnvName": null,
+ "instanceGroupId": null,
+ "instanceGroupName": null,
+ "requestUrl": null,
+ "requestURI": "a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f"
+ }
+] \ No newline at end of file