aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java340
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java182
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java47
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java152
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java330
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java444
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java483
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java221
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java147
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java64
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java143
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java189
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java190
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java154
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java145
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java83
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json44
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json62
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/ALaCarteNull.json13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json19
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json19
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CustomWorkflowRequest.json21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModuleRetainAssignments.json33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceNoOE.json33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json56
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json56
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json56
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json56
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json35
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json131
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json56
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql27
47 files changed, 4178 insertions, 323 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java
deleted file mode 100644
index 276b438529..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============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.apihandler.filters;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import java.io.IOException;
-import java.net.URI;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.core.UriInfo;
-import org.junit.Test;
-import org.onap.so.apihandlerinfra.BaseTest;
-
-
-
-public class RequestUriFilterTest extends BaseTest {
-
- @Test
- public void filterTest() throws IOException {
- RequestUriFilter URIFilter = new RequestUriFilter();
- URI baseURI = URI.create("http://localhost:58879/");
- String requestURI = "onap/so/infra/serviceInstances/v5";
-
- ContainerRequestContext mockContext = mock(ContainerRequestContext.class);
- UriInfo mockInfo = mock(UriInfo.class);
-
- when(mockContext.getUriInfo()).thenReturn(mockInfo);
- when(mockInfo.getBaseUri()).thenReturn(baseURI);
- when(mockInfo.getPath()).thenReturn(requestURI);
-
-
- URIFilter.filter(mockContext);
- assertEquals("http://localhost:58879/onap/so/infra/serviceInstantiation/v5/serviceInstances",
- URIFilter.getRequestUri());
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java
new file mode 100644
index 0000000000..830f38f98b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java
@@ -0,0 +1,340 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.ResourceAccessException;
+import org.springframework.web.client.RestTemplate;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CamundaRequestHandlerTest {
+
+ @Mock
+ private RestTemplate restTemplate;
+
+ @Mock
+ private Environment env;
+
+ @InjectMocks
+ @Spy
+ private CamundaRequestHandler camundaRequestHandler;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static final String REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4";
+ private ResponseEntity<List<HistoricActivityInstanceEntity>> activityInstanceResponse = null;
+ private ResponseEntity<List<HistoricProcessInstanceEntity>> processInstanceResponse = null;
+ private List<HistoricActivityInstanceEntity> activityInstanceList = null;
+ private List<HistoricProcessInstanceEntity> processInstanceList = null;
+
+
+
+ @Before
+ public void setup() throws IOException {
+ ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ activityInstanceList = mapper.readValue(
+ new String(Files.readAllBytes(
+ Paths.get("src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json"))),
+ new TypeReference<List<HistoricActivityInstanceEntity>>() {});
+ processInstanceList = mapper.readValue(
+ new String(Files.readAllBytes(
+ Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json"))),
+ new TypeReference<List<HistoricProcessInstanceEntity>>() {});
+ processInstanceResponse =
+ new ResponseEntity<List<HistoricProcessInstanceEntity>>(processInstanceList, HttpStatus.ACCEPTED);
+ activityInstanceResponse =
+ new ResponseEntity<List<HistoricActivityInstanceEntity>>(activityInstanceList, HttpStatus.ACCEPTED);
+
+ doReturn("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_").when(env)
+ .getProperty("mso.camunda.rest.history.uri");
+ doReturn("/sobpmnengine/history/activity-instance?processInstanceId=").when(env)
+ .getProperty("mso.camunda.rest.activity.uri");
+ doReturn("auth").when(env).getRequiredProperty("mso.camundaAuth");
+ doReturn("key").when(env).getRequiredProperty("mso.msoKey");
+ doReturn("http://localhost:8089").when(env).getProperty("mso.camundaURL");
+ }
+
+ public HttpHeaders setHeaders() {
+ HttpHeaders headers = new HttpHeaders();
+ List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ headers.add(HttpHeaders.AUTHORIZATION, "auth");
+
+ return headers;
+ }
+
+ @Test
+ public void getActivityNameTest() {
+ String expectedActivityName = "Last task executed: BB to Execute";
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getActivityNameNullActivityNameTest() {
+ String expectedActivityName = "Task name is null.";
+ HistoricActivityInstanceEntity activityInstance = new HistoricActivityInstanceEntity();
+ List<HistoricActivityInstanceEntity> activityInstanceList = new ArrayList<>();
+ activityInstanceList.add(activityInstance);
+
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getActivityNameNullListTest() {
+ String expectedActivityName = "No results returned on activityInstance history lookup.";
+ List<HistoricActivityInstanceEntity> activityInstanceList = null;
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getActivityNameEmptyListTest() {
+ String expectedActivityName = "No results returned on activityInstance history lookup.";
+ List<HistoricActivityInstanceEntity> activityInstanceList = new ArrayList<>();
+ String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
+
+ assertEquals(expectedActivityName, actualActivityName);
+ }
+
+ @Test
+ public void getTaskNameTest() throws ContactCamundaException {
+ doReturn(processInstanceResponse).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ doReturn(activityInstanceResponse).when(camundaRequestHandler)
+ .getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
+ doReturn("Last task executed: BB to Execute").when(camundaRequestHandler).getActivityName(activityInstanceList);
+ String expectedTaskName = "Last task executed: BB to Execute";
+
+ String actualTaskName = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expectedTaskName, actualTaskName);
+ }
+
+ @Test
+ public void getTaskNameNullProcessInstanceListTest() throws ContactCamundaException {
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response = new ResponseEntity<>(null, HttpStatus.OK);
+ doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ String expected = "No processInstances returned for requestId: " + REQUEST_ID;
+
+ String actual = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTaskNameNullProcessInstanceIdTest() throws ContactCamundaException {
+ HistoricProcessInstanceEntity processInstance = new HistoricProcessInstanceEntity();
+ List<HistoricProcessInstanceEntity> processInstanceList = new ArrayList<>();
+ processInstanceList.add(processInstance);
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response =
+ new ResponseEntity<>(processInstanceList, HttpStatus.OK);
+ doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ String expected = "No processInstanceId returned for requestId: " + REQUEST_ID;
+
+ String actual = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTaskNameEmptyProcessInstanceListTest() throws ContactCamundaException {
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response =
+ new ResponseEntity<>(Collections.emptyList(), HttpStatus.OK);
+ doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ String expected = "No processInstances returned for requestId: " + REQUEST_ID;
+
+ String actual = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTaskNameProcessInstanceLookupFailureTest() throws ContactCamundaException {
+ doThrow(HttpClientErrorException.class).when(camundaRequestHandler)
+ .getCamundaProcessInstanceHistory(REQUEST_ID);
+
+ thrown.expect(ContactCamundaException.class);
+ camundaRequestHandler.getTaskName(REQUEST_ID);
+ }
+
+ @Test
+ public void getCamundaActivityHistoryTest() throws ContactCamundaException {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId="
+ + "c4c6b647-a26e-11e9-b144-0242ac14000b";
+ doReturn(activityInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+ ResponseEntity<List<HistoricActivityInstanceEntity>> actualResponse =
+ camundaRequestHandler.getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
+ assertEquals(activityInstanceResponse, actualResponse);
+ }
+
+ @Test
+ public void getCamundaActivityHistoryErrorTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId="
+ + "c4c6b647-a26e-11e9-b144-0242ac14000b";
+ doThrow(new ResourceAccessException("IOException")).when(restTemplate).exchange(targetUrl, HttpMethod.GET,
+ requestEntity, new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ try {
+ camundaRequestHandler.getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
+ } catch (ContactCamundaException e) {
+ // Exception thrown after retries are completed
+ }
+
+ verify(restTemplate, times(4)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {});
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ doReturn(processInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse =
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ assertEquals(processInstanceResponse, actualResponse);
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryRetryTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ doThrow(new ResourceAccessException("I/O error")).when(restTemplate).exchange(targetUrl, HttpMethod.GET,
+ requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ try {
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ } catch (ResourceAccessException e) {
+ // Exception thrown after retries are completed
+ }
+ verify(restTemplate, times(4)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryNoRetryTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ doThrow(HttpClientErrorException.class).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ try {
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ } catch (HttpStatusCodeException e) {
+ // Exception thrown, no retries
+ }
+ verify(restTemplate, times(1)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ }
+
+ @Test
+ public void getCamundaProccesInstanceHistoryFailThenSuccessTest() {
+ HttpHeaders headers = setHeaders();
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ String targetUrl =
+ "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID;
+ when(restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}))
+ .thenThrow(new ResourceAccessException("I/O Exception")).thenReturn(processInstanceResponse);
+ doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key");
+
+ ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse =
+ camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID);
+ assertEquals(processInstanceResponse, actualResponse);
+ verify(restTemplate, times(2)).exchange(targetUrl, HttpMethod.GET, requestEntity,
+ new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {});
+ }
+
+ @Test
+ public void setCamundaHeadersTest() {
+ String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
+ String key = "07a7159d3bf51a0e53be7a8f89699be7";
+
+ HttpHeaders headers = camundaRequestHandler.setCamundaHeaders(encryptedAuth, key);
+ List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
+
+ String expectedAcceptedType = "application/json";
+ assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
+ String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
+ String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
+
+ assertEquals(expectedBasicAuth, basicAuth);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java
index 928b488f6a..0291cfd2ea 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java
@@ -20,70 +20,67 @@
package org.onap.so.apihandlerinfra;
-import static org.junit.Assert.assertArrayEquals;
+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.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
+import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-import org.springframework.test.util.ReflectionTestUtils;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import org.json.JSONException;
-import org.junit.Rule;
import org.junit.Test;
-import org.mockito.InjectMocks;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
+import org.onap.so.apihandlerinfra.HealthCheckConfig.Endpoint;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.boot.test.mock.mockito.SpyBean;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.client.RestTemplate;
+import com.fasterxml.jackson.core.JsonProcessingException;
+@RunWith(SpringRunner.class)
+@ContextConfiguration(classes = {GenericStringConverter.class, HealthCheckConverter.class},
+ initializers = {ConfigFileApplicationContextInitializer.class})
+@ActiveProfiles("test")
+@EnableConfigurationProperties({HealthCheckConfig.class})
public class GlobalHealthcheckHandlerTest {
- @Mock
- RestTemplate restTemplate;
+ @MockBean
+ private RestTemplate restTemplate;
- @Mock
- ContainerRequestContext requestContext;
+ @MockBean
+ private ContainerRequestContext requestContext;
- @InjectMocks
- @Spy
- GlobalHealthcheckHandler globalhealth;
-
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule();
+ @SpyBean
+ private GlobalHealthcheckHandler globalhealth;
@Test
public void testQuerySubsystemHealthNullResult() {
ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
- ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8080");
Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), ArgumentMatchers.any(HttpMethod.class),
ArgumentMatchers.<HttpEntity<?>>any(), ArgumentMatchers.<Class<Object>>any())).thenReturn(null);
- String result = globalhealth.querySubsystemHealth(MsoSubsystems.BPMN);
- System.out.println(result);
- assertEquals(HealthcheckStatus.DOWN.toString(), result);
+ HealthCheckSubsystem result = globalhealth
+ .querySubsystemHealth(new Endpoint(SoSubsystems.BPMN, UriBuilder.fromPath("http://localhost").build()));
+ assertEquals(HealthCheckStatus.DOWN, result.getStatus());
}
@Test
public void testQuerySubsystemHealthNotNullResult() {
ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
- ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080");
SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse();
subSystemResponse.setStatus("UP");
@@ -92,20 +89,13 @@ public class GlobalHealthcheckHandlerTest {
Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), ArgumentMatchers.any(HttpMethod.class),
ArgumentMatchers.<HttpEntity<?>>any(), ArgumentMatchers.<Class<Object>>any())).thenReturn(r);
- String result = globalhealth.querySubsystemHealth(MsoSubsystems.ASDC);
- System.out.println(result);
- assertEquals(HealthcheckStatus.UP.toString(), result);
+ HealthCheckSubsystem result = globalhealth
+ .querySubsystemHealth(new Endpoint(SoSubsystems.ASDC, UriBuilder.fromPath("http://localhost").build()));
+ assertEquals(HealthCheckStatus.UP, result.getStatus());
}
private Response globalHealthcheck(String status) {
ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
- ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080");
- ReflectionTestUtils.setField(globalhealth, "endpointSdnc", "http://localhost:8081");
- ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8082");
- ReflectionTestUtils.setField(globalhealth, "endpointCatalogdb", "http://localhost:8083");
- ReflectionTestUtils.setField(globalhealth, "endpointOpenstack", "http://localhost:8084");
- ReflectionTestUtils.setField(globalhealth, "endpointRequestdb", "http://localhost:8085");
- ReflectionTestUtils.setField(globalhealth, "endpointRequestdbAttsvc", "http://localhost:8086");
SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse();
@@ -116,70 +106,41 @@ public class GlobalHealthcheckHandlerTest {
Mockito.when(requestContext.getProperty(anyString())).thenReturn("1234567890");
Response response = globalhealth.globalHealthcheck(true, requestContext);
-
return response;
}
@Test
- public void globalHealthcheckAllUPTest() throws JSONException {
- Response response = globalHealthcheck("UP");
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
- HealthcheckResponse root;
- root = (HealthcheckResponse) response.getEntity();
- String apistatus = root.getApih();
- assertTrue(apistatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
-
- String bpmnstatus = root.getBpmn();
- assertTrue(bpmnstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
-
- String sdncstatus = root.getSdncAdapter();
- assertTrue(sdncstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+ public void globalHealthcheckAllUPTest() throws JSONException, JsonProcessingException {
- String asdcstatus = root.getAsdcController();
- assertTrue(asdcstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+ HealthCheckResponse expected = new HealthCheckResponse();
- String catastatus = root.getCatalogdbAdapter();
- assertTrue(catastatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
-
- String reqdbstatus = root.getRequestdbAdapter();
- assertTrue(reqdbstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
-
- String openstatus = root.getOpenstackAdapter();
- assertTrue(openstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+ for (Subsystem system : SoSubsystems.values()) {
+ expected.getSubsystems().add(new HealthCheckSubsystem(system,
+ UriBuilder.fromUri("http://localhost").build(), HealthCheckStatus.UP));
+ }
+ expected.setMessage("HttpStatus: 200");
+ Response response = globalHealthcheck("UP");
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ HealthCheckResponse root;
+ root = (HealthCheckResponse) response.getEntity();
+ assertThat(root, sameBeanAs(expected).ignoring("subsystems.uri").ignoring("subsystems.subsystem"));
- String reqdbattstatus = root.getRequestdbAdapterAttsvc();
- assertTrue(reqdbattstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
}
@Test
public void globalHealthcheckAllDOWNTest() throws JSONException {
+ HealthCheckResponse expected = new HealthCheckResponse();
+
+ for (Subsystem system : SoSubsystems.values()) {
+ expected.getSubsystems().add(new HealthCheckSubsystem(system,
+ UriBuilder.fromUri("http://localhost").build(), HealthCheckStatus.DOWN));
+ }
+ expected.setMessage("HttpStatus: 200");
Response response = globalHealthcheck("DOWN");
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
- HealthcheckResponse root;
- root = (HealthcheckResponse) response.getEntity();
- String apistatus = root.getApih();
- assertTrue(apistatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
-
- String bpmnstatus = root.getBpmn();
- assertTrue(bpmnstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
-
- String sdncstatus = root.getSdncAdapter();
- assertTrue(sdncstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
-
- String asdcstatus = root.getAsdcController();
- assertTrue(asdcstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
-
- String catastatus = root.getCatalogdbAdapter();
- assertTrue(catastatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
-
- String reqdbstatus = root.getRequestdbAdapter();
- assertTrue(reqdbstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
-
- String openstatus = root.getOpenstackAdapter();
- assertTrue(openstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
-
- String reqdbattstatus = root.getRequestdbAdapterAttsvc();
- assertTrue(reqdbattstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+ HealthCheckResponse root;
+ root = (HealthCheckResponse) response.getEntity();
+ assertThat(root, sameBeanAs(expected).ignoring("subsystems.uri").ignoring("subsystems.subsystem"));
}
@Test
@@ -189,40 +150,15 @@ public class GlobalHealthcheckHandlerTest {
assertEquals(MediaType.APPLICATION_JSON, he.getHeaders().getContentType());
}
- @Test
- public void getEndpointUrlForSubsystemEnumTest() {
- ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
- ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080");
- ReflectionTestUtils.setField(globalhealth, "endpointSdnc", "http://localhost:8081");
- ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8082");
- ReflectionTestUtils.setField(globalhealth, "endpointCatalogdb", "http://localhost:8083");
- ReflectionTestUtils.setField(globalhealth, "endpointOpenstack", "http://localhost:8084");
- ReflectionTestUtils.setField(globalhealth, "endpointRequestdb", "http://localhost:8085");
- ReflectionTestUtils.setField(globalhealth, "endpointRequestdbAttsvc", "http://localhost:8086");
-
- String result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.ASDC);
- assertEquals("http://localhost:8080", result);
- result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.SDNC);
- assertEquals("http://localhost:8081", result);
- result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.BPMN);
- assertEquals("http://localhost:8082", result);
- result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.CATALOGDB);
- assertEquals("http://localhost:8083", result);
- result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.OPENSTACK);
- assertEquals("http://localhost:8084", result);
- result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.REQUESTDB);
- assertEquals("http://localhost:8085", result);
- result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.REQUESTDBATT);
- assertEquals("http://localhost:8086", result);
- }
@Test
public void processResponseFromSubsystemTest() {
SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse();
subSystemResponse.setStatus("UP");
ResponseEntity<SubsystemHealthcheckResponse> r = new ResponseEntity<>(subSystemResponse, HttpStatus.OK);
- String result = globalhealth.processResponseFromSubsystem(r, MsoSubsystems.BPMN);
- assertEquals("UP", result);
+ Endpoint endpoint = new Endpoint(SoSubsystems.BPMN, UriBuilder.fromUri("http://localhost").build());
+ HealthCheckStatus result = globalhealth.processResponseFromSubsystem(r, endpoint);
+ assertEquals(HealthCheckStatus.UP, result);
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index c30b9dedf2..86bf8060a7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -24,13 +24,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.StringReader;
-import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Optional;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilder;
@@ -46,13 +44,13 @@ import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
@RunWith(JUnitParamsRunner.class)
public class MsoRequestTest extends BaseTest {
@@ -83,6 +81,12 @@ public class MsoRequestTest extends BaseTest {
return input;
}
+ public String inputStreamVpnBonding(String JsonInput) throws IOException {
+ JsonInput = "src/test/resources/Validation" + JsonInput;
+ String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
+ return input;
+ }
+
// Tests for successful validation of incoming JSON requests through the parse method
@Test
@Parameters(method = "successParameters")
@@ -188,6 +192,8 @@ public class MsoRequestTest extends BaseTest {
instanceIdMapTest, Action.addRelationships, "5"},
{mapper.readValue(inputStream("/SuccessfulValidation/ServiceAssign.json"),
ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, "7"},
+ {mapper.readValue(inputStream("/RelatedInstances/ServiceInstanceVpnBondingService.json"),
+ ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "7"},
{mapper.readValue(inputStream("/SuccessfulValidation/ServiceUnassign.json"),
ServiceInstancesRequest.class), instanceIdMapTest, Action.unassignInstance, "7"}});
}
@@ -546,6 +552,22 @@ public class MsoRequestTest extends BaseTest {
mapper.readValue(inputStream("/RelatedInstances/v6AddRelationshipsInstanceName.json"),
ServiceInstancesRequest.class),
instanceIdMapTest, Action.addRelationships, 6},
+ {"No valid modelType in relatedInstance is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoModelType.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
+ {"No valid instanceId in relatedInstance is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceId.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
+ {"No valid instanceName in relatedInstance for vpnBinding modelType is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceNameVpnBinding.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
+ {"No valid instanceName in relatedInstance for network modelType is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceNameNetwork.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
{"No valid modelCustomizationName or modelCustomizationId in relatedInstance of vnf is specified",
mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelCustomizationId.json"),
ServiceInstancesRequest.class),
@@ -1038,20 +1060,5 @@ public class MsoRequestTest extends BaseTest {
assertNotNull(result);
}
- @Test
- public void buildSelfLinkUrlTest() throws Exception {
- // v - version
- String incomingUrl = "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances";
- String expectedSelfLink = "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1";
- String requestId = "efce3167-5e45-4666-9d4d-22e23648e5d1";
- this.msoRequest = new MsoRequest();
- Optional<URL> actualSelfLinkUrl = msoRequest.buildSelfLinkUrl(incomingUrl, requestId);
- assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString());
- // V - Version
- String incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances";
- String expectedSelfLinkV =
- "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1";
- Optional<URL> actualSelfLinkUrlV = msoRequest.buildSelfLinkUrl(incomingUrlV, requestId);
- assertEquals(expectedSelfLinkV, actualSelfLinkUrlV.get().toString());
- }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 321ea3ac7d..12f0ffcc11 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
@@ -42,12 +43,13 @@ import java.util.Map;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
-import org.junit.Ignore;
+import org.junit.Before;
import org.junit.Test;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudRequestData;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.Request;
@@ -92,6 +94,21 @@ public class OrchestrationRequestsTest extends BaseTest {
return list;
}
+ @Before
+ public void setup() throws IOException {
+ wireMockServer.stubFor(get(urlMatching("/sobpmnengine/history/process-instance.*")).willReturn(aResponse()
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(
+ Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json"))))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+ wireMockServer.stubFor(
+ get(("/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths.get(
+ "src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json"))))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
@Test
public void testGetOrchestrationRequest() throws Exception {
setupTestGetOrchestrationRequest();
@@ -119,7 +136,7 @@ public class OrchestrationRequestsTest extends BaseTest {
assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("00032ab7-na18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
+ assertEquals("00032ab7-1a18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
assertNotNull(response.getBody().getRequest().getFinishTime());
}
@@ -149,12 +166,22 @@ public class OrchestrationRequestsTest extends BaseTest {
}
@Test
- public void testGetOrchestrationRequestRequestDetails() throws Exception {
- setupTestGetOrchestrationRequestRequestDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
+ public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
+ setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
// Test request with modelInfo request body
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
+ List<CloudRequestData> cloudRequestData = new ArrayList<>();
+ CloudRequestData cloudData = new CloudRequestData();
+ cloudData.setCloudIdentifier("heatstackName/123123");
+ ObjectMapper mapper = new ObjectMapper();
+ Object reqData = mapper.readValue(
+ "{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ Object.class);
+ cloudData.setCloudRequest(reqData);
+ cloudRequestData.add(cloudData);
+ request.setCloudRequestData(cloudRequestData);
testResponse.setRequest(request);
String testRequestId = request.getRequestId();
@@ -163,13 +190,14 @@ public class OrchestrationRequestsTest extends BaseTest {
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
+ "/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
ResponseEntity<GetOrchestrationResponse> response =
restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
+ System.out.println("Response :" + response.getBody().toString());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
.ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
@@ -194,6 +222,29 @@ public class OrchestrationRequestsTest extends BaseTest {
}
@Test
+ public void testGetOrchestrationRequestInvalidRequestID() throws Exception {
+ setupTestGetOrchestrationRequest();
+ // TEST INVALID REQUESTID
+ GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
+
+ Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
+ testResponse.setRequest(request);
+ String testRequestId = "00032ab7-pfb3-42e5-965d-8ea592502016";
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
+
+ ResponseEntity<GetOrchestrationResponse> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
public void testGetOrchestrationRequestFilter() throws Exception {
setupTestGetOrchestrationRequestFilter();
List<String> values = new ArrayList<>();
@@ -319,75 +370,11 @@ public class OrchestrationRequestsTest extends BaseTest {
"/onap/so/infra/orchestrationRequests/v7/" + "5ffbabd6-b793-4377-a1ab-082670fbc7ac" + "/unlock"));
response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
- // Cannot assert anything further here, already have a wiremock in place which ensures that the post was
+ // Cannot assert anything further here, already have a wiremock in place
+ // which ensures that the post was
// properly called to update.
}
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsWhiteSpace() throws Exception {
- InfraActiveRequests requests = new InfraActiveRequests();
- requests.setAction("create");
- requests.setRequestBody(" ");
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(requests);
-
- requestsDbClient.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
-
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsAlaCarte() throws IOException {
- InfraActiveRequests requests = new InfraActiveRequests();
-
- String requestJSON = new String(
- Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/AlaCarteRequest.json")));
-
- requests.setAction("create");
- requests.setRequestBody(requestJSON);
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- // iar.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
-
@Test
public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
RequestProcessingData entry = new RequestProcessingData();
@@ -423,14 +410,14 @@ public class OrchestrationRequestsTest extends BaseTest {
public void setupTestGetOrchestrationRequest() throws Exception {
// For testGetOrchestrationRequest
- wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(
Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
.withStatus(HttpStatus.SC_OK)));
wireMockServer
.stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
- .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
+ .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths
.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
@@ -439,14 +426,14 @@ public class OrchestrationRequestsTest extends BaseTest {
public void setupTestGetOrchestrationRequestInstanceGroup() throws Exception {
// For testGetOrchestrationRequest
- wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get(
"src/test/resources/OrchestrationRequest/getOrchestrationRequestInstanceGroup.json"))))
.withStatus(HttpStatus.SC_OK)));
wireMockServer
.stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
- .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
+ .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths
.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
@@ -461,15 +448,20 @@ public class OrchestrationRequestsTest extends BaseTest {
.withStatus(HttpStatus.SC_OK)));
}
+ private void setupTestGetOrchestrationRequestOpenstackDetails(String requestId, String status) throws Exception {
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths
+ .get("src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json"))))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, requestId, status)).withStatus(HttpStatus.SC_OK)));
-
}
-
-
private void setupTestUnlockOrchestrationRequest_invalid_Json() {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
new file mode 100644
index 0000000000..627bbc631d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
@@ -0,0 +1,330 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang.StringUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.constants.OrchestrationRequestFormat;
+import org.onap.so.constants.Status;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.InstanceReferences;
+import org.onap.so.serviceinstancebeans.Request;
+import org.onap.so.serviceinstancebeans.RequestStatus;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OrchestrationRequestsUnitTest {
+ @Mock
+ private RequestsDbClient requestDbClient;
+ @Mock
+ private MsoRequest msoRequest;
+ @Mock
+ private ResponseBuilder builder;
+ @Mock
+ private Response response;
+ @Mock
+ private CamundaRequestHandler camundaRequestHandler;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+ @InjectMocks
+ private OrchestrationRequests orchestrationRequests;
+
+ private static final String REQUEST_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebba";
+ private static final String SERVICE_INSTANCE_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebbb";
+ private static final String ORIGINAL_REQUEST_ID = "8f2d38a6-7c20-465a-bd7e-075645f1394b";
+ private static final String SERVICE = "service";
+ private static final String EXT_SYSTEM_ERROR_SOURCE = "external system error source";
+ private static final String FLOW_STATUS = "FlowStatus";
+ private static final String RETRY_STATUS_MESSAGE = "RetryStatusMessage";
+ private static final String ROLLBACK_STATUS_MESSAGE = "RollbackStatusMessage";
+ private static final String TASK_INFORMATION = " TASK INFORMATION: Last task executed: Call SDNC";
+ private InfraActiveRequests iar;
+ boolean includeCloudRequest = false;
+ private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC";
+
+
+ @Before
+ public void setup() {
+ iar = new InfraActiveRequests();
+ iar.setRequestScope(SERVICE);
+ iar.setRequestId(REQUEST_ID);
+ iar.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
+ iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
+ iar.setFlowStatus(FLOW_STATUS);
+ iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
+ iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
+ }
+
+ @Test
+ public void mapInfraActiveRequestToRequestWithOriginalRequestIdTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ iar.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+
+ Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+ assertThat(result, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapInfraActiveRequestToRequestOriginalRequestIdNullTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+ assertThat(result, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestFalseTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestStatusDetailTest() throws ApiException {
+ doReturn(null).when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
+ requestStatus.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setFlowStatus(FLOW_STATUS);
+ requestStatus.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
+ requestStatus.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.STATUSDETAIL.toString());
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestDetailTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestNoFlowStatusTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(
+ String.format("RETRY STATUS: %s ROLLBACK STATUS: %s", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+ iar.setFlowStatus(null);
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestErrorMessageTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ iar.setExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
+ iar.setFlowStatus(null);
+ iar.setStatusMessage("Error retrieving cloud region from AAI");
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertTrue(actual.getRequestStatus().getStatusMessage()
+ .contains("Error Source: " + ROLLBACK_EXT_SYSTEM_ERROR_SOURCE));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+ iar.setFlowStatus("Successfully completed all Building Blocks");
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulRollbackTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
+ "All Rollback flows have completed successfully", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ includeCloudRequest = false;
+ iar.setFlowStatus("All Rollback flows have completed successfully");
+
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void requestStatusExtSystemErrorSourceTest() {
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
+ assertThat(requestStatus.getExtSystemErrorSource(), is(equalTo(EXT_SYSTEM_ERROR_SOURCE)));
+ }
+
+ @Test
+ public void mapRequestStatusToRequestForFormatDetailTest() throws ApiException {
+ iar.setRequestStatus(Status.ABORTED.toString());
+ String result =
+ orchestrationRequests.mapRequestStatusToRequest(iar, OrchestrationRequestFormat.DETAIL.toString());
+
+ assertEquals(Status.ABORTED.toString(), result);
+ }
+
+ @Test
+ public void mapRequestStatusToRequestForFormatStatusDetailTest() throws ApiException {
+ iar.setRequestStatus(Status.ABORTED.toString());
+ String result = orchestrationRequests.mapRequestStatusToRequest(iar, "statusDetail");
+
+ assertEquals(Status.ABORTED.toString(), result);
+ }
+
+
+ @Test
+ public void mapRequestStatusToRequestForFormatEmptyStringTest() throws ApiException {
+ iar.setRequestStatus(Status.ABORTED.toString());
+ String result = orchestrationRequests.mapRequestStatusToRequest(iar, StringUtils.EMPTY);
+
+ assertEquals(Status.FAILED.toString(), result);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
index dc0cd473c2..e4532cd8d7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
@@ -27,6 +27,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
@@ -38,7 +39,6 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
-import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.MediaType;
import org.apache.http.HttpStatus;
import org.junit.Before;
@@ -50,6 +50,7 @@ import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
@@ -76,6 +77,9 @@ public class RequestHandlerUtilsTest extends BaseTest {
@Autowired
private RequestHandlerUtils requestHandlerUtils;
+ @Autowired
+ private CamundaRequestHandler camundaRequestHandler;
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -147,6 +151,18 @@ public class RequestHandlerUtilsTest extends BaseTest {
}
+ @Test
+ public void test_mapJSONtoMSOStyleCustomWorkflowRequest() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest = inputStream("/CustomWorkflowRequest.json");
+ String resultString =
+ requestHandlerUtils.mapJSONtoMSOStyle(testRequest, null, true, Action.inPlaceSoftwareUpdate);
+ ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ assertEquals(sir.getRequestDetails().getCloudConfiguration().getTenantId(), "88a6ca3ee0394ade9403f075db23167e");
+ assertNotEquals(sir.getRequestDetails().getRequestParameters().getUserParams().size(), 0);
+ }
+
@Test
public void test_mapJSONtoMSOStyleUsePreload() throws IOException {
@@ -327,7 +343,7 @@ public class RequestHandlerUtilsTest extends BaseTest {
public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException {
String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
String key = "07a7159d3bf51a0e53be7a8f89699be7";
- HttpHeaders headers = requestHandlerUtils.setCamundaHeaders(encryptedAuth, key);
+ HttpHeaders headers = camundaRequestHandler.setCamundaHeaders(encryptedAuth, key);
List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
String expectedAcceptedType = "application/json";
assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java
new file mode 100644
index 0000000000..d4b0c3aad1
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java
@@ -0,0 +1,444 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.sql.Timestamp;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
+import org.onap.so.constants.Status;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RequestHandlerUtilsUnitTest {
+
+ @Mock
+ private CatalogDbClient catDbClient;
+
+ @InjectMocks
+ @Spy
+ private RequestHandlerUtils requestHandler;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static final String CURRENT_REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4";
+ private static final String RESUMED_REQUEST_ID = "59c7247f-839f-4923-90c3-05faa3ab354d";
+ private static final String SERVICE_INSTANCE_ID = "00032ab7-na18-42e5-965d-8ea592502018";
+ private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName";
+ private static final String VNF_ID = "00032ab7-na18-42e5-965d-8ea592502017";
+ private static final String VFMODULE_ID = "00032ab7-na18-42e5-965d-8ea592502016";
+ private static final String NETWORK_ID = "00032ab7-na18-42e5-965d-8ea592502015";
+ private static final String VOLUME_GROUP_ID = "00032ab7-na18-42e5-965d-8ea592502014";
+ private static final String VNF_NAME = "vnfName";
+ private static final String VFMODULE_NAME = "vfModuleName";
+ private static final String NETWORK_NAME = "networkName";
+ private static final String VOLUME_GROUP_NAME = "volumeGroupName";
+ private static final String MODEL_VERSION_ID = "883f4a7a-b5a5-44e0-8738-361c6413d24c";
+ private static final String MODEL_VERSION = "1.0";
+ private static final String MODEL_INVARIANT_ID = "d358b828-e7f8-4833-ac96-2782bed1a9a9";
+ private static final String MODEL_NAME = "modelName";
+ private final Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ private String requestUri =
+ "http:localhost:6746/onap/so/infra/orchestrationRequests/v7/00032ab7-na18-42e5-965d-8ea592502019/resume";
+ private InfraActiveRequests infraActiveRequest = new InfraActiveRequests();
+ private InfraActiveRequests currentActiveRequest = new InfraActiveRequests();
+ private InfraActiveRequests currentActiveRequestIARNull = new InfraActiveRequests();
+ private Action action = Action.createInstance;
+ private String vnfType = "vnfType";
+ private String sdcServiceModelVersion = "7";
+
+ public String getRequestBody(String request) throws IOException {
+ request = "src/test/resources/ResumeOrchestrationRequest" + request;
+ return new String(Files.readAllBytes(Paths.get(request)));
+ }
+
+ @Before
+ public void setup() throws IOException {
+ setInfraActiveRequest();
+ setCurrentActiveRequest();
+ setCurrentActiveRequestNullInfraActive();
+ }
+
+ private void setInfraActiveRequest() throws IOException {
+ infraActiveRequest.setTenantId("tenant-id");
+ infraActiveRequest.setRequestBody(getRequestBody("/RequestBody.json"));
+ infraActiveRequest.setAicCloudRegion("cloudRegion");
+ infraActiveRequest.setRequestScope("service");
+ infraActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ infraActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME);
+ infraActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ infraActiveRequest.setRequestAction(Action.createInstance.toString());
+ infraActiveRequest.setServiceType("serviceType");
+ }
+
+ private void setCurrentActiveRequest() throws IOException {
+ currentActiveRequest.setRequestId(CURRENT_REQUEST_ID);
+ currentActiveRequest.setSource("VID");
+ currentActiveRequest.setStartTime(startTimeStamp);
+ currentActiveRequest.setTenantId("tenant-id");
+ currentActiveRequest.setRequestBody(getRequestBody("/RequestBodyNewRequestorId.json"));
+ currentActiveRequest.setAicCloudRegion("cloudRegion");
+ currentActiveRequest.setRequestScope("service");
+ currentActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ currentActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ currentActiveRequest.setRequestAction(Action.createInstance.toString());
+ currentActiveRequest.setRequestUrl(requestUri);
+ currentActiveRequest.setRequestorId("yyyyyy");
+ currentActiveRequest.setProgress(new Long(5));
+ currentActiveRequest.setOriginalRequestId(RESUMED_REQUEST_ID);
+ }
+
+ private void setCurrentActiveRequestNullInfraActive() throws IOException {
+ currentActiveRequestIARNull.setRequestId(CURRENT_REQUEST_ID);
+ currentActiveRequestIARNull.setSource("VID");
+ currentActiveRequestIARNull.setStartTime(startTimeStamp);
+ currentActiveRequestIARNull.setRequestStatus(Status.IN_PROGRESS.toString());
+ currentActiveRequestIARNull.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ currentActiveRequestIARNull.setRequestUrl(requestUri);
+ currentActiveRequestIARNull.setRequestorId("xxxxxx");
+ currentActiveRequestIARNull.setProgress(new Long(5));
+ currentActiveRequestIARNull.setOriginalRequestId(RESUMED_REQUEST_ID);
+ }
+
+
+ @Test
+ public void createNewRecordCopyFromInfraActiveRequestTest() throws IOException, ApiException {
+ doNothing().when(requestHandler).setInstanceIdAndName(infraActiveRequest, currentActiveRequest);
+ doReturn(getRequestBody("/RequestBodyNewRequestorId.json")).when(requestHandler)
+ .updateRequestorIdInRequestBody(infraActiveRequest, "yyyyyy");
+ InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(infraActiveRequest,
+ CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "yyyyyy", RESUMED_REQUEST_ID);
+ assertThat(currentActiveRequest, sameBeanAs(result));
+ }
+
+ @Test
+ public void createNewRecordCopyFromInfraActiveRequestNullIARTest() throws ApiException {
+ InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(null, CURRENT_REQUEST_ID,
+ startTimeStamp, "VID", requestUri, "xxxxxx", RESUMED_REQUEST_ID);
+ assertThat(currentActiveRequestIARNull, sameBeanAs(result));
+ }
+
+ @Test
+ public void setInstanceIdAndNameServiceTest() throws ApiException {
+ InfraActiveRequests serviceRequest = new InfraActiveRequests();
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ expected.setServiceInstanceName(SERVICE_INSTANCE_NAME);
+
+ requestHandler.setInstanceIdAndName(infraActiveRequest, serviceRequest);
+ assertThat(serviceRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void setInstanceIdAndNameServiceNullInstanceNameTest() throws ApiException {
+ InfraActiveRequests serviceRequest = new InfraActiveRequests();
+
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ request.setRequestScope(ModelType.service.toString());
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setServiceInstanceId(SERVICE_INSTANCE_ID);
+
+ requestHandler.setInstanceIdAndName(request, serviceRequest);
+ assertThat(serviceRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void setInstanceIdAndNameServiceNullInstanceNameVfModuleTest() throws ApiException {
+ InfraActiveRequests vfModuleRequest = new InfraActiveRequests();
+ String errorMessage =
+ "vfModule for requestId: 59c7247f-839f-4923-90c3-05faa3ab354d being resumed does not have an instanceName.";
+ doNothing().when(requestHandler).updateStatus(vfModuleRequest, Status.FAILED, errorMessage);
+
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setServiceInstanceId(VFMODULE_ID);
+ request.setRequestScope(ModelType.vfModule.toString());
+ request.setRequestId(RESUMED_REQUEST_ID);
+
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(errorMessage);
+
+ requestHandler.setInstanceIdAndName(request, vfModuleRequest);
+ }
+
+ @Test
+ public void setInstanceIdAndNameRequestScopeNotValidTest() throws ApiException {
+ InfraActiveRequests originalServiceRequest = new InfraActiveRequests();
+ originalServiceRequest.setRequestScope("test");
+ InfraActiveRequests serviceRequest = new InfraActiveRequests();
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+
+ requestHandler.setInstanceIdAndName(originalServiceRequest, serviceRequest);
+ assertThat(serviceRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void setInstanceIdAndNameVnfTest() throws ApiException {
+ InfraActiveRequests vnfRequestOriginal = new InfraActiveRequests();
+ vnfRequestOriginal.setRequestScope("vnf");
+ vnfRequestOriginal.setVnfId(VNF_ID);
+ vnfRequestOriginal.setVnfName(VNF_NAME);
+ InfraActiveRequests vnfRequest = new InfraActiveRequests();
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setVnfId(VNF_ID);
+ expected.setVnfName(VNF_NAME);
+
+ requestHandler.setInstanceIdAndName(vnfRequestOriginal, vnfRequest);
+ assertThat(vnfRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void setInstanceIdAndNameVfModuleTest() throws ApiException {
+ InfraActiveRequests vfModuleRequestOriginal = new InfraActiveRequests();
+ vfModuleRequestOriginal.setRequestScope("vfModule");
+ vfModuleRequestOriginal.setVfModuleId(VFMODULE_ID);
+ vfModuleRequestOriginal.setVfModuleName(VFMODULE_NAME);
+ InfraActiveRequests vfModuleRequest = new InfraActiveRequests();
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setVfModuleId(VFMODULE_ID);
+ expected.setVfModuleName(VFMODULE_NAME);
+
+ requestHandler.setInstanceIdAndName(vfModuleRequestOriginal, vfModuleRequest);
+ assertThat(vfModuleRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void setInstanceIdAndNameNetworkTest() throws ApiException {
+ InfraActiveRequests networkRequestOriginal = new InfraActiveRequests();
+ networkRequestOriginal.setRequestScope("network");
+ networkRequestOriginal.setNetworkId(NETWORK_ID);
+ networkRequestOriginal.setNetworkName(NETWORK_NAME);
+ InfraActiveRequests networkRequest = new InfraActiveRequests();
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setNetworkId(NETWORK_ID);
+ expected.setNetworkName(NETWORK_NAME);
+
+ requestHandler.setInstanceIdAndName(networkRequestOriginal, networkRequest);
+ assertThat(networkRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void setInstanceIdAndNameVolumeGroupTest() throws ApiException {
+ InfraActiveRequests volumeGroupRequestOriginal = new InfraActiveRequests();
+ volumeGroupRequestOriginal.setRequestScope("volumeGroup");
+ volumeGroupRequestOriginal.setVolumeGroupId(VOLUME_GROUP_ID);
+ volumeGroupRequestOriginal.setVolumeGroupName(VOLUME_GROUP_NAME);
+ InfraActiveRequests volumeGroupRequest = new InfraActiveRequests();
+
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setVolumeGroupId(VOLUME_GROUP_ID);
+ expected.setVolumeGroupName(VOLUME_GROUP_NAME);
+
+ requestHandler.setInstanceIdAndName(volumeGroupRequestOriginal, volumeGroupRequest);
+ assertThat(volumeGroupRequest, sameBeanAs(expected));
+ }
+
+ @Test
+ public void getIsBaseVfModuleTrueTest() throws ApiException {
+ VfModule vfModule = new VfModule();
+ vfModule.setIsBase(true);
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId(MODEL_VERSION_ID);
+
+ doReturn(vfModule).when(catDbClient).getVfModuleByModelUUID(MODEL_VERSION_ID);
+ Boolean expected = true;
+
+ Boolean result = requestHandler.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion,
+ currentActiveRequest);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void getIsBaseVfModuleFalseTest() throws ApiException {
+ VfModule vfModule = new VfModule();
+ vfModule.setIsBase(false);
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId(MODEL_VERSION_ID);
+
+ doReturn(vfModule).when(catDbClient).getVfModuleByModelUUID(MODEL_VERSION_ID);
+ Boolean expected = false;
+
+ Boolean result = requestHandler.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion,
+ currentActiveRequest);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void getIsBaseVfModuleNullTest() throws ApiException {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId(MODEL_VERSION_ID);
+ modelInfo.setModelName(MODEL_NAME);
+ String errorMessage =
+ "VnfType vnfType and VF Module Model Name modelName with version 7 not found in MSO Catalog DB";
+
+ doNothing().when(requestHandler).updateStatus(currentActiveRequest, Status.FAILED, errorMessage);
+ doReturn(null).when(catDbClient).getVfModuleByModelUUID(MODEL_VERSION_ID);
+
+ thrown.expect(VfModuleNotFoundException.class);
+ thrown.expectMessage(errorMessage);
+ requestHandler.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, currentActiveRequest);
+ }
+
+ @Test
+ public void getIsBaseVfModuleModelVersionIdNullTest() throws ApiException {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId(MODEL_INVARIANT_ID);
+ modelInfo.setModelVersion(MODEL_VERSION);
+ modelInfo.setModelName(MODEL_NAME);
+ Boolean expected = false;
+
+ doReturn(null).when(catDbClient).getVfModuleByModelInvariantUUIDAndModelVersion(MODEL_INVARIANT_ID,
+ MODEL_VERSION);
+
+ Boolean result = requestHandler.getIsBaseVfModule(modelInfo, Action.deleteInstance, vnfType,
+ sdcServiceModelVersion, currentActiveRequest);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void getIsBaseVfModuleModelInfoNotSetTest() throws ApiException {
+ ModelInfo modelInfo = new ModelInfo();
+ Boolean expected = false;
+
+ Boolean result = requestHandler.getIsBaseVfModule(modelInfo, Action.deleteInstance, vnfType,
+ sdcServiceModelVersion, currentActiveRequest);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void getIsBaseVfModuleModelVersionNullTest() throws ApiException {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId(MODEL_INVARIANT_ID);
+ modelInfo.setModelName(MODEL_NAME);
+ Boolean expected = false;
+
+ Boolean result = requestHandler.getIsBaseVfModule(modelInfo, Action.deleteInstance, vnfType,
+ sdcServiceModelVersion, currentActiveRequest);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void getIsBaseVfModuleModelVersionNullUpdateTest() throws ApiException {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId(MODEL_INVARIANT_ID);
+ modelInfo.setModelName(MODEL_NAME);
+ String errorMessage = "VnfType vnfType and VF Module Model Name modelName not found in MSO Catalog DB";
+
+ doNothing().when(requestHandler).updateStatus(currentActiveRequest, Status.FAILED, errorMessage);
+
+ thrown.expect(VfModuleNotFoundException.class);
+ thrown.expectMessage(errorMessage);
+ requestHandler.getIsBaseVfModule(modelInfo, Action.updateInstance, vnfType, null, currentActiveRequest);
+ }
+
+ @Test
+ public void getIsBaseVfModulesdcModelVersionEmptyTest() throws ApiException {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId(MODEL_INVARIANT_ID);
+ modelInfo.setModelName(MODEL_NAME);
+ String errorMessage = "VnfType vnfType and VF Module Model Name modelName not found in MSO Catalog DB";
+
+ doNothing().when(requestHandler).updateStatus(currentActiveRequest, Status.FAILED, errorMessage);
+
+ thrown.expect(VfModuleNotFoundException.class);
+ thrown.expectMessage(errorMessage);
+ requestHandler.getIsBaseVfModule(modelInfo, Action.updateInstance, vnfType, "", currentActiveRequest);
+ }
+
+ @Test
+ public void getModelTypeApplyUpdatedConfigTest() throws ApiException {
+ ModelType modelTypeExpected = ModelType.vnf;
+
+ ModelType modelTypeResult = requestHandler.getModelType(Action.applyUpdatedConfig, null);
+ assertEquals(modelTypeResult, modelTypeExpected);
+ }
+
+ @Test
+ public void getModelTypeInPlaceSoftwareUpdateTest() throws ApiException {
+ ModelType modelTypeExpected = ModelType.vnf;
+
+ ModelType modelTypeResult = requestHandler.getModelType(Action.inPlaceSoftwareUpdate, null);
+ assertEquals(modelTypeResult, modelTypeExpected);
+ }
+
+ @Test
+ public void getModelTypeAddMembersTest() throws ApiException {
+ ModelType modelTypeExpected = ModelType.instanceGroup;
+
+ ModelType modelTypeResult = requestHandler.getModelType(Action.addMembers, null);
+ assertEquals(modelTypeResult, modelTypeExpected);
+ }
+
+ @Test
+ public void getModelTypeRemoveMembersTest() throws ApiException {
+ ModelType modelTypeExpected = ModelType.instanceGroup;
+
+ ModelType modelTypeResult = requestHandler.getModelType(Action.removeMembers, null);
+ assertEquals(modelTypeResult, modelTypeExpected);
+ }
+
+ @Test
+ public void getModelTypeTest() throws ApiException {
+ ModelType modelTypeExpected = ModelType.service;
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.service);
+
+ ModelType modelTypeResult = requestHandler.getModelType(Action.createInstance, modelInfo);
+ assertEquals(modelTypeResult, modelTypeExpected);
+ }
+
+ @Test
+ public void updateRequestorIdInRequestBodyTest() throws IOException {
+ String newRequestorId = "yyyyyy";
+ String expected = getRequestBody("/RequestBodyNewRequestorId.json");
+ String result = requestHandler.updateRequestorIdInRequestBody(infraActiveRequest, newRequestorId);
+ assertEquals(expected, result);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java
new file mode 100644
index 0000000000..1e755419be
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java
@@ -0,0 +1,483 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.apihandlerinfra;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.junit.Assert.assertEquals;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.sql.Timestamp;
+import java.util.HashMap;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Response;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.constants.Status;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.web.client.HttpClientErrorException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.serviceinstancebeans.ModelType;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ResumeOrchestrationRequestTest {
+ @Mock
+ private RequestHandlerUtils requestHandler;
+
+ @Mock
+ private MsoRequest msoRequest;
+
+ @Mock
+ private ServiceInstances serviceInstances;
+
+ @Mock
+ private RequestsDbClient requestDbClient;
+
+ @InjectMocks
+ @Spy
+ private ResumeOrchestrationRequest resumeReq;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static final String CURRENT_REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4";
+ private static final String REQUEST_ID = "00032ab7-na18-42e5-965d-8ea592502019";
+ private static final String SERVICE_INSTANCE_ID = "00032ab7-na18-42e5-965d-8ea592502018";
+ private static final String VNF_ID = "00032ab7-na18-42e5-965d-8ea592502017";
+ private static final String VFMODULE_ID = "00032ab7-na18-42e5-965d-8ea592502016";
+ private static final String NETWORK_ID = "00032ab7-na18-42e5-965d-8ea592502015";
+ private static final String VOLUME_GROUP_ID = "00032ab7-na18-42e5-965d-8ea592502014";
+ private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName";
+ private static final String VNF_NAME = "vnfName";
+ private static final String VFMODULE_NAME = "vfModuleName";
+ private static final String NETWORK_NAME = "networkName";
+ private static final String VOLUME_GROUP_NAME = "volumeGroupName";
+ private static final String SERVICE = "service";
+ private static final String VNF = "vnf";
+ private static final String VFMODULE = "vfModule";
+ private static final String NETWORK = "network";
+ private static final String VOLUME_GROUP = "volumeGroup";
+ private final Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ private final Action action = Action.createInstance;
+ private final Boolean aLaCarte = false;
+ private final String version = "7";
+ private final String requestUri =
+ "http:localhost:6746/onap/so/infra/orchestrationRequests/v7/00032ab7-na18-42e5-965d-8ea592502019/resume";
+ private final RecipeLookupResult lookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 80);
+ private RequestClientParameter requestClientParameter = null;
+ private RequestClientParameter requestClientParameterVfModule = null;
+ private ObjectMapper mapper = new ObjectMapper();
+ private InfraActiveRequests infraActiveRequest = new InfraActiveRequests();
+ private InfraActiveRequests currentActiveRequest = new InfraActiveRequests();
+ private InfraActiveRequests infraActiveRequestVfModule = new InfraActiveRequests();
+ private ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ private ServiceInstancesRequest sirNullALaCarte = new ServiceInstancesRequest();
+ private String requestBody = null;
+ private String requestBodyNullALaCarte = null;
+ private ContainerRequestContext requestContext = null;
+ private HashMap<String, String> instanceIdMap = new HashMap<>();
+ ModelInfo modelInfo;
+
+
+ @Before
+ public void setup() throws ValidateException, IOException {
+ // Setup general requestHandler mocks
+ when(requestHandler.getRequestUri(any(), anyString())).thenReturn(requestUri);
+
+ // Setup InfraActiveRequests
+ setInfraActiveRequest();
+ setCurrentActiveRequest();
+ setInfraActiveRequestVfModule();
+
+ requestBody = infraActiveRequest.getRequestBody();
+ sir = mapper.readValue(requestBody, ServiceInstancesRequest.class);
+ requestBodyNullALaCarte = getRequestBody("/ALaCarteNull.json");
+ sirNullALaCarte = mapper.readValue(requestBodyNullALaCarte, ServiceInstancesRequest.class);
+ setRequestClientParameter();
+ setRequestClientParameterVfModule();
+ instanceIdMap.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+ modelInfo = sir.getRequestDetails().getModelInfo();
+ }
+
+ public String getRequestBody(String request) throws IOException {
+ request = "src/test/resources/ResumeOrchestrationRequest" + request;
+ return new String(Files.readAllBytes(Paths.get(request)));
+ }
+
+ private void setInfraActiveRequest() throws IOException {
+ infraActiveRequest.setTenantId("tenant-id");
+ infraActiveRequest.setRequestBody(getRequestBody("/RequestBody.json"));
+ infraActiveRequest.setAicCloudRegion("cloudRegion");
+ infraActiveRequest.setRequestScope(SERVICE);
+ infraActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ infraActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME);
+ infraActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ infraActiveRequest.setRequestAction(Action.createInstance.toString());
+ infraActiveRequest.setServiceType("serviceType");
+ infraActiveRequest.setVnfId(VNF_ID);
+ infraActiveRequest.setVfModuleId(VFMODULE_ID);
+ infraActiveRequest.setNetworkId(NETWORK_ID);
+ infraActiveRequest.setVolumeGroupId(VOLUME_GROUP_ID);
+ infraActiveRequest.setVnfName(VNF_NAME);
+ infraActiveRequest.setVfModuleName(VFMODULE_NAME);
+ infraActiveRequest.setNetworkName(NETWORK_NAME);
+ infraActiveRequest.setVolumeGroupName(VOLUME_GROUP_NAME);
+ infraActiveRequest.setRequestId(REQUEST_ID);
+ }
+
+ private void setCurrentActiveRequest() throws IOException {
+ currentActiveRequest.setRequestId(CURRENT_REQUEST_ID);
+ currentActiveRequest.setSource("VID");
+ currentActiveRequest.setStartTime(startTimeStamp);
+ currentActiveRequest.setTenantId("tenant-id");
+ currentActiveRequest.setRequestBody(getRequestBody("/RequestBody.json"));
+ currentActiveRequest.setAicCloudRegion("cloudRegion");
+ currentActiveRequest.setRequestScope(SERVICE);
+ currentActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ currentActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME);
+ currentActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString());
+ currentActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ currentActiveRequest.setRequestAction(Action.createInstance.toString());
+ currentActiveRequest.setRequestUrl(requestUri);
+ currentActiveRequest.setRequestorId("xxxxxx");
+ currentActiveRequest.setProgress(new Long(5));
+ }
+
+ private void setInfraActiveRequestVfModule() throws IOException {
+ infraActiveRequestVfModule.setRequestBody(getRequestBody("/RequestBody.json"));
+ infraActiveRequestVfModule.setRequestScope(VFMODULE);
+ infraActiveRequestVfModule.setRequestStatus(Status.IN_PROGRESS.toString());
+ infraActiveRequestVfModule.setRequestAction(Action.createInstance.toString());
+ infraActiveRequestVfModule.setVnfId(VNF_ID);
+ infraActiveRequestVfModule.setVfModuleId(VFMODULE_ID);
+ infraActiveRequestVfModule.setVnfName(VNF_NAME);
+ infraActiveRequestVfModule.setVfModuleName(VFMODULE_NAME);
+ }
+
+ private void setRequestClientParameter() {
+ requestClientParameter =
+ new RequestClientParameter.Builder().setRequestId(CURRENT_REQUEST_ID).setRecipeTimeout(80)
+ .setRequestAction(Action.createInstance.toString()).setServiceInstanceId(SERVICE_INSTANCE_ID)
+ .setPnfCorrelationId("pnfCorrelationId").setVnfId(VNF_ID).setVfModuleId(VFMODULE_ID)
+ .setVolumeGroupId(VOLUME_GROUP_ID).setNetworkId(NETWORK_ID).setServiceType("serviceType")
+ .setVnfType(null).setNetworkType(null).setRequestDetails(requestBody).setApiVersion(version)
+ .setALaCarte(aLaCarte).setRequestUri(requestUri).setInstanceGroupId(null).build();
+ }
+
+ private void setRequestClientParameterVfModule() {
+ requestClientParameterVfModule =
+ new RequestClientParameter.Builder().setRequestId(CURRENT_REQUEST_ID).setRecipeTimeout(80)
+ .setRequestAction(Action.createInstance.toString()).setPnfCorrelationId("pnfCorrelationId")
+ .setVnfId(VNF_ID).setVfModuleId(VFMODULE_ID).setRequestDetails(requestBody)
+ .setApiVersion(version).setALaCarte(aLaCarte).setRequestUri(requestUri).build();
+ }
+
+ @Test
+ public void resumeOrchestationRequestTest() throws Exception {
+ Response response = null;
+ when(requestDbClient.getInfraActiveRequestbyRequestId(REQUEST_ID)).thenReturn(infraActiveRequest);
+ doReturn(currentActiveRequest).when(requestHandler).createNewRecordCopyFromInfraActiveRequest(
+ any(InfraActiveRequests.class), nullable(String.class), any(Timestamp.class), nullable(String.class),
+ nullable(String.class), nullable(String.class), anyString());
+ doReturn(response).when(resumeReq).resumeRequest(any(InfraActiveRequests.class), any(InfraActiveRequests.class),
+ anyString(), nullable(String.class));
+
+ resumeReq.resumeOrchestrationRequest(REQUEST_ID, "v7", requestContext);
+
+ verify(resumeReq).resumeRequest(infraActiveRequest, currentActiveRequest, version, null);
+ }
+
+ @Test
+ public void resumeOrchestationRequestDbNullResultTest() throws Exception {
+ when(requestDbClient.getInfraActiveRequestbyRequestId("00032ab7-na18-42e5-965d-8ea592502018")).thenReturn(null);
+
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(
+ "Null response from requestDB when searching by requestId: 00032ab7-na18-42e5-965d-8ea592502018");
+ resumeReq.resumeOrchestrationRequest("00032ab7-na18-42e5-965d-8ea592502018", "v7", requestContext);
+ }
+
+ @Test
+ public void resumeOrchestationRequestDbErrorTest() throws Exception {
+ when(requestDbClient.getInfraActiveRequestbyRequestId("00032ab7-na18-42e5-965d-8ea592502018"))
+ .thenThrow(HttpClientErrorException.class);
+
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage("Exception while performing requestDb lookup by requestId");
+ resumeReq.resumeOrchestrationRequest("00032ab7-na18-42e5-965d-8ea592502018", "v7", requestContext);
+ }
+
+ @Test
+ public void resumeRequestTest() throws ApiException, IOException {
+ Response response = null;
+ doReturn(instanceIdMap).when(resumeReq).setInstanceIdMap(infraActiveRequest, ModelType.service.toString());
+ doReturn(SERVICE_INSTANCE_NAME).when(resumeReq).getInstanceName(infraActiveRequest,
+ ModelType.service.toString(), currentActiveRequest);
+ when(requestHandler.convertJsonToServiceInstanceRequest(anyString(), any(Actions.class), anyString(),
+ anyString())).thenReturn(sir);
+ when(serviceInstances.getPnfCorrelationId(any(ServiceInstancesRequest.class))).thenReturn("pnfCorrelationId");
+ doReturn(lookupResult).when(serviceInstances).getServiceInstanceOrchestrationURI(sir, action, aLaCarte,
+ currentActiveRequest);
+ doReturn(requestClientParameter).when(resumeReq).setRequestClientParameter(lookupResult, version,
+ infraActiveRequest, currentActiveRequest, "pnfCorrelationId", aLaCarte, sir);
+ doNothing().when(resumeReq).requestDbSave(currentActiveRequest);
+ when(requestHandler.postBPELRequest(any(InfraActiveRequests.class), any(RequestClientParameter.class),
+ anyString(), anyString())).thenReturn(response);
+ doNothing().when(resumeReq).checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE,
+ SERVICE_INSTANCE_NAME, action);
+
+ resumeReq.resumeRequest(infraActiveRequest, currentActiveRequest, version,
+ "/onap/so/infra/orchestrationRequests/v7/requests/00032ab7-na18-42e5-965d-8ea592502018/resume");
+ verify(requestHandler).postBPELRequest(currentActiveRequest, requestClientParameter,
+ lookupResult.getOrchestrationURI(), infraActiveRequest.getRequestScope());
+ }
+
+ @Test
+ public void setRequestClientParameterTest() throws ApiException, IOException {
+ doReturn(ModelType.service).when(requestHandler).getModelType(action, modelInfo);
+ when(requestHandler.mapJSONtoMSOStyle(anyString(), any(ServiceInstancesRequest.class), anyBoolean(),
+ any(Action.class))).thenReturn(requestBody);
+ RequestClientParameter result = resumeReq.setRequestClientParameter(lookupResult, version, infraActiveRequest,
+ currentActiveRequest, "pnfCorrelationId", aLaCarte, sir);
+ assertThat(requestClientParameter, sameBeanAs(result));
+ }
+
+ @Test
+ public void setRequestClientParameterVfModuleTest() throws ApiException, IOException {
+ when(requestHandler.mapJSONtoMSOStyle(anyString(), any(ServiceInstancesRequest.class), anyBoolean(),
+ any(Action.class))).thenReturn(requestBody);
+ doReturn(ModelType.vfModule).when(requestHandler).getModelType(action, modelInfo);
+ RequestClientParameter result = resumeReq.setRequestClientParameter(lookupResult, version,
+ infraActiveRequestVfModule, currentActiveRequest, "pnfCorrelationId", aLaCarte, sir);
+ assertThat(requestClientParameterVfModule, sameBeanAs(result));
+ }
+
+ @Test
+ public void requestDbSaveTest() throws RequestDbFailureException {
+ doNothing().when(requestDbClient).save(currentActiveRequest);
+ resumeReq.requestDbSave(currentActiveRequest);
+ verify(requestDbClient).save(currentActiveRequest);
+ }
+
+ @Test
+ public void resumeRequestTestALaCarteNull() throws ApiException, IOException {
+ Response response = null;
+ doReturn(instanceIdMap).when(resumeReq).setInstanceIdMap(infraActiveRequest, ModelType.service.toString());
+ doReturn(SERVICE_INSTANCE_NAME).when(resumeReq).getInstanceName(infraActiveRequest,
+ ModelType.service.toString(), currentActiveRequest);
+ when(requestHandler.convertJsonToServiceInstanceRequest(anyString(), any(Actions.class), anyString(),
+ anyString())).thenReturn(sirNullALaCarte);
+ when(serviceInstances.getPnfCorrelationId(any(ServiceInstancesRequest.class))).thenReturn("pnfCorrelationId");
+ doReturn(false).when(msoRequest).getAlacarteFlag(sirNullALaCarte);
+ doReturn(lookupResult).when(serviceInstances).getServiceInstanceOrchestrationURI(sirNullALaCarte, action, false,
+ currentActiveRequest);
+ doReturn(requestClientParameter).when(resumeReq).setRequestClientParameter(lookupResult, version,
+ infraActiveRequest, currentActiveRequest, "pnfCorrelationId", aLaCarte, sirNullALaCarte);
+ doReturn(false).when(resumeReq).setALaCarteFlagIfNull(SERVICE, action);
+ doNothing().when(resumeReq).requestDbSave(currentActiveRequest);
+ when(requestHandler.postBPELRequest(any(InfraActiveRequests.class), any(RequestClientParameter.class),
+ anyString(), anyString())).thenReturn(response);
+ doNothing().when(resumeReq).checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE,
+ SERVICE_INSTANCE_NAME, action);
+
+ resumeReq.resumeRequest(infraActiveRequest, currentActiveRequest, version,
+ "/onap/so/infra/orchestrationRequests/v7/requests/00032ab7-na18-42e5-965d-8ea592502018/resume");
+ verify(requestHandler).postBPELRequest(currentActiveRequest, requestClientParameter,
+ lookupResult.getOrchestrationURI(), infraActiveRequest.getRequestScope());
+ }
+
+ @Test
+ public void setRequestClientParameterErrorTest() throws ApiException, IOException {
+ doReturn(ModelType.service).when(requestHandler).getModelType(action, modelInfo);
+ when(requestHandler.mapJSONtoMSOStyle(anyString(), any(ServiceInstancesRequest.class), anyBoolean(),
+ any(Action.class))).thenThrow(new IOException("IOException"));
+
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage("IOException while generating requestClientParameter to send to BPMN: IOException");
+ resumeReq.setRequestClientParameter(lookupResult, version, infraActiveRequest, currentActiveRequest,
+ "pnfCorrelationId", aLaCarte, sir);
+ }
+
+ @Test
+ public void checkForInProgressRequest() throws ApiException {
+ doReturn(infraActiveRequest).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME,
+ SERVICE, currentActiveRequest);
+ doReturn(true).when(requestHandler).camundaHistoryCheck(infraActiveRequest, currentActiveRequest);
+ doThrow(DuplicateRequestException.class).when(requestHandler).buildErrorOnDuplicateRecord(currentActiveRequest,
+ action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE, infraActiveRequest);
+
+ thrown.expect(DuplicateRequestException.class);
+ resumeReq.checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME,
+ action);
+ }
+
+ @Test
+ public void checkForInProgressRequestNoInProgressRequests() throws ApiException {
+ doReturn(null).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE,
+ currentActiveRequest);
+
+ resumeReq.checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME,
+ action);
+ verify(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE,
+ currentActiveRequest);
+ }
+
+ @Test
+ public void checkForInProgressRequestCamundaHistoryCheckReturnsNoInProgress() throws ApiException {
+ doReturn(infraActiveRequest).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME,
+ SERVICE, currentActiveRequest);
+ doReturn(false).when(requestHandler).camundaHistoryCheck(infraActiveRequest, currentActiveRequest);
+
+ resumeReq.checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME,
+ action);
+ verify(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE,
+ currentActiveRequest);
+ verify(requestHandler).camundaHistoryCheck(infraActiveRequest, currentActiveRequest);
+ }
+
+ @Test
+ public void setInstanceIdMapServiceTest() {
+ HashMap<String, String> expected = new HashMap<>();
+ expected.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+ HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, SERVICE);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void setInstanceIdMapRequestScopeNotValidTest() {
+ HashMap<String, String> expected = new HashMap<>();
+ HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, "test");
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void setInstanceIdMapVnfTest() {
+ HashMap<String, String> expected = new HashMap<>();
+ expected.put("vnfInstanceId", VNF_ID);
+ HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, VNF);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void setInstanceIdMapVfModuleTest() {
+ HashMap<String, String> expected = new HashMap<>();
+ expected.put("vfModuleInstanceId", VFMODULE_ID);
+ HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, VFMODULE);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void setInstanceIdMapNetworkTest() {
+ HashMap<String, String> expected = new HashMap<>();
+ expected.put("networkInstanceId", NETWORK_ID);
+ HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, NETWORK);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void setInstanceIdMapVolumeGroupTest() {
+ HashMap<String, String> expected = new HashMap<>();
+ expected.put("volumeGroupInstanceId", VOLUME_GROUP_ID);
+ HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, VOLUME_GROUP);
+ assertEquals(result, expected);
+ }
+
+ @Test
+ public void setInstanceNameServiceTest() throws ValidateException, RequestDbFailureException {
+ String result = resumeReq.getInstanceName(infraActiveRequest, SERVICE, currentActiveRequest);
+ assertEquals(result, SERVICE_INSTANCE_NAME);
+ }
+
+ @Test
+ public void setInstanceNameRequestScopeNotValidTest() throws ValidateException, RequestDbFailureException {
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(
+ "requestScope: \"test\" from request: 00032ab7-na18-42e5-965d-8ea592502019 does not match a ModelType enum.");
+
+ resumeReq.getInstanceName(infraActiveRequest, "test", currentActiveRequest);
+ }
+
+ @Test
+ public void setInstanceNameVnfTest() throws ValidateException, RequestDbFailureException {
+ String result = resumeReq.getInstanceName(infraActiveRequest, VNF, currentActiveRequest);
+ assertEquals(result, VNF_NAME);
+ }
+
+ @Test
+ public void setInstanceNameVfModuleTest() throws ValidateException, RequestDbFailureException {
+ String result = resumeReq.getInstanceName(infraActiveRequest, VFMODULE, currentActiveRequest);
+ assertEquals(result, VFMODULE_NAME);
+ }
+
+ @Test
+ public void setInstanceNameNetworkTest() throws ValidateException, RequestDbFailureException {
+ String result = resumeReq.getInstanceName(infraActiveRequest, NETWORK, currentActiveRequest);
+ assertEquals(result, NETWORK_NAME);
+ }
+
+ @Test
+ public void setInstanceNameVolumeGroupTest() throws ValidateException, RequestDbFailureException {
+ String result = resumeReq.getInstanceName(infraActiveRequest, VOLUME_GROUP, currentActiveRequest);
+ assertEquals(result, VOLUME_GROUP_NAME);
+ }
+
+ @Test
+ public void setALaCarteFlagIfNullTest() {
+ Boolean aLaCarteFlag = resumeReq.setALaCarteFlagIfNull(SERVICE, action);
+ assertEquals(aLaCarteFlag, false);
+ }
+
+ @Test
+ public void setALaCarteFlagIfNullVnfTest() {
+ Boolean aLaCarteFlag = resumeReq.setALaCarteFlagIfNull(VNF, action);
+ assertEquals(aLaCarteFlag, true);
+ }
+
+ @Test
+ public void setALaCarteFlagIfNullRecreateTest() {
+ Boolean aLaCarteFlag = resumeReq.setALaCarteFlagIfNull(VNF, Action.recreateInstance);
+ assertEquals(aLaCarteFlag, false);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index db6273dc4a..48a5343104 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -28,11 +28,14 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
import static org.onap.so.logger.MdcConstants.CLIENT_ID;
import static org.onap.so.logger.MdcConstants.ENDTIME;
import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
@@ -41,7 +44,6 @@ import static org.onap.so.logger.MdcConstants.RESPONSECODE;
import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
import static org.onap.so.logger.MdcConstants.STATUSCODE;
-import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -57,12 +59,18 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -75,7 +83,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.util.UriComponentsBuilder;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -84,7 +91,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.http.Fault;
import ch.qos.logback.classic.spi.ILoggingEvent;
-
public class ServiceInstancesTest extends BaseTest {
private final ObjectMapper mapper = new ObjectMapper();
@@ -93,6 +99,9 @@ public class ServiceInstancesTest extends BaseTest {
@Autowired
private ServiceInstances servInstances;
+ @Autowired
+ private RequestHandlerUtils requestHandlerUtils;
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -276,14 +285,13 @@ public class ServiceInstancesTest extends BaseTest {
requestReferences.setInstanceId("1882939");
requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceUriPrev7 + "v5";
+ uri = servInstanceuri + "v5";
ResponseEntity<String> response =
sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
// then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ assertEquals(404, response.getStatusCode().value());
ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
}
@Test
@@ -887,7 +895,7 @@ public class ServiceInstancesTest extends BaseTest {
ResponseEntity<String> response =
sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertEquals(404, response.getStatusCode().value());
}
@Test
@@ -2239,14 +2247,12 @@ public class ServiceInstancesTest extends BaseTest {
requestReferences.setInstanceId("1882939");
requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceUriPrev7 + "v5";
+ uri = servInstanceuri + "v5";
ResponseEntity<String> response =
sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
// then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertEquals(404, response.getStatusCode().value());
}
@Test
@@ -2389,7 +2395,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
+ "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
realResponse.getServiceException().getText());
}
@@ -2434,7 +2440,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
+ "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
realResponse.getServiceException().getText());
}
@@ -2451,7 +2457,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
+ "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
realResponse.getServiceException().getText());
}
@@ -2483,7 +2489,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
+ "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
realResponse.getServiceException().getText());
}
@@ -2503,7 +2509,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
+ "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
realResponse.getServiceException().getText());
}
@@ -2520,7 +2526,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
+ "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
realResponse.getServiceException().getText());
}
@@ -2748,5 +2754,182 @@ public class ServiceInstancesTest extends BaseTest {
"No valid modelCustomizationId for networkResourceCustomization lookup is specified");
}
+ @Test
+ public void setServiceTypeTestALaCarte() throws JsonProcessingException {
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = true;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceTypeALaCarte");
+
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceTypeALaCarte");
+ }
+
+ @Test
+ public void setServiceTypeTest() throws JsonProcessingException {
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+
+ @Test
+ public void setServiceTypeTestDefault() throws JsonProcessingException {
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+
+ @Test
+ public void setServiceTypeTestNetwork() throws JsonProcessingException {
+ String requestScope = ModelType.network.toString();
+ Boolean aLaCarteFlag = null;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelName("networkModelName");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "networkModelName");
+ }
+ @Test
+ public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
+ String requestScope = "instanceGroup";
+ ServiceInstancesRequest sir =
+ mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
+ assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
+ requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+
+ @Test
+ public void setServiceInstanceIdTest() {
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
+ requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+
+ @Test
+ public void setServiceInstanceIdReturnNullTest() {
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+
+ @Test
+ public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
+ wireMockServer.stubFor(get(
+ ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponse.json")
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertTrue(inProgress);
+ }
+
+ @Test
+ public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
+ wireMockServer.stubFor(get(
+ ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+
+ @Test
+ public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException {
+ wireMockServer.stubFor(get(
+ ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponseCompleted.json")
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+
+ @Test
+ public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
+ String replaceVfModule = inputStream("/ReplaceVfModule.json");
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
+ Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
+ assertEquals(Action.replaceInstance, action);
+ }
+
+ @Test
+ public void handleReplaceInstance_retainAssignments_Test()
+ throws JsonParseException, JsonMappingException, IOException {
+ String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
+ Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
+ assertEquals(Action.replaceInstanceRetainAssignments, action);
+ }
}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
new file mode 100644
index 0000000000..f73da49e0d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import java.io.File;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class BpmnRequestBuilderTest {
+
+ private static final String RESOURCE_PATH = "src/test/resources/__files/infra/";
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+
+ @Mock
+ private AAIResourcesClient aaiResourcesClient;
+
+ @InjectMocks
+ private AAIDataRetrieval aaiData = spy(AAIDataRetrieval.class);
+
+ @Mock
+ private RequestsDbClient requestDBClient;
+
+ @InjectMocks
+ private BpmnRequestBuilder reqBuilder = spy(BpmnRequestBuilder.class);
+
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ private GraphInventoryCommonObjectMapperProvider provider = new GraphInventoryCommonObjectMapperProvider();
+
+ @Before
+ public void setup() {
+ // aaiData.setAaiResourcesClient(aaiResourcesClient);
+ }
+
+ @Test
+ public void test_buildServiceInstanceDeleteRequest() throws Exception {
+ ServiceInstance service =
+ provider.getMapper().readValue(new File(RESOURCE_PATH + "ServiceInstance.json"), ServiceInstance.class);
+
+ doReturn(service).when(aaiData).getServiceInstance("serviceId");
+ ServiceInstancesRequest expectedRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "ExpectedServiceRequest.json"), ServiceInstancesRequest.class);
+ expectedRequest.getRequestDetails().getModelInfo().setModelId(null); // bad getter/setter setting multiple
+ // fields
+ ServiceInstancesRequest actualRequest = reqBuilder.buildServiceDeleteRequest("serviceId");
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+ @Test
+ public void test_buildVnfDeleteRequest() throws Exception {
+ GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
+
+ doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+
+ ServiceInstancesRequest expectedRequest =
+ mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest actualRequest = reqBuilder.buildVnfDeleteRequest("vnfId");
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+ @Test
+ public void test_buildVFModuleDeleteRequest() throws Exception {
+ GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
+
+ doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ VfModule vfModule = provider.getMapper().readValue(new File(RESOURCE_PATH + "VfModule.json"), VfModule.class);
+
+ doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnfId", "vfModuleId"));
+
+ ServiceInstancesRequest expectedRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "ExpectedVfModuleRequest.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest actualRequest =
+ reqBuilder.buildVFModuleDeleteRequest("vnfId", "vfModuleId", ModelType.vfModule);
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+ @Test
+ public void test_buildVolumeGroupDeleteRequest() throws Exception {
+ GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
+
+ doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"));
+ VolumeGroup volumeGroup =
+ provider.getMapper().readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
+ AAIResultWrapper wrapper = new AAIResultWrapper(volumeGroup);
+ doReturn(wrapper).when(aaiResourcesClient)
+ .get(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")
+ .relatedTo(AAIObjectType.VOLUME_GROUP, "volumeGroupId"));
+
+ ServiceInstancesRequest expectedRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "ExpectedVolumeGroupRequest.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest actualRequest = reqBuilder.buildVolumeGroupDeleteRequest("vnfId", "volumeGroupId");
+ assertThat(actualRequest, sameBeanAs(expectedRequest));
+ }
+
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
new file mode 100644
index 0000000000..d39192cdf0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandlerTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.mockito.Mockito.doReturn;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Optional;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AbstractRestHandlerTest {
+
+ @Spy
+ AbstractRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Test
+ public void test_createResponse() throws MalformedURLException {
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ URL selfLinkURL = new URL("http://localhost:8080/v1");
+ requestReferences.setInstanceId("instanceId");
+ requestReferences.setRequestId("requestId");
+ requestReferences.setRequestSelfLink(selfLinkURL);
+ expectedResponse.setRequestReferences(requestReferences);
+
+ doReturn("http://localhost:8080/v1").when(restHandler).getRequestUri(mockRequestContext);
+ doReturn(Optional.of(selfLinkURL)).when(restHandler).buildSelfLinkUrl("http://localhost:8080/v1", "requestId");
+ ServiceInstancesResponse actualResponse =
+ restHandler.createResponse("instanceId", "requestId", mockRequestContext);
+ assertThat(actualResponse, sameBeanAs(expectedResponse));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java
new file mode 100644
index 0000000000..59308215ac
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler;
+import org.onap.so.constants.Status;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class NetworkRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ NetworkRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "networkId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.network.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("NetworkId should exit in map", "networkId", actualMap.get("networkInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getNetworkName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setNetworkId("networkId").setALaCarte(true)
+ .setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "networkId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setNetworkId("networkId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestScope(ModelType.network.toString());
+ expected.setRequestUrl("http://localhost:9090");
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId",
+ "networkId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java
new file mode 100644
index 0000000000..c1e6347943
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java
@@ -0,0 +1,189 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler;
+import org.onap.so.constants.Status;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ServiceInstanceRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ ServiceInstanceRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_find_service_recipe() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setAction("createInstance");
+ doReturn(expected).when(catalogDbClient)
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ }
+
+ @Test
+ public void test_find_service_recipe_default_recipe() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setAction("createInstance");
+ doReturn(null).when(catalogDbClient)
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ doReturn(expected).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID(
+ Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
+ Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ Mockito.verify(catalogDbClient, Mockito.times(1)).findServiceRecipeByActionAndServiceModelUUID(
+ Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
+ }
+
+ @Test
+ public void test_find_service_recipe_not_found() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setAction("createInstance");
+ doReturn(null).when(catalogDbClient)
+ .findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
+ doReturn(null).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID(
+ Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
+ exceptionRule.expect(NoRecipeException.class);
+ exceptionRule.expectMessage(
+ "Unable to locate custom or default recipe for, Action: createInstance, Model UUID: testModelId");
+ restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_checkDuplicateRequest()
+ throws MalformedURLException, NoRecipeException, RequestConflictedException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.service.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("serviceInstanceId", actualMap.get("serviceInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getServiceInstanceName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected =
+ new RequestClientParameter.Builder().setRequestId("requestId").setServiceInstanceId("serviceInstanceId")
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestUrl("http://localhost:9090");
+ expected.setRequestScope(ModelType.service.toString());
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId",
+ "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java
new file mode 100644
index 0000000000..7d146791fe
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java
@@ -0,0 +1,190 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
+import org.onap.so.constants.Status;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VfModuleRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ VFModuleRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_find_vf_module_recipe() throws MalformedURLException, NoRecipeException {
+ VnfComponentsRecipe expected = new VnfComponentsRecipe();
+ expected.setAction("createInstance");
+ doReturn(expected).when(catalogDbClient)
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(),
+ Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_find_vf_module_recipe_default_recipe() throws MalformedURLException, NoRecipeException {
+ VnfComponentsRecipe expected = new VnfComponentsRecipe();
+ expected.setAction("createInstance");
+ doReturn(null).when(catalogDbClient).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
+ "testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
+ doReturn(expected).when(catalogDbClient)
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("GR-API-DEFAULT",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(),
+ Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ Mockito.verify(catalogDbClient, Mockito.times(1))
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId",
+ ModelType.vfModule.toString(), Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_find_vf_module_recipe_not_found() throws MalformedURLException, NoRecipeException {
+ VnfComponentsRecipe expected = new VnfComponentsRecipe();
+ expected.setAction("createInstance");
+ exceptionRule.expect(NoRecipeException.class);
+ exceptionRule.expectMessage(
+ "Unable to locate custom or default recipe for ModelType: vfModule , Action: createInstance, CustomizationId: testModelId");
+ restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
+ }
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "vfModuleId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.vfModule.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId"));
+ assertEquals("VFModuleId should exit in map", "vfModuleId", actualMap.get("vfModuleInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVfModuleName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setVfModuleId("vfModuleId")
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId", "vfModuleId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setVnfId("vnfId");
+ expected.setVfModuleId("vfModuleId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestUrl("http://localhost:9090");
+ expected.setRequestScope(ModelType.vfModule.toString());
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "vfModuleId",
+ "serviceInstanceId", "vnfId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java
new file mode 100644
index 0000000000..03725ec85b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler;
+import org.onap.so.constants.Status;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VnfRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ VnfRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_find_vnf_recipe() throws MalformedURLException, NoRecipeException {
+ ServiceRecipe expected = new ServiceRecipe();
+ expected.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
+ Recipe actual = restHandler.findVnfModuleRecipe("testModelId", ModelType.vnf.toString(),
+ Action.createInstance.toString());
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.vnf.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVnfName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setALaCarte(true)
+ .setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setVnfId("vnfId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestUrl("http://localhost:9090");
+ expected.setRequestScope(ModelType.vnf.toString());
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "serviceInstanceId",
+ "vnfId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java
new file mode 100644
index 0000000000..efa27743ef
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.apihandlerinfra.infra.rest.handler;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.container.ContainerRequestContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler;
+import org.onap.so.constants.Status;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VolumeRestHandlerTest {
+
+ @Rule
+ public ExpectedException exceptionRule = ExpectedException.none();
+
+ @InjectMocks
+ VolumeRestHandler restHandler;
+
+ @Mock
+ ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private RequestsDbClient infraActiveRequestsClient;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void test_checkDuplicateRequest() throws MalformedURLException, NoRecipeException {
+ ArgumentCaptor<HashMap> instanceIdCaptor = ArgumentCaptor.forClass(HashMap.class);
+ restHandler.checkDuplicateRequest("serviceInstanceId", "vnfId", "volumeGroupId", "instanceName", "requestId");
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).checkInstanceNameDuplicate(
+ instanceIdCaptor.capture(), eq("instanceName"), eq(ModelType.volumeGroup.toString()));
+ Map actualMap = instanceIdCaptor.getValue();
+ assertEquals("ServiceInstanceID should exist in map", "serviceInstanceId", actualMap.get("serviceInstanceId"));
+ assertEquals("VnfId should exit in map", "vnfId", actualMap.get("vnfInstanceId"));
+ assertEquals("VolumeGroupId should exit in map", "volumeGroupId", actualMap.get("volumeGroupInstanceId"));
+ }
+
+ @Test
+ public void test_saveInstanceName() throws MalformedURLException, NoRecipeException {
+ ServiceInstancesRequest request = createTestRequest();
+ InfraActiveRequests dbRequest = createDatabaseRecord();
+ restHandler.saveInstanceName(request, dbRequest);
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).updateInfraActiveRequests(dbRequest);
+ assertEquals("InstanceName Should Be Equal", "instanceName", dbRequest.getVolumeGroupName());
+ }
+
+ @Test
+ public void test_buildRequestParams() throws Exception {
+ RequestClientParameter expected = new RequestClientParameter.Builder().setRequestId("requestId")
+ .setServiceInstanceId("serviceInstanceId").setVnfId("vnfId").setVolumeGroupId("volumeGroupId")
+ .setALaCarte(true).setRequestDetails(mapper.writeValueAsString(createTestRequest()))
+ .setRequestAction(Action.deleteInstance.toString())
+ .setRequestUri("http://localhost:8080/serviceInstances").setApiVersion("v8").build();
+ RequestClientParameter actual = restHandler.buildRequestParams(createTestRequest(),
+ "http://localhost:8080/serviceInstances", "requestId", "serviceInstanceId", "vnfId", "volumeGroupId");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void test_createInfraActiveRequestForDelete() throws Exception {
+ InfraActiveRequests expected = new InfraActiveRequests();
+ expected.setRequestAction(Action.deleteInstance.toString());
+ expected.setAction(Action.deleteInstance.toString());
+ expected.setServiceInstanceId("serviceInstanceId");
+ expected.setVnfId("vnfId");
+ expected.setVolumeGroupId("volumeGroupId");
+ expected.setRequestId("requestId");
+ expected.setRequestorId("userId");
+ expected.setSource("VID");
+ expected.setRequestStatus(Status.IN_PROGRESS.toString());
+ expected.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ expected.setRequestScope(ModelType.volumeGroup.toString());
+ expected.setRequestUrl("http://localhost:9090");
+ InfraActiveRequests actual = restHandler.createInfraActiveRequestForDelete("requestId", "volumeGroupId",
+ "serviceInstanceId", "vnfId", "userId", "VID", "http://localhost:9090");
+ assertThat(actual, sameBeanAs(expected).ignoring("startTime"));
+ Mockito.verify(infraActiveRequestsClient, Mockito.times(1)).save(actual);
+ }
+
+ private ServiceInstancesRequest createTestRequest() {
+ ServiceInstancesRequest request = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("instanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ request.setRequestDetails(requestDetails);
+ return request;
+ }
+
+ private InfraActiveRequests createDatabaseRecord() {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId("requestId");
+ return request;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
index 9ae1e5b232..a74c11c08b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
@@ -35,9 +35,9 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.so.apihandlerinfra.BaseTest;
-import org.onap.so.apihandlerinfra.Status;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantIsolationRequest;
+import org.onap.so.constants.Status;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
index 54da0baa92..93a19a9531 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
@@ -25,15 +25,38 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import com.fasterxml.jackson.databind.ObjectMapper;
public class RelatedInstancesValidationTest extends BaseTest {
+ RelatedInstancesValidation validation = new RelatedInstancesValidation();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ public ValidationInformation setupValidationInformation(String path) throws IOException {
+ String jsonInput = new String(Files.readAllBytes(Paths.get(path)));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(jsonInput, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, null, Action.createInstance, 7, false,
+ sir.getRequestDetails().getRequestParameters());
+
+ info.setRequestScope("service");
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
+
+ info.setRequestInfo(sir.getRequestDetails().getRequestInfo());
+ return info;
+ }
+
@Test
public void testCreateVnfNetworkInstanceGroup() throws IOException, ValidationException {
String requestJson = new String(Files.readAllBytes(
@@ -50,4 +73,64 @@ public class RelatedInstancesValidationTest extends BaseTest {
assertEquals(info.getVnfType(), "Test/name");
}
+
+ @Test
+ public void testCreateSIVpnBonding() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(
+ Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(),
+ Action.createInstance, 7, false, sir.getRequestDetails().getRequestParameters());
+ info.setRequestScope("service");
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
+ RelatedInstancesValidation validation = new RelatedInstancesValidation();
+ validation.validate(info);
+ RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
+
+ assertEquals(info.getRequestScope(), "service");
+ assertEquals(instanceList[0].getRelatedInstance().getModelInfo().getModelType().toString(), "vpnBinding");
+ assertEquals(instanceList[1].getRelatedInstance().getModelInfo().getModelType().toString(), "network");
+ }
+
+ @Test
+ public void validateModelTypeExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid modelType in relatedInstance is specified");
+ validation.validate(
+ setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoModelType.json"));
+ }
+
+ @Test
+ public void validateInstanceNameVpnBindingExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid instanceName in relatedInstance for vpnBinding modelType is specified");
+ validation.validate(setupValidationInformation(
+ "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json"));
+ }
+
+ @Test
+ public void validateInstanceNameNetworkExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid instanceName in relatedInstance for network modelType is specified");
+ validation.validate(setupValidationInformation(
+ "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json"));
+ }
+
+ @Test
+ public void validateInstanceIdExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid instanceId in relatedInstance is specified");
+ validation.validate(
+ setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json"));
+ }
+
+ @Test
+ public void validatemodelInvariantIdExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid modelInvariantId in relatedInstance is specified");
+ validation.validate(setupValidationInformation(
+ "src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json"));
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json
new file mode 100644
index 0000000000..573b7a3ebb
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json
@@ -0,0 +1,57 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "vpn-name",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "network-name",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json
new file mode 100644
index 0000000000..efd80f3347
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json
@@ -0,0 +1,48 @@
+[
+ {
+ "id":"Call_BBToExecute:c4f603e4-a26e-11e9-b144-0242ac14000b",
+ "parentActivityInstanceId":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "activityId":"Call_BBToExecute",
+ "activityName":"BB to Execute",
+ "activityType":"callActivity",
+ "processDefinitionKey":"ExecuteBuildingBlock",
+ "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
+ "processInstanceId":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "executionId":"c4f603e3-a26e-11e9-b144-0242ac14000b",
+ "taskId":null,
+ "calledProcessInstanceId":"c4f603e6-a26e-11e9-b144-0242ac14000b",
+ "calledCaseInstanceId":null,
+ "assignee":null,
+ "startTime":"2019-07-09T17:27:04.607+0000",
+ "endTime":"2019-07-09T17:27:05.545+0000",
+ "durationInMillis":938,
+ "canceled":true,
+ "completeScope":false,
+ "tenantId":null,
+ "removalTime":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b"
+ },
+ {
+ "id":"EndEvent_0mvmk3i:c59b1d39-a26e-11e9-b144-0242ac14000b",
+ "parentActivityInstanceId":"SubProcess_0tv8zda:c5852427-a26e-11e9-b144-0242ac14000b",
+ "activityId":"EndEvent_0mvmk3i",
+ "activityName":null,
+ "activityType":"noneEndEvent",
+ "processDefinitionKey":"ExecuteBuildingBlock",
+ "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
+ "processInstanceId":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "executionId":"c5852426-a26e-11e9-b144-0242ac14000b",
+ "taskId":null,
+ "calledProcessInstanceId":null,
+ "calledCaseInstanceId":null,
+ "assignee":null,
+ "startTime":"2019-07-09T17:27:05.689+0000",
+ "endTime":"2019-07-09T17:27:05.689+0000",
+ "durationInMillis":0,
+ "canceled":false,
+ "completeScope":true,
+ "tenantId":null,
+ "removalTime":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b"
+ }
+ ] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
index 3b2eca7ce2..96fed36d45 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
@@ -61,7 +61,7 @@
},
"requestStatus": {
"requestState": "COMPLETE",
- "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. ROLLBACK STATUS: Rollback has been completed successfully.",
+ "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress": 100,
"timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
index 90089c0c7e..801841313a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
@@ -34,7 +34,7 @@
},
{
"request":{
- "requestId":"00032ab7-na18-42e5-965d-8ea592502018",
+ "requestId":"00032ab7-1a18-42e5-965d-8ea592502018",
"requestScope":"vfModule",
"requestType":"deleteInstance",
"requestDetails":{
@@ -58,7 +58,7 @@
},
"requestStatus":{
"requestState":"PENDING",
- "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
+ "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress":0,
"timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
@@ -298,7 +298,7 @@
},
{
"request":{
- "requestId":"00032ab7-na18-42e5-965d-8ea592502018",
+ "requestId":"00032ab7-1a18-42e5-965d-8ea592502018",
"requestScope":"instanceGroup",
"requestType":"addMembers",
"requestDetails":{
@@ -321,7 +321,7 @@
},
"requestStatus":{
"requestState":"PENDING",
- "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
+ "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress":0,
"timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
new file mode 100644
index 0000000000..faa283463b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
@@ -0,0 +1,44 @@
+[
+ {
+ "id":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "businessKey":"84eacc7b-b046-4333-9272-5e8513bdd4cc",
+ "processDefinitionId":"WorkflowActionBB:1:a461210d-a26b-11e9-b144-0242ac14000b",
+ "processDefinitionKey":"WorkflowActionBB",
+ "processDefinitionName":"WorkflowActionBB",
+ "processDefinitionVersion":1,
+ "startTime":"2019-07-09T17:27:01.299+0000",
+ "endTime":"2019-07-09T17:27:06.585+0000",
+ "removalTime":null,
+ "durationInMillis":5286,
+ "startUserId":null,
+ "startActivityId":"Start_WorkflowActionBB",
+ "deleteReason":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "superProcessInstanceId":null,
+ "superCaseInstanceId":null,
+ "caseInstanceId":null,
+ "tenantId":null,
+ "state":"COMPLETED"
+ },
+ {
+ "id":"c4c6b647-a26e-11e9-b144-0242ac14000b",
+ "businessKey":null,
+ "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
+ "processDefinitionKey":"ExecuteBuildingBlock",
+ "processDefinitionName":"ExecuteBuildingBlock",
+ "processDefinitionVersion":1,
+ "startTime":"2019-07-09T17:27:04.298+0000",
+ "endTime":"2019-07-09T17:27:05.690+0000",
+ "removalTime":null,
+ "durationInMillis":1392,
+ "startUserId":null,
+ "startActivityId":"Start_ExecuteBuildingBlock",
+ "deleteReason":null,
+ "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "superProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
+ "superCaseInstanceId":null,
+ "caseInstanceId":null,
+ "tenantId":null,
+ "state":"COMPLETED"
+ }
+ ] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json
new file mode 100644
index 0000000000..41d7e4d706
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json
@@ -0,0 +1,62 @@
+{
+ "clientRequestId": "00032ab7-3fb3-42e5-965d-8ea592502016",
+ "action": "deleteInstance",
+ "requestStatus": "COMPLETE",
+ "statusMessage": "Vf Module has been deleted successfully.",
+ "progress": 100,
+ "startTime": "2016-12-22T13:29:54.000+0000",
+ "endTime": "2016-12-22T13:30:28.000+0000",
+ "source": "VID",
+ "vnfId": "b92f60c8-8de3-46c1-8dc1-e4390ac2b005",
+ "vnfName": null,
+ "vnfType": null,
+ "serviceType": null,
+ "aicNodeClli": null,
+ "tenantId": "6accefef3cb442ff9e644d589fb04107",
+ "provStatus": null,
+ "vnfParams": null,
+ "vnfOutputs": null,
+ "requestBody": "{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"test::base::module-0\"},\"requestInfo\":{\"source\":\"VID\"},\"cloudConfiguration\":{\"tenantId\":\"6accefef3cb442ff9e644d589fb04107\",\"lcpCloudRegionId\":\"n6\"}}",
+ "responseBody": null,
+ "lastModifiedBy": "BPMN",
+ "modifyTime": "2016-12-22T13:30:28.000+0000",
+ "requestType": null,
+ "volumeGroupId": null,
+ "volumeGroupName": null,
+ "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992",
+ "vfModuleName": null,
+ "vfModuleModelName": "test::base::module-0",
+ "aaiServiceId": null,
+ "aicCloudRegion": "n6",
+ "callBackUrl": null,
+ "correlator": null,
+ "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc",
+ "serviceInstanceName": null,
+ "requestScope": "vfModule",
+ "requestAction": "deleteInstance",
+ "networkId": null,
+ "networkName": null,
+ "networkType": null,
+ "requestorId": null,
+ "configurationId": null,
+ "configurationName": null,
+ "operationalEnvId": null,
+ "operationalEnvName": null,
+ "cloudApiRequests":[
+ {
+ "id": 1,
+ "cloudIdentifier": "heatstackName/123123",
+ "requestBody":"{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ "created": "2016-12-22T13:29:54.000+0000"
+ }
+ ],
+ "requestURI": "00032ab7-3fb3-42e5-965d-8ea592502017",
+ "_links": {
+ "self": {
+ "href": "http://localhost:8087/infraActiveRequests/00032ab7-3fb3-42e5-965d-8ea592502017"
+ },
+ "infraActiveRequests": {
+ "href": "http://localhost:8087/infraActiveRequests/00032ab7-3fb3-42e5-965d-8ea592502017"
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/ALaCarteNull.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/ALaCarteNull.json
new file mode 100644
index 0000000000..5da139e711
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/ALaCarteNull.json
@@ -0,0 +1,13 @@
+{
+ "requestDetails":{
+ "requestInfo":{
+ "source":"VID",
+ "requestorId":"xxxxxx",
+ "instanceName":"testService",
+ "productFamilyId":"test"
+ },
+ "requestParameters":{
+ "usePreload": "false"
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json
new file mode 100644
index 0000000000..d6406338a0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json
@@ -0,0 +1,19 @@
+{
+ "requestDetails":{
+ "modelInfo":{
+ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965",
+ "modelVersion": "1.0",
+ "modelType":"service",
+ "modelName":"serviceModel"
+ },
+ "requestInfo":{
+ "source":"VID",
+ "requestorId":"xxxxxx",
+ "instanceName":"testService",
+ "productFamilyId":"test"
+ },
+ "requestParameters":{
+ "aLaCarte":"false"
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json
new file mode 100644
index 0000000000..740d4e2ec2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json
@@ -0,0 +1,19 @@
+{
+ "requestDetails":{
+ "modelInfo":{
+ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965",
+ "modelVersion": "1.0",
+ "modelType":"service",
+ "modelName":"serviceModel"
+ },
+ "requestInfo":{
+ "source":"VID",
+ "requestorId":"yyyyyy",
+ "instanceName":"testService",
+ "productFamilyId":"test"
+ },
+ "requestParameters":{
+ "aLaCarte":"false"
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CustomWorkflowRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CustomWorkflowRequest.json
new file mode 100644
index 0000000000..6c59ec5f1f
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/CustomWorkflowRequest.json
@@ -0,0 +1,21 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx",
+ "instanceName": "inPlaceSoftwareUpdateTest"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestParameters": {
+ "payload": "{\"request-parameters\":{\"host-ip-address\":\"10.10.10.10\"},\"configuration-parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}",
+ "userParams": [{
+ "name": "vnf-id",
+ "value": "4603ad6d-dbfb-4899-a8bd-bc1dd0d74914"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModuleRetainAssignments.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModuleRetainAssignments.json
new file mode 100644
index 0000000000..166f7ccce8
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModuleRetainAssignments.json
@@ -0,0 +1,33 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx",
+ "instanceName": "testService60"
+ },
+ "requestParameters": {
+ "aLaCarte": true,
+ "autoBuildVfModules": false,
+ "retainAssignments": true,
+ "subscriptionServiceType": "test"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "modelInfo":{
+ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7968",
+ "modelVersion":"2",
+ "modelVersionId":"78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelType":"vfModule",
+ "modelName":"serviceModel",
+ "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "MSO_1610_dev",
+ "subscriberName": "MSO_1610_dev"
+ }
+ }
+}
+
+ \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceNoOE.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceNoOE.json
new file mode 100644
index 0000000000..a6aa3e1c25
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceNoOE.json
@@ -0,0 +1,33 @@
+{
+ "serviceInstanceId":"1882939",
+ "vnfInstanceId":"1882938",
+ "networkInstanceId":"1882937",
+ "volumeGroupInstanceId":"1882935",
+ "vfModuleInstanceId":"1882934",
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "xxxxxx",
+ "instanceName": "testService9"
+ },
+ "requestParameters": {
+ "aLaCarte": true,
+ "autoBuildVfModules": false,
+ "subscriptionServiceType": "test",
+ "disableOwningEntityProject": true
+ },
+ "modelInfo":{
+ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965",
+ "modelVersion":"1",
+ "modelVersionId":"10",
+ "modelType":"service",
+ "modelName":"serviceModel",
+ "modelInstanceName":"modelInstanceName",
+ "modelCustomizationId":"f7ce78bb-423b-11e7-93f8-0050569a796"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "someTestId",
+ "subscriberName": "someTestId"
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json
new file mode 100644
index 0000000000..573b7a3ebb
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json
@@ -0,0 +1,57 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "vpn-name",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "network-name",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json
new file mode 100644
index 0000000000..97e480c8d8
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json
@@ -0,0 +1,56 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceName": "vpn-name",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "network-name",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json
new file mode 100644
index 0000000000..f7ba4761b6
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json
@@ -0,0 +1,56 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "vpn-name",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json
new file mode 100644
index 0000000000..ac570b3830
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json
@@ -0,0 +1,56 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "network-name",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json
new file mode 100644
index 0000000000..ca02c5371a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json
@@ -0,0 +1,57 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "vpn-name",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "network-name",
+ "modelInfo": {
+ "modelType": "service"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json
new file mode 100644
index 0000000000..1d46ce2ccd
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json
@@ -0,0 +1,56 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21",
+ "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "test-mgr",
+ "lcpCloudRegionId": "abc1",
+ "tenantId": "19123c2924c648eb8e42a3c1f14b7682"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "projectName"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TEST_123",
+ "subscriberName": "TEST_123"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "xxxxxx",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "vpn-name",
+ "modelInfo": {
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "instanceName": "network-name",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "subscriptionServiceType": "dev-service-type",
+ "aLaCarte": false
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json
new file mode 100644
index 0000000000..3ad3d1efec
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedServiceRequest.json
@@ -0,0 +1,20 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "modelUuid": "bad955c3-29b2-4a27-932e-28e942cc6480"
+ },
+ "requestInfo": {
+ "instanceName": "Robot_SI_For_VolumeGroup",
+ "suppressRollback": false
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json
new file mode 100644
index 0000000000..9670c3b645
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVfModuleRequest.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelCustomizationUuid": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
+ "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d"
+ },
+ "requestInfo": {
+ "instanceName": "dummy_id",
+ "suppressRollback": false
+ },
+ "cloudConfiguration": {
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "cloudOwner": "cloudOwner",
+ "lcpCloudRegionId": "regionOne"
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json
new file mode 100644
index 0000000000..59602f7ac2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVnfRequest.json
@@ -0,0 +1,20 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelCustomizationUuid": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade",
+ "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade"
+ },
+ "requestInfo": {
+ "instanceName": "Robot_VNF_For_Volume_Group",
+ "suppressRollback": false
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json
new file mode 100644
index 0000000000..ec7acf1e41
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ExpectedVolumeGroupRequest.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelCustomizationUuid": "e38906fa-717c-49b0-b391-e6ec12b50c4a",
+ "modelCustomizationId": "e38906fa-717c-49b0-b391-e6ec12b50c4a"
+ },
+ "requestInfo": {
+ "instanceName": "VolumeGroup",
+ "suppressRollback": false
+ },
+ "cloudConfiguration": {
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "cloudOwner": "cloudOwner",
+ "lcpCloudRegionId": "regionOne"
+ },
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "instanceName": [],
+ "configurationParameters": []
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json
new file mode 100644
index 0000000000..7d7a103123
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/ServiceInstance.json
@@ -0,0 +1,35 @@
+{
+ "service-instance-id": "e9fbfab4-d91c-4508-a429-2046c8751371",
+ "service-instance-name": "Robot_SI_For_VolumeGroup",
+ "environment-context": "General_Revenue-Bearing",
+ "model-invariant-id": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
+ "model-version-id": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "resource-version": "1560538276937",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "project",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/business/projects/project/GR_API_OE_MSO_Test200",
+ "relationship-data": [
+ {
+ "relationship-key": "project.project-name",
+ "relationship-value": "GR_API_OE_MSO_Test200"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v15/business/owning-entities/owning-entity/c3f57fa8-ac7d-11e8-98d0-529269fb1459",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "c3f57fa8-ac7d-11e8-98d0-529269fb1459"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json
new file mode 100644
index 0000000000..cfd9eb3e3c
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VfModule.json
@@ -0,0 +1,37 @@
+{
+ "vf-module-id": "b70060b7-0031-4065-9462-3cd5b753d2db",
+ "vf-module-name": "dummy_id",
+ "heat-stack-id": "dummy_id/stackId",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "automated-assignment": false,
+ "resource-version": "1560538368229",
+ "model-invariant-id": "f7a867f2-596b-4f4a-a128-421e825a6190",
+ "model-version-id": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
+ "model-customization-id": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
+ "module-index": 0,
+ "selflink": "/sim/restconf/config/GENERIC-RESOURCE-API:services/service/e9fbfab4-d91c-4508-a429-2046c8751371/service-data/vnfs/vnf/829924cc-8932-4875-b0af-d7a02799da9a/vnf-data//vf-modules/vf-module/dummy_id/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "volume-group",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/volume-groups/volume-group/18b220c8-af84-4b82-a8c0-41bbea6328a6",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "volume-group.volume-group-id",
+ "relationship-value": "18b220c8-af84-4b82-a8c0-41bbea6328a6"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json
new file mode 100644
index 0000000000..0b03f56caa
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/Vnf.json
@@ -0,0 +1,131 @@
+{
+ "vnf-id": "829924cc-8932-4875-b0af-d7a02799da9a",
+ "vnf-name": "Robot_VNF_For_Volume_Group",
+ "vnf-type": "Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0",
+ "service-id": "06f76284-8710-11e6-ae22-56b6b6499611",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Active",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1560538316260",
+ "model-invariant-id": "23122c9b-dd7f-483f-bf0a-e069303db2f7",
+ "model-version-id": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
+ "model-customization-id": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade",
+ "selflink": "/sim/restconf/config/GENERIC-RESOURCE-API:services/service/e9fbfab4-d91c-4508-a429-2046c8751371/service-data/vnfs/vnf/829924cc-8932-4875-b0af-d7a02799da9a/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v15/business/customers/customer/Robot_Test_Subscriber_ID/service-subscriptions/service-subscription/Robot_Test_Service_Type/service-instances/service-instance/e9fbfab4-d91c-4508-a429-2046c8751371",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Robot_Test_Subscriber_ID"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "Robot_Test_Service_Type"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "e9fbfab4-d91c-4508-a429-2046c8751371"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Robot_SI_For_VolumeGroup"
+ }
+ ]
+ },
+ {
+ "related-to": "platform",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/business/platforms/platform/vSAMP12_14-2XXX-Aug18-9001%20-%20Platform",
+ "relationship-data": [
+ {
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "vSAMP12_14-2XXX-Aug18-9001 - Platform"
+ }
+ ]
+ },
+ {
+ "related-to": "line-of-business",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v15/business/lines-of-business/line-of-business/vSAMP12_14-2XXX-Aug18-9001%20-%20LOB",
+ "relationship-data": [
+ {
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "vSAMP12_14-2XXX-Aug18-9001 - LOB"
+ }
+ ]
+ },
+ {
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "tenant.tenant-name",
+ "property-value": "tenantName"
+ }
+ ]
+ },
+ {
+ "related-to": "volume-group",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/volume-groups/volume-group/volumeGroupId",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "volume-group.volume-group-id",
+ "relationship-value": "volumeGroupId"
+ }
+ ]
+ },
+ {
+ "related-to": "cloud-region",
+ "relationship-label": "org.onap.relationships.inventory.LocatedIn",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": "LCP"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json
new file mode 100644
index 0000000000..328b82ed55
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VolumeGroup.json
@@ -0,0 +1,56 @@
+{
+ "volume-group-id": "5e6bca5b-8e14-4bdd-a419-820f68019b19",
+ "volume-group-name": "VolumeGroup",
+ "heat-stack-id": "VolumeGroup/stackId",
+ "vnf-type": "Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0",
+ "orchestration-status": "Active",
+ "model-customization-id": "e38906fa-717c-49b0-b391-e6ec12b50c4a",
+ "vf-module-model-customization-id": "e38906fa-717c-49b0-b391-e6ec12b50c4a",
+ "resource-version": "1560526466219",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/regionOne/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "regionOne"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "tenant.tenant-name",
+ "property-value": "tenantName"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v15/network/generic-vnfs/generic-vnf/82035634-1878-4fd9-ab14-04b819bea24b",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "82035634-1878-4fd9-ab14-04b819bea24b"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Robot_VNF_For_Volume_Group"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
index 712fbf54ca..27e1ae90d2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
@@ -9,14 +9,20 @@ server:
mso:
health:
endpoints:
- catalogdb: http://localhost:${wiremock.server.port}
- requestdb: http://localhost:${wiremock.server.port}
- sdnc: http://localhost:${wiremock.server.port}
- openstack: http://localhost:${wiremock.server.port}
- bpmn: http://localhost:${wiremock.server.port}
- asdc: http://localhost:${wiremock.server.port}
- requestdbattsvc: http://localhost:${wiremock.server.port}
-
+ - subsystem: apih
+ uri: http://localhost:${wiremock.server.port}
+ - subsystem: asdc
+ uri: http://localhost:${wiremock.server.port}
+ - subsystem: bpmn
+ uri: http://localhost:${wiremock.server.port}
+ - subsystem: catalogdb
+ uri: http://localhost:${wiremock.server.port}
+ - subsystem: openstack
+ uri: http://localhost:${wiremock.server.port}
+ - subsystem: requestdb
+ uri: http://localhost:${wiremock.server.port}
+ - subsystem: sdnc
+ uri: http://localhost:${wiremock.server.port}
infra-requests:
archived:
period: 180
@@ -83,6 +89,8 @@ mso:
spring:
+ jersey:
+ type: filter
datasource:
jdbcUrl: jdbc:mariadb://localhost:3307/catalogdb
username: root
@@ -97,11 +105,10 @@ spring:
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
enable-lazy-load-no-trans: true
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
- jersey:
- type: filter
+
security:
usercredentials:
- -
+ -
username: test
password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
role: InfraPortal-Client
@@ -117,7 +124,13 @@ mariaDB4j:
port: 3307
databaseName: catalogdb
databaseName2: requestdb
-
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
org:
onap:
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index bc9003f5d0..ee53e491a4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -806,6 +806,9 @@ CREATE TABLE `service` (
`WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
`SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_ORDER` varchar(200) default NULL,
+ `OVERALL_DISTRIBUTION_STATUS` varchar(45),
+ `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL,
+ `NAMING_POLICY` varchar(200) DEFAULT NULL,
PRIMARY KEY (`MODEL_UUID`),
KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`),
CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
@@ -1108,6 +1111,8 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `NF_DATA_VALID` tinyint(1) DEFAULT '0',
+ `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`),
@@ -1134,6 +1139,8 @@ CREATE TABLE `vnfc_customization` (
`MODEL_NAME` varchar(200) NOT NULL,
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
+ `RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@@ -1284,7 +1291,10 @@ CREATE TABLE `infra_active_requests` (
`CONFIGURATION_NAME` varchar(200) DEFAULT NULL,
`OPERATIONAL_ENV_ID` varchar(45) DEFAULT NULL,
`OPERATIONAL_ENV_NAME` varchar(200) DEFAULT NULL,
- `REQUEST_URL` varchar(500) DEFAULT NULL,
+ `REQUEST_URL` varchar(500) DEFAULT NULL,
+ `ORIGINAL_REQUEST_ID` varchar(45) DEFAULT NULL,
+ `EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL,
+ `ROLLBACK_EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL,
PRIMARY KEY (`REQUEST_ID`),
UNIQUE KEY `UK_bhu6w8p7wvur4pin0gjw2d5ak` (`CLIENT_REQUEST_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@@ -1460,6 +1470,16 @@ create table if not exists model (
FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE IF NOT EXISTS `requestdb`.`cloud_api_requests` (
+`ID` INT(13) NOT NULL AUTO_INCREMENT,
+`REQUEST_BODY` LONGTEXT NOT NULL,
+`CLOUD_IDENTIFIER` VARCHAR(200) NULL,
+`SO_REQUEST_ID` VARCHAR(45) NOT NULL,
+`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`ID`),
+INDEX `fk_cloud_api_requests__so_request_id_idx` (`SO_REQUEST_ID` ASC))
+ENGINE = InnoDB DEFAULT CHARSET=latin1;
+
CREATE TABLE IF NOT EXISTS `workflow` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`ARTIFACT_UUID` varchar(200) NOT NULL,
@@ -1477,8 +1497,3 @@ CREATE TABLE IF NOT EXISTS `workflow` (
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_workflow` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`SOURCE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
-
-
-
-