aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-requests-db-adapter/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-requests-db-adapter/src/test')
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java92
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java5
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java270
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java33
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java100
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java37
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java41
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java192
-rw-r--r--adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml20
-rw-r--r--adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql8
-rw-r--r--adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml72
11 files changed, 813 insertions, 57 deletions
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java
new file mode 100644
index 0000000000..c1e620ba74
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.requestdb.rest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.Transactional;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.onap.so.db.request.beans.RequestProcessingData;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class RequestProcessingDataRequestDbQueryTest {
+ @Autowired
+ private RequestsDbClient client;
+
+ @LocalServerPort
+ private int port;
+
+ @Before
+ public void setPort() {
+ client.removePortFromEndpoint();
+ client.setPortToEndpoint(Integer.toString(port));
+ }
+
+ @Test
+ @Transactional
+ public void RequestProcessingDataBySoRequestIdTest() {
+ String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018";
+ String tag = "pincFabricConfigRequest";
+ RequestProcessingData firstEntry = new RequestProcessingData();
+ RequestProcessingData secondEntry = new RequestProcessingData();
+ List<RequestProcessingData> expectedList = new ArrayList<>();
+ firstEntry.setSoRequestId(soRequestId);
+ firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
+ firstEntry.setName("configurationId");
+ firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2");
+ firstEntry.setTag(tag);
+ secondEntry.setSoRequestId(soRequestId);
+ secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
+ secondEntry.setName("requestAction");
+ secondEntry.setValue("assign");
+ secondEntry.setTag(tag);
+ expectedList.add(firstEntry);
+ expectedList.add(secondEntry);
+
+ List<RequestProcessingData> dataFound = client.getRequestProcessingDataBySoRequestId(soRequestId);
+ //bean comparison with shazam fails serialization: Forgot to register a type adapter?
+ assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId());
+ assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId());
+ assertEquals(dataFound.get(0).getName(), firstEntry.getName());
+ assertEquals(dataFound.get(0).getValue(), firstEntry.getValue());
+ assertEquals(dataFound.get(0).getTag(), firstEntry.getTag());
+ assertEquals(dataFound.get(1).getSoRequestId(), secondEntry.getSoRequestId());
+ assertEquals(dataFound.get(1).getGroupingId(), secondEntry.getGroupingId());
+ assertEquals(dataFound.get(1).getName(), secondEntry.getName());
+ assertEquals(dataFound.get(1).getValue(), secondEntry.getValue());
+ assertEquals(dataFound.get(1).getTag(), secondEntry.getTag());
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java
index 54debac36f..f05a301caa 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java
@@ -28,6 +28,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
@@ -61,6 +62,7 @@ public class ArchiveInfraRequestsSchedulerTest {
private int archivedPeriod;
@Test
+ @Transactional
public void testArchiveInfraRequests() {
String requestId1 = "requestId1";
String requestId2 = "requestId2";
@@ -85,7 +87,8 @@ public class ArchiveInfraRequestsSchedulerTest {
assertEquals(requestId2, archivedRepo.findOne(requestId2).getRequestId());
}
- @Test
+ @Test
+ @Ignore
public void testInfraRequestsScheduledTask() {
Date currentDate= new Date();
Calendar calendar = Calendar.getInstance();
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
new file mode 100644
index 0000000000..58fd517c91
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
@@ -0,0 +1,270 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.requestsdb;
+
+
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.UUID;
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+@Transactional
+public class InfraActiveRequestsRepositoryCustomControllerTest {
+
+ @LocalServerPort
+ private int port;
+
+ @Value("${mso.adapters.requestDb.auth}")
+ private String msoAdaptersAuth;
+
+ private String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
+
+ private InfraActiveRequests infraActiveRequests;
+ private InfraActiveRequests infraActiveRequestsResponse;
+ private HttpHeaders headers;
+ private TestRestTemplate restTemplate;
+
+ private void verifyInfraActiveRequests() {
+ assertEquals(infraActiveRequests.getRequestId(), infraActiveRequestsResponse.getRequestId());
+ assertEquals(infraActiveRequests.getServiceInstanceId(), infraActiveRequestsResponse.getServiceInstanceId());
+ assertEquals(infraActiveRequests.getServiceInstanceName(), infraActiveRequestsResponse.getServiceInstanceName());
+ assertEquals(infraActiveRequests.getVnfId(), infraActiveRequestsResponse.getVnfId());
+ assertEquals(infraActiveRequests.getVnfName(), infraActiveRequestsResponse.getVnfName());
+ assertEquals(infraActiveRequests.getVfModuleId(), infraActiveRequestsResponse.getVfModuleId());
+ assertEquals(infraActiveRequests.getVfModuleName(), infraActiveRequestsResponse.getVfModuleName());
+ assertEquals(infraActiveRequests.getVolumeGroupId(), infraActiveRequestsResponse.getVolumeGroupId());
+ assertEquals(infraActiveRequests.getVolumeGroupName(), infraActiveRequestsResponse.getVolumeGroupName());
+ assertEquals(infraActiveRequests.getNetworkId(), infraActiveRequestsResponse.getNetworkId());
+ assertEquals(infraActiveRequests.getNetworkName(), infraActiveRequestsResponse.getNetworkName());
+ assertEquals(infraActiveRequests.getConfigurationId(), infraActiveRequestsResponse.getConfigurationId());
+ assertEquals(infraActiveRequests.getConfigurationName(), infraActiveRequestsResponse.getConfigurationName());
+ assertEquals(infraActiveRequests.getAaiServiceId(), infraActiveRequestsResponse.getAaiServiceId());
+ assertEquals(infraActiveRequests.getTenantId(), infraActiveRequestsResponse.getTenantId());
+ assertEquals(infraActiveRequests.getRequestScope(), infraActiveRequestsResponse.getRequestScope());
+ assertEquals(infraActiveRequests.getRequestorId(), infraActiveRequestsResponse.getRequestorId());
+ assertEquals(infraActiveRequests.getSource(), infraActiveRequestsResponse.getSource());
+ assertEquals(infraActiveRequests.getOperationalEnvId(), infraActiveRequestsResponse.getOperationalEnvId());
+ assertEquals(infraActiveRequests.getOperationalEnvName(), infraActiveRequestsResponse.getOperationalEnvName());
+ assertEquals(infraActiveRequests.getRequestStatus(), infraActiveRequestsResponse.getRequestStatus());
+ assertEquals(infraActiveRequests.getAction(), infraActiveRequestsResponse.getAction());
+ }
+
+ @Before
+ public void setup() {
+
+ headers = new HttpHeaders();
+ restTemplate = new TestRestTemplate("test", "test");
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set("Authorization", msoAdaptersAuth);
+
+ infraActiveRequests = new InfraActiveRequests();
+
+ infraActiveRequests.setRequestId(UUID.randomUUID().toString());
+ infraActiveRequests.setOperationalEnvId(UUID.randomUUID().toString());
+ infraActiveRequests.setServiceInstanceId(UUID.randomUUID().toString());
+ infraActiveRequests.setServiceInstanceName("serviceInstanceNameTest");
+ infraActiveRequests.setVnfId(UUID.randomUUID().toString());
+ infraActiveRequests.setVnfName("vnfInstanceNameTest");
+ infraActiveRequests.setVfModuleId(UUID.randomUUID().toString());
+ infraActiveRequests.setVfModuleName("vfModuleInstanceNameTest");
+ infraActiveRequests.setVolumeGroupId(UUID.randomUUID().toString());
+ infraActiveRequests.setVolumeGroupName("volumeGroupInstanceNameTest");
+ infraActiveRequests.setNetworkId(UUID.randomUUID().toString());
+ infraActiveRequests.setNetworkName("networkInstanceNameTest");
+ infraActiveRequests.setConfigurationId(UUID.randomUUID().toString());
+ infraActiveRequests.setConfigurationName("configurationInstanceNameTest");
+ infraActiveRequests.setAicCloudRegion("1");
+ infraActiveRequests.setTenantId(UUID.randomUUID().toString());
+ infraActiveRequests.setRequestScope("operationalEnvironment");
+ infraActiveRequests.setRequestorId(UUID.randomUUID().toString());
+ infraActiveRequests.setSource("sourceTest");
+ infraActiveRequests.setOperationalEnvName(UUID.randomUUID().toString());
+ infraActiveRequests.setRequestStatus("IN_PROGRESS");
+ infraActiveRequests.setAction("create");
+
+ HttpEntity<String> entity = new HttpEntity(infraActiveRequests, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests"));
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(201, response.getStatusCodeValue());
+ }
+
+
+ @Test
+ public void getCloudOrchestrationFiltersFromInfraActiveTest() {
+
+ Map<String, String> requestMap = new HashMap<>();
+ requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
+ requestMap.put("operationalEnvironmentName", infraActiveRequests.getOperationalEnvName());
+ requestMap.put("resourceType", "operationalEnvironment");
+
+ HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestMap, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getCloudOrchestrationFiltersFromInfraActive");
+
+ ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {
+ });
+
+ List<InfraActiveRequests> iarr = response.getBody();
+ assertEquals(200, response.getStatusCodeValue());
+
+ assertTrue(iarr.size() == 1);
+ infraActiveRequestsResponse = iarr.get(0);
+
+ verifyInfraActiveRequests();
+
+ }
+
+ @Test
+ public void getOrchestrationFiltersFromInfraActiveTest() {
+
+ Map<String, List<String>> requestMap = new HashMap<>();
+ List<String> values = new ArrayList<>();
+ values.add("EQUALS");
+ values.add(infraActiveRequests.getServiceInstanceId());
+ requestMap.put("serviceInstanceId", values);
+
+ values = new ArrayList<>();
+ values.add("EQUALS");
+ values.add(infraActiveRequests.getServiceInstanceName());
+ requestMap.put("serviceInstanceName", values);
+
+ HttpEntity<Map<String, List<String>>> entityList = new HttpEntity(requestMap, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getOrchestrationFiltersFromInfraActive");
+
+ ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entityList, new ParameterizedTypeReference<List<InfraActiveRequests>>() {
+ });
+
+ List<InfraActiveRequests> iarr = response.getBody();
+
+ assertEquals(200, response.getStatusCodeValue());
+
+ assertTrue(iarr.size() == 1);
+ infraActiveRequestsResponse = iarr.get(0);
+
+ verifyInfraActiveRequests();
+ }
+
+ @Test
+ public void checkVnfIdStatusTest() {
+
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests" + "/checkVnfIdStatus/" + infraActiveRequests.getOperationalEnvId()));
+ HttpEntity<String> entity = new HttpEntity(HttpEntity.EMPTY, headers);
+
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET,entity , InfraActiveRequests.class);
+
+ infraActiveRequestsResponse = response.getBody();
+
+ assertEquals(200, response.getStatusCodeValue());
+
+ verifyInfraActiveRequests();
+ }
+
+ @Test
+ public void checkInstanceNameDuplicateTest() {
+
+ InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) null,
+ infraActiveRequests.getOperationalEnvName(),
+ infraActiveRequests.getRequestScope());
+
+ HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
+
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
+ });
+
+ infraActiveRequestsResponse = response.getBody();
+
+ assertEquals(200, response.getStatusCodeValue());
+
+ verifyInfraActiveRequests();
+ }
+
+ @Test
+ public void checkInstanceNameDuplicateViaTest() {
+
+ Map<String, String> requestMap = new HashMap<>();
+ requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
+
+ InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) requestMap,
+ null,
+ infraActiveRequests.getRequestScope());
+
+ HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate");
+
+ ResponseEntity<InfraActiveRequests> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() {
+ });
+
+ infraActiveRequestsResponse = response.getBody();
+
+ assertEquals(200, response.getStatusCodeValue());
+
+ verifyInfraActiveRequests();
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
index 005eba0ec2..21ec8f7518 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
@@ -21,16 +21,16 @@
package org.onap.so.adapters.requestsdb.adapters;
import static org.junit.Assert.*;
-
-
-
+import java.util.Map;
import javax.ws.rs.core.Response;
import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
-
+import org.onap.so.adapters.requestsdb.application.TestAppender;
+import org.onap.so.logger.MsoLogger;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -40,6 +40,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import ch.qos.logback.classic.spi.ILoggingEvent;
@RunWith(SpringRunner.class)
@@ -57,7 +58,7 @@ public class HealthCheckHandlerTest {
@Test
public void testHealthcheck() throws JSONException {
-
+ TestAppender.events.clear();
HttpEntity<String> entity = new HttpEntity<String>(null, headers);
ResponseEntity<String> response = restTemplate.exchange(
@@ -65,6 +66,28 @@ public class HealthCheckHandlerTest {
HttpMethod.GET, entity, String.class);
assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
+ logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
+ assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ }
+ TestAppender.events.clear();
}
private String createURLWithPort(String uri) {
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
index 4d00421e6c..571a2c053f 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
@@ -23,15 +23,20 @@ package org.onap.so.adapters.requestsdb.adapters;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
-
+import java.util.Map;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
+import org.onap.so.adapters.requestsdb.application.TestAppender;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter;
import org.onap.so.adapters.requestsdb.RequestStatusType;
import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
@@ -41,12 +46,17 @@ import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import org.onap.so.db.request.data.repository.OperationStatusRepository;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
+import ch.qos.logback.classic.spi.ILoggingEvent;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -55,8 +65,7 @@ public class MSORequestDBImplTest {
@LocalServerPort
private int port;
-
- @Autowired
+
private MsoRequestsDbAdapter dbAdapter;
@Autowired
@@ -71,6 +80,16 @@ public class MSORequestDBImplTest {
public InfraActiveRequests setupTestEntities() {
return buildTestRequest();
}
+
+ @Before
+ public void before(){
+ JaxWsProxyFactoryBean jaxWsProxyFactory = new JaxWsProxyFactoryBean();
+ jaxWsProxyFactory.setServiceClass(MsoRequestsDbAdapter.class);
+ jaxWsProxyFactory.setAddress("http://localhost:" + port + "/services/RequestsDbAdapter");
+ jaxWsProxyFactory.setUsername("bpel");
+ jaxWsProxyFactory.setPassword("mso-db-1507!");
+ dbAdapter = (MsoRequestsDbAdapter) jaxWsProxyFactory.create();
+ }
private InfraActiveRequests buildTestRequest() {
InfraActiveRequests testRequest= new InfraActiveRequests();
@@ -94,11 +113,9 @@ public class MSORequestDBImplTest {
return testRequest;
}
-
-
-
@Test
public void getByRequestId() throws MsoRequestsDbException {
+
InfraActiveRequests testRequest = setupTestEntities();
// Given
String requestId = "00032ab7-3fb3-42e5-965d-8ea592502017";
@@ -121,10 +138,8 @@ public class MSORequestDBImplTest {
try {
dbAdapter.getInfraRequest(requestId);
fail("Expected MsoRequestsDbException to be thrown");
- } catch (MsoRequestsDbException e) {
- assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
} catch (Exception e) {
- fail("Expected MsoRequestsDbException to be thrown, unknown exception thrown");
+ assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
}
}
@@ -230,11 +245,9 @@ public class MSORequestDBImplTest {
null,
null,
null);
- fail("Expected MsoRequestsDbException to be thrown");
- } catch (MsoRequestsDbException e) {
- assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
+ fail("Expected MsoRequestsDbException to be thrown");
} catch (Exception e) {
- fail("Expected MsoRequestsDbException to be thrown, unknown exception thrown");
+ assertEquals(e.getMessage(),"Error retrieving MSO Infra Requests DB for Request ID invalidRequestId");
}
}
@@ -328,6 +341,7 @@ public class MSORequestDBImplTest {
@Test
public void updateServiceOperation_Not_Found() throws MsoRequestsDbException{
+ TestAppender.events.clear();
String serviceId = "badserviceId";
String operationId = "operationid";
String operation = "newOperationType";
@@ -349,12 +363,35 @@ public class MSORequestDBImplTest {
updatedOperationStatus.setProgress(progress);
updatedOperationStatus.setReason(reason);
updatedOperationStatus.setOperationContent(operationContent);
-
- thrown.expect(MsoRequestsDbException.class);
- thrown.expectMessage("Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId);
-
- dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId,
- result, operationContent, progress, reason);
+
+ try {
+ dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId,
+ result, operationContent, progress, reason);
+ fail("Expected MsoRequestsDbException to be thrown");
+ } catch (Exception e) {
+ assertEquals("Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId,e.getMessage());
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor") &&
+ logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ assertEquals("500",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
+ assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("ERROR",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ }
+ }
}
@@ -423,6 +460,7 @@ public class MSORequestDBImplTest {
@Test
public void updateResourceOperationStatus() throws MsoRequestsDbException{
+ TestAppender.events.clear();
String resourceTemplateUUID = "template1";
String serviceId = "serviceId";
String operationId = "operationId";
@@ -454,7 +492,29 @@ public class MSORequestDBImplTest {
ResourceOperationStatus actualResource = dbAdapter.getResourceOperationStatus(serviceId, operationId,"template1");
assertThat(actualResource, sameBeanAs(expectedResource));
+
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor") &&
+ logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ assertEquals(null,mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
+ assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
+ assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ }
}
-} \ No newline at end of file
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java
new file mode 100644
index 0000000000..0da1fd7565
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/application/TestAppender.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.requestsdb.application;
+
+import java.util.ArrayList;
+import java.util.List;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.AppenderBase;
+
+
+
+public class TestAppender extends AppenderBase<ILoggingEvent> {
+ public static List<ILoggingEvent> events = new ArrayList<>();
+
+ @Override
+ public void append(ILoggingEvent loggingEvent) {
+ events.add(loggingEvent);
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java
new file mode 100644
index 0000000000..bd15396c03
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestDbClientPortChanger.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.requestsdb.client;
+
+
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.springframework.stereotype.Component;
+import java.net.URI;
+@Component
+public class RequestDbClientPortChanger extends RequestsDbClient {
+ private int port;
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ @Override
+ public URI getUri(String uri) {
+ uri = uri.replace("8081", String.valueOf(port));
+ return URI.create(uri);
+ }
+}
+
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
new file mode 100644
index 0000000000..f1269f412b
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
@@ -0,0 +1,192 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.requestsdb.client;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.beans.OperationStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import java.util.List;
+import java.util.UUID;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class RequestsDbClientTest {
+
+ @Autowired
+ private RequestDbClientPortChanger requestsDbClient;
+
+ private InfraActiveRequests infraActiveRequests;
+
+ @LocalServerPort
+ private int port;
+
+ @Before
+ public void setup() {
+ requestsDbClient.setPort(port);
+
+ infraActiveRequests = new InfraActiveRequests();
+ infraActiveRequests.setRequestId(UUID.randomUUID().toString());
+ infraActiveRequests.setOperationalEnvId(UUID.randomUUID().toString());
+ infraActiveRequests.setServiceInstanceId(UUID.randomUUID().toString());
+ infraActiveRequests.setServiceInstanceName("serviceInstanceNameTest");
+ infraActiveRequests.setVnfId(UUID.randomUUID().toString());
+ infraActiveRequests.setVnfName("vnfInstanceNameTest");
+ infraActiveRequests.setVfModuleId(UUID.randomUUID().toString());
+ infraActiveRequests.setVfModuleName("vfModuleInstanceNameTest");
+ infraActiveRequests.setVolumeGroupId(UUID.randomUUID().toString());
+ infraActiveRequests.setVolumeGroupName("volumeGroupInstanceNameTest");
+ infraActiveRequests.setNetworkId(UUID.randomUUID().toString());
+ infraActiveRequests.setNetworkName("networkInstanceNameTest");
+ infraActiveRequests.setConfigurationId(UUID.randomUUID().toString());
+ infraActiveRequests.setConfigurationName("configurationInstanceNameTest");
+ infraActiveRequests.setAicCloudRegion("1");
+ infraActiveRequests.setTenantId(UUID.randomUUID().toString());
+ infraActiveRequests.setRequestScope("operationalEnvironment");
+ infraActiveRequests.setRequestorId(UUID.randomUUID().toString());
+ infraActiveRequests.setSource("sourceTest");
+ infraActiveRequests.setOperationalEnvName(UUID.randomUUID().toString());
+ infraActiveRequests.setRequestStatus("IN_PROGRESS");
+ infraActiveRequests.setAction("create");
+ infraActiveRequests.setRequestAction("someaction");
+ requestsDbClient.save(infraActiveRequests);
+ }
+
+ private void verifyOperationStatus(OperationStatus request,OperationStatus response){
+ assertThat(request, sameBeanAs(response).ignoring("operateAt").ignoring("finishedAt"));
+ }
+
+ private void verifyInfraActiveRequests(InfraActiveRequests infraActiveRequestsResponse) {
+ assertThat(infraActiveRequestsResponse, sameBeanAs(infraActiveRequests).ignoring("modifyTime").ignoring("log"));
+ }
+
+ @Test
+ public void getCloudOrchestrationFiltersFromInfraActiveTest() {
+ Map<String, String> requestMap = new HashMap<>();
+ requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
+ requestMap.put("operationalEnvironmentName", infraActiveRequests.getOperationalEnvName());
+ requestMap.put("resourceType", "operationalEnvironment");
+
+ List<InfraActiveRequests> iarr = requestsDbClient.getCloudOrchestrationFiltersFromInfraActive(requestMap);
+
+ assertEquals(1, iarr.size());
+ InfraActiveRequests infraActiveRequestsResponse = iarr.get(0);
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ }
+
+
+ @Test
+ public void checkVnfIdStatusTest() {
+ InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkVnfIdStatus(infraActiveRequests.getOperationalEnvId());
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ assertNull(requestsDbClient.checkVnfIdStatus(UUID.randomUUID().toString()));
+ }
+
+ @Test
+ public void checkInstanceNameDuplicateTest() {
+ InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkInstanceNameDuplicate(null,infraActiveRequests.getOperationalEnvName(),infraActiveRequests.getRequestScope());
+
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ }
+
+ @Test
+ public void checkInstanceNameDuplicateViaTest() {
+ Map<String, String> requestMap = new HashMap<>();
+ requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId());
+
+ InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.checkInstanceNameDuplicate((HashMap<String, String>)requestMap,null,infraActiveRequests.getRequestScope());
+
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ }
+
+ @Test
+ public void getOrchestrationFiltersFromInfraActiveTest() {
+ Map<String, List<String>> requestMap = new HashMap<>();
+ List<String> values = new ArrayList<>();
+ values.add("EQUALS");
+ values.add(infraActiveRequests.getServiceInstanceId());
+ requestMap.put("serviceInstanceId", values);
+
+ values = new ArrayList<>();
+ values.add("EQUALS");
+ values.add(infraActiveRequests.getServiceInstanceName());
+ requestMap.put("serviceInstanceName", values);
+
+ List<InfraActiveRequests> iaar = requestsDbClient.getOrchestrationFiltersFromInfraActive(requestMap);
+
+ assertEquals(1, iaar.size());
+ InfraActiveRequests infraActiveRequestsResponse = iaar.get(0);
+
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ values = new ArrayList<>();
+ values.add("EQUALS");
+ values.add(UUID.randomUUID().toString());
+ requestMap.put("serviceInstanceName", values);
+ requestsDbClient.getOrchestrationFiltersFromInfraActive(requestMap);
+ }
+
+ @Test
+ public void getInfraActiveRequestbyRequestIdTest(){
+ InfraActiveRequests infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
+ verifyInfraActiveRequests(infraActiveRequestsResponse);
+ infraActiveRequestsResponse = requestsDbClient.getInfraActiveRequestbyRequestId(infraActiveRequests.getRequestId());
+
+ assertNull(requestsDbClient.getInfraActiveRequestbyRequestId(UUID.randomUUID().toString()));
+ }
+
+
+ @Test
+ public void getOneByServiceIdAndOperationIdTest(){
+ OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setProgress("IN_PROGRESS");
+ operationStatus.setResult("FAILED");
+ operationStatus.setServiceId(UUID.randomUUID().toString());
+ operationStatus.setOperationContent("operation-content");
+ operationStatus.setOperation("operation");
+ operationStatus.setOperationId(UUID.randomUUID().toString());
+ operationStatus.setReason("reason-test");
+ operationStatus.setUserId(UUID.randomUUID().toString());
+ operationStatus.setServiceName("test-service");
+ requestsDbClient.save(operationStatus);
+
+ OperationStatus operationStatusResponse = requestsDbClient.getOneByServiceIdAndOperationId(operationStatus.getServiceId(),operationStatus.getOperationId());
+
+ verifyOperationStatus(operationStatus,operationStatusResponse);
+
+ assertNull(requestsDbClient.getOneByServiceIdAndOperationId(UUID.randomUUID().toString(),operationStatus.getOperationId()));
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml
index c3be9323fb..35b3ec9360 100644
--- a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml
@@ -1,16 +1,22 @@
# will be used as entry in DB to say SITE OFF/ON for healthcheck
-
+security:
+ basic:
+ enabled: false
server:
port: 8080
tomcat:
max-threads: 50
ssl-enable: false
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
site-name: localSite
infra-requests:
archived:
- period: 1
+ period: 0
spring:
datasource:
url: jdbc:mariadb://localhost:3307/requestdb
@@ -29,10 +35,14 @@ spring:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
security:
usercredentials:
- -
- username: test
- password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ -
+ username: bpel
+ password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO'
role: BPEL-Client
+ -
+ username: mso_admin
+ password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa'
+ role: ACTUATOR
mariaDB4j:
dataDir:
port: 3307
diff --git a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql
index ec02ac0734..ae5f5e9124 100644
--- a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql
+++ b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql
@@ -29,4 +29,10 @@ insert into watchdog_service_mod_ver_id_lookup(distribution_id, service_model_ve
insert into site_status(site_name, status, creation_timestamp) values
-('testsite', 0, '2017-11-30 15:48:09'); \ No newline at end of file
+('testsite', 0, '2017-11-30 15:48:09');
+
+INSERT INTO requestdb.request_processing_data (ID, SO_REQUEST_ID, GROUPING_ID, NAME, VALUE, TAG)
+VALUES
+(1, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca714', 'requestAction', 'assign', 'pincFabricConfigRequest'),
+(2, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca715', 'configurationId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfigRequest'),
+(3, '5ffbabd6-b793-4377-a1ab-082670fbc7ac', '5ffbabd6-b793-4377-a1ab-082670fbc7ac', 'configId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfig');
diff --git a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml
index 54fa1cdd65..d1596cd374 100644
--- a/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml
+++ b/adapters/mso-requests-db-adapter/src/test/resources/logback-test.xml
@@ -1,33 +1,55 @@
<configuration>
-
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="com.att.ecomp.audit" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
+ <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
+ <property name="p_lvl" value="%level"/>
+ <property name="p_log" value="%logger"/>
+ <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/>
+ <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_thr" value="%thread"/>
+ <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
+
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>${pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="test"
+ class="org.onap.so.adapters.requestsdb.application.TestAppender" />
+
+ <logger name="com.att.ecomp.audit" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.error" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
- <logger name="com.att.eelf.error" level="trace" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
<logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
<appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
</logger>
- <logger name="org.flywaydb" level="DEBUG" additivity="false">
+
+ <logger name="org.flywaydb" level="DEBUG" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
- <root level="WARN">
- <appender-ref ref="STDOUT" />
- </root>
-
+
+
+ <logger name="ch.vorburger" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
+ </root>
+
+
</configuration> \ No newline at end of file