aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java66
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java54
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql9
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java8
-rw-r--r--so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java3
-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
9 files changed, 386 insertions, 77 deletions
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
index 39cccd8aaa..761aaa1446 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
@@ -22,23 +22,6 @@
package org.onap.so.db.request.data.repository;
-import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NonUniqueResultException;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Order;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -52,6 +35,24 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
+import javax.persistence.EntityManager;
+import javax.persistence.NonUniqueResultException;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Order;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
@Repository
@Transactional(readOnly = true)
@@ -219,17 +220,17 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
}
}
}
- if(!predicates.isEmpty()){
- predicates.add(tableRoot.get(REQUEST_STATUS)
- .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
-
- final Order order = cb.desc(tableRoot.get(START_TIME));
-
- final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
-
- if (dupList != null && !dupList.isEmpty()) {
- infraActiveRequests = dupList.get(0);
- }
+ if (!predicates.isEmpty()) {
+ predicates.add(tableRoot.get(REQUEST_STATUS)
+ .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
+
+ final Order order = cb.desc(tableRoot.get(START_TIME));
+
+ final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
+
+ if (dupList != null && !dupList.isEmpty()) {
+ infraActiveRequests = dupList.get(0);
+ }
}
return infraActiveRequests;
@@ -560,7 +561,14 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
predicates.add(criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime));
predicates.add(criteriaBuilder.lessThanOrEqualTo(tableRoot.get(END_TIME), maxTime));
- criteriaQuery.where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));
+ final Predicate basePredicate = criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+
+ final Predicate additionalPredicate = criteriaBuilder.and(tableRoot.get(END_TIME).isNull(),
+ criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime),
+ criteriaBuilder.lessThanOrEqualTo(tableRoot.get(START_TIME), maxTime));
+
+ criteriaQuery.where(criteriaBuilder.or(basePredicate, additionalPredicate));
+
if (maxResult != null) {
return entityManager.createQuery(criteriaQuery).setMaxResults(maxResult).getResultList();
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java
index 4097aee7d5..def999b556 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java
@@ -49,9 +49,26 @@ import org.springframework.test.context.junit4.SpringRunner;
@ActiveProfiles("test")
public class InfraActiveRequestsRepositoryImplTest {
+ /**
+ * January 1, 2019 2:00:00 PM
+ */
+ private static final long END_TIME = 1546351200000l;
+
+ /**
+ * January 1, 2019 12:45:00 PM
+ */
+ private static final long START_TIME = 1546346700000l;
private static final int MAX_LIMIT = 1;
- private static final long END_TIME_IN_MILISEC = 1482580740000l; // December 23, 2016 23:59 PM
- private static final long START_TIME_IN_MILISEC = 1482282000000l; // December 21, 2016 01:00 AM
+
+ /**
+ * December 23, 2016 23:59 PM
+ */
+ private static final long END_TIME_IN_MILISEC = 1482580740000l;
+
+ /**
+ * December 21, 2016 01:00 AM
+ */
+ private static final long START_TIME_IN_MILISEC = 1482282000000l;
private static final String REQUEST_ID_VALUE = "00032ab7-3fb3-42e5-965d-8ea592502017";
private static final String SERVICE_INSTANCE_ID_VALUE = "e3b5744d-2ad1-4cdd-8390-c999a38829bc";
@@ -96,7 +113,6 @@ public class InfraActiveRequestsRepositoryImplTest {
assertEquals(SERVICE_INSTANCE_ID_VALUE, actualRequests.get(0).getServiceInstanceId());
}
-
@Test
public void test_GetInfraActiveRequestsData_withLikeRequestID() {
final Map<String, String[]> values = new HashMap<>();
@@ -182,12 +198,34 @@ public class InfraActiveRequestsRepositoryImplTest {
objUnderTest.getInfraActiveRequests(null, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, MAX_LIMIT);
assertTrue(actualRequests.isEmpty());
}
-
+
@Test
- public void checkInstanceNameDuplicateNullInstanceNameTest(){
- Map<String, String> instanceIdMap = new HashMap<>();
+ public void checkInstanceNameDuplicateNullInstanceNameTest() {
+ final Map<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", "e05864f0-ab35-47d0-8be4-56fd9619ba3b");
- InfraActiveRequests results = objUnderTest.checkInstanceNameDuplicate((HashMap<String, String>)instanceIdMap, null, "vnf");
- assertNull(results);
+ final InfraActiveRequests results =
+ objUnderTest.checkInstanceNameDuplicate((HashMap<String, String>) instanceIdMap, null, "vnf");
+ assertNull(results);
}
+
+ @Test
+ public void test_GetInfraActiveRequestsData_returnRecordWithNullEndTime() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(SERVICE_INSTANCE_ID,
+ new String[] {QueryOperationType.EQ.name(), "f7712652-b516-4925-a243-64550d26fd84"});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME, END_TIME, null);
+ assertFalse(actualRequests.isEmpty());
+
+ assertEquals(3, actualRequests.size());
+ final Map<String, InfraActiveRequests> result = new HashMap<>();
+ for (final InfraActiveRequests actualActiveRequests : actualRequests) {
+ result.put(actualActiveRequests.getRequestId(), actualActiveRequests);
+
+ }
+ final InfraActiveRequests actualInfraActiveRequests = result.get("9383dc81-7a6c-4673-8082-650d50a82a1a");
+ assertNull(actualInfraActiveRequests.getEndTime());
+ assertEquals("IN_PROGRESS", actualInfraActiveRequests.getRequestStatus());
+ }
+
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
index 541f356055..3358d770e2 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
@@ -105,7 +105,14 @@ INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION,
INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, AIC_NODE_CLLI, TENANT_ID, PROV_STATUS, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, REQUEST_TYPE, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, AAI_SERVICE_ID, AIC_CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME, REQUEST_URL) VALUES
('00164b9e-784d-48a8-8973-bbad6ef818ed', null, 'createInstance', 'COMPLETE', 'Service Instance was created successfully.', '100', '2017-09-28 12:45:51', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f","modelType":"service","modelNameVersionId":null,"modelName":"MSO Test Network","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":"DEV-MTN6-3100-0927-1","suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":null,"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"aicNodeClli":null,"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":true},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'CreateGenericALaCarteServiceInstance', '2017-09-28 12:45:52', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', 'b2f59173-b7e5-4e0f-8440-232fd601b865', 'DEV-MTN6-3100-0927-1', 'md5621', null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
('00173cc9-5ce2-4673-a810-f87fefb2829e', null, 'createInstance', 'FAILED', 'Error parsing request. No valid instanceName is specified', '100', '2017-04-14 21:08:46', '2017-04-14 21:08:46', 'VID', null, null, null, null, null, 'a259ae7b7c3f493cb3d91f95a7c18149', null, null, null, '{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}}', null, 'APIH', null, null, null, null, null, null, null, null, 'mtn16', null, null, null, null, null, 'service', 'createInstance', null, null, null, null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
-('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', null, 'VID', null, null, null, null, null, null, null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances');
+('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', null, 'VID', null, null, null, null, null, null, null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances');
+INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, START_TIME, END_TIME, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME ) VALUES
+('a5294d37-21db-4e3a-ae04-57412adcb4ac', null, 'createInstance', 'COMPLETE', '2019-01-01 12:45:00', '2019-01-01 12:50:00', 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_1'),
+('9383dc81-7a6c-4673-8082-650d50a82a1a', null, 'createInstance', 'IN_PROGRESS', '2019-01-01 12:55:00', null, 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_2'),
+('a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f', null, 'activateInstance', 'FAILED', '2019-01-01 13:00:00', '2019-01-01 14:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_3'),
+('81b8e152-ee89-49f4-b82b-08b0dcae27cd', null, 'createInstance', 'COMPLETE', '2019-01-01 14:10:00', '2019-01-01 15:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'SHOULD_NOT_RETURN_1'),
+('0c28cad2-ff79-4dfa-a04a-9e44996fd7f7', null, 'createInstance', 'IN_PROGRESS', '2019-01-01 13:30:00', '2019-01-01 15:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'SHOULD_NOT_RETURN_2'),
+('d0d995a7-549b-4e7e-9101-2bab17ec24ea', null, 'createInstance', 'IN_PROGRESS', '2019-01-01 14:15:00', null, 'f7712652-b516-4925-a243-64550d26fd84', 'SHOULD_NOT_RETURN_3');
CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS(
REQUEST_ID VARCHAR NOT NULL SELECTIVITY 100,
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java
index 557e2a63b7..0bcf24dbd8 100644
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java
+++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java
@@ -20,16 +20,12 @@
package org.onap.so.monitoring.configuration.rest;
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
-import java.util.concurrent.TimeUnit;
-
/**
* @author waqas.ikram@ericsson, eoin.hanan@ericsson.com
*/
@@ -38,8 +34,8 @@ public class CorsConfigurer {
@Bean
public CorsFilter corsFilter() {
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- CorsConfiguration config = new CorsConfiguration();
+ final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java
index 31ef747939..58666671a7 100644
--- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java
+++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java
@@ -79,7 +79,6 @@ public class DatabaseServiceProviderTest {
assertTrue(objUnderTest.getSoInfraRequest(Collections.emptyMap(), 0, 0, null).isEmpty());
}
-
@Test
public void test_GetSoInfraRequest_WithFilters_InfraActiveRequestsList() {
final String searchUrl = URL_PROVIDER.getSearchUrl(0, 0, null);
@@ -87,7 +86,7 @@ public class DatabaseServiceProviderTest {
final Map<String, String[]> filters = new HashMap<>();
filters.put("requestId", new String[] {"EQ", requestID});
- SoActiveInfraRequests soActiveInfraRequests = new SoActiveInfraRequests();
+ final SoActiveInfraRequests soActiveInfraRequests = new SoActiveInfraRequests();
soActiveInfraRequests.setRequestId(requestID);
final Optional<SoActiveInfraRequests[]> response =
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