aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/common/ResponseBuilderTest.java73
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java72
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AllTestsTestSuite.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandlerTest.java)27
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java102
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java128
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java90
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeansTest.java)65
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java229
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java102
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java102
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java118
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java467
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java389
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestActionMapTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RequestActionMapTest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstanceBeansTest.java50
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java1407
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java123
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TestAppender.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ManualTasksTest.java)27
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetailsTest.java)142
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfoTest.java)236
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskListTest.java)493
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java)142
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValueTest.java)226
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariablesTest.java)138
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponseTest.java)138
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequestTest.java)140
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/ValueTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValueTest.java)136
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/VariablesTest.java)190
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java289
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java401
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java114
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java)55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java)30
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java)38
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/SDCDmaapClientTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/AsdcDmaapClientTest.java)13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailedTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/TasksHandlerTest.java)30
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationExceptionTest.java45
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java147
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java)23
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelperTest.java142
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java194
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java238
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java640
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java130
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java146
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java160
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java)112
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeanTest.java59
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java1327
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java60
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java624
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java248
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java96
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java1168
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java134
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java74
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java120
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java247
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java72
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java114
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java71
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java71
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java72
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java69
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java97
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java209
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java333
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java93
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java94
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelperTest.java209
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/AaiStubResponse.java57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/MockTest.java64
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java249
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java670
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java90
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java106
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java91
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationTest.java113
86 files changed, 7500 insertions, 8303 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/common/ResponseBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/common/ResponseBuilderTest.java
new file mode 100644
index 0000000000..8a45752949
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/common/ResponseBuilderTest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.common;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ResponseBuilderTest extends BaseTest {
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @Test
+ public void testBuildResponseResponse () throws ApiException {
+
+ String requestId = null;
+ String apiVersion = "1";
+ String jsonResponse = "Successfully started the process";
+
+ Response response = builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion);
+
+ assertEquals(202, response.getStatus());
+ 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("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+
+ }
+
+ @Test
+ public void testBuildResponseVersion () throws ApiException {
+
+ String requestId = "123456-67889";
+ String apiVersion = "v5";
+ String jsonResponse = "Successfully started the process";
+
+ Response response = builder.buildResponse(HttpStatus.SC_CREATED, requestId, jsonResponse, apiVersion);
+
+ assertEquals(201, response.getStatus());
+ 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("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+
+ }
+
+}
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
new file mode 100644
index 0000000000..db3dcb5af5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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/apihandler/recipe/CamundaClientErrorHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java
new file mode 100644
index 0000000000..564121b7b5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java
@@ -0,0 +1,72 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 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.recipe;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.client.ClientHttpResponse;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class CamundaClientErrorHandlerTest {
+
+ private ClientHttpResponse clientHttpResponse;
+ private CamundaClientErrorHandler clientErrorHandler;
+
+ @Before
+ public void before() {
+ clientHttpResponse = Mockito.mock(ClientHttpResponse.class);
+ clientErrorHandler = new CamundaClientErrorHandler();
+ }
+
+ @Test
+ public void handleError_SERVER_ERROR_Test() throws IOException {
+ Mockito.when(clientHttpResponse.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
+ Mockito.when(clientHttpResponse.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes()));
+ clientErrorHandler.handleError(clientHttpResponse);
+ boolean serverHasError = clientErrorHandler.hasError(clientHttpResponse);
+ assertEquals(true, serverHasError);
+ }
+
+ @Test
+ public void handleError_CLIENT_ERROR_Test() throws IOException {
+ Mockito.when(clientHttpResponse.getStatusCode()).thenReturn(HttpStatus.BAD_REQUEST);
+ Mockito.when(clientHttpResponse.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes()));
+ clientErrorHandler.handleError(clientHttpResponse);
+ boolean clientHasError = clientErrorHandler.hasError(clientHttpResponse);
+ assertEquals(true, clientHasError);
+ }
+
+ @Test
+ public void handleError_SUCCESS_Test() throws IOException {
+ Mockito.when(clientHttpResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ Mockito.when(clientHttpResponse.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes()));
+ clientErrorHandler.handleError(clientHttpResponse);
+ boolean hasNoError = clientErrorHandler.hasError(clientHttpResponse);
+ assertEquals(false, hasNoError);
+ }
+
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AllTestsTestSuite.java
index c115b7c44b..68869b77d4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AllTestsTestSuite.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
+ * 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.
@@ -18,18 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
+import org.junit.runner.RunWith;
-import org.junit.Test;
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
-public class NodeHealthcheckHandlerTest {
-
- // TODO: currently test case is done for coverage
- // later, it should be modified properly.
- NodeHealthcheckHandler test = new NodeHealthcheckHandler();
-
- @Test(expected = NullPointerException.class)
- public void nodeHealthcheckTest() throws Exception {
- test.nodeHealthcheck();
- }
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java
new file mode 100644
index 0000000000..95daf2e501
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyObject;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
+import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ApiExceptionMapperTest extends BaseTest {
+
+ ApiExceptionMapper mapper = new ApiExceptionMapper();
+
+
+ @Test
+ public void testObjectMapperError() throws JsonProcessingException {
+ ObjectMapper mockedMapper = Mockito.mock(ObjectMapper.class);
+ Mockito.when(mockedMapper.writeValueAsString(anyObject())).thenThrow(JsonProcessingException.class);
+ ValidateException validateException = new ValidateException.Builder("Test", 0 , null).build();
+ ApiExceptionMapper mockedException = Mockito.spy(new ApiExceptionMapper());
+ Mockito.doReturn(mockedMapper).when(mockedException).createObjectMapper();
+ Response resp = mockedException.toResponse((ApiException) validateException);
+
+ /// assertEquals(resp.getStatus(), HttpStatus.SC_BAD_REQUEST);
+ assertThat(resp.getEntity().toString(),startsWith("Exception in buildServiceErrorResponse writing exceptionType to string"));
+ }
+
+ @Test
+ public void testValidateResponse(){
+ ValidateException validateException = new ValidateException.Builder("Test Message", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).build();
+ Response resp = mapper.toResponse((ApiException) validateException);
+
+ assertEquals(resp.getStatus(), HttpStatus.SC_BAD_REQUEST);
+ }
+
+ @Test
+ public void testBPMNFailureResponse(){
+ BPMNFailureException bpmnException = new BPMNFailureException.Builder("Test Message", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).build();
+ Response resp = mapper.toResponse((ApiException) bpmnException);
+
+ assertEquals(resp.getStatus(), HttpStatus.SC_NOT_FOUND);
+ }
+ @Test
+ public void testClientConnectionResponse(){
+ ClientConnectionException clientConnectionException = new ClientConnectionException.Builder("test", HttpStatus.SC_INTERNAL_SERVER_ERROR,ErrorNumbers.SVC_BAD_PARAMETER).build();
+ Response resp = mapper.toResponse((ApiException) clientConnectionException);
+
+ assertEquals(resp.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+ @Test
+ public void testVFModuleResponse() {
+ VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_CONFLICT,ErrorNumbers.SVC_BAD_PARAMETER).build();
+ Response resp = mapper.toResponse((ApiException) vfModuleException);
+
+ assertEquals(resp.getStatus(), HttpStatus.SC_CONFLICT);
+ }
+ @Test
+ public void testDuplicateRequestResponse() throws IOException {
+ DuplicateRequestException duplicateRequestException = new DuplicateRequestException.Builder("Test1", "Test2","Test3","Test4", HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_BAD_PARAMETER).build();
+ Response resp = mapper.toResponse((ApiException) duplicateRequestException);
+
+ assertEquals(resp.getStatus(), HttpStatus.SC_BAD_GATEWAY);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java
new file mode 100644
index 0000000000..4e3a930955
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import org.apache.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.*;
+import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoAlarmLogger;
+import org.onap.so.logger.MsoLogger;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+
+
+public class ApiExceptionTest extends BaseTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testRecipeNotFoundException() throws ApiException {
+ thrown.expect(RecipeNotFoundException.class);
+ thrown.expectMessage("Message rewritten");
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ RecipeNotFoundException testException = new RecipeNotFoundException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).message("Message rewritten").build();
+ throw testException;
+ }
+
+
+ @Test
+ public void testBPMNFailureException() throws ApiException {
+ List<String> testVariables = new LinkedList<>();
+ testVariables.add("hello");
+ thrown.expect(BPMNFailureException.class);
+ thrown.expectMessage(startsWith("Request Failed due to BPEL error with HTTP Status ="));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ thrown.expect(hasProperty("variables",sameBeanAs(testVariables)));
+ BPMNFailureException testException = new BPMNFailureException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).variables(testVariables).build();
+ throw testException;
+ }
+
+
+ @Test
+ public void testClientConnectionException() throws ApiException {
+ IOException ioException = new IOException();
+ thrown.expect(ClientConnectionException.class);
+ thrown.expectMessage("Client from test failed to connect");
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ thrown.expect(hasProperty("cause", sameBeanAs(ioException)));
+ ClientConnectionException testException = new ClientConnectionException.Builder("test", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).cause(ioException).build();
+ throw testException;
+ }
+
+
+ @Test
+ public void testDuplicateRequestException() throws ApiException {
+ ErrorLoggerInfo testLog = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ thrown.expect(DuplicateRequestException.class);
+ thrown.expectMessage(startsWith("Error: Locked instance"));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ thrown.expect(hasProperty("errorLoggerInfo", sameBeanAs(testLog)));
+ DuplicateRequestException testException = new DuplicateRequestException.Builder("Test1", "Test2","Test3","Test4", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(testLog).build();
+ throw testException;
+ }
+
+
+ @Test
+ public void testValidateException() throws ApiException {
+ AlarmLoggerInfo testLog = new AlarmLoggerInfo.Builder("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_SDNC_ADAPTER)).build();
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage("Test Message");
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)));
+ thrown.expect(hasProperty("alarmLoggerInfo", sameBeanAs(testLog)));
+ ValidateException testException = new ValidateException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).messageID(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).alarmInfo(testLog).build();
+ throw testException;
+ }
+
+
+ @Test
+ public void testVfModuleNotFoundException() throws ApiException {
+ thrown.expect(VfModuleNotFoundException.class);
+ thrown.expectMessage("Test Message");
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_CONFLICT)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ VfModuleNotFoundException testException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).httpResponseCode(HttpStatus.SC_CONFLICT).build();
+ throw testException;
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
new file mode 100644
index 0000000000..d0426bf69f
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.transaction.Transactional;
+
+import org.junit.After;
+import org.junit.runner.RunWith;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.logger.MsoLogger.Catalog;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpHeaders;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.jdbc.Sql;
+import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.tomakehurst.wiremock.client.WireMock;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ApiHandlerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+@ContextConfiguration
+@Transactional
+@Sql(executionPhase=ExecutionPhase.AFTER_TEST_METHOD,scripts="classpath:InfraActiveRequestsReset.sql")
+@AutoConfigureWireMock(port = 0)
+public abstract class BaseTest {
+
+ protected MsoLogger logger = MsoLogger.getMsoLogger(Catalog.GENERAL, BaseTest.class);
+ protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ protected HttpHeaders headers = new HttpHeaders();
+
+ @Autowired
+ protected Environment env;
+
+ @Autowired
+ protected InfraActiveRequestsRepository iar;
+
+ @LocalServerPort
+ private int port;
+
+ protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode jsonNode = mapper.readTree(new File(fileLocation));
+ return jsonNode.asText();
+ }
+
+ protected String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
+
+ @After
+ public void tearDown(){
+ iar.deleteAll();
+ WireMock.reset();
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeansTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java
index 43f3b59e4d..68c5c918ba 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeansTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BeanMultiTest.java
@@ -1,3 +1,4 @@
+package org.onap.so.apihandlerinfra;
/*-
* ============LICENSE_START=======================================================
* ONAP - SO
@@ -7,9 +8,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.
@@ -17,56 +18,46 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
-package org.openecomp.mso.apihandlerinfra;
-
+import org.junit.Before;
import org.junit.Test;
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.PojoClassFilter;
+import com.openpojo.reflection.filters.FilterEnum;
import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.rule.impl.GetterMustExistRule;
import com.openpojo.validation.rule.impl.SetterMustExistRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.PojoClassFilter;
-import com.openpojo.reflection.filters.FilterEnum;
-import com.openpojo.reflection.filters.FilterNonConcrete;
-import com.openpojo.reflection.filters.FilterPackageInfo;
-import org.openecomp.mso.openpojo.rules.HasToStringRule;
-import org.openecomp.mso.openpojo.rules.ToStringTester;
-
-public class BeansTest {
+public class BeanMultiTest {
+ Validator validator;
+ PojoClassFilter enumFilter;
private PojoClassFilter filterTestClasses = new FilterTestClasses();
-
- private PojoClassFilter enumFilter = new FilterEnum();
-
+ @Before
+ public void setup(){
+ enumFilter = new FilterEnum();
+ validator = ValidatorBuilder.create()
+ .with(new SetterMustExistRule(),
+ new GetterMustExistRule())
+ .with(new SetterTester(),
+ new GetterTester())
+ .build();
+ }
@Test
- public void pojoStructure() {
- test("org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans");
- test("org.openecomp.mso.apihandlerinfra.tasksbeans");
- test("org.openecomp.mso.apihandlerinfra.vnfbeans");
+ public void validateBeansMsoApihandlerBeans() {
+ test("org.onap.so.apihandlerinfra.e2eserviceinstancebeans");
+ test("org.onap.so.apihandlerinfra.tasksbeans");
+ test("org.onap.so.apihandlerinfra.vnfbeans");
+ test("org.onap.so.apihandlerinfra.tenantisolationbeans");
}
- private void test(String pojoPackage) {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterMustExistRule())
-
- .with(new SetterTester())
- .with(new GetterTester())
-
- .with(new SetterTester())
- .with(new GetterTester())
- .with(new ToStringTester())
-
- .build();
-
-
- validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete());
+ private void test(String packageName) {
+ validator.validate(packageName, enumFilter, filterTestClasses);
+
}
private static class FilterTestClasses implements PojoClassFilter {
public boolean include(PojoClass pojoClass) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
new file mode 100644
index 0000000000..2baa54fdec
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
@@ -0,0 +1,229 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+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.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.tomakehurst.wiremock.http.Fault;
+
+public class E2EServiceInstancesTest extends BaseTest {
+private ObjectMapper mapper = new ObjectMapper();
+
+ private final String e2eServInstancesUri = "/e2eServiceInstances/";
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/E2EServiceInstancesTest" + JsonInput;
+ String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
+ return input;
+ }
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type",MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
+ HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
+ ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+
+ return response;
+ }
+ //Currently returning a 500 response
+ @Ignore
+ @Test
+ public void createE2EServiceInstanceNoRequestInfo() throws JsonParseException, JsonMappingException, IOException{
+ String uri = e2eServInstancesUri + "v5";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void updateE2EServiceInstanceJSONMappingError() throws JsonParseException, JsonMappingException, IOException{
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
+ ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.PUT);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
+ }
+ @Test
+ public void updateE2EServiceInstanceNoRequestorId() throws JsonParseException, JsonMappingException, IOException{
+ RequestError expectedResponse = new RequestError();
+ ServiceException exception = new ServiceException();
+ exception.setMessageId("SVC0002");
+ exception.setText("Error parsing request. Error parsing request: No valid requestorId is specified");
+ expectedResponse.setServiceException(exception);
+
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.PUT);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
+ @Test
+ public void deleteE2EServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{
+ RequestError expectedResponse = new RequestError();
+ ServiceException exception = new ServiceException();
+ exception.setMessageId("SVC1000");
+ exception.setText("No communication to catalog DB null");
+ expectedResponse.setServiceException(exception);
+
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteRequest.json"), uri, HttpMethod.DELETE);
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
+ @Test
+ public void deleteE2EServiceInstanceNotValid() throws JsonParseException, JsonMappingException, IOException{
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.DELETE);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
+ }
+ @Test
+ public void getE2EServiceInstanceNullOperationalStatus() throws JsonParseException, JsonMappingException, IOException{
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.GET);
+
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void scaleE2EServiceInstanceMappingError() throws JsonParseException, JsonMappingException, IOException{
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
+ }
+ @Test
+ public void scaleE2EServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ RequestError expectedResponse = new RequestError();
+ ServiceException exception = new ServiceException();
+ exception.setMessageId("SVC1000");
+ exception.setText("No communication to catalog DB null");
+ expectedResponse.setServiceException(exception);
+
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale";
+ ResponseEntity<String> response = sendRequest(inputStream("/ScaleRequest.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
+ @Test
+ public void compareModelWithTargetVersionBadRequest() throws JsonParseException, JsonMappingException, IOException{
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
+ }
+ @Test
+ public void compareModelWithTargetVersion() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/SuccessfulResponse.json").withStatus(org.apache.http.HttpStatus.SC_ACCEPTED)));
+
+ String expectedResponse = "success";
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
+ ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ String actualResponse = response.getBody();
+ assertEquals(expectedResponse, actualResponse);
+ }
+ @Test
+ public void compareModelWithTargetVersionEmptyResponse() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
+
+ RequestError expectedResponse = new RequestError();
+ ServiceException exception = new ServiceException();
+ exception.setMessageId("SVC1000");
+ exception.setText("Failed calling bpmn localhost:" + env.getProperty("wiremock.server.port") + " failed to respond");
+ expectedResponse.setServiceException(exception);
+
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
+ ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
+ @Test
+ public void compareModelWithTargetVersionBadBpelResponse() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
+
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
+ ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("Request Failed due to BPEL error with HTTP Status"));
+ }
+ @Test
+ public void compareModelWithTargetVersionNoBPELResponse() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody("{}").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
+
+ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
+ ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("Request Failed due to BPEL error with HTTP Status"));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java
new file mode 100644
index 0000000000..f504d88008
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java
@@ -0,0 +1,102 @@
+/*-
+ * ============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.apihandlerinfra;
+import ch.vorburger.exec.ManagedProcessException;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
+@Configuration
+@Profile({"test"})
+@EnableTransactionManagement
+@EnableJpaRepositories(
+ entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.db.catalog.data.repository"}
+ )
+public class EmbeddedCatalogDbConfig {
+
+ @Bean
+ MariaDB4jSpringService mariaDB4jSpringService() {
+ return new MariaDB4jSpringService();
+ }
+
+ @Primary
+ @Bean(name = "dataSource")
+ DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ //Create our database with default root user and no password
+ mariaDB4jSpringService.getDB().createDB(databaseName);
+
+ DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
+
+ return DataSourceBuilder
+ .create()
+ .username(datasourceUsername)
+ .password(datasourcePassword)
+ .url(config.getURL(databaseName))
+ .driverClassName(datasourceDriver)
+ .build();
+ }
+
+
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean
+ entityManagerFactory(
+ EntityManagerFactoryBuilder builder,
+ @Qualifier("dataSource") DataSource dataSource
+ ) {
+ return builder
+ .dataSource(dataSource)
+ .packages("org.onap.so.db.catalog.beans")
+ .persistenceUnit("catalogDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") EntityManagerFactory
+ entityManagerFactory
+ ) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java
new file mode 100644
index 0000000000..d150fd773a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java
@@ -0,0 +1,102 @@
+/*-
+ * ============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.apihandlerinfra;
+import ch.vorburger.exec.ManagedProcessException;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
+@Configuration
+@Profile({"test"})
+@EnableTransactionManagement
+@EnableJpaRepositories(
+ entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
+ basePackages = { "org.onap.so.db.request.data.repository" }
+ )
+public class EmbeddedRequestDbConfig {
+
+ @Bean
+ MariaDB4jSpringService mariaDB4jSpringService() {
+ return new MariaDB4jSpringService();
+ }
+
+
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "request.datasource")
+ DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
+ @Value("${mariaDB4j.databaseName2}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ //Create our database with default root user and no password
+ mariaDB4jSpringService.getDB().createDB(databaseName);
+
+ DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
+
+ return DataSourceBuilder
+ .create()
+ .username(datasourceUsername)
+ .password(datasourcePassword)
+ .url(config.getURL(databaseName))
+ .driverClassName(datasourceDriver)
+ .build();
+ }
+
+
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean
+ entityManagerFactory(
+ EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource
+ ) {
+ return builder
+ .dataSource(dataSource)
+ .packages("org.onap.so.db.request.beans")
+ .persistenceUnit("requestDB")
+ .build();
+ }
+
+
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory
+ entityManagerFactory
+ ) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java
new file mode 100644
index 0000000000..e16f265a2e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+
+import org.json.JSONException;
+import org.junit.Test;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+
+public class HealthCheckHandlerTest extends BaseTest{
+
+ @Test
+ public void testHealthcheckGet() throws JSONException {
+
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ createURLWithPort("/manage/health"),
+ HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
+ assertThat(response.getBody(), containsString("UP"));
+
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
new file mode 100644
index 0000000000..c9d83efced
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+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.assertThat;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.apache.log4j.MDC;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.tasksbeans.RequestDetails;
+import org.onap.so.apihandlerinfra.tasksbeans.RequestInfo;
+import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference;
+import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
+import org.onap.so.apihandlerinfra.tasksbeans.ValidResponses;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+
+public class ManualTasksTest extends BaseTest{
+
+ private final String basePath = "/tasks/v1/";
+
+
+
+ @Test
+ public void testCreateOpEnvObjectMapperError() throws IOException {
+ TestAppender.events.clear();
+ stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+
+ String taskId = "55";
+ TasksRequest taskReq = new TasksRequest();
+ RequestDetails reqDetail = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setRequestorId("testId");
+ reqInfo.setSource("testSource");
+ reqInfo.setResponseValue(ValidResponses.skip);
+ reqDetail.setRequestInfo(reqInfo);
+ taskReq.setRequestDetails(reqDetail);
+
+ //expected response
+ TaskRequestReference expectedResponse = new TaskRequestReference();
+ expectedResponse.setTaskId(taskId);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class);
+
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ ILoggingEvent logEvent = TestAppender.events.get(0);
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertEquals("987654321", mdc.get(MsoLogger.REQUEST_ID));
+ assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
+ 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("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ assertEquals("987654321", response.getHeaders().get("X-TransactionID").get(0));
+ MDC.remove(MsoLogger.CLIENT_ID);
+
+ }
+}
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
new file mode 100644
index 0000000000..7feea9a456
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -0,0 +1,467 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.http.HttpStatus;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.onap.so.apihandler.common.ErrorNumbers;
+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 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 {
+ private ObjectMapper mapper = new ObjectMapper();
+ private HashMap<String, String> instanceIdMapTest = new HashMap<String, String>();
+ private ServiceInstancesRequest sir;
+ private MsoRequest msoRequest;
+ private Action action;
+ private String version;
+ private int reqVersion;
+ private String originalRequestJSON;
+ private String requestJSON;
+ private boolean expected;
+ private String expectedException;
+
+ @ClassRule
+ public static final SpringClassRule SPRING_CLASS_RULE = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/MsoRequestTest" + 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")
+ public void successTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, int reqVersion) throws ValidationException, IOException{
+ this.sir = sir;
+ this.instanceIdMapTest = instanceIdMapTest;
+ this.action = action;
+ this.reqVersion = reqVersion;
+ this.version = "v" + reqVersion;
+ this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("vfModuleInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("volumeGroupInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("networkInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("configurationInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Parameters
+ private Collection<Object[]> successParameters() throws JsonParseException, JsonMappingException, IOException{
+ return Arrays.asList(new Object[][]{
+ {mapper.readValue(inputStream("/CloudConfiguration/EmptyCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "3"},
+ {mapper.readValue(inputStream("/ProjectAndOwningEntity/EmptyOwningEntityName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "5"},
+ {mapper.readValue(inputStream("/PlatformAndLineOfBusiness/OptionalLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "6"},
+ {mapper.readValue(inputStream("/ProjectAndOwningEntity/OptionalProject.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "6"},
+ {mapper.readValue(inputStream("/PlatformAndLineOfBusiness/PlatformTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "5"},
+ {mapper.readValue(inputStream("/RequestInfo/EmptyRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "3"},
+ {mapper.readValue(inputStream("/RequestInfo/ServiceProductFamilyIdFlag.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "5"},
+ {mapper.readValue(inputStream("/RequestInfo/ServiceProductFamilyIdUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "5"},
+ {mapper.readValue(inputStream("/ModelInfo/ModelCustomizationIdUsingPreload.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "5"},
+ {mapper.readValue(inputStream("/ModelInfo/ModelInvariantIdConfigurationDelete.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "3"},
+ {mapper.readValue(inputStream("/ModelInfo/ModelInvariantIdService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "4"},
+ {mapper.readValue(inputStream("/ModelInfo/ModelVersionNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "3"},
+ {mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationIdEmpty.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "5"},
+ {mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationNameNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "5"},
+ {mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "5"},
+ {mapper.readValue(inputStream("/ModelInfo/ServiceModelNameEmptyOnActivate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "2"},
+ {mapper.readValue(inputStream("/ModelInfo/ServiceModelNameEmptyOnDelete.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "2"},
+ {mapper.readValue(inputStream("/ModelInfo/ValidModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "4"},
+ {mapper.readValue(inputStream("/ModelInfo/ValidModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "5"},
+ {mapper.readValue(inputStream("/ModelInfo/ValidModelCustomizationIdService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "5"},
+ {mapper.readValue(inputStream("/RelatedInstances/RelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "5"},
+ {mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "5"},
+ {mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "6"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "6"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v5EnableService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/VnfActivate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "6"},
+ {mapper.readValue(inputStream("/RequestParameters/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "6"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v3DeleteNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "3"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v3UpdateNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "3"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v5CreateConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v6CreateConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "6"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v5EnableConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v5EnableConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v5ActivateConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "5"},
+ {mapper.readValue(inputStream("/RelatedInstances/v5ActivateNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v5DeactivateConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "5"},
+ {mapper.readValue(inputStream("/RelatedInstances/v5DeactivateNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/v6AddRelationships.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "6"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/UserParams.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "5"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/ServiceAssign.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, "7"},
+ {mapper.readValue(inputStream("/SuccessfulValidation/ServiceUnassign.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.unassignInstance, "7"}
+ });
+ }
+ @Test
+ @Parameters(method = "aLaCarteParameters")
+ public void aLaCarteFlagTest(boolean expected, ServiceInstancesRequest sir) throws JsonParseException, IOException, ValidationException{
+ this.expected = expected;
+ this.sir = sir;
+ this.msoRequest = new MsoRequest();
+ assertEquals(expected, msoRequest.getAlacarteFlag(sir));
+ }
+ @Parameters
+ private Collection<Object[]> aLaCarteParameters() throws IOException{
+ return Arrays.asList(new Object[][] {
+ {false, mapper.readValue(inputStream("/RequestParameters/RequestParametersNull.json"), ServiceInstancesRequest.class)},
+ {true, mapper.readValue(inputStream("/RequestParameters/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class)}
+ });
+ }
+ //Tests various scenarios ensuring that requests containing missing or invalid information will throw a ValidationException
+ @Test
+ @Parameters(method = "validationParameters")
+ public void validationFailureTest(String expectedException, ServiceInstancesRequest sir, HashMap<String,String> instanceIdMapTest, Action action, int reqVersion) throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.expectedException = expectedException;
+ this.sir = sir;
+ this.instanceIdMapTest = instanceIdMapTest;
+ this.action = action;
+ this.reqVersion = reqVersion;
+ this.version = "v" + reqVersion;
+ this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(expectedException);
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Parameters
+ private Collection<Object[]> validationParameters() throws IOException{
+ return Arrays.asList(new Object[][] {
+ //ValidationException for CloudConfiguration
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/CloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 4},
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/CloudConfigurationNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/CloudConfigurationVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5},
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/CloudConfigurationConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateAndCloudDelete, 7},
+ {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyLcpCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ {"No valid tenantId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid tenantId is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ //ValidationException for ModelInfo
+ {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5},
+ {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelInfo/v5CreateConfigurationModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelInfo/v4CreateVfModuleMissingModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 4},
+ {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationIdPreload.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5},
+ {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomizationName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 6},
+ {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 6},
+ {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5},
+ {"No valid model-info is specified", mapper.readValue(inputStream("/ModelInfo/ModelInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelInvariantId format is specified", mapper.readValue(inputStream("/ModelInfo/InvalidModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 2},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 4},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v5ModelInvariantIdNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v5ModelInvariantIdDisablePort.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, 5},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantIdVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantIdConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 3},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v5DeactivateModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 5},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v3UpdateNetworkBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4},
+ {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/VfModuleModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, 4},
+ {"No valid modelType is specified", mapper.readValue(inputStream("/ModelInfo/ModelTypeNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3},
+ {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
+ {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionServiceCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ConfigurationModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 4},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 4},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionIdCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v5ActivateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ //ValidationException for Platform and LineOfBusiness
+ {"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid platform is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 6},
+ {"No valid platformName is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/EmptyPlatformName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ //ValidationException for Project and OwningEntity
+ {"No valid owningEntity is specified", mapper.readValue(inputStream("/ProjectAndOwningEntity/OwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 6},
+ {"No valid owningEntityId is specified", mapper.readValue(inputStream("/ProjectAndOwningEntity/EmptyOwningEntityId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid projectName is specified", mapper.readValue(inputStream("/ProjectAndOwningEntity/EmptyProjectName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid owningEntity is specified", mapper.readValue(inputStream("/ProjectAndOwningEntity/ServiceAssignNoOE.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ //ValidationException for RelatedInstances
+ {"No valid connectionPoint relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/RelatedInstances/v5EnablePortNoConnectionPoint.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, 5},
+ {"No valid connectionPoint relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/RelatedInstances/v5EnablePortNoConnectionPoint.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
+ {"No valid destination vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/RelatedInstances/v5CreateNoDestinationRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid instanceId format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesIdFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid instanceId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid instanceName format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesNameFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid instanceName in relatedInstance for pnf modelType is specified", mapper.readValue(inputStream("/RelatedInstances/v6AddRelationshipsInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeRelationships, 6},
+ {"No valid instanceName in relatedInstance for pnf modelType is specified", mapper.readValue(inputStream("/RelatedInstances/v6AddRelationshipsInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, 6},
+ {"No valid modelCustomizationName or modelCustomizationId in relatedInstance of vnf is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid modelInfo in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelInvariantId format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelInvariantIdFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelInvariantId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelName in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelType in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelVersion in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid modelVersionId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/ServiceNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, 2},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/ServiceNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeRelationships, 2},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5EnablePortNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, 2},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5EnablePortNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5CreateNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v4RelatedInstancesNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4},
+ {"No valid related service instance for vfModule request is specified", mapper.readValue(inputStream("/RelatedInstances/VfModuleRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid related service instance for vnf request is specified", mapper.readValue(inputStream("/RelatedInstances/VnfRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid related service instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesServiceInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid related vnf instance for vfModule request is specified", mapper.readValue(inputStream("/RelatedInstances/VfModuleRelatedInstancesVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid related vnf instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesVnfInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid serviceInstanceId matching the serviceInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid serviceInstanceId matching the serviceInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstances/v6VnfDeleteInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, 6},
+ {"No valid source vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/RelatedInstances/v5CreateNoSourceRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid vnfInstanceId matching the vnfInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesVnfInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid instanceName format is specified", mapper.readValue(inputStream("/RelatedInstances/InvalidInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 2},
+ //ValidationException for RequestInfo
+ {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, 6},
+ {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/VnfProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
+ {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
+ {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3},
+ {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/ServiceProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestInfo/EmptyRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestInfo/RequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, 6},
+ {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestInfo/RequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ //ValidationException for RequestParameters
+ {"No valid aLaCarte in requestParameters", mapper.readValue(inputStream("/RequestParameters/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, 4},
+ {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters/RequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, 6},
+ {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters/RequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters/AssignEmptyReqParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ //ValidationException for SubscriberInfo
+ {"No valid globalSubscriberId is specified", mapper.readValue(inputStream("/SubscriberInfo/EmptyGlobalSubscriberId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid subscriberInfo is specified", mapper.readValue(inputStream("/SubscriberInfo/EmptySubscriberInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid subscriptionServiceType is specified", mapper.readValue(inputStream("/SubscriberInfo/EmptySubscriptionServiceType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
+ {"No valid subscriberInfo is specified", mapper.readValue(inputStream("/SubscriberInfo/AssignEmptySubscriberInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ //Validation for UserParams
+ {"No valid cloudConfiguration in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/AssignCloudConfigVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid cloudConfiguration in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkCloudConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid model-info in userParams is specified", mapper.readValue(inputStream("/RequestParameters/UserParamsModelInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid model-info in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/UserParamsVnfModelInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelVersionId in userParams is specified", mapper.readValue(inputStream("/RequestParameters/UserParamsModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelVersionId in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/VnfModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelVersionId in userParams vfModule resources is specified", mapper.readValue(inputStream("/RequestParameters/VfModuleModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelVersionId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid platform in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/UserParamsPlatform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid platformName in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/UserParamsPlatformName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid productFamilyId in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/ProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid vfModules in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/VfModules.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid model-info in userParams vfModules resources is specified", mapper.readValue(inputStream("/RequestParameters/VfModulesModelInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid model-info in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/Network.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelCustomizationId in userParams vfModule resources is specified", mapper.readValue(inputStream("/RequestParameters/VfModuleModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelCustomizationId in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ {"No valid modelCustomizationId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7}
+ });
+ }
+ @Test
+ public void nullInstanceIdMapTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/RequestParameters/RequestParametersNull.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest = null;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(NullPointerException.class);
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+
+ @Test
+ public void serviceInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("serviceInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid serviceInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void vnfInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("vnfInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid vnfInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void vfModuleInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("vfModuleInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid vfModuleInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void volumeGroupInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("volumeGroupInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid volumeGroupInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void networkInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("networkInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid networkInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void configurationInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("configurationInstanceId", "test");
+ this.action = Action.createInstance;
+ thrown.expect(ValidationException.class);
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expectMessage("No valid configurationInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void testVfModuleV4UsePreLoad() throws JsonParseException, JsonMappingException, IOException, ValidationException {
+ this.requestJSON = inputStream("/SuccessfulValidation/v4CreateVfModule.json");
+ this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ this.instanceIdMapTest.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ this.reqVersion = 4;
+ this.version = "v" + reqVersion;
+ this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+ this.msoRequest = new MsoRequest ();
+ msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, version, originalRequestJSON, reqVersion, false);
+
+ this.requestJSON = inputStream("/ModelInfo/v4CreateVfModuleNoCustomizationId.json");
+ this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ this.instanceIdMapTest.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
+ this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+ msoRequest = new MsoRequest ();
+ msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, version, originalRequestJSON, reqVersion, false);
+ }
+ @Test
+ public void buildServiceErrorResponseTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("serviceInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid serviceInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Mapping of request to JSON object failed. ",
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
+ 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));
+ }
+ @Test
+ public void buildServiceErrorPolicyExceptionResponseTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
+ this.sir = mapper.readValue(inputStream("/SuccessfulValidation/InstanceIdHashMap.json"), ServiceInstancesRequest.class);
+ this.instanceIdMapTest.put("serviceInstanceId", "test");
+ this.action = Action.createInstance;
+ this.reqVersion = 5;
+ this.version = "v" + reqVersion;
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid serviceInstanceId is specified");
+ this.msoRequest = new MsoRequest();
+
+
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.PolicyException, "Mapping of request to JSON object failed. ",
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
+ 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));
+ }
+
+ @Test
+ public void domToStrTest() throws Exception {
+ String xmlStr = "<dummy><service-instance-id>1234</service-instance-id></dummy>";
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(new InputSource(new StringReader(xmlStr)));
+ String result = MsoRequest.domToStr(document);
+ assertNotNull(result);
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..c1ee40f911
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -0,0 +1,389 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+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.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
+import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
+import org.onap.so.serviceinstancebeans.Request;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+@Transactional
+public class OrchestrationRequestsTest extends BaseTest {
+
+ @Autowired
+ private InfraActiveRequestsRepository iar;
+
+ private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";
+ public static final Response RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
+ private static final GetOrchestrationListResponse ORCHESTRATION_LIST = generateOrchestrationList();
+ private static final String INVALID_REQUEST_ID = "invalid-request-id";
+
+ private static GetOrchestrationListResponse generateOrchestrationList() {
+ GetOrchestrationListResponse list = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ list = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationList.json"),
+ GetOrchestrationListResponse.class);
+ } catch (JsonParseException jpe) {
+ jpe.printStackTrace();
+ } catch (JsonMappingException jme) {
+ jme.printStackTrace();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ return list;
+ }
+
+ @Test
+ public void testGetOrchestrationRequest() {
+
+ // TEST VALID REQUEST
+ GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
+
+ Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
+ testResponse.setRequest(request);
+ String testRequestId = request.getRequestId();
+
+ 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.OK.getStatusCode(), response.getStatusCode().value());
+ assertThat(response.getBody(),
+ sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.requestStatus.finishTime"));
+ 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("00032ab7-na18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
+ }
+
+ @Test
+ public void testGetOrchestrationRequestRequestDetails() {
+ //Test request with modelInfo request body
+ GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
+
+ Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
+ testResponse.setRequest(request);
+ String testRequestId = request.getRequestId();
+
+ 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.OK.getStatusCode(), response.getStatusCode().value());
+ assertThat(response.getBody(),
+ sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.requestStatus.finishTime"));
+ 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("00032ab7-3fb3-42e5-965d-8ea592502017", response.getHeaders().get("X-TransactionID").get(0));
+ }
+
+ @Test
+ public void testGetOrchestrationRequestNoRequestID() {
+
+ HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/"));
+
+ ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.GET, entity, GetOrchestrationListResponse.class);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void testGetOrchestrationRequestFilter() {
+ List<String> values = new ArrayList<>();
+ values.add("EQUALS");
+ values.add("vfModule");
+
+ Map<String, List<String>> orchestrationMap = new HashMap<>();
+ orchestrationMap.put("modelType", values);
+
+ List<InfraActiveRequests> requests = iar.getOrchestrationFiltersFromInfraActive(orchestrationMap);
+ HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
+
+ ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.GET, entity, GetOrchestrationListResponse.class);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ assertEquals(requests.size(), response.getBody().getRequestList().size());
+ }
+
+ @Test
+ public void testUnlockOrchestrationRequest()
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder;
+ ResponseEntity<String> response;
+ RequestError expectedRequestError;
+ RequestError actualRequestError;
+ ServiceException se;
+
+ // Test invalid JSON
+ expectedRequestError = new RequestError();
+ se = new ServiceException();
+ se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ se.setText("Orchestration RequestId 0017f68c-eb2d-45bb-b7c7-ec31b37dc349 has a status of UNLOCKED and can not be unlocked");
+ expectedRequestError.setServiceException(se);
+
+ builder = UriComponentsBuilder.fromHttpUrl(
+ createURLWithPort("/onap/so/infra/orchestrationRequests/v6/0017f68c-eb2d-45bb-b7c7-ec31b37dc349/unlock"));
+
+ response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+ actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertThat(actualRequestError, sameBeanAs(expectedRequestError));
+ }
+
+ @Test
+ public void testUnlockOrchestrationRequest_invalid_Json()
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder;
+ ResponseEntity<String> response;
+ RequestError expectedRequestError;
+ RequestError actualRequestError;
+ ServiceException se;
+
+ // Test invalid requestId
+ expectedRequestError = new RequestError();
+ se = new ServiceException();
+ se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ se.setText("Null response from RequestDB when searching by RequestId");
+ expectedRequestError.setServiceException(se);
+
+ builder = UriComponentsBuilder.fromHttpUrl(
+ createURLWithPort("/onap/so/infra/orchestrationRequests/v6/" + INVALID_REQUEST_ID + "/unlock"));
+
+ response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+ actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ assertThat(actualRequestError, sameBeanAs(expectedRequestError));
+ }
+
+ @Test
+ public void testUnlockOrchestrationRequest_Valid_Status()
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {
+
+ ObjectMapper mapper = new ObjectMapper();
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder;
+ ResponseEntity<String> response;
+ Request request;
+
+ // Test valid status
+ request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
+ builder = UriComponentsBuilder.fromHttpUrl(
+ createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + "5ffbabd6-b793-4377-a1ab-082670fbc7ac" + "/unlock"));
+
+ response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+ String status = iar.findOneByRequestId("5ffbabd6-b793-4377-a1ab-082670fbc7ac").getRequestStatus();
+
+ assertEquals("UNLOCKED", status);
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatusCode().value());
+ assertEquals(response.getBody(), null);
+ }
+
+ @Test
+ public void testUnlockOrchestrationRequest_invalid_Status()
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder;
+ ResponseEntity<String> response;
+ Request request;
+ RequestError expectedRequestError;
+ RequestError actualRequestError;
+ ServiceException se;
+ // Update UNLOCKED Request
+ request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
+ request.getRequestStatus().setRequestState(Status.UNLOCKED.toString());
+ request.getRequestStatus().setStatusMessage(null);
+ request.getRequestStatus().setPercentProgress(null);
+ request.setRequestDetails(null);
+ request.setRequestScope(null);
+ request.setRequestType(null);
+
+ // Test invalid status
+ request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
+ expectedRequestError = new RequestError();
+ se = new ServiceException();
+ se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ se.setText("Orchestration RequestId " + request.getRequestId() + " has a status of "
+ + request.getRequestStatus().getRequestState() + " and can not be unlocked");
+ expectedRequestError.setServiceException(se);
+
+ builder = UriComponentsBuilder.fromHttpUrl(
+ createURLWithPort("/onap/so/infra/orchestrationRequests/v6/" + request.getRequestId() + "/unlock"));
+
+ response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+ actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertThat(actualRequestError, sameBeanAs(expectedRequestError));
+ }
+
+ @Test
+ public void testGetOrchestrationRequestRequestDetailsWhiteSpace() {
+ InfraActiveRequests requests = new InfraActiveRequests();
+ requests.setAction("create");
+ requests.setRequestBody(" ");
+ requests.setRequestId("requestId");
+ requests.setRequestScope("service");
+ requests.setRequestType("createInstance");
+ iar.save(requests);
+
+ 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 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);
+
+ 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));
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RequestActionMapTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestActionMapTest.java
index debaa9b3cd..57513088b4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RequestActionMapTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestActionMapTest.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.
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
import org.junit.Test;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstanceBeansTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstanceBeansTest.java
new file mode 100644
index 0000000000..33d9d413d6
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstanceBeansTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.filters.FilterEnum;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.*;
+import com.openpojo.validation.test.impl.*;
+
+
+public class ServiceInstanceBeansTest extends BaseTest{
+ List<PojoClass> pojoClasses;
+ @Before
+ public void setup() {
+ pojoClasses = PojoClassFactory.getPojoClassesRecursively("org.onap.so.serviceinstancebeans", new FilterEnum());
+ }
+ @Test
+ public void validateGettersAndSetters() {
+ Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule())
+ .with(new SetterTester(), new GetterTester()).build();
+ validator.validate(pojoClasses);
+ }
+}
+
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
new file mode 100644
index 0000000000..1ab66561b0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -0,0 +1,1407 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+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 java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.log4j.MDC;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+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{
+
+ @Autowired
+ private InfraActiveRequestsRepository iar;
+
+ @Autowired
+ private ServiceInstances servInstances;
+
+ private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
+ private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
+ private String uri;
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
+ String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
+ return input;
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type",MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
+
+ HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
+ ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+
+ return response;
+ }
+
+ @Test
+ public void test_mapJSONtoMSOStyle() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
+ ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
+ assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
+ assertEquals("10",modelInfo.getModelUuid());
+
+ }
+ @Test
+ public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{
+ TestAppender.events.clear();
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ ILoggingEvent logEvent = TestAppender.events.get(0);
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(MsoLogger.REQUEST_ID));
+ assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
+ MDC.remove(MsoLogger.CLIENT_ID);
+ assertTrue(response.getBody().contains("1882939"));
+ 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("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", response.getHeaders().get("X-TransactionID").get(0));
+
+ //ExpectedRecord
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("IN_PROGRESS");
+ expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json"));
+ expectedRecord.setAction("createInstance");
+ expectedRecord.setSource("VID");
+ expectedRecord.setVnfId("1882938");
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setServiceInstanceId("1882939");
+ expectedRecord.setServiceInstanceName("testService9");
+ expectedRecord.setRequestScope("service");
+ expectedRecord.setRequestorId("xxxxxx");
+ expectedRecord.setRequestAction("createInstance");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString());
+
+ }
+ @Test
+ public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceUriPrev7 + "v5";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
+ headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST);
+
+ //ExpectedRecord
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setAction("activateInstance");
+ expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setSource("VID");
+ expectedRecord.setVnfId("1882938");
+ expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968");
+ expectedRecord.setServiceInstanceName("testService7");
+ expectedRecord.setRequestScope("service");
+ expectedRecord.setRequestAction("activateInstance");
+ expectedRecord.setRequestorId("xxxxxx");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/assign";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void enablePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void disablePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void activatePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deactivatePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void addRelationships() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
+ ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void removeRelationships() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
+ ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
+ headers.set(MsoLogger.TRANSACTION_ID, requestId);
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests record = iar.findOneByRequestId(requestId);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ assertEquals(record.getVnfType(), "vSAMP12/test");
+ }
+ @Test
+ public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified"));
+ }
+ @Test
+ public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+ ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+ ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
+ logger.debug(response.getBody());
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
+ headers.set(MsoLogger.TRANSACTION_ID, requestId);
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
+ ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests record = iar.findOneByRequestId(requestId);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertNull(record.getVnfType());
+ }
+ @Test
+ public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified"));
+ }
+ @Test
+ public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+ ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
+ logger.debug(response.getBody());
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{
+ headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setAction("createInstance");
+ expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setSource("VID");
+ expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setVfModuleName("testVfModule2");
+ expectedRecord.setVfModuleModelName("serviceModel");
+ expectedRecord.setRequestScope("vfModule");
+ expectedRecord.setRequestAction("createInstance");
+ expectedRecord.setRequestorId("zz9999");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //VnfType is not sent in this request, should be blank in db
+ expectedRecord.setVnfType("");
+ uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
+
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST);
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
+ assertNotNull(requestRecord.getStartTime());
+ assertNotNull(requestRecord.getEndTime());
+ }
+ @Test
+ public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
+ ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setRequestStatus("IN_PROGRESS");
+ req.setAction("inPlaceSoftwareUpdate");
+ req.setProgress(new Long(10));
+ req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
+ req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908");
+ req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033");
+ req.setRequestScope("vnf");
+ req.setVnfName("duplicateCheck123");
+ req.setRequestAction("inPlaceSoftwareUpdate");
+ req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ iar.save(req);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate";
+ ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
+
+ InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json"));
+
+ assertNotNull(newRecord.getServiceInstanceId());
+ assertNotNull(newRecord.getVnfId());
+
+ }
+
+ @Test
+ public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
+ ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
+ headers.set(MsoLogger.TRANSACTION_ID, requestId);
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests record = iar.findOneByRequestId(requestId);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertEquals(record.getNetworkType(), "TestNetworkType");
+ }
+ @Test
+ public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException {
+ headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //ExpectedRecord
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setStatusMessage("Error mapping request: ");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setRequestScope("network");
+ expectedRecord.setRequestAction("deleteInstance");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE);
+
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage"));
+ assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: "));
+ assertNotNull(requestRecord.getStartTime());
+ assertNotNull(requestRecord.getEndTime());
+ }
+ @Test
+ public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
+ ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiGrApi() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiVnfApi() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setAction("activateInstance");
+ expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setSource("VID");
+ expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999");
+ expectedRecord.setServiceInstanceName("testService1234");
+ expectedRecord.setRequestScope("service");
+ expectedRecord.setRequestAction("activateInstance");
+ expectedRecord.setRequestorId("xxxxxx");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //then
+ assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus());
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void invalidRequestId() throws IOException {
+ String illegalRequestId = "1234";
+ headers.set("X-ECOMP-RequestID", illegalRequestId);
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
+ }
+ @Test
+ public void invalidBPELResponse() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
+ }
+
+ @Test
+ public void invalidBPELResponse2() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
+ }
+
+ @Test
+ public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceUriPrev7 + "v5";
+ ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void testUserParams() throws JsonParseException, JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
+ RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
+ String userParamsTxt = inputStream("/userParams.txt");
+
+ List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
+ System.out.println(userParams);
+ assertTrue(userParams.size() > 0);
+ assertTrue(userParams.get(0).containsKey("name"));
+ assertTrue(userParams.get(0).containsKey("value"));
+ assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+","")));
+ }
+
+ @Test
+ public void testConfigureCloudConfig() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
+ CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
+
+ assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
+ assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
+ }
+
+ @Test
+ public void testMapToLegacyRequest() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
+ servInstances.mapToLegacyRequest(request.getRequestDetails());
+ System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
+ assertThat(request, sameBeanAs(expected));
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
new file mode 100644
index 0000000000..459214b4ce
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+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.stubFor;
+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.assertThat;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONException;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.tasksbeans.TaskList;
+import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse;
+import org.onap.so.apihandlerinfra.tasksbeans.ValidResponses;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class TasksHandlerTest extends BaseTest{
+
+ private final String basePath = "onap/so/infra/tasks/v1";
+
+ @Test
+ public void getTasksTestByOriginalRequestId() throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/sobpmnengine/task"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/GetTaskResponse.json").withStatus(HttpStatus.SC_OK)));
+
+ stubFor(get(urlPathEqualTo("/sobpmnengine/task/b5fa707a-f55a-11e7-a796-005056856d52/variables"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/GetTaskVariablesResponse.json").withStatus(HttpStatus.SC_OK)));
+
+ String requestId = "4f6fe9ac-800c-4540-a93e-10d179fa1b0a";
+
+ //expected response
+ TasksGetResponse expectedResponse = new TasksGetResponse();
+
+ List<TaskList> taskList = new ArrayList<TaskList>();
+ TaskList taskList1 = new TaskList();
+ List<String> validEntries = new ArrayList<String>();
+ validEntries.add(ValidResponses.rollback.toString());
+ validEntries.add(ValidResponses.skip.toString());
+ validEntries.add(ValidResponses.manual.toString());
+ validEntries.add(ValidResponses.abort.toString());
+ taskList1.setBuildingBlockName("UpdateConfigurationState");
+ taskList1.setBuildingBlockStep("Configurationactivate SDNO Post-Check");
+ taskList1.setErrorCode("1002");
+ taskList1.setErrorSource("SDNO");
+ taskList1.setErrorMessage("SDN-O exception: failed with message FAIL - AnsibleOperations exception: Failed : HTTP error code : 400 - Error Msg : no node list provided and no inventory file found");
+ taskList1.setNfRole("VPROBE");
+ taskList1.setType("fallout");
+ taskList1.setOriginalRequestId(requestId);
+ taskList1.setOriginalRequestorId("VID");
+ taskList1.setSubscriptionServiceType("PORT-MIRROR");
+ taskList1.setTaskId("b5fa707a-f55a-11e7-a796-005056856d52");
+ taskList1.setValidResponses(validEntries);
+ taskList.add(taskList1);
+
+ expectedResponse.setTaskList(taskList);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath))
+ .queryParam("taskId", "b5fa707a-f55a-11e7-a796-005056856d52");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ TasksGetResponse realResponse = mapper.readValue(response.getBody(), TasksGetResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ 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("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TestAppender.java
index e18bc5e911..48711a2595 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TestAppender.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.
@@ -18,21 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
-import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
+import java.util.List;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.AppenderBase;
-import org.junit.Test;
-import javax.ws.rs.core.Response;
-public class ManualTasksTest {
-
- ManualTasks task = new ManualTasks();
-
- @Test
- public void completeTaskTest(){
- Response resp = task.completeTask("test", "v2", "1882993");
- assertTrue(resp.getEntity().toString() != null);
+public class TestAppender extends AppenderBase<ILoggingEvent> {
+ public static List<ILoggingEvent> events = new ArrayList<>();
+
+ @Override
+ protected void append(ILoggingEvent loggingEvent) {
+ events.add(loggingEvent);
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java
index e501bf06ca..96ac02ae75 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import org.junit.Test;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java
index 489991162c..7cfee66d48 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import org.junit.Test;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java
index 808c701606..a3bab01dfd 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import org.junit.Test;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java
index 23676c0bba..59bfa2a1d2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import org.junit.Test;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java
index 87f9315bc9..59e10b3938 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import org.junit.Test;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetailsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java
index bfe1ff67e8..80cd0fac2f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetailsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java
@@ -1,71 +1,71 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-public class RequestDetailsTest {
-
- RequestDetails _requestDetails;
- RequestInfo _requestInfo;
-
- public RequestDetailsTest() {
- }
-
- @Before
- public void setUp() {
- _requestDetails = mock(RequestDetails.class);
- _requestInfo = new RequestInfo();
- when(_requestDetails.getRequestInfo()).thenReturn(_requestInfo);
- }
-
- @After
- public void tearDown() {
- _requestDetails = null;
- _requestInfo = null;
- }
-
- /**
- * Test of getRequestInfo method
- */
- @Test
- public void testGetRequestInfo() {
- _requestDetails.setRequestInfo(_requestInfo);
- assertTrue(_requestDetails.getRequestInfo().equals(_requestInfo));
-
- }
-
- /**
- * Test setRequestInfo
- */
- @Test
- public void testSetRequestInfo() {
- _requestDetails.setRequestInfo(_requestInfo);
- verify(_requestDetails).setRequestInfo(_requestInfo);
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+
+public class RequestDetailsTest {
+
+ RequestDetails _requestDetails;
+ RequestInfo _requestInfo;
+
+ public RequestDetailsTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _requestDetails = mock(RequestDetails.class);
+ _requestInfo = new RequestInfo();
+ when(_requestDetails.getRequestInfo()).thenReturn(_requestInfo);
+ }
+
+ @After
+ public void tearDown() {
+ _requestDetails = null;
+ _requestInfo = null;
+ }
+
+ /**
+ * Test of getRequestInfo method
+ */
+ @Test
+ public void testGetRequestInfo() {
+ _requestDetails.setRequestInfo(_requestInfo);
+ assertTrue(_requestDetails.getRequestInfo().equals(_requestInfo));
+
+ }
+
+ /**
+ * Test setRequestInfo
+ */
+ @Test
+ public void testSetRequestInfo() {
+ _requestDetails.setRequestInfo(_requestInfo);
+ verify(_requestDetails).setRequestInfo(_requestInfo);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfoTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java
index 96a1f9e04d..852376eb7a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfoTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java
@@ -1,118 +1,118 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class RequestInfoTest {
-
- RequestInfo _requestInfo;
- String _source;
- ValidResponses _responseValue;
- String _requestorId;
-
- public RequestInfoTest() {
- }
-
- @Before
- public void setUp() {
- _requestInfo = mock(RequestInfo.class);
- _responseValue = ValidResponses.abort;
- _requestorId = "ab1234";
- _source = "VID";
- when(_requestInfo.getRequestorId()).thenReturn(_requestorId);
- when(_requestInfo.getSource()).thenReturn(_source);
- when(_requestInfo.getResponseValue()).thenReturn(_responseValue);
-
- }
-
- @After
- public void tearDown() {
- _requestInfo = null;
- _responseValue = null;
- }
-
- /**
- * Test of getSource method
- */
- @Test
- public void testGetSource() {
- String result = _requestInfo.getSource();
- assertEquals(_source, result);
-
- }
-
- /**
- * Test setSource
- */
- @Test
- public void testSetSource() {
- _requestInfo.setSource("VID");
- verify(_requestInfo).setSource(_source);
- }
-
- /**
- * Test of getRequestorId method
- */
- @Test
- public void testGetRequestorId() {
- String result = _requestInfo.getRequestorId();
- assertEquals(_requestorId, result);
-
- }
-
- /**
- * Test setRequestInfo
- */
- @Test
- public void testSetRequestorId() {
- _requestInfo.setRequestorId(_requestorId);
- verify(_requestInfo).setRequestorId(_requestorId);
- }
-
-
- /**
- * Test of getResponseValue method
- */
- @Test
- public void testGetResponseValue() {
- ValidResponses result = _requestInfo.getResponseValue();
- assertEquals(_responseValue, result);
-
- }
-
- /**
- * Test setResponseValues method
- */
- @Test
- public void testSetResponseValue() {
- _requestInfo.setResponseValue(ValidResponses.abort);
- verify(_requestInfo).setResponseValue(_responseValue);
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class RequestInfoTest {
+
+ RequestInfo _requestInfo;
+ String _source;
+ ValidResponses _responseValue;
+ String _requestorId;
+
+ public RequestInfoTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _requestInfo = mock(RequestInfo.class);
+ _responseValue = ValidResponses.abort;
+ _requestorId = "xxxxxx";
+ _source = "VID";
+ when(_requestInfo.getRequestorId()).thenReturn(_requestorId);
+ when(_requestInfo.getSource()).thenReturn(_source);
+ when(_requestInfo.getResponseValue()).thenReturn(_responseValue);
+
+ }
+
+ @After
+ public void tearDown() {
+ _requestInfo = null;
+ _responseValue = null;
+ }
+
+ /**
+ * Test of getSource method
+ */
+ @Test
+ public void testGetSource() {
+ String result = _requestInfo.getSource();
+ assertEquals(_source, result);
+
+ }
+
+ /**
+ * Test setSource
+ */
+ @Test
+ public void testSetSource() {
+ _requestInfo.setSource("VID");
+ verify(_requestInfo).setSource(_source);
+ }
+
+ /**
+ * Test of getRequestorId method
+ */
+ @Test
+ public void testGetRequestorId() {
+ String result = _requestInfo.getRequestorId();
+ assertEquals(_requestorId, result);
+
+ }
+
+ /**
+ * Test setRequestInfo
+ */
+ @Test
+ public void testSetRequestorId() {
+ _requestInfo.setRequestorId(_requestorId);
+ verify(_requestInfo).setRequestorId(_requestorId);
+ }
+
+
+ /**
+ * Test of getResponseValue method
+ */
+ @Test
+ public void testGetResponseValue() {
+ ValidResponses result = _requestInfo.getResponseValue();
+ assertEquals(_responseValue, result);
+
+ }
+
+ /**
+ * Test setResponseValues method
+ */
+ @Test
+ public void testSetResponseValue() {
+ _requestInfo.setResponseValue(ValidResponses.abort);
+ verify(_requestInfo).setResponseValue(_responseValue);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskListTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java
index 4909407722..62bfee989b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskListTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java
@@ -1,246 +1,247 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.json.JSONArray;
-
-public class TaskListTest {
-
- TaskList _taskList;
- protected String _taskId;
- protected String _type;
- protected String _nfRole;
- protected String _subscriptionServiceType;
- protected String _originalRequestId;
- protected String _originalRequestorId;
- protected String _errorSource;
- protected String _errorCode;
- protected String _errorMessage;
- protected String _buildingBlockName;
- protected String _buildingBlockStep;
- protected JSONArray _validResponses;
-
- public TaskListTest() {
- }
-
- @Before
- public void setUp() {
- _taskList = mock(TaskList.class);
- _taskId = "_taskid";
- _type = "type";
- _nfRole = "nfrole";
- _subscriptionServiceType = "subscriptionservicetype";
- _originalRequestId = "originalrequestid";
- _originalRequestorId = "originalrequestorid";
- _errorSource = "errorsource";
- _errorCode = "errorcode";
- _errorMessage = "errormessage";
- _buildingBlockName = "buildingblockname";
- _buildingBlockStep = "buildingblockstep";
- _validResponses = mock(JSONArray.class);
-
- when(_taskList.getTaskId()).thenReturn(_taskId);
- when(_taskList.getType()).thenReturn(_type);
- when(_taskList.getNfRole()).thenReturn(_nfRole);
- when(_taskList.getSubscriptionServiceType()).thenReturn(_subscriptionServiceType);
- when(_taskList.getOriginalRequestId()).thenReturn(_originalRequestId);
- when(_taskList.getOriginalRequestorId()).thenReturn(_originalRequestorId);
- when(_taskList.getErrorSource()).thenReturn(_errorSource);
- when(_taskList.getErrorCode()).thenReturn(_errorCode);
- when(_taskList.getErrorMessage()).thenReturn(_errorMessage);
- when(_taskList.getBuildingBlockName()).thenReturn(_buildingBlockName);
- when(_taskList.getBuildingBlockStep()).thenReturn(_buildingBlockStep);
- when(_taskList.getValidResponses()).thenReturn(_validResponses);
- }
-
- @After
- public void tearDown() {
- _taskList = null;
- _validResponses = null;
- }
-
- @Test
- public void testGetTaskId() {
- String result = _taskList.getTaskId();
- assertEquals(_taskId, result);
-
- }
-
- @Test
- public void testSetTaskId() {
- _taskList.setTaskId("_taskid");
- verify(_taskList).setTaskId(_taskId);
- }
-
- @Test
- public void testGetType() {
- String result = _taskList.getType();
- assertEquals(_type, result);
-
- }
-
- @Test
- public void testSetType() {
- _taskList.setType(_type);
- verify(_taskList).setType(_type);
- }
-
- @Test
- public void testGetNfRole() {
- String result = _taskList.getNfRole();
- assertEquals(_nfRole, result);
-
- }
-
- @Test
- public void testSetNfRole() {
- _taskList.setType(_nfRole);
- verify(_taskList).setType(_nfRole);
- }
-
- @Test
- public void testGetSubscriptionServiceType() {
- String result = _taskList.getSubscriptionServiceType();
- assertEquals(_subscriptionServiceType, result);
-
- }
-
- @Test
- public void testSetSubscriptionServiceType() {
- _taskList.setSubscriptionServiceType(_subscriptionServiceType);
- verify(_taskList).setSubscriptionServiceType(_subscriptionServiceType);
- }
-
- @Test
- public void testGetOriginalRequestId() {
- String result = _taskList.getOriginalRequestId();
- assertEquals(_originalRequestId, result);
-
- }
-
- @Test
- public void testSetOriginalRequestId() {
- _taskList.setOriginalRequestId(_originalRequestId);
- verify(_taskList).setOriginalRequestId(_originalRequestId);
- }
-
- @Test
- public void testGetOriginalRequestorId() {
- String result = _taskList.getOriginalRequestorId();
- assertEquals(_originalRequestorId, result);
-
- }
-
- @Test
- public void testSetOriginalRequestorId() {
- _taskList.setOriginalRequestorId(_originalRequestorId);
- verify(_taskList).setOriginalRequestorId(_originalRequestorId);
- }
-
- @Test
- public void testGetErrorSource() {
- String result = _taskList.getErrorSource();
- assertEquals(_errorSource, result);
-
- }
-
- @Test
- public void testSetErrorSource() {
- _taskList.setErrorSource(_errorSource);
- verify(_taskList).setErrorSource(_errorSource);
- }
-
- @Test
- public void testGetErrorCode() {
- String result = _taskList.getErrorCode();
- assertEquals(_errorCode, result);
-
- }
-
- @Test
- public void testSetErrorCode() {
- _taskList.setErrorCode(_errorCode);
- verify(_taskList).setErrorCode(_errorCode);
- }
-
- @Test
- public void testGetErrorMessage() {
- String result = _taskList.getErrorMessage();
- assertEquals(_errorMessage, result);
-
- }
-
- @Test
- public void testSetErrorMessage() {
- _taskList.setErrorMessage(_errorMessage);
- verify(_taskList).setErrorMessage(_errorMessage);
- }
-
- @Test
- public void testGetBuildingBlockName() {
- String result = _taskList.getBuildingBlockName();
- assertEquals(_buildingBlockName, result);
-
- }
-
- @Test
- public void testSetBuildingBlockName() {
- _taskList.setBuildingBlockName(_buildingBlockName);
- verify(_taskList).setBuildingBlockName(_buildingBlockName);
- }
-
- @Test
- public void testGetBuildingBlockStep() {
- String result = _taskList.getBuildingBlockStep();
- assertEquals(_buildingBlockStep, result);
-
- }
-
- @Test
- public void testSetBuildingBlockStep() {
- _taskList.setBuildingBlockStep(_buildingBlockStep);
- verify(_taskList).setBuildingBlockStep(_buildingBlockStep);
- }
-
- @Test
- public void testGetValidResponses() {
-
- JSONArray result = _taskList.getValidResponses();
- assertEquals(_validResponses, result);
-
- }
-
- @Test
- public void testSetValidResponses() {
- _taskList.setValidResponses(_validResponses);
- verify(_taskList).setValidResponses(_validResponses);
- }
-
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TaskListTest {
+
+ TaskList _taskList;
+ protected String _taskId;
+ protected String _type;
+ protected String _nfRole;
+ protected String _subscriptionServiceType;
+ protected String _originalRequestId;
+ protected String _originalRequestorId;
+ protected String _errorSource;
+ protected String _errorCode;
+ protected String _errorMessage;
+ protected String _buildingBlockName;
+ protected String _buildingBlockStep;
+ protected List<String> _validResponses;
+
+ public TaskListTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _taskList = mock(TaskList.class);
+ _taskId = "_taskid";
+ _type = "type";
+ _nfRole = "nfrole";
+ _subscriptionServiceType = "subscriptionservicetype";
+ _originalRequestId = "originalrequestid";
+ _originalRequestorId = "originalrequestorid";
+ _errorSource = "errorsource";
+ _errorCode = "errorcode";
+ _errorMessage = "errormessage";
+ _buildingBlockName = "buildingblockname";
+ _buildingBlockStep = "buildingblockstep";
+ _validResponses = mock(List.class);
+
+ when(_taskList.getTaskId()).thenReturn(_taskId);
+ when(_taskList.getType()).thenReturn(_type);
+ when(_taskList.getNfRole()).thenReturn(_nfRole);
+ when(_taskList.getSubscriptionServiceType()).thenReturn(_subscriptionServiceType);
+ when(_taskList.getOriginalRequestId()).thenReturn(_originalRequestId);
+ when(_taskList.getOriginalRequestorId()).thenReturn(_originalRequestorId);
+ when(_taskList.getErrorSource()).thenReturn(_errorSource);
+ when(_taskList.getErrorCode()).thenReturn(_errorCode);
+ when(_taskList.getErrorMessage()).thenReturn(_errorMessage);
+ when(_taskList.getBuildingBlockName()).thenReturn(_buildingBlockName);
+ when(_taskList.getBuildingBlockStep()).thenReturn(_buildingBlockStep);
+ when(_taskList.getValidResponses()).thenReturn(_validResponses);
+ }
+
+ @After
+ public void tearDown() {
+ _taskList = null;
+ _validResponses = null;
+ }
+
+ @Test
+ public void testGetTaskId() {
+ String result = _taskList.getTaskId();
+ assertEquals(_taskId, result);
+
+ }
+
+ @Test
+ public void testSetTaskId() {
+ _taskList.setTaskId("_taskid");
+ verify(_taskList).setTaskId(_taskId);
+ }
+
+ @Test
+ public void testGetType() {
+ String result = _taskList.getType();
+ assertEquals(_type, result);
+
+ }
+
+ @Test
+ public void testSetType() {
+ _taskList.setType(_type);
+ verify(_taskList).setType(_type);
+ }
+
+ @Test
+ public void testGetNfRole() {
+ String result = _taskList.getNfRole();
+ assertEquals(_nfRole, result);
+
+ }
+
+ @Test
+ public void testSetNfRole() {
+ _taskList.setType(_nfRole);
+ verify(_taskList).setType(_nfRole);
+ }
+
+ @Test
+ public void testGetSubscriptionServiceType() {
+ String result = _taskList.getSubscriptionServiceType();
+ assertEquals(_subscriptionServiceType, result);
+
+ }
+
+ @Test
+ public void testSetSubscriptionServiceType() {
+ _taskList.setSubscriptionServiceType(_subscriptionServiceType);
+ verify(_taskList).setSubscriptionServiceType(_subscriptionServiceType);
+ }
+
+ @Test
+ public void testGetOriginalRequestId() {
+ String result = _taskList.getOriginalRequestId();
+ assertEquals(_originalRequestId, result);
+
+ }
+
+ @Test
+ public void testSetOriginalRequestId() {
+ _taskList.setOriginalRequestId(_originalRequestId);
+ verify(_taskList).setOriginalRequestId(_originalRequestId);
+ }
+
+ @Test
+ public void testGetOriginalRequestorId() {
+ String result = _taskList.getOriginalRequestorId();
+ assertEquals(_originalRequestorId, result);
+
+ }
+
+ @Test
+ public void testSetOriginalRequestorId() {
+ _taskList.setOriginalRequestorId(_originalRequestorId);
+ verify(_taskList).setOriginalRequestorId(_originalRequestorId);
+ }
+
+ @Test
+ public void testGetErrorSource() {
+ String result = _taskList.getErrorSource();
+ assertEquals(_errorSource, result);
+
+ }
+
+ @Test
+ public void testSetErrorSource() {
+ _taskList.setErrorSource(_errorSource);
+ verify(_taskList).setErrorSource(_errorSource);
+ }
+
+ @Test
+ public void testGetErrorCode() {
+ String result = _taskList.getErrorCode();
+ assertEquals(_errorCode, result);
+
+ }
+
+ @Test
+ public void testSetErrorCode() {
+ _taskList.setErrorCode(_errorCode);
+ verify(_taskList).setErrorCode(_errorCode);
+ }
+
+ @Test
+ public void testGetErrorMessage() {
+ String result = _taskList.getErrorMessage();
+ assertEquals(_errorMessage, result);
+
+ }
+
+ @Test
+ public void testSetErrorMessage() {
+ _taskList.setErrorMessage(_errorMessage);
+ verify(_taskList).setErrorMessage(_errorMessage);
+ }
+
+ @Test
+ public void testGetBuildingBlockName() {
+ String result = _taskList.getBuildingBlockName();
+ assertEquals(_buildingBlockName, result);
+
+ }
+
+ @Test
+ public void testSetBuildingBlockName() {
+ _taskList.setBuildingBlockName(_buildingBlockName);
+ verify(_taskList).setBuildingBlockName(_buildingBlockName);
+ }
+
+ @Test
+ public void testGetBuildingBlockStep() {
+ String result = _taskList.getBuildingBlockStep();
+ assertEquals(_buildingBlockStep, result);
+
+ }
+
+ @Test
+ public void testSetBuildingBlockStep() {
+ _taskList.setBuildingBlockStep(_buildingBlockStep);
+ verify(_taskList).setBuildingBlockStep(_buildingBlockStep);
+ }
+
+ @Test
+ public void testGetValidResponses() {
+
+ List<String> result = _taskList.getValidResponses();
+ assertEquals(_validResponses, result);
+
+ }
+
+ @Test
+ public void testSetValidResponses() {
+ _taskList.setValidResponses(_validResponses);
+ verify(_taskList).setValidResponses(_validResponses);
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java
index 6d9df82f87..043f4ea93d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java
@@ -1,71 +1,71 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TaskRequestReferenceTest {
-
- TaskRequestReference _taskRequestReference;
-
- protected String _taskId;
- public TaskRequestReferenceTest() {
- }
-
- @Before
- public void setUp() {
- _taskRequestReference = mock(TaskRequestReference.class);
- _taskId = "taskid";
-
- when(_taskRequestReference.getTaskId()).thenReturn(_taskId);
- }
-
- @After
- public void tearDown() {
- _taskRequestReference = null;
- }
-
- /**
- * Test getTaskRequestReference
- */
- @Test
- public void taskGetRequestReference() {
- String result = _taskRequestReference.getTaskId();
- assertEquals(_taskId, result);
- }
-
- /**
- * Test setTaskRequestReference
- */
- @Test
- public void testSetRequestInfo() {
- _taskRequestReference.setTaskId(_taskId);
- verify(_taskRequestReference).setTaskId(_taskId);
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class TaskRequestReferenceTest {
+
+ TaskRequestReference _taskRequestReference;
+
+ protected String _taskId;
+ public TaskRequestReferenceTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _taskRequestReference = mock(TaskRequestReference.class);
+ _taskId = "taskid";
+
+ when(_taskRequestReference.getTaskId()).thenReturn(_taskId);
+ }
+
+ @After
+ public void tearDown() {
+ _taskRequestReference = null;
+ }
+
+ /**
+ * Test getTaskRequestReference
+ */
+ @Test
+ public void taskGetRequestReference() {
+ String result = _taskRequestReference.getTaskId();
+ assertEquals(_taskId, result);
+ }
+
+ /**
+ * Test setTaskRequestReference
+ */
+ @Test
+ public void testSetRequestInfo() {
+ _taskRequestReference.setTaskId(_taskId);
+ verify(_taskRequestReference).setTaskId(_taskId);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java
index 692cdab877..bc6a5ab890 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValueTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java
@@ -1,113 +1,113 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TaskVariableValueTest {
- TaskVariableValue _taskVariableValue;
- protected String _name;
- protected String _value;
- protected String _operator;
-
- public TaskVariableValueTest() {
- }
-
- @Before
- public void setUp() {
- _taskVariableValue = mock(TaskVariableValue.class);
- _name = "name";
- _value = "value";
- _operator = "operator";
- when(_taskVariableValue.getName()).thenReturn(_name);
- when(_taskVariableValue.getValue()).thenReturn(_value);
- when(_taskVariableValue.getOperator()).thenReturn(_operator);
- }
-
- @After
- public void tearDown() {
- _taskVariableValue = null;
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetName() {
- _taskVariableValue.setName(_name);
- assertEquals(_taskVariableValue.getName(),_name);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetName() {
- _taskVariableValue.setName(_name);
- verify(_taskVariableValue).setName(_name);
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetValue() {
- _taskVariableValue.setValue(_value);
- assertEquals(_taskVariableValue.getValue(),_value);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetValue() {
- _taskVariableValue.setValue(_value);
- verify(_taskVariableValue).setValue(_value);
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetOperator() {
- _taskVariableValue.setOperator(_operator);
- assertEquals(_taskVariableValue.getOperator(),_operator);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetRequestDetails() {
- _taskVariableValue.setOperator(_operator);
- verify(_taskVariableValue).setOperator(_operator);
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class TaskVariableValueTest {
+ TaskVariableValue _taskVariableValue;
+ protected String _name;
+ protected String _value;
+ protected String _operator;
+
+ public TaskVariableValueTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _taskVariableValue = mock(TaskVariableValue.class);
+ _name = "name";
+ _value = "value";
+ _operator = "operator";
+ when(_taskVariableValue.getName()).thenReturn(_name);
+ when(_taskVariableValue.getValue()).thenReturn(_value);
+ when(_taskVariableValue.getOperator()).thenReturn(_operator);
+ }
+
+ @After
+ public void tearDown() {
+ _taskVariableValue = null;
+ }
+
+ /**
+ * Test of getName method
+ */
+ @Test
+ public void testGetName() {
+ _taskVariableValue.setName(_name);
+ assertEquals(_taskVariableValue.getName(),_name);
+
+ }
+
+ /**
+ * Test setName
+ */
+ @Test
+ public void testSetName() {
+ _taskVariableValue.setName(_name);
+ verify(_taskVariableValue).setName(_name);
+ }
+
+ /**
+ * Test of getName method
+ */
+ @Test
+ public void testGetValue() {
+ _taskVariableValue.setValue(_value);
+ assertEquals(_taskVariableValue.getValue(),_value);
+
+ }
+
+ /**
+ * Test setName
+ */
+ @Test
+ public void testSetValue() {
+ _taskVariableValue.setValue(_value);
+ verify(_taskVariableValue).setValue(_value);
+ }
+
+ /**
+ * Test of getName method
+ */
+ @Test
+ public void testGetOperator() {
+ _taskVariableValue.setOperator(_operator);
+ assertEquals(_taskVariableValue.getOperator(),_operator);
+
+ }
+
+ /**
+ * Test setName
+ */
+ @Test
+ public void testSetRequestDetails() {
+ _taskVariableValue.setOperator(_operator);
+ verify(_taskVariableValue).setOperator(_operator);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java
index 08a9669889..8e2c3ae7da 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariablesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java
@@ -1,69 +1,69 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-public class TaskVariablesTest {
-
- TaskVariables _taskVariables;
- private List<TaskVariableValue> _taskVariableValueList;
-
- public TaskVariablesTest() {
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- _taskVariables = mock(TaskVariables.class);
- _taskVariableValueList = mock(List.class);
- when(_taskVariables.getTaskVariables()).thenReturn(_taskVariableValueList);
- }
-
- @After
- public void tearDown() {
- _taskVariables = null;
- }
-
- @Test
- public void testGetTaskVariables() {
- List<TaskVariableValue> result = _taskVariables.getTaskVariables();
- assertEquals(_taskVariableValueList, result);
-
- }
-
- @Test
- public void testSetTaskVariables() {
- _taskVariables.setTaskVariables(_taskVariableValueList);
- verify(_taskVariables).setTaskVariables(_taskVariableValueList);
-
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+
+public class TaskVariablesTest {
+
+ TaskVariables _taskVariables;
+ private List<TaskVariableValue> _taskVariableValueList;
+
+ public TaskVariablesTest() {
+ }
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() {
+ _taskVariables = mock(TaskVariables.class);
+ _taskVariableValueList = mock(List.class);
+ when(_taskVariables.getTaskVariables()).thenReturn(_taskVariableValueList);
+ }
+
+ @After
+ public void tearDown() {
+ _taskVariables = null;
+ }
+
+ @Test
+ public void testGetTaskVariables() {
+ List<TaskVariableValue> result = _taskVariables.getTaskVariables();
+ assertEquals(_taskVariableValueList, result);
+
+ }
+
+ @Test
+ public void testSetTaskVariables() {
+ _taskVariables.setTaskVariables(_taskVariableValueList);
+ verify(_taskVariables).setTaskVariables(_taskVariableValueList);
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java
index 9a9756994c..f4ec27e852 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponseTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java
@@ -1,69 +1,69 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-public class TasksGetResponseTest {
-
- TasksGetResponse _tasksGetResponse;
- private List<TaskList> _taskList;
-
- public TasksGetResponseTest() {
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- _tasksGetResponse = mock(TasksGetResponse.class);
- _taskList = mock(List.class);
- when(_tasksGetResponse.getTaskList()).thenReturn(_taskList);
- }
-
- @After
- public void tearDown() {
- _tasksGetResponse = null;
- }
-
- @Test
- public void testGetTaskList() {
- List<TaskList> result = _tasksGetResponse.getTaskList();
- assertEquals(_taskList, result);
-
- }
-
- @Test
- public void testSetTaskList() {
- _tasksGetResponse.setTaskList(_taskList);
- verify(_tasksGetResponse).setTaskList(_taskList);
-
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+
+public class TasksGetResponseTest {
+
+ TasksGetResponse _tasksGetResponse;
+ private List<TaskList> _taskList;
+
+ public TasksGetResponseTest() {
+ }
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() {
+ _tasksGetResponse = mock(TasksGetResponse.class);
+ _taskList = mock(List.class);
+ when(_tasksGetResponse.getTaskList()).thenReturn(_taskList);
+ }
+
+ @After
+ public void tearDown() {
+ _tasksGetResponse = null;
+ }
+
+ @Test
+ public void testGetTaskList() {
+ List<TaskList> result = _tasksGetResponse.getTaskList();
+ assertEquals(_taskList, result);
+
+ }
+
+ @Test
+ public void testSetTaskList() {
+ _tasksGetResponse.setTaskList(_taskList);
+ verify(_tasksGetResponse).setTaskList(_taskList);
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java
index 12aa8ef735..09af2b0a52 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java
@@ -1,70 +1,70 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-public class TasksRequestTest {
- TasksRequest _tasksRequest;
- private RequestDetails _requestDetails;
-
- public TasksRequestTest() {
- }
-
- @Before
- public void setUp() {
- _tasksRequest = mock(TasksRequest.class);
- _requestDetails = new RequestDetails();
- when(_tasksRequest.getRequestDetails()).thenReturn(_requestDetails);
- }
-
- @After
- public void tearDown() {
- _tasksRequest = null;
- }
-
- /**
- * Test of getRequestDetails method
- */
- @Test
- public void testGetRequestDetails() {
- _tasksRequest.setRequestDetails(_requestDetails);
- assertTrue(_tasksRequest.getRequestDetails().equals(_requestDetails));
-
- }
-
- /**
- * Test setRequestDetails
- */
- @Test
- public void testSetRequestDetails() {
- _tasksRequest.setRequestDetails(_requestDetails);
- verify(_tasksRequest).setRequestDetails(_requestDetails);
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+
+public class TasksRequestTest {
+ TasksRequest _tasksRequest;
+ private RequestDetails _requestDetails;
+
+ public TasksRequestTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _tasksRequest = mock(TasksRequest.class);
+ _requestDetails = new RequestDetails();
+ when(_tasksRequest.getRequestDetails()).thenReturn(_requestDetails);
+ }
+
+ @After
+ public void tearDown() {
+ _tasksRequest = null;
+ }
+
+ /**
+ * Test of getRequestDetails method
+ */
+ @Test
+ public void testGetRequestDetails() {
+ _tasksRequest.setRequestDetails(_requestDetails);
+ assertTrue(_tasksRequest.getRequestDetails().equals(_requestDetails));
+
+ }
+
+ /**
+ * Test setRequestDetails
+ */
+ @Test
+ public void testSetRequestDetails() {
+ _tasksRequest.setRequestDetails(_requestDetails);
+ verify(_tasksRequest).setRequestDetails(_requestDetails);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/ValueTest.java
index 8affd08529..dc5cf8ed39 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValueTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/ValueTest.java
@@ -1,68 +1,68 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ValueTest {
- Value _valueInstance;
- protected String _value;
-
- public ValueTest() {
- }
-
- @Before
- public void setUp() {
- _valueInstance = mock(Value.class);
- _value = "_value";
- when(_valueInstance.getValue()).thenReturn(_value);
- }
-
- @After
- public void tearDown() {
- _valueInstance = null;
- }
-
- /**
- * Test of getValue method
- */
- @Test
- public void testGetValue() {
- _valueInstance.setValue(_value);
- assertEquals(_valueInstance.getValue(),_value);
-
- }
-
- /**
- * Test setValue
- */
- @Test
- public void testSetValue() {
- _valueInstance.setValue(_value);
- verify(_valueInstance).setValue(_value);
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class ValueTest {
+ Value _valueInstance;
+ protected String _value;
+
+ public ValueTest() {
+ }
+
+ @Before
+ public void setUp() {
+ _valueInstance = mock(Value.class);
+ _value = "_value";
+ when(_valueInstance.getValue()).thenReturn(_value);
+ }
+
+ @After
+ public void tearDown() {
+ _valueInstance = null;
+ }
+
+ /**
+ * Test of getValue method
+ */
+ @Test
+ public void testGetValue() {
+ _valueInstance.setValue(_value);
+ assertEquals(_valueInstance.getValue(),_value);
+
+ }
+
+ /**
+ * Test setValue
+ */
+ @Test
+ public void testSetValue() {
+ _valueInstance.setValue(_value);
+ verify(_valueInstance).setValue(_value);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/VariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java
index ad61675bbc..d79e5f6294 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/VariablesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java
@@ -1,95 +1,95 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class VariablesTest {
-
- Variables _variables;
- protected Value _source;
- protected Value _responseValue;
- protected Value _requestorId;
-
- @Before
- public void setUp() {
- _variables = mock(Variables.class);
- _source = mock(Value.class);
- _responseValue = mock(Value.class);
- _requestorId = mock(Value.class);
-
- when(_variables.getSource()).thenReturn(_source);
- when(_variables.getRequestorId()).thenReturn(_requestorId);
- when(_variables.getResponseValue()).thenReturn(_responseValue);
-
- }
-
- @After
- public void tearDown() {
- _variables = null;
- _source = null;
- _responseValue = null;
- _requestorId = null;
- }
-
- @Test
- public void testGetSource() {
- _variables.setSource(_source);
- assertTrue(_variables.getSource().equals(_source));
- }
-
- @Test
- public void testSetSource(){
- _variables.setSource(_source);
- verify(_variables).setSource(_source);
- }
-
- @Test
- public void testGetResponseValue() {
- _variables.setResponseValue(_responseValue);
- assertTrue(_variables.getResponseValue().equals(_responseValue));
- }
-
- @Test
- public void testSetResponseValue(){
- _variables.setResponseValue(_responseValue);
- verify(_variables).setResponseValue(_responseValue);
- }
-
- @Test
- public void testGetRequestorId() {
- _variables.setRequestorId(_requestorId);
- assertTrue(_variables.getRequestorId().equals(_requestorId));
- }
-
- @Test
- public void testSetRequestorId(){
- _variables.setRequestorId(_requestorId);
- verify(_variables).setRequestorId(_requestorId);
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.tasksbeans;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class VariablesTest {
+
+ Variables _variables;
+ protected Value _source;
+ protected Value _responseValue;
+ protected Value _requestorId;
+
+ @Before
+ public void setUp() {
+ _variables = mock(Variables.class);
+ _source = mock(Value.class);
+ _responseValue = mock(Value.class);
+ _requestorId = mock(Value.class);
+
+ when(_variables.getSource()).thenReturn(_source);
+ when(_variables.getRequestorId()).thenReturn(_requestorId);
+ when(_variables.getResponseValue()).thenReturn(_responseValue);
+
+ }
+
+ @After
+ public void tearDown() {
+ _variables = null;
+ _source = null;
+ _responseValue = null;
+ _requestorId = null;
+ }
+
+ @Test
+ public void testGetSource() {
+ _variables.setSource(_source);
+ assertTrue(_variables.getSource().equals(_source));
+ }
+
+ @Test
+ public void testSetSource(){
+ _variables.setSource(_source);
+ verify(_variables).setSource(_source);
+ }
+
+ @Test
+ public void testGetResponseValue() {
+ _variables.setResponseValue(_responseValue);
+ assertTrue(_variables.getResponseValue().equals(_responseValue));
+ }
+
+ @Test
+ public void testSetResponseValue(){
+ _variables.setResponseValue(_responseValue);
+ verify(_variables).setResponseValue(_responseValue);
+ }
+
+ @Test
+ public void testGetRequestorId() {
+ _variables.setRequestorId(_requestorId);
+ assertTrue(_variables.getRequestorId().equals(_requestorId));
+ }
+
+ @Test
+ public void testSetRequestorId(){
+ _variables.setRequestorId(_requestorId);
+ verify(_variables).setRequestorId(_requestorId);
+ }
+
+}
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
new file mode 100644
index 0000000000..37813811ee
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
@@ -0,0 +1,289 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.CharEncoding;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.apihandlerinfra.ApiHandlerApplication;
+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.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+public class CloudOrchestrationTest extends BaseTest {
+
+ private static final String path = "/onap/so/infra/cloudResources/v1";
+ private HttpHeaders headers = new HttpHeaders();
+
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private InfraActiveRequestsRepository iarRepo;
+
+ @Test
+ public void testCreateOpEnvObjectMapperError() throws IOException {
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ String body = response.getBody().toString();
+ assertTrue(body.contains("Mapping of request to JSON object failed."));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testCreateOpEnvError() throws IOException {
+
+ String request = "{\"requestDetails\":{\"requestInfo\":{\"resourceType\":\"operationalEnvironment\",\"instanceName\": \"myOpEnv\",\"source\": \"VID\",\"requestorId\": \"xxxxxx\"},"
+ + " \"requestParameters\": {\"tenantContext\": \"Test\",\"workloadContext\": \"ECOMP_E2E-IST\"}}}";
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(request, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ String body = response.getBody().toString();
+ assertTrue(body.contains("Mapping of request to JSON object failed"));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testCreateOpEnvReqRecord() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("123");
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ iarRepo.saveAndFlush(iar);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(409, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testCreateOperationalEnvironment() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set("X-TransactionID", "987654321");
+ HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ InfraActiveRequests iar = iarRepo.findOneByRequestId("987654321");
+ assertEquals(iar.getRequestBody(), mapper.writeValueAsString(request.getRequestDetails()));
+ assertEquals(200, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testCreateVNFDuplicateCheck() throws IOException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestId");
+ iar.setOperationalEnvName("myVnfOpEnv");
+ iar.setRequestStatus(Status.IN_PROGRESS.toString());
+ iar.setAction(Action.create.toString());
+ iar.setRequestAction(Action.create.toString());
+ iar.setRequestScope("UNKNOWN");
+ iarRepo.saveAndFlush(iar);
+
+ ObjectMapper mapper = new ObjectMapper();
+ TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ assertEquals(409, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testCreateVNF() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json"), TenantIsolationRequest.class);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ assertEquals(200, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testActivate() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/ActivateOperationEnvironment.json"), TenantIsolationRequest.class);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/activate");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(200, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testDeactivate() throws IOException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("ff3514e3-5a33-55df-13ab-12abad84e7fa");
+ iar.setRequestStatus(Status.COMPLETE.toString());
+ iar.setRequestAction("UNKNOWN");
+ iar.setRequestScope("UNKNOWN");
+ iarRepo.saveAndFlush(iar);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+ TenantIsolationRequest request = mapper.readValue(new File("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json"), TenantIsolationRequest.class);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
+
+
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7fa/deactivate");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(200, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testDeactivateThreadException() throws IOException {
+ //need to simulate a 500 error
+ /*CloudOrchestration co = new CloudOrchestration();
+ TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
+ RequestsDatabase reqDB = mock(RequestsDatabase.class);
+ TenantIsolationRunnable thread = mock(TenantIsolationRunnable.class);
+ Response res = Response.status(500).entity("Failed creating a Thread").build();
+
+ co.setRequestsDatabase(reqDB);
+ co.setThread(thread);
+ co.setTenantIsolationRequest(tenantIsolationRequest);
+ String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironment.json"), CharEncoding.UTF_8);
+ when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(null);
+ doNothing().when(tenantIsolationRequest).createRequestRecord(Status.IN_PROGRESS, Action.deactivate);
+ doThrow(Exception.class).when(thread).run();
+ when(tenantIsolationRequest.buildServiceErrorResponse(any(Integer.class), any(MsoException.class), any(String.class), any(String.class), any(List.class))).thenReturn(res);
+
+ Response response = co.activateOperationEnvironment(request, null, "ff3514e3-5a33-55df-13ab-12abad84e7ff");
+ assertEquals(500, response.getStatus());*/
+ }
+
+ @Test
+ @Ignore
+ public void testDeactivateDupCheck() throws IOException {
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestId");
+ iar.setOperationalEnvName("myVnfOpEnv");
+ iar.setRequestStatus(Status.IN_PROGRESS.toString());
+ iar.setAction(Action.create.toString());
+ iar.setRequestAction(Action.create.toString());
+ iar.setRequestScope("UNKNOWN");
+ iarRepo.saveAndFlush(iar);
+ ObjectMapper mapper = new ObjectMapper();
+ String request = mapper.readValue(new File("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json"), String.class);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(request, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/deactivate");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ assertEquals(409, response.getStatusCodeValue());
+ }
+
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
new file mode 100644
index 0000000000..cc0b9f64e4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
@@ -0,0 +1,401 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.ws.rs.core.MediaType;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+
+public class CloudResourcesOrchestrationTest extends BaseTest{
+
+ @Autowired
+ private InfraActiveRequestsRepository iarRepo;
+ private String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"VID\",\"requestorId\":\"xxxxxx\" } } }";
+ private static final String path = "/onap/so/infra/cloudResourcesRequests";
+
+ @LocalServerPort
+ private int port;
+
+
+
+ HttpHeaders headers = new HttpHeaders();
+
+ @Test
+ public void testUnlockFailObjectMapping() {
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/test/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ String body = response.getBody();
+ assertTrue(body.contains("Mapping of request to JSON object failed."));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testParseOrchestrationError1() {
+ String requestJSON = "{\"requestDetails\": null }";
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/test/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ String body = response.getBody();
+ assertTrue(body.contains("No valid requestDetails is specified"));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testParseOrchestrationError2() {
+ String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"\",\"requestorId\":\"xxxxxx\" } } }";
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/test/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ String body = response.getBody();
+ assertTrue(body.contains("No valid source is specified"));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testParseOrchestrationError3() {
+ String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"VID\",\"requestorId\":\"\" } } }";
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/test/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ String body = response.getBody();
+ assertTrue(body.contains("No valid requestorId is specified"));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testGetInfraActiveRequestNull() {
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/request-id-null-check/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ String body = response.getBody();
+ assertTrue(body.contains("Orchestration RequestId request-id-null-check is not found in DB"));
+ assertEquals(400, response.getStatusCodeValue());
+
+ }
+
+ @Test
+ public void testUnlockError() {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestIdtestUnlockError");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvironmentId");
+ iar.setOperationalEnvName("operationalEnvName");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("");
+ iar.setRequestStatus("IN_PROGRESS");
+ iar.setRequestAction("TEST");
+
+ iarRepo.saveAndFlush(iar);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/requestId/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testUnlock() throws ParseException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestIdtestUnlock");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvironmentId");
+ iar.setOperationalEnvName("operationalEnvName");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("{}");
+ iar.setRequestStatus("IN_PROGRESS");
+ iar.setRequestAction("TEST");
+
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ iar.setStartTime(new Timestamp(time));
+
+ iarRepo.saveAndFlush(iar);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/requestIdtestUnlock/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(204, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testUnlockComplete() throws ParseException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestIdtestUnlockComplete");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvironmentId");
+ iar.setOperationalEnvName("operationalEnvName");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("{}");
+ iar.setRequestStatus("COMPLETE");
+ iar.setRequestAction("TEST");
+
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ iar.setStartTime(new Timestamp(time));
+
+ iarRepo.saveAndFlush(iar);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>(requestJSON, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1/requestIdtestUnlockComplete/unlock");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+ String body = response.getBody().toString();
+ assertTrue(body.contains("Orchestration RequestId requestIdtestUnlockComplete has a status of COMPLETE and can not be unlocked"));
+ assertEquals(400, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testGetOperationalEnvFilter() {
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1");
+
+ builder.queryParam("requestId", "not-there");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+ //204s cannot have a body
+ //assertTrue(response.getBody().contains("Orchestration RequestId not-there is not found in DB"));
+ assertEquals(204, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testGetOperationalEnvSuccess() throws ParseException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("90c56827-1c78-4827-bc4d-6afcdb37a51f");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvironmentId");
+ iar.setOperationalEnvName("operationalEnvName");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("{}");
+ iar.setRequestStatus("COMPLETE");
+ iar.setRequestAction("TEST");
+
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ iar.setStartTime(new Timestamp(time));
+
+ iarRepo.saveAndFlush(iar);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>("", headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1");
+
+ builder.queryParam("requestId", "90c56827-1c78-4827-bc4d-6afcdb37a51f");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+ assertEquals(200, response.getStatusCodeValue());
+ 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("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ assertEquals("90c56827-1c78-4827-bc4d-6afcdb37a51f", response.getHeaders().get("X-TransactionID").get(0));
+ }
+
+ @Test
+ public void testGetOperationalEnvFilterSuccess() throws ParseException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestIdtestGetOperationalEnvFilterSuccess");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvironmentId");
+ iar.setOperationalEnvName("myVnfOpEnv");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("");
+ iar.setRequestStatus("COMPLETE");
+ iar.setStatusMessage("status Message");
+ iar.setProgress(20L);
+ iar.setRequestAction("TEST");
+
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ iar.setStartTime(new Timestamp(time));
+ iar.setEndTime(new Timestamp(time));
+
+ iarRepo.saveAndFlush(iar);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>(null, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1");
+
+ builder.queryParam("requestId", "requestIdtestGetOperationalEnvFilterSuccess");
+ builder.queryParam("operationalEnvironmentName", "myVnfOpEnv");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+ assertEquals(200, response.getStatusCodeValue());
+ 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("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+
+ }
+
+ @Test
+ public void testGetOperationalEnvFilterException1() throws ParseException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestId-getOpEnvFilterEx1");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvironmentId");
+ iar.setOperationalEnvName("operationalEnvName");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("");
+ iar.setRequestStatus("COMPLETE");
+ iar.setRequestAction("TEST");
+
+ iarRepo.saveAndFlush(iar);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>("", headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1");
+
+ builder.queryParam("filter", "operationalEnvironmentName:EQUALS:myVnfOpEnv");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+ assertEquals(500, response.getStatusCodeValue());
+ }
+
+ @Test
+ public void testGetOperationalEnvFilterException2() throws ParseException {
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("requestIdFilterException2");
+ iar.setRequestScope("requestScope");
+ iar.setRequestType("requestType");
+ iar.setOperationalEnvId("operationalEnvId");
+ iar.setOperationalEnvName("operationalEnvName");
+ iar.setRequestorId("xxxxxx");
+ iar.setRequestBody("");
+ iar.setRequestStatus("COMPLETE");
+ iar.setRequestAction("TEST");
+
+ iarRepo.saveAndFlush(iar);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<String> entity = new HttpEntity<>(null, headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1");
+
+ builder.queryParam("operationalEnvironmentName", "");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+
+ assertEquals(500, response.getStatusCodeValue());
+ assertTrue(response.getBody().toString().contains("No valid operationalEnvironmentName value is specified"));
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
new file mode 100644
index 0000000000..37ec14a0b5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
@@ -0,0 +1,114 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.contains;
+import static org.mockito.Mockito.doNothing;
+
+import javax.inject.Provider;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+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.Mockito;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.ApiHandlerApplication;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+
+public class ModelDistributionRequestTest extends BaseTest{
+
+ private static final String requestJSON = "{\"status\": \"DISTRIBUTION_COMPLETE_ERROR\", \"errorReason\": \"Distribution failed in AAI\" }";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+ @Mock
+ private Provider<TenantIsolationRunnable> thread;
+ @InjectMocks
+ @Spy
+ private ModelDistributionRequest request = new ModelDistributionRequest();
+ @Mock
+ private TenantIsolationRunnable runnable = new TenantIsolationRunnable();
+
+ @Before
+ public void beforeTest() {
+ Mockito.when(thread.get()).thenReturn(runnable);
+ }
+
+ @Test
+ public void testObjectMapperError() throws ApiException{
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(startsWith("Mapping of request to JSON object failed"));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ request.updateModelDistributionStatus("", null, null);
+ }
+
+ @Test
+ public void testParseError1() throws ApiException{
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(startsWith("No valid status is specified"));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ String requestErrorJSON = "{\"errorReason\": \"Distribution failed in AAI\" }";
+ request.updateModelDistributionStatus(requestErrorJSON, null, null);
+ }
+
+ @Test
+ public void testParseError2() throws ApiException{
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(startsWith("No valid errorReason is specified"));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
+ String requestErrorJSON = "{\"status\": \"DISTRIBUTION_COMPLETE_ERROR\"}";
+ request.updateModelDistributionStatus(requestErrorJSON, null, null);
+ }
+
+ @Test
+ public void testSuccess() throws ApiException{
+ doNothing().when(runnable).run(any(Action.class), anyString(), any(CloudOrchestrationRequest.class), anyString());
+
+ Response response = request.updateModelDistributionStatus(requestJSON, null, null);
+
+ assertEquals(200, response.getStatus());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java
index d2d7959622..426be98486 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.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.
@@ -18,27 +18,34 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
+package org.onap.so.apihandlerinfra.tenantisolation;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.HashMap;
-import org.apache.commons.io.IOUtils;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Rule;
import org.junit.Test;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.TenantIsolationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
+import org.junit.rules.ExpectedException;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
+import org.onap.so.exceptions.ValidationException;
+import org.springframework.test.context.ActiveProfiles;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
-public class TenantIsolationRequestTest {
+public class TenantIsolationRequestTest extends BaseTest{
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
@Test
public void testParseCloudResourceECOMP() throws Exception{
try {
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/ECOMPOperationEnvironmentCreate.json"));
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/ECOMPOperationEnvironmentCreate.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -53,7 +60,7 @@ public class TenantIsolationRequestTest {
@Test
public void testParseCloudResourceVNF() throws Exception{
try {
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/VNFOperationEnvironmentCreate.json"));
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreate.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -65,9 +72,11 @@ public class TenantIsolationRequestTest {
}
}
- @Test(expected=ValidationException.class)
+ @Test
public void testParseCloudResourceVNFInvalid() throws Exception {
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/VNFOperationEnvironmentCreateInvalid.json"));
+ expectedException.expect(ValidationException.class);
+
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/VNFOperationEnvironmentCreateInvalid.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -79,7 +88,7 @@ public class TenantIsolationRequestTest {
@Test
public void testParseActivateCloudResource() throws Exception{
try {
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/ActivateOperationEnvironment.json"));
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/ActivateOperationEnvironment.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -91,9 +100,11 @@ public class TenantIsolationRequestTest {
}
}
- @Test(expected = ValidationException.class)
+ @Test
public void testParseActivateCloudResourceInvalid() throws Exception{
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/ActivateOperationEnvironmentInvalid.json"));
+ expectedException.expect(ValidationException.class);
+
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/ActivateOperationEnvironmentInvalid.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -105,7 +116,7 @@ public class TenantIsolationRequestTest {
@Test
public void testParseDeactivateCloudResource() throws Exception{
try {
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironment.json"));
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/DeactivateOperationEnvironment.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -117,9 +128,11 @@ public class TenantIsolationRequestTest {
}
}
- @Test(expected= ValidationException.class)
+ @Test
public void testParseDeactivateCloudResourceInvalid() throws Exception{
- String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironmentInvalid.json"));
+ expectedException.expect(ValidationException.class);
+
+ String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/TenantIsolation/DeactivateOperationEnvironmentInvalid.json")));
ObjectMapper mapper = new ObjectMapper();
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
@@ -127,4 +140,4 @@ public class TenantIsolationRequestTest {
request.parse(cor, instanceIdMap, Action.deactivate);
assertNotNull(request.getRequestId());
}
-} \ No newline at end of file
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java
index 539b1816bd..ef57fa1a76 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.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.
@@ -18,10 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
import java.io.IOException;
import java.nio.file.Files;
@@ -29,31 +28,36 @@ import java.nio.file.Paths;
import java.text.ParseException;
import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.CreateEcompOperationEnvironmentBean;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
+import org.junit.runner.RunWith;
+import org.onap.so.apihandlerinfra.ApiHandlerApplication;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class DmaapOperationalEnvClientTest {
+public class DmaapOperationalEnvClientTest extends BaseTest{
- private final String fileLocation = "src/test/resources/org/openecomp/mso/client/asdc/create-ecompoe/";
+ private final String fileLocation = "src/test/resources/org/onap/so/client/asdc/create-ecompoe/";
private static final String operationalEnvironmentId = "28122015552391";
private static final String operationalEnvironmentName = "OpEnv-name";
private static final String operationalEnvironmentType = "VNF";
private static final String tenantContext = "Test";
private static final String workloadContext = "VNF_E2E-IST";
private static final String action = "Create";
-
+ @Autowired
+ private DmaapOperationalEnvClient client;
@Test
- public void verifyCreateEcompOperationEnvironmentRequest() throws IOException, ParseException{
+ public void verifyCreateEcompOperationEnvironmentRequest() throws IOException, ApiException {
String content = this.getJson("ecomp-openv-request.json");
ObjectMapper mapper = new ObjectMapper();
CreateEcompOperationEnvironmentBean expected = mapper.readValue(content, CreateEcompOperationEnvironmentBean.class);
- DmaapOperationalEnvClient client = new DmaapOperationalEnvClient();
- DmaapOperationalEnvClient spy = spy(client);
- String actual = spy.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType,
+ String actual = client.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType,
tenantContext, workloadContext, action);
assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java
index a9763f1d39..59df7ae960 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.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.
@@ -18,38 +18,34 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
import static org.junit.Assert.assertEquals;
import java.io.FileNotFoundException;
import java.io.IOException;
-import org.junit.BeforeClass;
import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.OperationalEnvironmentPublisher;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.junit.runner.RunWith;
+import org.onap.so.apihandlerinfra.ApiHandlerApplication;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
-public class OperationalEnvironmentPublisherTest {
- private static final String APIH_INFRA_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.apihandler-infra.properties").toString().substring(5);
-
- @BeforeClass
- public static void setUp() throws MsoPropertiesException {
- MsoPropertiesFactory propertiesFactory = new MsoPropertiesFactory();
- propertiesFactory.removeAllMsoProperties();
- propertiesFactory.initializeMsoProperties("MSO_PROP_APIHANDLER_INFRA", APIH_INFRA_PROP);
- }
+public class OperationalEnvironmentPublisherTest extends BaseTest {
+
+ @Autowired
+ private OperationalEnvironmentPublisher publisher;
@Test
public void getProperties() throws FileNotFoundException, IOException {
- OperationalEnvironmentPublisher publisher = new OperationalEnvironmentPublisher();
- assertEquals("m97898@mso.ecomp.att.com", publisher.getUserName());
+ assertEquals("testuser", publisher.getUserName());
assertEquals("VjR5NDcxSzA=", publisher.getPassword());
- assertEquals("com.att.ecomp.mso.operationalEnvironmentEvent", publisher.getTopic());
- assertEquals("https://dcae-mrtr-ftl3.ecomp.cci.att.com:3905", publisher.getHost().get());
+ assertEquals("test.operationalEnvironmentEvent", publisher.getTopic());
+ assertEquals("http://localhost:" + env.getProperty("wiremock.server.port"), publisher.getHost().get());
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/AsdcDmaapClientTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/SDCDmaapClientTest.java
index f62b360071..3fcfa5dfa8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/AsdcDmaapClientTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/SDCDmaapClientTest.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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
import static org.junit.Assert.assertEquals;
@@ -26,13 +26,14 @@ import java.io.IOException;
import java.text.ParseException;
import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.CreateEcompOperationEnvironmentBean;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.tenantisolation.dmaap.CreateEcompOperationEnvironmentBean;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class AsdcDmaapClientTest {
+public class SDCDmaapClientTest extends BaseTest{
- private final String fileLocation = "src/test/resources/org/openecomp/mso/client/asdc/create-ecompoe/";
+ private final String fileLocation = "src/test/resources/org/onap/so/client/asdc/create-ecompoe/";
private static final String operationalEnvironmentId = "28122015552391";
private static final String operationalEnvironmentName = "Operational Environment Name";
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/TasksHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailedTest.java
index 91225190a3..5ee2eeaeba 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/TasksHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailedTest.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.
@@ -18,24 +18,28 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra.tenantisolation.exceptions;
-import static org.junit.Assert.assertTrue;
-
-import java.text.ParseException;
-
-import javax.ws.rs.core.Response;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
-public class TasksHandlerTest {
+public class SDCClientCallFailedTest extends BaseTest{
- TasksHandler handler = new TasksHandler();
+ @Test
+ public void testAsdcException() {
+ SDCClientCallFailed asdc = new SDCClientCallFailed("failed");
+
+ assertEquals("failed", asdc.getMessage());
+ }
@Test
- public void queryFiltersTest() throws ParseException{
- Response resp = handler.queryFilters("10020", "399495", "test", "nfRole", "buildingBlockName", "originalRequestDate", "originalRequestorId", "v2");
- assertTrue(resp.getEntity().toString() != null);
+ public void testAsdcExceptionWithCause() {
+ SDCClientCallFailed asdc = new SDCClientCallFailed("failed", new Throwable("throwable"));
+
+ assertEquals("failed", asdc.getMessage());
+ assertEquals("throwable", asdc.getCause().getMessage());
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationExceptionTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationExceptionTest.java
new file mode 100644
index 0000000000..f73a194a7b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationExceptionTest.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.exceptions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+
+public class TenantIsolationExceptionTest extends BaseTest{
+
+ @Test
+ public void testTenantIsolation() {
+ TenantIsolationException exception = new TenantIsolationException();
+
+ assertNotNull(exception);
+ }
+
+ @Test
+ public void testTenantIsolationException() {
+ TenantIsolationException exception = new TenantIsolationException("exception");
+
+ assertEquals("Tenant Isolation error: exception", exception.getMessage());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
new file mode 100644
index 0000000000..9aa961c665
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+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.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+
+public class AAIClientHelperTest extends BaseTest{
+
+ @Autowired
+ private AAIClientHelper clientHelper;
+
+ @Test
+ public void testGetAaiOperationalEnvironmentSuccess() throws Exception {
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
+ Optional<AAIOperationalEnvironment> aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class);
+ assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId());
+ }
+
+ @Test
+ public void testUpdateSuccess() {
+ stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ ecompEnv.setTenantContext("Test");
+ ecompEnv.setWorkloadContext("ECOMPL_PSL");
+
+ try {
+ AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+ doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(AAIOperationalEnvironment.class));
+ clientHelper.updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
+
+ verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", ecompEnv);
+ } catch(Exception e) {
+ fail("shouldn't reach here");
+ }
+ }
+
+ @Test
+ public void testUpdateMapSuccess() {
+ stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ Map<String, String> payload = new HashMap<String, String>();
+ payload.put("tenant-context", "Test");
+ payload.put("workload-context", "ECOMPL_PSL");
+
+ try {
+ AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+ doNothing().when(clientHelper).updateAaiOperationalEnvironment("EMOE-001", payload);
+ clientHelper.updateAaiOperationalEnvironment("EMOE-001", payload);
+
+ verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", payload);
+ } catch(Exception e) {
+ fail("shouldn't reach here");
+ }
+ }
+
+ @Test
+ public void testCreateSuccess() {
+ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ ecompEnv.setOperationalEnvironmentId("opeEvnId");
+ ecompEnv.setTenantContext("Test");
+ ecompEnv.setWorkloadContext("ECOMPL_PSL");
+
+ try {
+ AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+ doNothing().when(clientHelper).createOperationalEnvironment(any(AAIOperationalEnvironment.class));
+ clientHelper.createOperationalEnvironment(ecompEnv);
+
+ verify(clientHelper, times(1)).createOperationalEnvironment(ecompEnv);
+ } catch(Exception e) {
+ fail("shouldn't reach here");
+ }
+ }
+
+ @Test
+ public void testcreateRelationshipSuccess() {
+ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ ecompEnv.setTenantContext("Test");
+ ecompEnv.setWorkloadContext("ECOMPL_PSL");
+
+ try {
+ AAIClientHelper clientHelper = mock(AAIClientHelper.class);
+ doNothing().when(clientHelper).createRelationship(anyString(), anyString());
+ clientHelper.createRelationship("managingEcomp", "vnfOp");
+
+ verify(clientHelper, times(1)).createRelationship("managingEcomp", "vnfOp");
+ } catch(Exception e) {
+ fail("shouldn't reach here");
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java
index 12312764c3..cf6facc59f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.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.
@@ -18,21 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.helpers;
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestInfo;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestParameters;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class AAIClientObjectBuilderTest {
+public class AAIClientObjectBuilderTest extends BaseTest{
private String expectedAAIObject = "{\"operational-environment-name\":\"TEST_ECOMP_ENVIRONMENT\",\"operational-environment-type\":\"ECOMP\",\"operational-environment-status\":\"Active\",\"tenant-context\":\"TEST\",\"workload-context\":\"ECOMP_TEST\"}";
private CloudOrchestrationRequest request;
@@ -60,8 +61,8 @@ public class AAIClientObjectBuilderTest {
@Test
public void testGetAaiClientObjectBuilder() throws Exception {
- AAIClientObjectBuilder builder = new AAIClientObjectBuilder(request);
- assertEquals(expectedAAIObject, mapper.writeValueAsString(builder.buildAAIOperationalEnvironment("Active")));
+ AAIClientObjectBuilder builder = new AAIClientObjectBuilder();
+ assertEquals(expectedAAIObject, mapper.writeValueAsString(builder.buildAAIOperationalEnvironment("Active", request)));
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelperTest.java
new file mode 100644
index 0000000000..3e06275fca
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelperTest.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.apihandlerinfra.ApiHandlerApplication;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+
+
+public class ActivateVnfDBHelperTest extends BaseTest{
+
+ String operationalEnvironmentId = "TEST_operationalEnvironmentId";
+ String requestId = "TEST_requestId";
+ String origRequestId = "TEST_requestId";
+
+ String workloadContext1 = "TEST_workloadContext1";
+ String serviceModelVersionId1 = "TEST_serviceModelVersionId1";
+ String distributionId1 = "TEST_distributionId1";
+ String errorReason = "ABORTED";
+ int retryCountThree = 3;
+ int retryCountZero = 0;
+ String recoveryActionRetry = "RETRY";
+ String statusOk = DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString();
+ String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
+ String statusSent = "SENT";
+
+ OperationalEnvDistributionStatus expectedDistStatus;
+ OperationalEnvServiceModelStatus expectedServiceModelStatus;
+
+ @Autowired
+ private ActivateVnfDBHelper dbHelper;
+
+ @Before
+ public void testSetUp() {
+ // prepare expected OperationalEnvDistributionStatus object
+ expectedDistStatus = new OperationalEnvDistributionStatus();
+ expectedDistStatus.setDistributionId(distributionId1);
+ expectedDistStatus.setOperationalEnvId(operationalEnvironmentId);
+ expectedDistStatus.setServiceModelVersionId(serviceModelVersionId1);
+ expectedDistStatus.setDistributionIdStatus(statusOk);
+ expectedDistStatus.setRequestId(requestId);
+ expectedDistStatus.setDistributionIdErrorReason("");
+
+ // prepare expected OperationalEnvServiceModelStatus object
+ expectedServiceModelStatus = new OperationalEnvServiceModelStatus();
+ expectedServiceModelStatus.setRequestId(requestId);
+ expectedServiceModelStatus.setOperationalEnvId(operationalEnvironmentId);
+ expectedServiceModelStatus.setServiceModelVersionId(serviceModelVersionId1);
+ expectedServiceModelStatus.setServiceModelVersionDistrStatus(statusOk);
+ expectedServiceModelStatus.setRecoveryAction(recoveryActionRetry);
+ expectedServiceModelStatus.setRetryCount(new Integer(retryCountThree));
+ expectedServiceModelStatus.setWorkloadContext(workloadContext1);
+ }
+
+ @Test
+ public void testOperationalEnvDistributionStatusDbMethods() throws Exception {
+
+ // test insert method
+ OperationalEnvDistributionStatus distStatus1 =
+ dbHelper.insertRecordToOperationalEnvDistributionStatus(distributionId1,
+ operationalEnvironmentId,
+ serviceModelVersionId1,
+ requestId,
+ statusOk,
+ "");
+ assertThat(distStatus1, sameBeanAs(expectedDistStatus));
+
+ // prepare updated expected object
+ OperationalEnvDistributionStatus expectedUpdatedDistStatus = expectedDistStatus;
+ expectedUpdatedDistStatus.setDistributionIdStatus(statusError);
+ expectedUpdatedDistStatus.setDistributionIdErrorReason(errorReason);
+
+ // test update method - statusOk to statusError
+ OperationalEnvDistributionStatus distStatus2 =
+ dbHelper.updateStatusInOperationalEnvDistributionStatus(distStatus1,
+ statusError,
+ errorReason
+ );
+ assertThat(distStatus2, sameBeanAs(expectedUpdatedDistStatus));
+
+ }
+
+ @Test
+ public void testOperationalEnvServiceModelStatusDbMethods() throws Exception {
+
+ // test insert method
+ OperationalEnvServiceModelStatus serviceModelStatus1 =
+ dbHelper.insertRecordToOperationalEnvServiceModelStatus(requestId,
+ operationalEnvironmentId,
+ serviceModelVersionId1,
+ statusOk,
+ recoveryActionRetry,
+ retryCountThree,
+ workloadContext1);
+ assertThat(serviceModelStatus1, sameBeanAs(expectedServiceModelStatus));
+
+ // prepare updated expected object
+ OperationalEnvServiceModelStatus expectedUpdatedServiceModelStatus = serviceModelStatus1;
+ expectedUpdatedServiceModelStatus.setServiceModelVersionDistrStatus(statusError);
+ expectedUpdatedServiceModelStatus.setRetryCount(new Integer(retryCountZero));
+
+ // test update method - update statusOk to statusError & retryCountThree to retryCountZero
+ OperationalEnvServiceModelStatus serviceModelStatus2 =
+ dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(serviceModelStatus1,
+ statusError,
+ retryCountZero);
+ assertThat(serviceModelStatus2, sameBeanAs(expectedUpdatedServiceModelStatus));
+
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java
new file mode 100644
index 0000000000..7fd92d2d7e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class SDCClientHelperTest extends BaseTest{
+
+ String serviceModelVersionId = "TEST_uuid1";
+ String operationalEnvironmentId = "TEST_operationalEnvironmentId";
+ String workloadContext = "TEST_workloadContext";
+
+ @Autowired
+ private SDCClientHelper sdcClientUtils;
+
+ @Test
+ public void postActivateOperationalEnvironment_Test() throws ApiException {
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", "202");
+ jsonObject.put("message", "Success");
+ jsonObject.put("distributionId", "TEST_distributionId");
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_uuid1/distr.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ JSONObject jsonResponse = sdcClientUtils.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
+
+ assertEquals("202", jsonResponse.get("statusCode"));
+ assertEquals("Success", jsonResponse.get("message"));
+
+ }
+
+ @Test
+ public void postActivateOperationalEnvironment_InvalidJson_Test() throws ApiException {
+
+ // ERROR in asdc response, invalid json object
+ JSONObject jsonErrorResponse = new JSONObject();
+ jsonErrorResponse.put("requestError", "");
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_uuid1/distr.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_BAD_REQUEST)));
+
+ JSONObject jsonResponse = sdcClientUtils.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
+
+ assertEquals("500", jsonResponse.get("statusCode"));
+ assertEquals("", jsonResponse.get("messageId"));
+ assertEquals(" Encountered Error while calling SDC POST Activate. JSONObject[\"requestError\"] is not a JSONObject.", jsonResponse.get("message"));
+
+ }
+
+ @Test
+ public void buildUriBuilderTest() {
+
+ try {
+ String url = sdcClientUtils.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId);
+ assertEquals("http://localhost:" + env.getProperty("wiremock.server.port") + "/sdc/v1/catalog/services/TEST_uuid1/distribution/TEST_operationalEnvironmentId/activate", url);
+
+ } catch (Exception e) {
+ fail("Exception caught: " + e.getMessage());
+
+ }
+ }
+
+
+ @Test
+ public void buildJsonWorkloadContextTest() throws JSONException {
+
+ String jsonPayload = sdcClientUtils.buildJsonWorkloadContext(workloadContext);
+ assertEquals("{\"workloadContext\":\"TEST_workloadContext\"}", jsonPayload);
+
+ }
+
+ @Test
+ public void enhanceJsonResponseTest_Success() throws JSONException {
+
+ // build success response data
+ JSONObject sdcResponseJsonObj = new JSONObject();
+ sdcResponseJsonObj.put("distributionId", "TEST_distributionId");
+
+ int statusCode = 202;
+ sdcResponseJsonObj = sdcClientUtils.enhanceJsonResponse(sdcResponseJsonObj, statusCode);
+
+ assertEquals("202", sdcResponseJsonObj.getString("statusCode"));
+ assertEquals("", sdcResponseJsonObj.getString("messageId"));
+ assertEquals("Success", sdcResponseJsonObj.getString("message"));
+ assertEquals("TEST_distributionId", sdcResponseJsonObj.getString("distributionId"));
+
+ }
+
+ @Test
+ public void enhanceJsonResponseTest_Error() throws JSONException {
+
+ // build error response data
+ JSONObject jsonMessages = new JSONObject();
+ jsonMessages.put("messageId", "SVC4675");
+ jsonMessages.put("text", "Error: Service state is invalid for this action.");
+ JSONObject jsonServException = new JSONObject();
+ jsonServException.put("serviceException", jsonMessages);
+ JSONObject jsonErrorRequest = new JSONObject();
+ jsonErrorRequest.put("requestError", jsonServException);
+
+ String responseData = jsonErrorRequest.toString();
+
+ JSONObject sdcResponseJsonObj = new JSONObject(responseData);
+ int statusCode = 409;
+ sdcResponseJsonObj = sdcClientUtils.enhanceJsonResponse(sdcResponseJsonObj, statusCode);
+
+ assertEquals("409", sdcResponseJsonObj.getString("statusCode"));
+ assertEquals("SVC4675", sdcResponseJsonObj.getString("messageId"));
+ assertEquals("Error: Service state is invalid for this action.", sdcResponseJsonObj.getString("message"));
+
+ }
+
+ @Test
+ public void enhanceJsonResponseTest_Error_policyException() throws JSONException {
+
+ // build error response data
+ JSONObject jsonMessages = new JSONObject();
+ jsonMessages.put("messageId", "POL5003");
+ jsonMessages.put("text", "Error: Not authorized to use the API.");
+ JSONObject jsonServException = new JSONObject();
+ jsonServException.put("policyException", jsonMessages);
+ JSONObject jsonErrorRequest = new JSONObject();
+ jsonErrorRequest.put("requestError", jsonServException);
+
+ String responseData = jsonErrorRequest.toString();
+
+ JSONObject sdcResponseJsonObj = new JSONObject(responseData);
+ int statusCode = 403;
+ sdcResponseJsonObj = sdcClientUtils.enhanceJsonResponse(sdcResponseJsonObj, statusCode);
+
+ assertEquals("403", sdcResponseJsonObj.getString("statusCode"));
+ assertEquals("POL5003", sdcResponseJsonObj.getString("messageId"));
+ assertEquals("Error: Not authorized to use the API.", sdcResponseJsonObj.getString("message"));
+
+ }
+
+ @Test
+ public void enhanceJsonResponseTest_Error_UnexpectedFormat() throws JSONException {
+
+ // build error response data
+ JSONObject jsonMessages = new JSONObject();
+ jsonMessages.put("messageId", "POL5003");
+ jsonMessages.put("text", "Error: Not authorized to use the API.");
+ JSONObject jsonServException = new JSONObject();
+ jsonServException.put("policyException", jsonMessages);
+ JSONObject jsonErrorRequest = new JSONObject();
+ jsonErrorRequest.put("unexpectedResponseTag", jsonServException);
+
+ String responseData = jsonErrorRequest.toString();
+
+ JSONObject sdcResponseJsonObj = new JSONObject(responseData);
+ int statusCode = 403;
+ sdcResponseJsonObj = sdcClientUtils.enhanceJsonResponse(sdcResponseJsonObj, statusCode);
+
+ assertEquals("500", sdcResponseJsonObj.getString("statusCode"));
+ assertEquals("Undefined Error Message!", sdcResponseJsonObj.getString("messageId"));
+ assertEquals("Unexpected response format from SDC.", sdcResponseJsonObj.getString("message"));
+
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
new file mode 100644
index 0000000000..3c991ef0c5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
@@ -0,0 +1,238 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+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.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONObject;
+import org.junit.After;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
+
+ @Autowired
+ private OperationalEnvDistributionStatusRepository distributionDbRepository;
+ @Autowired
+ private OperationalEnvServiceModelStatusRepository serviceModelDbRepository;
+ @Autowired
+ private ActivateVnfOperationalEnvironment activateVnf;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+ @Autowired
+ private AAIClientHelper clientHelper;
+
+ String requestId = "TEST_requestId";
+ String operationalEnvironmentId = "EMOE-001";
+ CloudOrchestrationRequest request = new CloudOrchestrationRequest();
+ String workloadContext = "PVT";
+ String recoveryActionRetry = "RETRY";
+ String serviceModelVersionId = "TEST_serviceModelVersionId";
+ int retryCount = 3;
+ String sdcDistributionId = "TEST_distributionId";
+ String statusSent = "SENT";
+
+ @After
+ public void after() throws Exception {
+ distributionDbRepository.deleteAll();
+ serviceModelDbRepository.deleteAll();
+ }
+
+ @Test
+ public void getAAIOperationalEnvironmentTest() throws Exception {
+
+ AAIOperationalEnvironment aaiOpEnv = null;
+
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
+ aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class).get();
+ assertEquals("EMOE-001", aaiOpEnv.getOperationalEnvironmentId());
+ assertNotNull(activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId));
+ assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).getOperationalEnvironmentId());
+
+ }
+
+ @Test
+ public void executionTest() throws Exception {
+
+ List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
+ ServiceModelList serviceModelList1 = new ServiceModelList();
+ serviceModelList1.setRecoveryAction(RecoveryAction.retry);
+ serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelVersionIdList.add(serviceModelList1);
+
+ RequestDetails requestDetails = new RequestDetails();
+ RequestParameters requestParameters = new RequestParameters();
+ Manifest manifest = new Manifest();
+ manifest.setServiceModelList(serviceModelVersionIdList);
+ requestParameters.setManifest(manifest);
+ requestParameters.setWorkloadContext(workloadContext);
+ requestDetails.setRequestParameters(requestParameters);
+
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+ request.setRequestDetails(requestDetails);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", "202");
+ jsonObject.put("message", "Success");
+ jsonObject.put("distributionId", sdcDistributionId);
+
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+
+
+ activateVnf.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+
+ // insert record, status sent
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusSent, distStatus.getDistributionIdStatus());
+
+ // insert record, status sent
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+
+ }
+
+ @Test
+ public void processActivateSDCRequestTest_202() throws Exception {
+
+ String distributionId = "TEST_distributionId";
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", "202");
+ jsonObject.put("message", "Success");
+ jsonObject.put("distributionId", distributionId);
+
+ // prepare request detail
+ List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
+ ServiceModelList serviceModelList1 = new ServiceModelList();
+ serviceModelList1.setRecoveryAction(RecoveryAction.retry);
+ serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelVersionIdList.add(serviceModelList1);
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext,
+ distributionDbRepository, serviceModelDbRepository);
+
+ // insert record, status sent
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusSent, distStatus.getDistributionIdStatus());
+
+ // insert record, status sent
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+
+ }
+
+ @Test
+ public void processActivateSDCRequestTest_409() throws Exception {
+
+ // ERROR in asdc
+ JSONObject jsonMessages = new JSONObject();
+ jsonMessages.put("message", "Failure");
+ jsonMessages.put("messageId", "SVC4675");
+ jsonMessages.put("text", "Error: Service state is invalid for this action.");
+ JSONObject jsonServException = new JSONObject();
+ jsonServException.put("policyException", jsonMessages);
+ //jsonServException.put("serviceException", jsonMessages);
+ JSONObject jsonErrorResponse = new JSONObject();
+ jsonErrorResponse.put("requestError", jsonServException);
+
+ // prepare request detail
+ List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
+ ServiceModelList serviceModelList1 = new ServiceModelList();
+ serviceModelList1.setRecoveryAction(RecoveryAction.retry);
+ serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelVersionIdList.add(serviceModelList1);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestId);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_CONFLICT)));
+
+ try {
+ activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext,
+ distributionDbRepository, serviceModelDbRepository);
+
+ } catch (Exception ex) {
+
+ // insert record, status sent
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
+
+ }
+
+ infraActiveRequestsRepository.delete(requestId);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
new file mode 100644
index 0000000000..3dcac0da18
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
@@ -0,0 +1,640 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertEquals;
+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 org.apache.http.HttpStatus;
+import org.json.JSONObject;
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Status;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
+
+ @Autowired
+ private OperationalEnvDistributionStatusRepository distributionDbRepository;
+ @Autowired
+ private OperationalEnvServiceModelStatusRepository serviceModelDbRepository;
+ @Autowired
+ private ActivateVnfStatusOperationalEnvironment activateVnfStatus;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+ @Autowired
+ private ActivateVnfDBHelper dbHelper;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private String requestId = "TEST_requestId";
+ private String requestIdOrig = "TEST_requestIdOrig";
+ private String operationalEnvironmentId = "TEST_operationalEnvironmentId";
+ private CloudOrchestrationRequest request = new CloudOrchestrationRequest();
+ private String workloadContext = "TEST_workloadContext";
+ private String recoveryActionRetry = "RETRY";
+ private String recoveryActionAbort = "ABORT";
+ private String recoveryActionSkip = "SKIP";
+ private String serviceModelVersionId = "TEST_serviceModelVersionId";
+ private String serviceModelVersionId1 = "TEST_serviceModelVersionId1";
+ private int retryCountThree = 3;
+ private int retryCountTwo = 2;
+ private int retryCountZero = 0;
+ private String sdcDistributionId = "TEST_distributionId";
+ private String sdcDistributionId1 = "TEST_distributionId1";
+ private String statusOk = Status.DISTRIBUTION_COMPLETE_OK.toString();
+ private String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
+ private String statusSent = "SENT";
+
+ @After
+ public void after() throws Exception {
+ distributionDbRepository.deleteAll();
+ serviceModelDbRepository.deleteAll();
+ }
+
+ @Test
+ public void checkOrUpdateOverallStatusTest_Ok() throws Exception {
+
+ // two entries, both status Ok & retry 0
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountZero);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusOk);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId1);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountZero);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusOk);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository);
+
+ // overall is success
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+ }
+
+ @Test
+ public void checkOrUpdateOverallStatusTest_Error() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountZero);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ try {
+ activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository);
+ }catch(ApiException e){
+ assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
+ assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
+ assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ }
+
+ // overall is failure
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+ }
+
+ @Test
+ public void checkOrUpdateOverallStatusTest_Waiting() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountTwo);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository);
+
+ // do nothing, waiting for more
+ assertNull(infraActiveRequestsRepository.findOne(requestIdOrig));
+ }
+
+ @Test
+ public void executionTest_Ok() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountThree);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusSent);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusSent);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+ distributionDbRepository.saveAndFlush(distributionDb);
+
+
+
+ // prepare distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_OK);
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+
+ // status ok
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusOk, distStatus.getDistributionIdStatus());
+ assertEquals("", distStatus.getDistributionIdErrorReason());
+
+ // status ok
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+ assertEquals(statusOk, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(new Integer(retryCountZero), servStatus.getRetryCount());
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+
+ }
+
+ @Test
+ public void executionTest_ERROR_Status_And_RETRY() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountThree);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusError);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+ distributionDbRepository.saveAndFlush(distributionDb);
+
+
+
+ // prepare new distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
+ distribution.setErrorReason("Unable to process.");
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ // prepare sdc return data
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", "202");
+ jsonObject.put("message", "Success");
+ jsonObject.put("distributionId", sdcDistributionId1);
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+
+ // old distributionId, status error
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusError, distStatus.getDistributionIdStatus());
+ assertEquals("Unable to process.", distStatus.getDistributionIdErrorReason());
+
+ // new distributionId, status sent
+ OperationalEnvDistributionStatus newDistStatus = distributionDbRepository.findOne(sdcDistributionId1);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, newDistStatus.getOperationalEnvId());
+ assertEquals(statusSent, newDistStatus.getDistributionIdStatus());
+ assertEquals("", newDistStatus.getDistributionIdErrorReason());
+
+ // count is less 1, status sent
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+ assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(new Integer(retryCountTwo), servStatus.getRetryCount());
+
+ // no update
+ assertNull(infraActiveRequestsRepository.findOne(requestIdOrig));
+
+ }
+
+ @Test
+ public void executionTest_ERROR_Status_And_RETRY_And_RetryZero() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountZero);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusError);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+ distributionDbRepository.saveAndFlush(distributionDb);
+
+
+
+ // prepare distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", "202");
+ jsonObject.put("message", "Success");
+ jsonObject.put("distributionId", sdcDistributionId);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ try {
+ activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+ }catch(ApiException e){
+ assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
+ assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
+ assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ }
+
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusError, distStatus.getDistributionIdStatus());
+ assertEquals(null, distStatus.getDistributionIdErrorReason());
+
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+ assertEquals(statusError, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(new Integer(retryCountZero), servStatus.getRetryCount());
+
+ // Retry count is zero, no more retry. all retry failed.
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+
+ }
+
+ @Test
+ public void executionTest_ERROR_Status_And_RETRY_And_ErrorSdc() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountThree);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusError);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+ distributionDbRepository.saveAndFlush(distributionDb);
+
+
+
+ // prepare distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
+ distribution.setErrorReason("Unable to process.");
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ // ERROR in sdc
+ JSONObject jsonMessages = new JSONObject();
+ jsonMessages.put("statusCode", "409");
+ jsonMessages.put("message", "Undefined Error Message!");
+ jsonMessages.put("messageId", "SVC4675");
+ jsonMessages.put("text", "Error: Service state is invalid for this action.");
+ JSONObject jsonServException = new JSONObject();
+ jsonServException.put("serviceException", jsonMessages);
+ JSONObject jsonErrorRequest = new JSONObject();
+ jsonErrorRequest.put("requestError", jsonServException);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonMessages.toString()).withStatus(HttpStatus.SC_CONFLICT)));
+
+ try {
+ activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+ }catch(ApiException e){
+ assertThat(e.getMessage(), startsWith("Failure calling SDC: statusCode: "));
+ assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
+ assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ }
+ // status as-is / no changes
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusError, distStatus.getDistributionIdStatus());
+ assertEquals(null, distStatus.getDistributionIdErrorReason());
+
+ // status as-is / no changes
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+ assertEquals(statusError, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(new Integer(retryCountThree), servStatus.getRetryCount());
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
+ assertTrue(infraActiveRequest.getStatusMessage().contains("Undefined Error Message!"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+
+ }
+
+ @Test
+ public void executionTest_ERROR_Status_And_SKIP() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionSkip);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountThree);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusError);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+ distributionDbRepository.saveAndFlush(distributionDb);
+
+
+
+ // prepare distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+
+ }
+
+ @Test
+ public void executionTest_ERROR_Status_And_ABORT() throws Exception {
+
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionAbort);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountThree);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusError);
+ serviceModelDbRepository.saveAndFlush(serviceModelDb);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusError);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+ distributionDbRepository.saveAndFlush(distributionDb);
+
+
+
+ // prepare distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestIdOrig);
+ iar.setRequestStatus("PENDING");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ try {
+ activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository);
+ }catch(ApiException e){
+ assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. "));
+ assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST);
+ assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
+ }
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
+ assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED"));
+
+ // cleanup
+ infraActiveRequestsRepository.delete(requestIdOrig);
+
+ }
+
+ @Test
+ @Ignore
+ public void callSDClientForRetryTest_202() throws Exception {
+ OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus();
+ serviceModelDb.setRequestId(requestIdOrig);
+ serviceModelDb.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelDb.setWorkloadContext(workloadContext);
+ serviceModelDb.setRecoveryAction(recoveryActionRetry);
+ serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelDb.setRetryCount(retryCountThree);
+ serviceModelDb.setServiceModelVersionDistrStatus(statusSent);
+
+ OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus();
+ distributionDb.setDistributionId(sdcDistributionId);
+ distributionDb.setRequestId(requestIdOrig);
+ distributionDb.setOperationalEnvId(operationalEnvironmentId);
+ distributionDb.setDistributionIdStatus(statusSent);
+ distributionDb.setServiceModelVersionId(serviceModelVersionId);
+ distributionDb.setDistributionIdErrorReason(null);
+
+
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", "202");
+ jsonObject.put("message", "Success");
+ jsonObject.put("distributionId", sdcDistributionId1);
+
+ // prepare distribution obj
+ Distribution distribution = new Distribution();
+ distribution.setStatus(Status.DISTRIBUTION_COMPLETE_OK);
+ request.setDistribution(distribution);
+ request.setDistributionId(sdcDistributionId);
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+
+ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution,
+ distributionDbRepository, serviceModelDbRepository);
+
+ assertEquals("TEST_distributionId1", jsonResponse.get("distributionId"));
+ assertEquals("Success", jsonResponse.get("message"));
+ assertEquals("202", jsonResponse.get("statusCode"));
+
+ // insert new record, status sent
+ OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId1);
+ assertNotNull(distStatus);
+ assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId());
+ assertEquals(statusSent, distStatus.getDistributionIdStatus());
+
+ // insert new record, status sent
+ OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId);
+ assertNotNull(servStatus);
+ assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus());
+ assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId());
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
new file mode 100644
index 0000000000..d64cf6106a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public class CreateEcompOperationalEnvironmentTest extends BaseTest{
+
+ @Autowired
+ private CreateEcompOperationalEnvironment createEcompOpEn;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+
+ public CloudOrchestrationRequest getCloudOrchestrationRequest() {
+ CloudOrchestrationRequest request = new CloudOrchestrationRequest();
+ RequestDetails reqDetails = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ RequestParameters reqParams = new RequestParameters();
+ reqParams.setTenantContext("TEST");
+ reqParams.setWorkloadContext("ECOMP_TEST");
+ reqParams.setOperationalEnvironmentType(OperationalEnvironment.ECOMP);
+ reqInfo.setInstanceName("TEST_ECOMP_ENVIRONMENT");
+ reqDetails.setRequestInfo(reqInfo);
+ reqDetails.setRequestParameters(reqParams);
+ request.setRequestDetails(reqDetails);
+ request.setOperationalEnvironmentId("operationalEnvId");
+
+ return request;
+ }
+
+ @Test
+ public void testProcess() throws ApiException {
+ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathMatching("/events/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("123");
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ createEcompOpEn.execute("123", getCloudOrchestrationRequest());
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOneByRequestId("123");
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS"));
+ assertTrue(infraActiveRequest.getRequestStatus().equals("COMPLETE"));
+ }
+
+ @Test
+ public void testProcessException() {
+ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathMatching("/events/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+ ValidateException expectedException = new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId("123");
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ try {
+ createEcompOpEn.execute("123", getCloudOrchestrationRequest());
+ }catch(ApiException e){
+ assertThat(e, sameBeanAs((ApiException) expectedException).ignoring("cause"));
+ }
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOneByRequestId("123");
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE"));
+ assertTrue(infraActiveRequest.getRequestStatus().equals("FAILED"));
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
new file mode 100644
index 0000000000..8fe40f31a4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+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.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.client.grm.beans.Property;
+import org.onap.so.client.grm.beans.ServiceEndPointList;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+public class CreateVnfOperationalEnvironmentTest extends BaseTest{
+
+ private CloudOrchestrationRequest request;
+ private ServiceEndPointList serviceEndpoints;
+
+ @Autowired
+ private CreateVnfOperationalEnvironment createVnfOpEnv;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+
+ @Before
+ public void testSetUp() throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ String jsonRequest = getFileContentsAsString("__files/vnfoperenv/createVnfOperationalEnvironmentRequest.json");
+ request = mapper.readValue(jsonRequest, CloudOrchestrationRequest.class);
+ String jsonServiceEndpoints = getFileContentsAsString("__files/vnfoperenv/endpoints.json");
+ serviceEndpoints = mapper.readValue(jsonServiceEndpoints, ServiceEndPointList.class);
+ }
+
+ @Test
+ public void testGetEcompManagingEnvironmentId() throws Exception {
+ createVnfOpEnv.setRequest(request);
+ assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff000", createVnfOpEnv.getEcompManagingEnvironmentId());
+ }
+
+ @Test
+ public void testGetTenantContext() throws Exception {
+ createVnfOpEnv.setRequest(request);
+ assertEquals("Test", createVnfOpEnv.getTenantContext());
+ }
+
+ @Test
+ public void testGetEnvironmentName() throws Exception {
+ createVnfOpEnv.setRequest(request);
+ List<Property> props = serviceEndpoints.getServiceEndPointList().get(0).getProperties();
+ assertEquals("DEV", createVnfOpEnv.getEnvironmentName(props));
+ }
+
+ @Test
+ public void testBuildServiceNameForVnf() throws Exception {
+ createVnfOpEnv.setRequest(request);
+ assertEquals("Test.VNF_E2E-IST.Inventory", createVnfOpEnv.buildServiceNameForVnf("TEST.ECOMP_PSL.Inventory"));
+ }
+
+ @Test
+ public void testGetSearchKey() {
+ createVnfOpEnv.setRequest(request);
+ AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
+ ecompEnv.setTenantContext("Test");
+ ecompEnv.setWorkloadContext("ECOMPL_PSL");
+ assertEquals("Test.ECOMPL_PSL.*", createVnfOpEnv.getSearchKey(ecompEnv));
+ }
+
+ public String getFileContentsAsString(String fileName) {
+ String content = "";
+ try {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ File file = new File(classLoader.getResource(fileName).getFile());
+ content = new String(Files.readAllBytes(file.toPath()));
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
+ }
+ return content;
+ }
+
+ @Test
+ public void testExecute() throws ApiException{
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/endpoints.json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/add"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
+ String requestId = UUID.randomUUID().toString();
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestId);
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+ createVnfOpEnv.execute(requestId, request);
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS"));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
new file mode 100644
index 0000000000..a9be10c3f4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+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.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Autowired
+ private DeactivateVnfOperationalEnvironment deactivate;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+
+ private CloudOrchestrationRequest request = new CloudOrchestrationRequest();
+ private String operationalEnvironmentId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
+ private String requestId = "ff3514e3-5a33-55df-13ab-12abad84e7fe";
+
+ @Test
+ public void testDeactivateOperationalEnvironment() throws Exception {
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+ request.setRequestDetails(null);
+
+ String json = "{\"operational-environment-status\" : \"ACTIVE\"}";
+
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestId);
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ deactivate.execute(requestId, request);
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL"));
+
+ }
+
+ @Test
+ public void testDeactivateInvalidStatus() throws Exception {
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+ request.setRequestDetails(null);
+
+ String json = "{\"operational-environment-status\" : \"SUCCESS\"}";
+
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(startsWith("Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: "));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)));
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestId);
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ deactivate.execute(requestId, request);
+ }
+
+ @Test
+ public void testDeactivateInactiveStatus() throws Exception {
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+ request.setRequestDetails(null);
+
+ String json = "{\"operational-environment-status\" : \"INACTIVE\"}";
+
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ InfraActiveRequests iar = new InfraActiveRequests();
+ iar.setRequestId(requestId);
+ iar.setOperationalEnvName("myOpEnv");
+ iar.setRequestScope("create");
+ iar.setRequestStatus("PENDING");
+ iar.setRequestAction("UNKNOWN");
+ infraActiveRequestsRepository.saveAndFlush(iar);
+
+ deactivate.execute(requestId, request);
+
+ InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId);
+ assertNotNull(infraActiveRequest);
+ assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS"));
+ }
+
+ @Test
+ public void testDeactivateNullStatus() throws Exception {
+ request.setOperationalEnvironmentId(operationalEnvironmentId);
+ request.setRequestDetails(null);
+
+ String json = "{\"operational-environment-status\" : \"\"}";
+
+ stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
+
+ thrown.expect(ValidateException.class);
+ thrown.expectMessage(startsWith("OperationalEnvironmentStatus is null on OperationalEnvironmentId: "));
+ thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST)));
+ thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)));
+ deactivate.execute(requestId, request);
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java
index 7cf60d339d..8236e6766f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.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.
@@ -18,44 +18,70 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.util.List;
-
-import org.junit.Test;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.filters.FilterPackageInfo;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.affirm.Affirm;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-
-public class TenantIsolationBeansTest {
-
- private static final int EXPECTED_CLASS_COUNT = 26;
- private static final String POJO_PACKAGE = "org.openecomp.mso.apihandlerinfra.tenantisolationbeans";
-
- @Test
- public void ensureExpectedPojoCount() {
- List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses( POJO_PACKAGE,
- new FilterPackageInfo());
- Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
- }
-
- @Test
- public void testPojoStructureAndBehavior() {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
-
- validator.validate(POJO_PACKAGE, new FilterPackageInfo());
- }
-}
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.BaseTest;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.affirm.Affirm;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+public class TenantIsolationBeansTest extends BaseTest{
+
+ private static final int EXPECTED_CLASS_COUNT = 25;
+ private static final String POJO_PACKAGE = "org.onap.so.apihandlerinfra.tenantisolationbeans";
+
+ @Test
+ public void ensureExpectedPojoCount() {
+ List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses( POJO_PACKAGE,
+ new FilterPackageInfo());
+ Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
+ }
+
+ @Test
+ public void testPojoStructureAndBehavior() {
+ Validator validator = ValidatorBuilder.create()
+ .with(new GetterMustExistRule())
+ .with(new SetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ validator.validate(POJO_PACKAGE, new FilterPackageInfo());
+ }
+
+ @Test
+ public void testTenantIsolationToString() {
+ TenantIsolationRequest request = new TenantIsolationRequest();
+ request.setRequestId("requestId");
+ request.setRequestScope("scope");
+ request.setRequestType("type");
+ request.setStartTime("time");
+ request.setRequestDetails(new RequestDetails());
+ request.setRequestStatus(new RequestStatus());
+
+ assertNotNull(request.toString());
+ }
+
+ @Test
+ public void testRequestListToString() {
+ RequestList list = new RequestList();
+ list.setRequest(new Request());
+ list.setRequestStatus(new RequestStatus());
+
+ assertNotNull(list.toString());
+ }
+}
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
new file mode 100644
index 0000000000..93542c0a76
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RelatedInstancesValidationTest extends BaseTest{
+
+ @Test
+ public void testCreateVnfNetworkCollection() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/v7CreateVnfNetworkCollection.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance,
+ 6, false, sir.getRequestDetails().getRequestParameters());
+ info.setRequestScope("vnf");
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
+ RelatedInstancesValidation validation = new RelatedInstancesValidation();
+ validation.validate(info);
+
+ assertEquals(info.getVnfType(), "Test/name");
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeanTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeanTest.java
deleted file mode 100644
index 9028109735..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeanTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs;
-
-public class BeanTest {
-
- @Test
- public void testVnfInputs(){
- VnfInputs bean = new VnfInputs();
- bean.setAicCloudRegion("south");
- bean.setAicNodeClli("38982");
- bean.setAsdcServiceModelVersion("v2");
- bean.setBackoutOnFailure(false);
- bean.setIsBaseVfModule(true);
- bean.setPersonaModelId("2017");
- bean.setPersonaModelVersion("v3");
- bean.setProvStatus("active");
- bean.setServiceId("123456");
- bean.setServiceInstanceId("aaa1234");
- bean.setServiceType("vnf");
- bean.setTenantId("89903042");
- bean.setVfModuleId("4993022");
- bean.setVfModuleModelName("m1");
- bean.setVnfId("34");
- bean.setVnfName("test");
- bean.setVnfPersonaModelId("1002");
- bean.setVnfPersonaModelVersion("v3");
- bean.setVnfType("fddf");
- bean.setVolumeGroupId("7889");
- bean.setVolumeGroupName("test");
-
- String str = bean.toString();
- assertTrue(str != null);
-
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
deleted file mode 100644
index 901e03fc17..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
+++ /dev/null
@@ -1,1327 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.message.BasicHttpResponse;
-import org.hibernate.Session;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openecomp.mso.apihandler.common.CamundaClient;
-import org.openecomp.mso.apihandler.common.RequestClient;
-import org.openecomp.mso.apihandler.common.RequestClientFactory;
-import org.openecomp.mso.apihandler.common.RequestClientParamater;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.OperationStatus;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-
-import mockit.Expectations;
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.Mocked;
-
-public class E2EServiceInstancesTest {
-
- private final String compareModelsRequest = "{" +
- "\"globalSubscriberId\": \"60c3e96e-0970-4871-b6e0-3b6de7561519\"," +
- "\"serviceType\": \"vnf\"," +
- "\"modelInvariantIdTarget\": \"60c3e96e-0970-4871-b6e0-3b6de1234567\"," +
- "\"modelVersionIdTarget\": \"modelVersionIdTarget\"" +
- "}";
-
- private final String scaleRequest = "{\"service\":{\"serviceType\":\"example-service-type\",\"globalSubscriberId\":\"test_custormer\",\"resources\":[{\"resourceInstanceId\":\"ns111\",\"scaleType\":\"SCALE_NS\",\"scaleNsData\":{\"scaleNsByStepsData\":{\"numberOfSteps\":\"4\",\"aspectId\":\"TIC_EDGE_HW\",\"scalingDirection\":\"UP\"}}}],\"serviceInstanceName\":\"XXXX\"}}";
-
- String jsonBody = "{" +
- "\"service\": {" +
- "\"name\": \"so_test4\"," +
- "\"description\": \"so_test2\"," +
- "\"serviceInvariantUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561519\"," +
- "\"serviceUuid\": \"592f9437-a9c0-4303-b9f6-c445bb7e9814\"," +
- "\"globalSubscriberId\": \"123457\"," +
- "\"serviceType\": \"voLTE\"," +
- "\"parameters\": {" +
- "\"resources\": [" +
- "{" +
- "\"resourceName\": \"vIMS\"," +
- "\"resourceInvariantUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561516\"," +
- "\"resourceUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561512\"," +
- "\"parameters\": {" +
- "\"locationConstraints\": [" +
- "{" +
- "\"vnfProfileId\": \"zte-vBAS-1.0\"," +
- "\"locationConstraints\": {" +
- "\"vimId\": \"4050083f-465f-4838-af1e-47a545222ad0\"" +
- "}" +
- "}," +
- "{" +
- "\"vnfProfileId\": \"zte-vMME-1.0\"," +
- "\"locationConstraints\": {" +
- "\"vimId\": \"4050083f-465f-4838-af1e-47a545222ad0\"" +
- "}" +
- "}" +
- "]" +
- "}" +
- "}," +
- "{" +
- "\"resourceName\": \"vEPC\"," +
- "\"resourceInvariantUuid\": \"61c3e96e-0970-4871-b6e0-3b6de7561516\"," +
- "\"resourceUuid\": \"62c3e96e-0970-4871-b6e0-3b6de7561512\"," +
- "\"parameters\": {" +
- "\"locationConstraints\": [" +
- "{" +
- "\"vnfProfileId\": \"zte-CSCF-1.0\"," +
- "\"locationConstraints\": {" +
- "\"vimId\": \"4050083f-465f-4838-af1e-47a545222ad1\"" +
- "}" +
- "}" +
- "]" +
- "}" +
- "}," +
- "{" +
- "\"resourceName\": \"underlayvpn\"," +
- "\"resourceInvariantUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561513\"," +
- "\"resourceUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561514\"," +
- "\"parameters\": {" +
- "\"locationConstraints\": []" +
- "}" +
- "}," +
- "{" +
- "\"resourceName\": \"overlayvpn\"," +
- "\"resourceInvariantUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561517\"," +
- "\"resourceUuid\": \"60c3e96e-0970-4871-b6e0-3b6de7561518\"," +
- "\"parameters\": {" +
- "\"locationConstraints\": []" +
- "}" +
- "}" +
- "]," +
- "\"requestInputs\": {" +
- "\"externalDataNetworkName\": \"Flow_out_net\"," +
- "\"m6000_mng_ip\": \"181.18.20.2\"," +
- "\"externalCompanyFtpDataNetworkName\": \"Flow_out_net\"," +
- "\"externalPluginManageNetworkName\": \"plugin_net_2014\"," +
- "\"externalManageNetworkName\": \"mng_net_2017\"," +
- "\"sfc_data_network\": \"sfc_data_net_2016\"," +
- "\"NatIpRange\": \"210.1.1.10-210.1.1.20\"," +
- "\"location\": \"4050083f-465f-4838-af1e-47a545222ad0\"," +
- "\"sdncontroller\": \"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"" +
- "}" +
- "}" +
- "}" +
- "}";
-
- @BeforeClass
- public static void setUp() throws Exception {
-
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
- }
-
- @Test
- public void createE2EServiceInstanceTestSuccess() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("success"));
- }
-
- @Test
- public void createE2EServiceInstanceTestBpelHTTPException() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 500,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- @Test
- public void createE2EServiceInstanceTestBpelHTTPExceptionWithNullREsponseBody() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 500,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- @Test
- public void createE2EServiceInstanceTestNullBPELResponse() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- HttpResponse resp = null;
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestBPMNNullREsponse() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(String camundaReqXML, String requestId,
- String requestTimeout, String schemaVersion,
- String serviceInstanceId, String action) {
- HttpResponse resp = null;
- return resp;
- }
- };
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestNullBpmn() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- ;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestNullReceipe() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestNullDBResponse() {
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestInvalidRequest() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestEmptyDBQuery() {
-
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- // assertTrue(true);
- }
-
- @Test
- public void createE2EServiceInstanceTestDBQueryFail() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceName(
- String serviceName) {
- OperationStatus operationStatus = new OperationStatus();
- return operationStatus;
- }
- };
-
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("serviceException"));
- }
-
- @Test
- public void createE2EServiceInstanceTestForEmptyRequest() {
-
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr
- .contains("Mapping of request to JSON object failed. No content to map due to end-of-input"));
- }
-
- @Test
- public void deleteE2EServiceInstanceTestNormal() {
-
- final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
-
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- rec.setOrchestrationUri("/test/delE2E");
- rec.setRecipeTimeout(180);
- return rec;
- }
- };
-
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- final MockUp<CamundaClient> mockCmaundaClient = new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 200, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
-
- instance.deleteE2EServiceInstance(request, "v3", "12345678");
- mockCDB.tearDown();
- mockMsoRequest.tearDown();
- mockCmaundaClient.tearDown();
-
- }
-
- @Test
- public void deleteE2EServiceInstanceTestFail() {
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
- instance.deleteE2EServiceInstance(request, "v3", "12345678");
- }
-
- @Test
- public void deleteE2EServiceInstanceTestFailClient(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session) {
- final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
-
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- rec.setOrchestrationUri("/test/delE2E");
- rec.setRecipeTimeout(180);
- return rec;
- }
- };
-
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
-
- instance.deleteE2EServiceInstance(request, "v3", "12345678");
- mockCDB.tearDown();
- mockMsoRequest.tearDown();
-
- }
-
- @Test
- public void deleteE2EServiceInstanceTestFailRecipe(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session) {
- final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
-
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
-
- instance.deleteE2EServiceInstance(request, "v3", "12345678");
- mockCDB.tearDown();
- mockMsoRequest.tearDown();
-
- }
-
- @Test
- public void deleteE2EServiceInstanceTestFailModelName(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session) {
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- new Expectations() {{
- sessionFactoryManager.getSessionFactory().openSession();
- result = session;
- }};
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
-
- instance.deleteE2EServiceInstance(request, "v3", "12345678");
- mockMsoRequest.tearDown();
-
- }
-
- @Test
- public void getE2EServiceInstanceTest() {
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatus(String serviceId,
- String operationId) {
- OperationStatus os = new OperationStatus();
- os.setOperation("");
- os.setOperationContent("");
- os.setOperationId("123456");
- os.setProgress("");
- os.setServiceId("12345");
- os.setServiceName("VoLTE");
- os.setReason("");
- os.setResult("");
- os.setUserId("");
- return os;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response resp = instance
- .getE2EServiceInstances("12345", "v3", "123456");
-
- }
-
- @Test
- public void updateE2EServiceInstanceTestNormal() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceId(
- String serviceID) {
- OperationStatus operationStatus = new OperationStatus();
- operationStatus.setProgress("100");
- operationStatus.setResult("finish");
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("success"));
- }
-
- @Test
- public void updateE2EServiceInstanceTestChkStatusFalse() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceId(
- String serviceID) {
- OperationStatus operationStatus = new OperationStatus();
- operationStatus.setResult("processing");
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
- String respStr = resp.getEntity().toString();
- assertTrue(!respStr.contains("SVC2000"));
- }
-
- @Test
- public void updateE2EServiceInstanceExceptionMsoRequestTest() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceId(
- String serviceID) {
- OperationStatus operationStatus = new OperationStatus();
- operationStatus.setProgress("100");
- operationStatus.setResult("finish");
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
- MockUp<MsoRequest> msoRequest = new MockUp<MsoRequest>() {
- @Mock
- void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Action action, String version, String originalRequestJSON) throws ValidationException {
-
- throw new ValidationException("mock failure");
- }
- };
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
- msoRequest.tearDown();
- }
-
- @Test
- public void updateE2EServiceInstanceExceptionCatalogDbTest() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceId(
- String serviceID) {
- OperationStatus operationStatus = new OperationStatus();
- operationStatus.setProgress("100");
- operationStatus.setResult("finish");
- return operationStatus;
- }
- };
-
- MockUp<CatalogDatabase> catalog = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) throws Exception {
- throw new Exception();
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
- catalog.tearDown();
- }
-
- @Test
- public void updateE2EServiceInstanceNullServiceTest() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceId(
- String serviceID) {
- OperationStatus operationStatus = new OperationStatus();
- operationStatus.setProgress("100");
- operationStatus.setResult("finish");
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- MockUp<CatalogDatabase> catalog = new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- return null;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus());
- catalog.tearDown();
- }
-
- @Test
- public void updateE2EServiceInstanceRequestClientExceptionTest() {
- new MockUp<RequestsDatabase>() {
- @Mock
- public OperationStatus getOperationStatusByServiceId(
- String serviceID) {
- OperationStatus operationStatus = new OperationStatus();
- operationStatus.setProgress("100");
- operationStatus.setResult("finish");
- return operationStatus;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- MockUp<CamundaClient> client = new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) throws Exception {
- throw new Exception();
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = jsonBody;
- Response resp = instance.updateE2EServiceInstance(request, "v3", "12345");
- assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), resp.getStatus());
- client.tearDown();
- }
-
- @Test
- public void compareModelwithTargetVersionBadRequest(){
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.compareModelwithTargetVersion("", "12345", "v3");
-
- assertNotNull(response);
- assertTrue(response.getEntity().toString().contains("Mapping of request to JSON object failed."));
-
- }
- @Test
- public void compareModelwithTargetVersionFailedBPMNCall(){
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) throws IOException {
- throw new ClientProtocolException();
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.compareModelwithTargetVersion(compareModelsRequest, "12345", "v3");
-
- assertNotNull(response);
- assertTrue(response.getEntity().toString().contains("Failed calling bpmn"));
-
- }
-
- @Test
- public void compareModelwithTargetVersionSuccess(){
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "compareModelwithTargetVersion, test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
-
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.compareModelwithTargetVersion(compareModelsRequest, "12345", "v3");
-
- assertNotNull(response);
- assertTrue(response.getStatus()==202);
-
- }
-
- @Test
- public void scaleE2EserviceInstancesTestFailInvalidRequest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session ) {
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.scaleE2EServiceInstance(jsonBody, "v3", "12345");
- }
-
- @Test
- public void scaleE2EserviceInstancesTestNormal() {
-
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
-
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- rec.setOrchestrationUri("/test/delE2E");
- rec.setRecipeTimeout(180);
- return rec;
- }
- };
-
- final MockUp<RequestClientFactory> mockRequestClient = new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- final MockUp<CamundaClient> mockCamundaClient = new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
- HttpResponse resp = new BasicHttpResponse(pv, 202,
- "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.scaleE2EServiceInstance(scaleRequest, "v3", "12345");
- mockMsoRequest.tearDown();
- mockCDB.tearDown();
- mockRequestClient.tearDown();
- mockCamundaClient.tearDown();
- }
-
- @Test
- public void scaleE2EserviceInstancesTestFailCamundaClient(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session) {
-
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
-
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- rec.setOrchestrationUri("/test/delE2E");
- rec.setRecipeTimeout(180);
- return rec;
- }
- };
-
- final MockUp<RequestClientFactory> mockRequestClient = new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI,
- MsoJavaProperties props) throws IllegalStateException {
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.scaleE2EServiceInstance(scaleRequest, "v3", "12345");
- mockMsoRequest.tearDown();
- mockCDB.tearDown();
- mockRequestClient.tearDown();
- }
-
- @Test
- public void scaleE2EserviceInstancesTestFailRequestClient(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session) {
-
- final MockUp<MsoRequest> mockMsoRequest = new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord(Status status, Action action) {
- return;
- }
- };
-
- final MockUp<CatalogDatabase> mockCDB = new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName(String modelName) {
- Service svc = new Service();
- return svc;
- }
-
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
- String action) {
- ServiceRecipe rec = new ServiceRecipe();
- rec.setOrchestrationUri("/test/delE2E");
- rec.setRecipeTimeout(180);
- return rec;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- Response response = instance.scaleE2EServiceInstance(scaleRequest, "v3", "12345");
- mockMsoRequest.tearDown();
- mockCDB.tearDown();
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java
deleted file mode 100644
index 5502d38268..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra;
-
-import static org.junit.Assert.*;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.MsoStatusUtil;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class GlobalHealthcheckHandlerTest {
-
- public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
- public static final Response HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
-
- @Test
- public final void testGlobalHealthcheck() {
- try {
- MsoStatusUtil statusUtil = Mockito.mock(MsoStatusUtil.class);
- HealthCheckUtils utils = Mockito.mock(HealthCheckUtils.class);
- Mockito.when(utils.verifyGlobalHealthCheck(true, null)).thenReturn(true);
- Mockito.when(statusUtil.getSiteStatus(Mockito.anyString())).thenReturn(true);
- GlobalHealthcheckHandler gh = Mockito.mock(GlobalHealthcheckHandler.class);
- Mockito.when(gh.globalHealthcheck(Mockito.anyBoolean())).thenReturn(HEALTH_CHECK_RESPONSE);
- Response resp = gh.globalHealthcheck(true);
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java
deleted file mode 100644
index 7fb3bf00b0..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java
+++ /dev/null
@@ -1,624 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-
-import mockit.Expectations;
-import mockit.Mocked;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.CharEncoding;
-import org.hibernate.Session;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-
-@RunWith(JUnitParamsRunner.class)
-public class MsoRequestTest {
- private ObjectMapper mapper = new ObjectMapper();
- private HashMap<String, String> instanceIdMapTest = new HashMap<>();
- private ServiceInstancesRequest sir;
- private MsoRequest msoRequest;
- private Action action;
- private String version;
- private String originalRequestJSON;
- private String requestJSON;
- private boolean expected;
- private String expectedException;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
-
- @Before
- public void validate(){
- msoRequest = new MsoRequest();
- }
- public String inputStream(String JsonInput)throws IOException{
- String input = IOUtils.toString(ClassLoader.class.getResourceAsStream (JsonInput), CharEncoding.UTF_8);
- return input;
- }
- @Test
- public void nullInstanceIdMapTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest = null;
- thrown.expect(NullPointerException.class);
- this.msoRequest = new MsoRequest("nullINstanceIdMap");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- @Parameters(method = "successParameters")
- public void successTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws ValidationException{
- this.sir = sir;
- this.instanceIdMapTest = instanceIdMapTest;
- this.action = action;
- this.version = version;
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.msoRequest = new MsoRequest("successTest");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Parameters
- private Collection<Object[]> successParameters() throws JsonParseException, JsonMappingException, IOException{
- return Arrays.asList(new Object[][]{
- {mapper.readValue(inputStream("/EmptyRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {mapper.readValue(inputStream("/ValidModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v4"},
- {mapper.readValue(inputStream("/EmptyCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
- {mapper.readValue(inputStream("/RelatedInstancesModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v5"},
- {mapper.readValue(inputStream("/PlatformTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
- {mapper.readValue(inputStream("/v5EnablePortMirrorService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
- {mapper.readValue(inputStream("/ValidModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {mapper.readValue(inputStream("/ValidModelCustomizationIdService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {mapper.readValue(inputStream("/ServiceProductFamilyIdUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
- {mapper.readValue(inputStream("/ServiceProductFamilyIdFlag.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
- {mapper.readValue(inputStream("/VnfModelCustomizationIdEmpty.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v5"},
- {mapper.readValue(inputStream("/RelatedInstancesVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {mapper.readValue(inputStream("/RelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {mapper.readValue(inputStream("/VnfModelCustomizationNameNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {mapper.readValue(inputStream("/VnfModelCustomizationTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {mapper.readValue(inputStream("/ServiceModelNameEmptyOnDelete.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v2"},
- {mapper.readValue(inputStream("/ServiceModelNameEmptyOnActivate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v2"},
- {mapper.readValue(inputStream("/ModelVersionNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v3"},
- {mapper.readValue(inputStream("/ModelInvariantIdService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v4"},
- {mapper.readValue(inputStream("/ModelInvariantIdConfigurationDelete.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v3"},
- {mapper.readValue(inputStream("/ModelCustomizationIdUsingPreload.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {mapper.readValue(inputStream("/ServiceInPlaceSoftwareUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {mapper.readValue(inputStream("/EmptyOwningEntityName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {mapper.readValue(inputStream("/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v6"},
- {mapper.readValue(inputStream("/VnfActivate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v6"},
- {mapper.readValue(inputStream("/ServiceInPlaceSoftwareUpdate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
- {mapper.readValue(inputStream("/ProjectAndOwningEntity2.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
- {mapper.readValue(inputStream("/PlatformAndLineOfBusiness2.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
- {mapper.readValue(inputStream("/UserParams.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"}
- });
- }
- @Test
- @Parameters(method = "aLaCarteParameters")
- public void aLaCarteFlagTest(boolean expected, ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws JsonParseException, IOException, ValidationException{
- this.expected = expected;
- this.sir = sir;
- this.instanceIdMapTest = instanceIdMapTest;
- this.action = action;
- this.version = version;
- this.msoRequest = new MsoRequest("aLaCarteCheck");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals(expected, msoRequest.getALaCarteFlag());
- }
- @Parameters
- private Collection<Object[]> aLaCarteParameters() throws IOException{
- return Arrays.asList(new Object[][] {
- {false, mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v3"},
- {true, mapper.readValue(inputStream("/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {true, mapper.readValue(inputStream("/v2requestParametersALaCarteFalse.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v2"},
- });
- }
- @Test
- @Parameters(method = "validationParameters")
- public void validationFailureTest(String expectedException, ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.expectedException = expectedException;
- this.sir = sir;
- this.instanceIdMapTest = instanceIdMapTest;
- this.action = action;
- this.version = version;
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- thrown.expect(ValidationException.class);
- thrown.expectMessage(expectedException);
- this.msoRequest = new MsoRequest("validationFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Parameters
- private Collection<Object[]> validationParameters() throws IOException{
- return Arrays.asList(new Object[][] {
- {"No valid aLaCarte in requestParameters", mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "v4"},
- {"No valid model-info is specified", mapper.readValue(inputStream("/ModelInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelType is specified", mapper.readValue(inputStream("/ModelTypeNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/EmptyLcpCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid tenantId is specified", mapper.readValue(inputStream("/EmptyTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParametersNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid subscriptionServiceType is specified", mapper.readValue(inputStream("/EmptySubscriptionServiceType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid instanceName format is specified", mapper.readValue(inputStream("/InvalidInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v2"},
- {"No valid requestorId is specified", mapper.readValue(inputStream("/EmptyRequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelInvariantId format is specified", mapper.readValue(inputStream("/InvalidModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v2"},
- {"No valid subscriberInfo is specified", mapper.readValue(inputStream("/EmptySubscriberInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid globalSubscriberId is specified", mapper.readValue(inputStream("/EmptyGlobalSubscriberId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid platformName is specified", mapper.readValue(inputStream("/EmptyPlatform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid platform is specified", mapper.readValue(inputStream("/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
- {"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid projectName is specified", mapper.readValue(inputStream("/EmptyProject.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid owningEntity is specified", mapper.readValue(inputStream("/OwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
- {"No valid owningEntityId is specified", mapper.readValue(inputStream("/EmptyOwningEntityId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {"No valid modelName is specified", mapper.readValue(inputStream("/VfModuleModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v4"},
- {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v4"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ConfigurationModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid productFamilyId is specified", mapper.readValue(inputStream("/VnfProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {"No valid productFamilyId is specified", mapper.readValue(inputStream("/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {"No valid productFamilyId is specified", mapper.readValue(inputStream("/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
- {"No valid productFamilyId is specified", mapper.readValue(inputStream("/ServiceProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelVersionId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelType in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelType.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelInfo in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid instanceName format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesNameFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid instanceId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid instanceId format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesIdFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelInvariantId in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelName in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelVersion in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelInvariantId format in relatedInstance is specified", mapper.readValue(inputStream("/RelatedInstancesModelInvariantIdFormat.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelCustomizationName or modelCustomizationId in relatedInstance of vnf is specified", mapper.readValue(inputStream("/RelatedInstancesModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid serviceInstanceId matching the serviceInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstancesInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid vnfInstanceId matching the vnfInstanceId in request URI is specified", mapper.readValue(inputStream("/RelatedInstancesVnfInstanceId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid related vnf instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstancesVnfInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid related service instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstancesServiceInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid related vnf instance for vfModule request is specified", mapper.readValue(inputStream("/VfModuleRelatedInstancesVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid related service instance for vfModule request is specified", mapper.readValue(inputStream("/VfModuleRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid related service instance for vnf request is specified", mapper.readValue(inputStream("/VnfRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfModelCustomizationIdPreload.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v5"},
- {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelVersionService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
- {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelVersionVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v4"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v5ModelInvariantIdNetwork.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v5ModelInvariantIdDisablePort.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v5"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInvariantIdVnf.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v3"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInvariantIdConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v3"},
- {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInvariantIdServiceCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v4"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v4"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v5"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v5"},
- {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelVersionIdTest.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelVersionIdCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
- {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
- {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, "v6"},
- {"No valid requestParameters is specified", mapper.readValue(inputStream("/RequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {"No valid requestorId is specified", mapper.readValue(inputStream("/RequestorId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/InPlaceSoftwareUpdateCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/InPlaceSoftwareUpdateCloudRegionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {"No valid tenantId is specified", mapper.readValue(inputStream("/InPlaceSoftwareUpdateTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "v6"},
- {"No valid serviceInstanceId matching the serviceInstanceId in request URI is specified", mapper.readValue(inputStream("/v6VnfDeleteInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, "v6"},
- {"No valid related instances is specified", mapper.readValue(inputStream("/ServiceNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "v2"},
- {"No valid related instances is specified", mapper.readValue(inputStream("/ServiceNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeRelationships, "v2"},
- {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, "v6"},
- {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/VnfRequestParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v6"},
- {"No valid instanceName in relatedInstance for pnf modelType is specified", mapper.readValue(inputStream("/v6AddRelationshipsBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.removeRelationships, "v6"},
- {"No valid instanceName in relatedInstance for pnf modelType is specified", mapper.readValue(inputStream("/v6AddRelationshipsBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, "v6"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v5DeactivatePortMirrorBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, "v5"},
- {"No valid modelVersionId is specified", mapper.readValue(inputStream("/v5ActivatePortMirrorBadData.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, "v5"},
- {"No valid related instances is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v2"},
- {"No valid connectionPoint relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoConnectionPoint.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, "v5"},
- {"No valid connectionPoint relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoConnectionPoint.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
- {"No valid related instances is specified", mapper.readValue(inputStream("/v5EnablePortMirrorNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, "v5"},
- {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/v5PortMirrorCreateConfigurationBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid source vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5PortMirrorCreateNoSourceRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid destination vnf relatedInstance for Port Configuration is specified", mapper.readValue(inputStream("/v5PortMirrorCreateNoDestinationRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid related instances is specified", mapper.readValue(inputStream("/v5PortMirrorCreateNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/v4CreateVfModuleMissingModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v4"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v3DeleteServiceInstanceALaCarte.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v3"},
- {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/v3UpdateNetworkBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v4"},
- {"No valid related instances is specified", mapper.readValue(inputStream("/v3VolumeGroupBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, "v4"}
- });
- }
- @Test
- public void setInstancedIdHashMapTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff001");
- this.instanceIdMapTest.put("vfModuleInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff002");
- this.instanceIdMapTest.put("volumeGroupInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff003");
- this.instanceIdMapTest.put("networkInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff004");
- this.instanceIdMapTest.put("configurationInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff005");
- this.action = Action.createInstance;
- this.version = "v5";
- this.msoRequest = new MsoRequest("setInstanceIdHashMap");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff000", msoRequest.getServiceInstancesRequest().getServiceInstanceId());
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff001", msoRequest.getServiceInstancesRequest().getVnfInstanceId());
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff002", msoRequest.getServiceInstancesRequest().getVfModuleInstanceId());
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff003", msoRequest.getServiceInstancesRequest().getVolumeGroupInstanceId());
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff004", msoRequest.getServiceInstancesRequest().getNetworkInstanceId());
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff005", msoRequest.getServiceInstancesRequest().getConfigurationId());
- }
- @Test
- public void serviceInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("serviceInstanceId", "test");
- this.action = Action.createInstance;
- this.version = "v5";
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid serviceInstanceId is specified");
- this.msoRequest = new MsoRequest("serviceInstanceIdFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- public void vnfInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("vnfInstanceId", "test");
- this.action = Action.createInstance;
- this.version = "v5";
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid vnfInstanceId is specified");
- this.msoRequest = new MsoRequest("vnfInstanceIdFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- public void vfModuleInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("vfModuleInstanceId", "test");
- this.action = Action.createInstance;
- this.version = "v5";
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid vfModuleInstanceId is specified");
- this.msoRequest = new MsoRequest("vfModuleInstanceIdFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- public void volumeGroupInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("volumeGroupInstanceId", "test");
- this.action = Action.createInstance;
- this.version = "v5";
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid volumeGroupInstanceId is specified");
- this.msoRequest = new MsoRequest("volumeGroupInstanceIdFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- public void networkInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("networkInstanceId", "test");
- this.action = Action.createInstance;
- this.version = "v5";
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid networkInstanceId is specified");
- this.msoRequest = new MsoRequest("networkInstanceIdFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- public void configurationInstanceIdHashMapFailureTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/v2AutoBuildVfModulesTrue.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("configurationInstanceId", "test");
- this.action = Action.createInstance;
- this.version = "v5";
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid configurationInstanceId is specified");
- this.msoRequest = new MsoRequest("configurationInstanceIdFailure");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- }
- @Test
- public void setVolumeGroupRelatedInstancesTest() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.sir = mapper.readValue(inputStream("/VolumeGroupRelatedInstances.json"), ServiceInstancesRequest.class);
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff001");
- this.action = Action.createInstance;
- this.version = "v5";
- this.msoRequest = new MsoRequest("setVolumeGroupRelatedInstances");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("vSAMP12", msoRequest.getServiceInstanceType());
- assertEquals("vSAMP12" + "/" + "test", msoRequest.getVnfType());
- assertEquals("1.0", msoRequest.getAsdcServiceModelVersion());
- }
- @Test
- @Parameters(method = "projectParameters")
- public void setProjectAndOwningEntityTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws ValidationException, JsonParseException, JsonMappingException, IOException{
- this.sir = sir;
- this.action = action;
- this.version = version;
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.msoRequest = new MsoRequest("setProjectAndOwningEntity");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("projectName", msoRequest.getProject().getProjectName());
- assertEquals("oeId", msoRequest.getOwningEntity().getOwningEntityId());
- assertEquals("oeName", msoRequest.getOwningEntity().getOwningEntityName());
- }
- @Parameters
- private Collection<Object[]> projectParameters() throws IOException{
- return Arrays.asList(new Object[][] {
- {mapper.readValue(inputStream("/ProjectAndOwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {mapper.readValue(inputStream("/ProjectAndOwningEntity.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
- });
- }
-
- @Test
- public void setModelInfoTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
- this.sir = mapper.readValue(inputStream("/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class);
- this.action = Action.createInstance;
- this.version = "v5";
- this.msoRequest = new MsoRequest("setModelInfo");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("test", msoRequest.getServiceInstancesRequest().getRequestDetails().getModelInfo().getModelVersionId());
- }
- @Test
- public void setServiceInstanceTypeTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
- this.sir = mapper.readValue(inputStream("/RequestParametersALaCarteTrue.json"), ServiceInstancesRequest.class);
- this.action = Action.createInstance;
- this.version = "v5";
- this.msoRequest = new MsoRequest("setServiceInstanceType");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("SDNW Service 1710", msoRequest.getServiceInstanceType());
- }
- @Test
- @Parameters(method = "platformParameters")
- public void setPlatformAndLineOfBusinessTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, String version) throws ValidationException, JsonParseException, JsonMappingException, IOException{
- this.sir = sir;
- this.action = action;
- this.instanceIdMapTest = instanceIdMapTest;
- this.version = version;
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.msoRequest = new MsoRequest("setPlatformAndLineOfBusiness");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("platformName", msoRequest.getPlatform().getPlatformName());
- assertEquals("lobName", msoRequest.getLineOfBusiness().getLineOfBusinessName());
- }
- @Parameters
- private Collection<Object[]> platformParameters() throws IOException{
- return Arrays.asList(new Object[][] {
- {mapper.readValue(inputStream("/PlatformAndLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v5"},
- {mapper.readValue(inputStream("/PlatformAndLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "v6"},
- });
- }
-
- @Test
- public void setNetworkTypeTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
- this.sir = mapper.readValue(inputStream("/NetworkType.json"), ServiceInstancesRequest.class);
- this.action = Action.createInstance;
- this.version = "v2";
- this.msoRequest = new MsoRequest("setNetworkType");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("TestNetworkType", msoRequest.getNetworkType());
- }
- @Test
- public void setModelNameVersionIdTest() throws ValidationException, JsonParseException, JsonMappingException, IOException{
- this.sir = mapper.readValue(inputStream("/ModelNameVersionId.json"), ServiceInstancesRequest.class);
- this.action = Action.createInstance;
- this.version = "v5";
- this.msoRequest = new MsoRequest("setModelNameVersionId");
- this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON);
- assertEquals("test", msoRequest.getModelInfo().getModelNameVersionId());
- }
- @Test
- public void testParseOrchestration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}";
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("ParseOrchestration");
- msoRequest.parseOrchestration(sir);
- assertEquals(msoRequest.getRequestInfo().getSource(),"VID");
- assertEquals(msoRequest.getRequestInfo().getRequestorId(),"zz9999");
-
- }
- @Test
- public void testParseOrchestrationFailure() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\"}}}";
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- thrown.expect(ValidationException.class);
- thrown.expectMessage("No valid requestorId is specified");
- this. msoRequest = new MsoRequest ("ParseOrchestration");
- msoRequest.parseOrchestration(sir);
- }
- @Test
- public void testParseV3VnfCreate() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v3VnfCreate.json");
- this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v3", originalRequestJSON);
- assertEquals(msoRequest.getRequestInfo().getSource(),"VID");
- assertEquals(msoRequest.getReqVersion(),3);
- }
- @Test
- public void testParseV3UpdateNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v3UpdateNetwork.json");
- this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.updateInstance, "v3", originalRequestJSON);
- }
- @Test
- public void testParseV3DeleteNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v3DeleteNetwork.json");
- this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.deleteInstance, "v3", originalRequestJSON);
- }
- @Test
- public void testParseV3ServiceInstanceDelete() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- String requestJSON2;
- this.requestJSON = inputStream("/v3DeleteServiceInstance.json");
- requestJSON2 = inputStream("/v3DeleteServiceInstanceALaCarte.json");
- this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.deleteInstance, "v3", originalRequestJSON);
- boolean testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isaLaCarte();
- assertFalse(testIsALaCarteSet);
- this.sir = mapper.readValue(requestJSON2, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("12345");
- msoRequest.parse(sir, instanceIdMapTest, Action.deleteInstance, "v3", originalRequestJSON);
- testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isaLaCarte();
- assertTrue(testIsALaCarteSet);
- assertTrue(msoRequest.getALaCarteFlag());
- }
- @Test
- public void testVfModuleV4UsePreLoad() throws JsonParseException, JsonMappingException, IOException, ValidationException {
- this.requestJSON = inputStream("/v4CreateVfModule.json");
- this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.instanceIdMapTest.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v4", originalRequestJSON);
-
- this.requestJSON = inputStream("/v4CreateVfModuleNoCustomizationId.json");
- this.instanceIdMapTest.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.instanceIdMapTest.put("vnfInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v4", originalRequestJSON);
- }
- @Test
- public void testV5PortMirrorCreateConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5PortMirrorCreateConfiguration.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v5", originalRequestJSON);
- }
- @Test
- public void testV6PortMirrorCreateConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v6PortMirrorCreateConfiguration.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.createInstance, "v6", originalRequestJSON);
- }
- @Test
- public void testV5EnablePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5EnablePortMirrorConfiguration.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.enablePort, "v5", originalRequestJSON);
- }
- @Test
- public void testV5DisablePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5EnablePortMirrorConfiguration.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.disablePort, "v5", originalRequestJSON);
- }
- @Test
- public void testV5ActivatePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5ActivatePortMirrorConfiguration.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.activateInstance, "v5", originalRequestJSON);
- }
- @Test
- public void testV5ActivatePortMirrorNoRelatedInstance() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5ActivatePortMirrorNoRelatedInstance.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.activateInstance, "v5", originalRequestJSON);
- }
- @Test
- public void testV5DeactivatePortMirrorConfiguration() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5DeactivatePortMirrorConfiguration.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.deactivateInstance, "v5", originalRequestJSON);
- }
- @Test
- public void testV5DeactivatePortMirrorNoRelatedInstance() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v5DeactivatePortMirrorNoRelatedInstance.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("1234");
- msoRequest.parse(sir, instanceIdMapTest, Action.deactivateInstance, "v5", originalRequestJSON);
- }
- @Test
- public void testV6AddRelationships() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v6AddRelationships.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("V6AddRelationships");
- msoRequest.parse(sir, instanceIdMapTest, Action.addRelationships, "v6", originalRequestJSON);
- }
- @Test
- public void testV6RemoveRelationships() throws JsonParseException, JsonMappingException, IOException, ValidationException{
- this.requestJSON = inputStream("/v6AddRelationships.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("V6RemoveRelationships");
- msoRequest.parse(sir, instanceIdMapTest, Action.removeRelationships, "v6", originalRequestJSON);
- assertNotNull(msoRequest.getRequestId());
- assertEquals(msoRequest.getReqVersion(), 6);
- }
-
- @Test
- public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
- @Mocked Session session) throws ValidationException, IOException {
-
- new Expectations() {{
- sessionFactoryManager.getSessionFactory().openSession(); result = session;
- }};
-
- this.requestJSON = inputStream("/v6AddRelationships.json");
- this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
- this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- this.msoRequest = new MsoRequest ("V6RemoveRelationships");
- msoRequest.parse(sir, instanceIdMapTest, Action.removeRelationships, "v6", originalRequestJSON);
- msoRequest.createRequestRecord(Status.COMPLETE, Action.createInstance);
-
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java
deleted file mode 100644
index 048efb1781..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.net.URI;
-import java.sql.Timestamp;
-import java.time.LocalDateTime;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import mockit.MockUp;
-import org.apache.http.HttpStatus;
-import org.jboss.resteasy.spi.ResteasyUriInfo;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.serviceinstancebeans.GetOrchestrationResponse;
-import org.openecomp.mso.serviceinstancebeans.InstanceReferences;
-import org.openecomp.mso.serviceinstancebeans.Request;
-import org.openecomp.mso.serviceinstancebeans.RequestStatus;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class OrchestrationRequestsTest {
-
- private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";
- public static final Response RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
- @Mock
- private static RequestsDatabase db;
- private static OrchestrationRequests orReq;
- private static GetOrchestrationResponse orRes;
-
- @Test
- public void testGetOrchestrationRequest() {
- orReq = Mockito.mock(OrchestrationRequests.class);
- orRes = new GetOrchestrationResponse();
- try {
- // create InfraActiveRequests object
- InfraActiveRequests infraRequests = new InfraActiveRequests();
- infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333");
- infraRequests.setNetworkType("CONTRAIL30_BASIC");
- infraRequests.setRequestType("createInstance");
- infraRequests.setSource("VID");
- infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682");
- infraRequests.setServiceInstanceId("bc305d54-75b4-431b-adb2-eb6b9e546014");
- infraRequests.setRequestStatus("IN_PROGRESS");
- infraRequests.setRequestorId("ab1234");
- String body = "{\"modelInfo\":{\"modelInvariantId\":\"9771b085-4705-4bf7-815d-8c0627bb7e36\",\"modelType\":\"service\",\"modelName\":\"Service with VNFs with modules\",\"modelVersion\":\"1.0\"}}";
- infraRequests.setRequestBody(body);
-
- db = Mockito.mock(RequestsDatabase.class);
- Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests);
-
- ///// mock mapInfraActiveRequestToRequest()
- Request request = new Request();
- request.setRequestId(infraRequests.getRequestId());
- request.setRequestScope(infraRequests.getRequestScope());
- request.setRequestType(infraRequests.getRequestAction());
-
- InstanceReferences ir = new InstanceReferences();
- if (infraRequests.getNetworkId() != null)
- ir.setNetworkInstanceId(infraRequests.getNetworkId());
- if (infraRequests.getNetworkName() != null)
- ir.setNetworkInstanceName(infraRequests.getNetworkName());
- if (infraRequests.getServiceInstanceId() != null)
- ir.setServiceInstanceId(infraRequests.getServiceInstanceId());
- if (infraRequests.getServiceInstanceName() != null)
- ir.setServiceInstanceName(infraRequests.getServiceInstanceName());
- if (infraRequests.getVfModuleId() != null)
- ir.setVfModuleInstanceId(infraRequests.getVfModuleId());
- if (infraRequests.getVfModuleName() != null)
- ir.setVfModuleInstanceName(infraRequests.getVfModuleName());
- if (infraRequests.getVnfId() != null)
- ir.setVnfInstanceId(infraRequests.getVnfId());
- if (infraRequests.getVnfName() != null)
- ir.setVnfInstanceName(infraRequests.getVnfName());
- if (infraRequests.getVolumeGroupId() != null)
- ir.setVolumeGroupInstanceId(infraRequests.getVolumeGroupId());
- if (infraRequests.getVolumeGroupName() != null)
- ir.setVolumeGroupInstanceName(infraRequests.getVolumeGroupName());
- if (infraRequests.getRequestorId() != null)
- ir.setRequestorId(infraRequests.getRequestorId());
-
- request.setInstanceReferences(ir);
- RequestStatus status = new RequestStatus();
-
- if (infraRequests.getRequestStatus() != null) {
- status.setRequestState(infraRequests.getRequestStatus());
- }
-
- request.setRequestStatus(status);
- // RequestStatus reqStatus = request.getRequestStatus();
- orRes.setRequest(request);
-// Mockito.when(orReq.getOrchestrationRequest(Mockito.anyString(), Mockito.anyString())).thenReturn(RESPONSE);
- Response resp = orReq.getOrchestrationRequest("rq1234d1-5a33-55df-13ab-12abad84e333", "v3");
-
- assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestId(),
- "rq1234d1-5a33-55df-13ab-12abad84e333");
- assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getSource(), "VID");
- assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getTenantId(),
- "19123c2924c648eb8e42a3c1f14b7682");
- assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getServiceInstanceId(),
- "bc305d54-75b4-431b-adb2-eb6b9e546014");
- assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestStatus(),
- "IN_PROGRESS");
- assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestorId(),
- "ab1234");
- assertEquals(request.getInstanceReferences().getServiceInstanceId(),"bc305d54-75b4-431b-adb2-eb6b9e546014");
- assertEquals(request.getInstanceReferences().getRequestorId(),"ab1234");
- assertEquals(orRes.getRequest().getRequestId(), "rq1234d1-5a33-55df-13ab-12abad84e333");
-// assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testGetOrchestrationRequestNotPresent() {
- String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"ab1234\"}}}";
- try {
-
- InfraActiveRequests infraRequests = new InfraActiveRequests();
- infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333");
- infraRequests.setNetworkType("CONTRAIL30_BASIC");
- infraRequests.setSource("VID");
- infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682");
- infraRequests.setServiceInstanceId("ea4d5374-d28d-4bbf-9691-22985f088b12");
- infraRequests.setRequestStatus(Status.IN_PROGRESS.name());
- infraRequests.setStartTime(Timestamp.valueOf(LocalDateTime.now()));
- final List<InfraActiveRequests> infraActiveRequests = Collections.singletonList(infraRequests);
-
- // create InfraActiveRequests object
- final MockUp<RequestsDatabase> mockUpRDB = new MockUp<RequestsDatabase>() {
- @mockit.Mock
- public InfraActiveRequests getRequestFromInfraActive(String requestId) {
- return infraRequests;
- }
-
- @mockit.Mock
- public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap) {
- return infraActiveRequests;
- }
-
- @mockit.Mock
- public int updateInfraStatus(String requestId, String requestStatus, String lastModifiedBy) {
- return 1;
- }
- };
-
- Response response = null;
- try {
- OrchestrationRequests requests = new OrchestrationRequests();
- final ResteasyUriInfo ui = new ResteasyUriInfo(new URI("", "", "", "filter=service-instance-id:EQUALS:abc", ""));
- response = requests.getOrchestrationRequest(ui,"v5");
- } finally {
- mockUpRDB.tearDown();
- }
- assertEquals(HttpStatus.SC_OK, response.getStatus());
- assertNotNull(response.getEntity());
-
-
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testUnlockOrchestrationRequest()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- ObjectMapper mapper = new ObjectMapper();
- String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"ab1234\"}}}";
- //String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"instanceName\":\"Vfmodule_vLB-0514-1\",\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"demo\"},\"modelInfo\":{\"modelType\":\"vfModule\",\"modelInvariantId\":\"80d62376-2d6d-4618-b666-bf00d0e58296\",\"modelVersionId\":\"578b52e5-4572-444d-8de7-2c140ec2e6e5\",\"modelName\":\"Vloadbalancer..base_vlb..module-0\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"bf87db73-2854-4cd1-adfd-8cd08e12befe\",\"modelCustomizationName\":\"Vloadbalancer..base_vlb..module-0\"},\"requestParameters\":{\"usePreload\":true},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"RegionOne\",\"tenantId\":\"ebb0ea7144004bacac1e39ff23105fa7\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"60e28eb9-2808-4a5a-830f-ec982f01dcfe\",\"modelInfo\":{\"modelType\":\"service\",\"modelName\":\"vLoadBalancer\",\"modelInvariantId\":\"3f95e3ed-394d-4301-8c9b-c5f39ff89cfd\",\"modelVersion\":\"1.0\",\"modelVersionId\":\"da1b5347-7bcb-4cc4-8c29-d18dafdb1a47\"}}},{\"relatedInstance\":{\"instanceId\":\"338811a1-f7cd-4093-9903-d0f69b7cb176\",\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"vLoadBalancer\",\"modelInvariantId\":\"040740de-1ce8-4737-ad39-970684b0e3e8\",\"modelVersion\":\"1.0\",\"modelVersionId\":\"5fd1ce25-c414-4baf-903b-5042a60cfb02\",\"modelCustomizationId\":\"5801ace5-7cc7-4011-b677-165a0e8a2a27\",\"modelCustomizationName\":\"vLoadBalancer 0\"}}}]}}";
-
- MsoRequest msoRequest = new MsoRequest("rq1234d1-5a33-55df-13ab-12abad84e333");
- ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- msoRequest.parseOrchestration(sir);
-
- //create object instead of a DB call.
-
-
- final MockUp<RequestsDatabase> mockUp = new MockUp<RequestsDatabase>() {
- @mockit.Mock
- public InfraActiveRequests getRequestFromInfraActive(String requestId) {
- InfraActiveRequests infraRequests = new InfraActiveRequests();
- infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333");
- infraRequests.setNetworkType("CONTRAIL30_BASIC");
- infraRequests.setSource("VID");
- infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682");
- infraRequests.setServiceInstanceId("ea4d5374-d28d-4bbf-9691-22985f088b12");
- infraRequests.setRequestStatus(Status.IN_PROGRESS.name());
- infraRequests.setStartTime(Timestamp.valueOf(LocalDateTime.now()));
- infraRequests.setRequestBody(requestJSON);
- return infraRequests;
- }
-
- @mockit.Mock
- public int updateInfraStatus(String requestId, String requestStatus, String lastModifiedBy) {
- return 1;
- }
- };
-
- final Response response;
- try {
- OrchestrationRequests requests = new OrchestrationRequests();
- response = requests.unlockOrchestrationRequest(requestJSON, "rq1234d1-5a33-55df-13ab-12abad84e333", "v5");
- } finally {
- mockUp.tearDown();
- }
-
- assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatus());
- assertEquals("", response.getEntity().toString());
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java
deleted file mode 100644
index 3bc2edf8e2..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra;
-
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-
-public class RecipeLookupResultTest {
-
- RecipeLookupResult instance;
-
- public RecipeLookupResultTest() {
- }
-
- @Before
- public void setUp() {
- instance = mock(RecipeLookupResult.class);
- }
-
- @After
- public void tearDown() {
- instance = null;
- }
-
- /**
- * Test of getOrchestrationURI method
- */
- @Test
- public void testGetOrchestrationURI() {
- String expResult = "orchestrationURI";
- when(instance.getOrchestrationURI()).thenReturn(expResult);
- String result = instance.getOrchestrationURI();
- assertEquals(expResult, result);
- }
-
-
- /**
- * Test of setOrchestrationURI method.
- */
- @Test
- public void testSetOrchestrationURI() {
- String orchestrationUri = "orchestrationURI";
- instance.setOrchestrationURI(orchestrationUri);
- verify(instance).setOrchestrationURI(orchestrationUri);
- }
-
- /**
- * Test of getRecipeTimeout method
- */
- @Test
- public void testGetRecipeTimeout() {
- int expResult = 10;
- when(instance.getRecipeTimeout()).thenReturn(expResult);
- int result = instance.getRecipeTimeout();
- assertEquals(expResult, result);
- }
-
-
- /**
- * Test of setRecipeTimeout method.
- */
- @Test
- public void testSetRecipeTimeout() {
- int recipeTimeOut = 10;
- instance.setRecipeTimeout(recipeTimeOut);
- verify(instance).setRecipeTimeout(10);
- }
-
-
-}
- \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java
deleted file mode 100644
index 938a1038a4..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java
+++ /dev/null
@@ -1,1168 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra;
-
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import javax.ws.rs.core.Response;
-import mockit.Mock;
-import mockit.MockUp;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.message.BasicHttpResponse;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.apihandler.common.CamundaClient;
-import org.openecomp.mso.apihandler.common.RequestClient;
-import org.openecomp.mso.apihandler.common.RequestClientFactory;
-import org.openecomp.mso.apihandler.common.RequestClientParamater;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe;
-import org.openecomp.mso.db.catalog.beans.VnfRecipe;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-
-public class ServiceInstanceTest {
-
- /*** Create Service Instance Test Cases ***/
-
- @BeforeClass
- public static void setUp() throws Exception {
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
- }
-
-
- @Test
- public void createServiceInstanceInvalidModelInfo(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v5");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid model-info is specified"));
- }
-
- @Test
- public void createServiceInstanceNormalDuplicate(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return new InfraActiveRequests();
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains(
- "Locked instance - This service (testService) already has a request being worked with a status of null (RequestId - null). The existing request must finish or be cleaned up before proceeding."));
- }
-
- @Test
- public void createServiceInstanceTestDBException(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Exception while creating record in DB") && respBody.contains("NullPointerException"));
- }
-
- @Ignore // 1802 merge
- @Test
- public void createServiceInstanceTestBpmnFail(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Failed calling bpmn properties")); // was: Request Failed due to BPEL error
- }
-
- @Test(expected = Exception.class)
- public void createServiceInstanceTest200Http(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- }
-
- @Test
- public void createServiceInstanceTest500Http(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Request Failed due to BPEL error with HTTP Status"));
- }
-
- @Test
- public void createServiceInstanceTestVnfModelType(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"vnf\",\"modelName\":\"serviceModel\",\"modelCustomizationName\":\"test\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v5");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("No valid modelVersionId is specified"));
- }
-
- @Test
- public void createServiceInstanceTestNullHttpResp(){
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater){
- return null;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("bpelResponse is null"));
- }
-
- @Test
- public void createServiceInstanceNormalNullDBFatch(){
- new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return Collections.EMPTY_LIST;
- }
- };
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Recipe could not be retrieved from catalog DB null"));
- }
-
-
- @Test
- public void createServiceInstanceInvalidModelVersionId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v5");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid modelVersionId is specified"));
- }
-
- @Ignore // 1802 merge
- @Test
- public void createServiceInstanceNullInstanceName(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid instanceName is specified"));
- }
-
-
- @Test
- public void createServiceInstanceNullModelInfo(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid model-info is specified"));
- }
-
- @Test
- public void createServiceInstanceInvalidModelInvariantId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"1234\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid modelType is specified"));
- }
-
- @Test
- public void createServiceInstanceNullModelVersion(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid modelType is specified"));
- }
-
-
- @Test
- public void createServiceInstanceNullModelType(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid modelType is specified"));
- }
-
- @Test
- public void createServiceInstanceInvalidModelType(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"testmodel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Mapping of request to JSON object failed."));
- }
-
- @Ignore // 1802 merge
- @Test
- public void createServiceInstanceNullModelName(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\":\"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid modelName is specified"));
- }
-
- @Ignore // 1802 merge
- @Test
- public void createServiceInstanceInvalidVersionForAutoBuildVfModules(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": true,\"subscriptionServiceType\":\"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("AutoBuildVfModule is not valid in the v2 version"));
- }
-
- @Test
- public void createServiceInstanceNullRequestParameter(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid subscriptionServiceType is specified"));
- }
-
- @Test
- public void createServiceInstanceNullSubscriptionType(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respBody = resp.getEntity().toString();
- assertTrue(respBody.contains("Error parsing request.") && respBody.contains("No valid subscriptionServiceType is specified"));
- }
-
- @Test
- public void createServiceInstanceAnbormalInvalidJson(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"name\":\"test\"}";
- Response resp = instance.createServiceInstance(requestJson, "v2");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Mapping of request to JSON object failed"));
- }
-
- /*** Activate Service Instance Test Cases ***/
-
- @Test
- public void activateServiceInstanceAnbormalInvalidJson(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"name\":\"test\"}";
- Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Mapping of request to JSON object failed"));
- }
-
- @Test
- public void activateServiceInstanceInvalidModelVersionId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid modelVersionId in relatedInstance is specified"));
- }
-
- @Test
- public void activateServiceInstanceInvalidServiceInstanceId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid serviceInstanceId matching the serviceInstanceId in request URI is specified"));
- }
-
- @Test
- public void activateServiceInstanceTestNormal(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- /*** Deactivate Service Instance Test Cases ***/
-
- @Test
- public void deactivateServiceInstanceAnbormalInvalidJson(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"name\":\"test\"}";
- Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Mapping of request to JSON object failed"));
- }
-
- @Test
- public void deactivateServiceInstanceInvalidModelVersionId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid modelVersionId in relatedInstance is specified"));
- }
-
- @Test
- public void deactivateServiceInstanceInvalidServiceInstanceId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid serviceInstanceId matching the serviceInstanceId in request URI is specified"));
- }
-
- @Test
- public void deactivateServiceInstanceTestNormal(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- /*** Delete Service Instance Test Cases ***/
-
- @Test
- public void deleteServiceInstanceAnbormalInvalidJson(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"name\":\"test\"}";
- Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Mapping of request to JSON object failed"));
- }
-
- @Test
- public void deleteServiceInstanceInvalidModelVersionId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid modelVersionId is specified"));
- }
-
- @Test
- public void deleteServiceInstanceInvalidServiceInstanceId(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
- Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid modelVersionId is specified"));
- }
-
- @Test
- public void deleteServiceInstanceTestNormal(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- /*** Create Vnf Instance Test Cases ***/
-
- @Ignore // 1802 merge
- @Test
- public void createVNFInstanceTestInvalidCloudConfiguration(){
- ServiceInstances instance = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid cloudConfiguration is specified"));
- }
-
- @Test
- public void createVNFInstanceTestInvalidIcpCloudRegionId(){
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"cloudConfiguration\":{}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid lcpCloudRegionId is specified"));
- }
-
- @Test
- public void createVNFInstanceTestInvalidTenantId(){
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("Error parsing request.") && respStr.contains("No valid tenantId is specified"));
- }
-
- @Test
- public void createVNFInstanceTestNormal(){
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 1;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public VnfResource getVnfResourceByModelCustomizationId(String modelCustomizationId) {
- VnfResource vnfResource = new VnfResource();
- return vnfResource;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public VnfRecipe getVnfRecipe (String vnfType, String action) {
- VnfRecipe recipe =new VnfRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
-
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
-
- final String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"1882939\",\"vnfInstanceId\":\"1882938\"," +
- "\"networkInstanceId\":\"1882937\",\"volumeGroupInstanceId\":\"1882935\",\"vfModuleInstanceId\":\"1882934\"," +
- "\"requestDetails\":{\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}," +
- "\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\"," +
- "\"modelInfo\":{\"modelInvariantId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\":{\"source\":\"VID\",\"requestorId\":\"zz9999\",\"instanceName\":\"testService\",\"productFamilyId\":\"productFamilyId1\"}," +
- "\"requestParameters\":{\"autoBuildVfModules\":false,\"subscriptionServiceType\":\"test\",\"aLaCarte\":false},\"modelInfo\":{\"modelInvariantId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"vnf\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\"}}}";
- Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.equals("success"));
- }
-
- /*** Replace Vnf Instance Test Cases ***/
- @Test
- public void replaceVNFInstanceTestNormal(){
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.replaceVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- /*** Update Vnf Instance Test Cases ***/
-
- @Test
- public void updateVNFInstanceTestNormal(){
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.updateVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- /*** Update Vnf Instance Test Cases ***/
-
- @Test
- public void deleteVNFInstanceTestNormal(){
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"1882939\","
- +"\"vnfInstanceId\":\"1882938\","
- +"\"networkInstanceId\":\"1882937\","
- +"\"volumeGroupInstanceId\":\"1882935\","
- +"\"vfModuleInstanceId\":\"1882934\","
- + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
- Response resp = instance.deleteVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.contains("SVC2000"));
- }
-
- @Test
- public void createVFModuleTestNormal(){
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 1;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String defaultServiceModelName) {
- Service serviceRecord = new Service();
- serviceRecord.setModelUUID("2883992993");
- return serviceRecord;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID (String uuid,String action) {
- ServiceRecipe recipe =new ServiceRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public VnfResource getVnfResourceByModelCustomizationId(String modelCustomizationId) {
- VnfResource vnfResource = new VnfResource();
- return vnfResource;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public VnfComponentsRecipe getVnfComponentsRecipeByVfModuleModelUUId (String vfModuleModelUUId, String vnfComponentType, String action) {
- VnfComponentsRecipe recipe =new VnfComponentsRecipe();
- recipe.setOrchestrationUri("/test/mso");
- recipe.setRecipeTimeout(1000);
- return recipe;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public VfModule getVfModuleByModelUuid(String modelUuid) {
- VfModule vfModule =new VfModule();
- return vfModule;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public VfModuleCustomization getVfModuleCustomizationByModelCustomizationId(String modelCustomizationUuid) {
- VfModuleCustomization vfModuleCustomization =new VfModuleCustomization();
- final VfModule vfModule = new VfModule();
- vfModule.setModelUUID("296e278c-bfa8-496e-b59e-fb1fe715f726");
- vfModuleCustomization.setVfModule(vfModule);
- return vfModuleCustomization;
- }
- };
-
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater){
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
-
- final String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- ServiceInstances instance = new ServiceInstances();
- String s = "\"cloudConfiguration\":{}";
- String requestJson = "{\"serviceInstanceId\":\"43b34d6d-1ab2-4c7a-a3a0-5471306550c5\",\"vnfInstanceId\":\"7b1ead4f-ea06-45c6-921e-124061e5eae7\",\"networkInstanceId\":\"1882937\",\"volumeGroupInstanceId\":\"1882935\",\"vfModuleInstanceId\":\"1882934\",\"requestDetails\":{\"requestInfo\":{\"instanceName\":\"vf-inst\",\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"123123\"},\"modelInfo\":{\"modelType\":\"vfModule\",\"modelInvariantId\":\"dde10afa-c732-4f0f-8501-2d2e01ea46ef\",\"modelVersionId\":\"296e278c-bfa8-496e-b59e-fb1fe715f726\",\"modelName\":\"CarrierTosca0::module-1\",\"modelCustomizationId\":\"ce0fdd17-c677-4bb5-b047-97016ec1e403\",\"modelCustomizationName\":\"ce0fdd17-c677-4bb5-b047-97016ec1e403\",\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[]},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"EastUS\",\"tenantId\":\"48de34f6-65a1-4d09-84b4-68b011151672\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"43b34d6d-1ab2-4c7a-a3a0-5471306550c5\",\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"1192c9b7-bc24-42c9-8f11-415dc679be88\",\"modelVersionId\":\"acb8b74b-afe6-4cc2-92c3-0a09961ab77e\",\"modelName\":\"service\",\"modelVersion\":\"1.0\"}}},{\"relatedInstance\":{\"instanceId\":\"7b1ead4f-ea06-45c6-921e-124061e5eae7\",\"modelInfo\":{\"modelType\":\"vnf\",\"modelInvariantId\":\"a545165e-9646-4030-824c-b9d9c66a886a\",\"modelVersionId\":\"a0b6dffe-0de3-4099-8b94-dc05be942914\",\"modelName\":\"vnf-mdoel\",\"modelVersion\":\"1.0\",\"modelCustomizationName\":\"vnf-mdoel 0\"}}}]}}";
- Response resp = instance.createVfModuleInstance(requestJson, "v5","43b34d6d-1ab2-4c7a-a3a0-5471306550c5", "7b1ead4f-ea06-45c6-921e-124061e5eae7");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.equals("success"));
- }
-
- @Test
- public void createPortConfigurationTestNormal() {
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 1;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(RequestClientParamater requestClientParamater) {
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
-
- final String body = "{\"content\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
- ServiceInstances sir = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"43b34d6d-1ab2-4c7a-a3a0-5471306550c5\",\"vnfInstanceId\":\"7b1ead4f-ea06-45c6-921e-124061e5eae7\",\"networkInstanceId\":\"1882937\",\"volumeGroupInstanceId\":\"1882935\",\"vfModuleInstanceId\":\"1882934\",\"requestDetails\":{\"requestInfo\":{\"instanceName\":\"vf-inst\",\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"123123\"},\"modelInfo\":{\"modelType\":\"vfModule\",\"modelInvariantId\":\"dde10afa-c732-4f0f-8501-2d2e01ea46ef\",\"modelVersionId\":\"296e278c-bfa8-496e-b59e-fb1fe715f726\",\"modelName\":\"CarrierTosca0::module-1\",\"modelCustomizationId\":\"ce0fdd17-c677-4bb5-b047-97016ec1e403\",\"modelCustomizationName\":\"ce0fdd17-c677-4bb5-b047-97016ec1e403\",\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[]},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"EastUS\",\"tenantId\":\"48de34f6-65a1-4d09-84b4-68b011151672\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"43b34d6d-1ab2-4c7a-a3a0-5471306550c5\",\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"1192c9b7-bc24-42c9-8f11-415dc679be88\",\"modelVersionId\":\"acb8b74b-afe6-4cc2-92c3-0a09961ab77e\",\"modelName\":\"service\",\"modelVersion\":\"1.0\"}}},{\"relatedInstance\":{\"instanceId\":\"7b1ead4f-ea06-45c6-921e-124061e5eae7\",\"modelInfo\":{\"modelType\":\"vnf\",\"modelInvariantId\":\"a545165e-9646-4030-824c-b9d9c66a886a\",\"modelVersionId\":\"a0b6dffe-0de3-4099-8b94-dc05be942914\",\"modelName\":\"vnf-mdoel\",\"modelVersion\":\"1.0\",\"modelCustomizationName\":\"vnf-mdoel 0\"}}}]}}";
- final Response response = sir.createPortConfiguration(requestJson, "v5", "43b34d6d-1ab2-4c7a-a3a0-5471306550c5");
- }
-
- @Test
- public void createPortConfigurationTestBlankOrchestrationURI() {
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
- return null;
- }
- };
-
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 1;
- }
- };
-
- new MockUp<MsoRequest>() {
- @Mock
- public void createRequestRecord (Status status, Action action) {
- return;
- }
- };
-
- ServiceInstances sir = new ServiceInstances();
- String requestJson = "{\"serviceInstanceId\":\"43b34d6d-1ab2-4c7a-a3a0-5471306550c5\",\"vnfInstanceId\":\"7b1ead4f-ea06-45c6-921e-124061e5eae7\",\"networkInstanceId\":\"1882937\",\"volumeGroupInstanceId\":\"1882935\",\"vfModuleInstanceId\":\"1882934\",\"requestDetails\":{\"requestInfo\":{\"instanceName\":\"vf-inst\",\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"123123\"},\"modelInfo\":{\"modelType\":\"vfModule\",\"modelInvariantId\":\"dde10afa-c732-4f0f-8501-2d2e01ea46ef\",\"modelVersionId\":\"296e278c-bfa8-496e-b59e-fb1fe715f726\",\"modelName\":\"CarrierTosca0::module-1\",\"modelCustomizationId\":\"ce0fdd17-c677-4bb5-b047-97016ec1e403\",\"modelCustomizationName\":\"ce0fdd17-c677-4bb5-b047-97016ec1e403\",\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[]},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"EastUS\",\"tenantId\":\"48de34f6-65a1-4d09-84b4-68b011151672\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"43b34d6d-1ab2-4c7a-a3a0-5471306550c5\",\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"1192c9b7-bc24-42c9-8f11-415dc679be88\",\"modelVersionId\":\"acb8b74b-afe6-4cc2-92c3-0a09961ab77e\",\"modelName\":\"service\",\"modelVersion\":\"1.0\"}}},{\"relatedInstance\":{\"instanceId\":\"7b1ead4f-ea06-45c6-921e-124061e5eae7\",\"modelInfo\":{\"modelType\":\"vnf\",\"modelInvariantId\":\"a545165e-9646-4030-824c-b9d9c66a886a\",\"modelVersionId\":\"a0b6dffe-0de3-4099-8b94-dc05be942914\",\"modelName\":\"vnf-mdoel\",\"modelVersion\":\"1.0\",\"modelCustomizationName\":\"vnf-mdoel 0\"}}}]}}";
- final Response response = sir.createPortConfiguration(requestJson, "v5", "43b34d6d-1ab2-4c7a-a3a0-5471306550c5");
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java
deleted file mode 100644
index a217922b4a..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.apihandler.common.ValidationException;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-public class ServiceInstancesTest {
-
- private static final String requestJSONCreate = "{ \"requestDetails\": { \"modelInfo\": { \"modelType\": \"service\", "
- + "\"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\","
- + " \"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\", \"modelName\": \"Test\","
- + " \"modelVersion\": \"1.0\" }, \"cloudConfiguration\": "
- + "{ \"lcpCloudRegionId\": \"mdt1\", \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" },"
- + " \"subscriberInfo\": { \"globalSubscriberId\": \"{some subscriber id}\","
- + " \"subscriberName\": \"{some subscriber name}\" },"
- + " \"requestInfo\": { \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", "
- + "\"source\": \"VID\", \"suppressRollback\": true, \"requestorId\": \"az2016\" },"
- + " \"requestParameters\": { \"subscriptionServiceType\": \"MOG\", \"aLaCarte\": false,"
- + " \"userParams\": [ { \"name\": \"someUserParam\", \"value\": \"someValue\" } ] } } } ";
-
- private static final String requestJSONActivateDeacivate =
- "{ \"requestDetails\": { \"modelInfo\": { \"modelType\": \"service\","
- + " \"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\", "
- + "\"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\", "
- + "\"modelName\": \"Test\", \"modelVersion\": \"1.0\" }, "
- + "\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"az2016\" }, "
- + "\"requestParameters\": { \"userParams\": [ { \"name\": \"aic_zone\", "
- + "\"value\": \"someValue\" } ] } } } ";
-
- private static final String requestJSONDelete =
- "{ \"requestDetails\": { \"modelInfo\": { \"modelType\":\"network\", "
- + "\"modelName\":\"CONTRAIL30_BASIC\" }, \"cloudConfiguration\": { \"lcpCloudRegionId\":\"mdt1\", "
- + "\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\" }, "
- + "\"requestInfo\": { \"source\":\"VID\", \"requestorId\":\"az2016\" } } }";
-
- @Test
- public void testCreateServiceInstance()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";
- final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
-
- try {
- ServiceInstances sir = Mockito.mock(ServiceInstances.class);
- sir.createServiceInstance(requestJSONCreate, "v3");
- Mockito.when(sir.createServiceInstance(requestJSONCreate, "v3")).thenReturn(SERVICE_RESPONSE);
- Response resp = sir.createServiceInstance(requestJSONCreate, "v3");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testActivateServiceInstance()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";
- final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
- try {
- ServiceInstances sir = Mockito.mock(ServiceInstances.class);
- Mockito.when(sir.activateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"))
- .thenReturn(SERVICE_RESPONSE);
- Response resp = sir.activateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testDeactivateServiceInstance()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";
- final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
- try {
- ServiceInstances sir = Mockito.mock(ServiceInstances.class);
- Mockito.when(sir.deactivateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"))
- .thenReturn(SERVICE_RESPONSE);
- Response resp = sir.deactivateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testDeleteServiceInstance()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
- final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();
- try {
- ServiceInstances sir = Mockito.mock(ServiceInstances.class);
- Mockito.when(sir.deleteServiceInstance(requestJSONDelete, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"))
- .thenReturn(SERVICE_RESPONSE);
- Response resp = sir.deleteServiceInstance(requestJSONDelete, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java
deleted file mode 100644
index f257ca7a80..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestInfo;
-
-
-
-public class RequestDetailsTest {
-
- RequestDetails _requestDetails;
- RequestInfo _requestInfo;
-
- public RequestDetailsTest() {
- }
-
- @Before
- public void setUp() {
- _requestDetails = mock(RequestDetails.class);
- _requestInfo = new RequestInfo();
- when(_requestDetails.getRequestInfo()).thenReturn(_requestInfo);
- }
-
- @After
- public void tearDown() {
- _requestDetails = null;
- _requestInfo = null;
- }
-
- /**
- * Test of getRequestInfo method
- */
- @Test
- public void testGetRequestInfo() {
- _requestDetails.setRequestInfo(_requestInfo);
- assertTrue(_requestDetails.getRequestInfo().equals(_requestInfo));
-
- }
-
- /**
- * Test setRequestInfo
- */
- @Test
- public void testSetRequestInfo() {
- _requestDetails.setRequestInfo(_requestInfo);
- verify(_requestDetails).setRequestInfo(_requestInfo);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java
deleted file mode 100644
index 3ff389124a..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestInfo;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.ValidResponses;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class RequestInfoTest {
-
- RequestInfo _requestInfo;
- String _source;
- ValidResponses _responseValue;
- String _requestorId;
-
- public RequestInfoTest() {
- }
-
- @Before
- public void setUp() {
- _requestInfo = mock(RequestInfo.class);
- _responseValue = ValidResponses.abort;
- _requestorId = "ab1234";
- _source = "VID";
- when(_requestInfo.getRequestorId()).thenReturn(_requestorId);
- when(_requestInfo.getSource()).thenReturn(_source);
- when(_requestInfo.getResponseValue()).thenReturn(_responseValue);
-
- }
-
- @After
- public void tearDown() {
- _requestInfo = null;
- _responseValue = null;
- }
-
- /**
- * Test of getSource method
- */
- @Test
- public void testGetSource() {
- String result = _requestInfo.getSource();
- assertEquals(_source, result);
-
- }
-
- /**
- * Test setSource
- */
- @Test
- public void testSetSource() {
- _requestInfo.setSource("VID");
- verify(_requestInfo).setSource(_source);
- }
-
- /**
- * Test of getRequestorId method
- */
- @Test
- public void testGetRequestorId() {
- String result = _requestInfo.getRequestorId();
- assertEquals(_requestorId, result);
-
- }
-
- /**
- * Test setRequestInfo
- */
- @Test
- public void testSetRequestorId() {
- _requestInfo.setRequestorId(_requestorId);
- verify(_requestInfo).setRequestorId(_requestorId);
- }
-
-
- /**
- * Test of getResponseValue method
- */
- @Test
- public void testGetResponseValue() {
- ValidResponses result = _requestInfo.getResponseValue();
- assertEquals(_responseValue, result);
-
- }
-
- /**
- * Test setResponseValues method
- */
- @Test
- public void testSetResponseValue() {
- _requestInfo.setResponseValue(ValidResponses.abort);
- verify(_requestInfo).setResponseValue(_responseValue);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java
deleted file mode 100644
index 293278955a..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.json.JSONArray;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskList;
-
-public class TaskListTest {
-
- TaskList _taskList;
- protected String _taskId;
- protected String _type;
- protected String _nfRole;
- protected String _subscriptionServiceType;
- protected String _originalRequestId;
- protected String _originalRequestorId;
- protected String _errorSource;
- protected String _errorCode;
- protected String _errorMessage;
- protected String _buildingBlockName;
- protected String _buildingBlockStep;
- protected JSONArray _validResponses;
-
- public TaskListTest() {
- }
-
- @Before
- public void setUp() {
- _taskList = mock(TaskList.class);
- _taskId = "_taskid";
- _type = "type";
- _nfRole = "nfrole";
- _subscriptionServiceType = "subscriptionservicetype";
- _originalRequestId = "originalrequestid";
- _originalRequestorId = "originalrequestorid";
- _errorSource = "errorsource";
- _errorCode = "errorcode";
- _errorMessage = "errormessage";
- _buildingBlockName = "buildingblockname";
- _buildingBlockStep = "buildingblockstep";
- _validResponses = mock(JSONArray.class);
-
- when(_taskList.getTaskId()).thenReturn(_taskId);
- when(_taskList.getType()).thenReturn(_type);
- when(_taskList.getNfRole()).thenReturn(_nfRole);
- when(_taskList.getSubscriptionServiceType()).thenReturn(_subscriptionServiceType);
- when(_taskList.getOriginalRequestId()).thenReturn(_originalRequestId);
- when(_taskList.getOriginalRequestorId()).thenReturn(_originalRequestorId);
- when(_taskList.getErrorSource()).thenReturn(_errorSource);
- when(_taskList.getErrorCode()).thenReturn(_errorCode);
- when(_taskList.getErrorMessage()).thenReturn(_errorMessage);
- when(_taskList.getBuildingBlockName()).thenReturn(_buildingBlockName);
- when(_taskList.getBuildingBlockStep()).thenReturn(_buildingBlockStep);
- when(_taskList.getValidResponses()).thenReturn(_validResponses);
- }
-
- @After
- public void tearDown() {
- _taskList = null;
- _validResponses = null;
- }
-
- @Test
- public void testGetTaskId() {
- String result = _taskList.getTaskId();
- assertEquals(_taskId, result);
-
- }
-
- @Test
- public void testSetTaskId() {
- _taskList.setTaskId("_taskid");
- verify(_taskList).setTaskId(_taskId);
- }
-
- @Test
- public void testGetType() {
- String result = _taskList.getType();
- assertEquals(_type, result);
-
- }
-
- @Test
- public void testSetType() {
- _taskList.setType(_type);
- verify(_taskList).setType(_type);
- }
-
- @Test
- public void testGetNfRole() {
- String result = _taskList.getNfRole();
- assertEquals(_nfRole, result);
-
- }
-
- @Test
- public void testSetNfRole() {
- _taskList.setType(_nfRole);
- verify(_taskList).setType(_nfRole);
- }
-
- @Test
- public void testGetSubscriptionServiceType() {
- String result = _taskList.getSubscriptionServiceType();
- assertEquals(_subscriptionServiceType, result);
-
- }
-
- @Test
- public void testSetSubscriptionServiceType() {
- _taskList.setSubscriptionServiceType(_subscriptionServiceType);
- verify(_taskList).setSubscriptionServiceType(_subscriptionServiceType);
- }
-
- @Test
- public void testGetOriginalRequestId() {
- String result = _taskList.getOriginalRequestId();
- assertEquals(_originalRequestId, result);
-
- }
-
- @Test
- public void testSetOriginalRequestId() {
- _taskList.setOriginalRequestId(_originalRequestId);
- verify(_taskList).setOriginalRequestId(_originalRequestId);
- }
-
- @Test
- public void testGetOriginalRequestorId() {
- String result = _taskList.getOriginalRequestorId();
- assertEquals(_originalRequestorId, result);
-
- }
-
- @Test
- public void testSetOriginalRequestorId() {
- _taskList.setOriginalRequestorId(_originalRequestorId);
- verify(_taskList).setOriginalRequestorId(_originalRequestorId);
- }
-
- @Test
- public void testGetErrorSource() {
- String result = _taskList.getErrorSource();
- assertEquals(_errorSource, result);
-
- }
-
- @Test
- public void testSetErrorSource() {
- _taskList.setErrorSource(_errorSource);
- verify(_taskList).setErrorSource(_errorSource);
- }
-
- @Test
- public void testGetErrorCode() {
- String result = _taskList.getErrorCode();
- assertEquals(_errorCode, result);
-
- }
-
- @Test
- public void testSetErrorCode() {
- _taskList.setErrorCode(_errorCode);
- verify(_taskList).setErrorCode(_errorCode);
- }
-
- @Test
- public void testGetErrorMessage() {
- String result = _taskList.getErrorMessage();
- assertEquals(_errorMessage, result);
-
- }
-
- @Test
- public void testSetErrorMessage() {
- _taskList.setErrorMessage(_errorMessage);
- verify(_taskList).setErrorMessage(_errorMessage);
- }
-
- @Test
- public void testGetBuildingBlockName() {
- String result = _taskList.getBuildingBlockName();
- assertEquals(_buildingBlockName, result);
-
- }
-
- @Test
- public void testSetBuildingBlockName() {
- _taskList.setBuildingBlockName(_buildingBlockName);
- verify(_taskList).setBuildingBlockName(_buildingBlockName);
- }
-
- @Test
- public void testGetBuildingBlockStep() {
- String result = _taskList.getBuildingBlockStep();
- assertEquals(_buildingBlockStep, result);
-
- }
-
- @Test
- public void testSetBuildingBlockStep() {
- _taskList.setBuildingBlockStep(_buildingBlockStep);
- verify(_taskList).setBuildingBlockStep(_buildingBlockStep);
- }
-
- @Test
- public void testGetValidResponses() {
-
- JSONArray result = _taskList.getValidResponses();
- assertEquals(_validResponses, result);
-
- }
-
- @Test
- public void testSetValidResponses() {
- _taskList.setValidResponses(_validResponses);
- verify(_taskList).setValidResponses(_validResponses);
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java
deleted file mode 100644
index ec45592704..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskRequestReference;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TaskRequestReferenceTest {
-
- TaskRequestReference _taskRequestReference;
-
- protected String _taskId;
- public TaskRequestReferenceTest() {
- }
-
- @Before
- public void setUp() {
- _taskRequestReference = mock(TaskRequestReference.class);
- _taskId = "taskid";
-
- when(_taskRequestReference.getTaskId()).thenReturn(_taskId);
- }
-
- @After
- public void tearDown() {
- _taskRequestReference = null;
- }
-
- /**
- * Test getTaskRequestReference
- */
- @Test
- public void taskGetRequestReference() {
- String result = _taskRequestReference.getTaskId();
- assertEquals(_taskId, result);
- }
-
- /**
- * Test setTaskRequestReference
- */
- @Test
- public void testSetRequestInfo() {
- _taskRequestReference.setTaskId(_taskId);
- verify(_taskRequestReference).setTaskId(_taskId);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java
deleted file mode 100644
index b593036556..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariableValue;
-
-public class TaskVariableValueTest {
- TaskVariableValue _taskVariableValue;
- protected String _name;
- protected String _value;
- protected String _operator;
-
- public TaskVariableValueTest() {
- }
-
- @Before
- public void setUp() {
- _taskVariableValue = mock(TaskVariableValue.class);
- _name = "name";
- _value = "value";
- _operator = "operator";
- when(_taskVariableValue.getName()).thenReturn(_name);
- when(_taskVariableValue.getValue()).thenReturn(_value);
- when(_taskVariableValue.getOperator()).thenReturn(_operator);
- }
-
- @After
- public void tearDown() {
- _taskVariableValue = null;
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetName() {
- _taskVariableValue.setName(_name);
- assertEquals(_taskVariableValue.getName(),_name);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetName() {
- _taskVariableValue.setName(_name);
- verify(_taskVariableValue).setName(_name);
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetValue() {
- _taskVariableValue.setValue(_value);
- assertEquals(_taskVariableValue.getValue(),_value);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetValue() {
- _taskVariableValue.setValue(_value);
- verify(_taskVariableValue).setValue(_value);
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetOperator() {
- _taskVariableValue.setOperator(_operator);
- assertEquals(_taskVariableValue.getOperator(),_operator);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetRequestDetails() {
- _taskVariableValue.setOperator(_operator);
- verify(_taskVariableValue).setOperator(_operator);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java
deleted file mode 100644
index b08729b0ff..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariableValue;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariables;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-public class TaskVariablesTest {
-
- TaskVariables _taskVariables;
- private List<TaskVariableValue> _taskVariableValueList;
-
- public TaskVariablesTest() {
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- _taskVariables = mock(TaskVariables.class);
- _taskVariableValueList = mock(List.class);
- when(_taskVariables.getTaskVariables()).thenReturn(_taskVariableValueList);
- }
-
- @After
- public void tearDown() {
- _taskVariables = null;
- }
-
- @Test
- public void testGetTaskVariables() {
- List<TaskVariableValue> result = _taskVariables.getTaskVariables();
- assertEquals(_taskVariableValueList, result);
-
- }
-
- @Test
- public void testSetTaskVariables() {
- _taskVariables.setTaskVariables(_taskVariableValueList);
- verify(_taskVariables).setTaskVariables(_taskVariableValueList);
-
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java
deleted file mode 100644
index eeb745d3bf..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskList;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TasksGetResponse;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-public class TasksGetResponseTest {
-
- TasksGetResponse _tasksGetResponse;
- private List<TaskList> _taskList;
-
- public TasksGetResponseTest() {
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- _tasksGetResponse = mock(TasksGetResponse.class);
- _taskList = mock(List.class);
- when(_tasksGetResponse.getTaskList()).thenReturn(_taskList);
- }
-
- @After
- public void tearDown() {
- _tasksGetResponse = null;
- }
-
- @Test
- public void testGetTaskList() {
- List<TaskList> result = _tasksGetResponse.getTaskList();
- assertEquals(_taskList, result);
-
- }
-
- @Test
- public void testSetTaskList() {
- _tasksGetResponse.setTaskList(_taskList);
- verify(_tasksGetResponse).setTaskList(_taskList);
-
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java
deleted file mode 100644
index 8bfdb645d7..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.TasksRequest;
-
-
-public class TasksRequestTest {
- TasksRequest _tasksRequest;
- private RequestDetails _requestDetails;
-
- public TasksRequestTest() {
- }
-
- @Before
- public void setUp() {
- _tasksRequest = mock(TasksRequest.class);
- _requestDetails = new RequestDetails();
- when(_tasksRequest.getRequestDetails()).thenReturn(_requestDetails);
- }
-
- @After
- public void tearDown() {
- _tasksRequest = null;
- }
-
- /**
- * Test of getRequestDetails method
- */
- @Test
- public void testGetRequestDetails() {
- _tasksRequest.setRequestDetails(_requestDetails);
- assertTrue(_tasksRequest.getRequestDetails().equals(_requestDetails));
-
- }
-
- /**
- * Test setRequestDetails
- */
- @Test
- public void testSetRequestDetails() {
- _tasksRequest.setRequestDetails(_requestDetails);
- verify(_tasksRequest).setRequestDetails(_requestDetails);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java
deleted file mode 100644
index 41b43c06d8..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.Value;
-
-public class ValueTest {
- Value _valueInstance;
- protected String _value;
-
- public ValueTest() {
- }
-
- @Before
- public void setUp() {
- _valueInstance = mock(Value.class);
- _value = "_value";
- when(_valueInstance.getValue()).thenReturn(_value);
- }
-
- @After
- public void tearDown() {
- _valueInstance = null;
- }
-
- /**
- * Test of getValue method
- */
- @Test
- public void testGetValue() {
- _valueInstance.setValue(_value);
- assertEquals(_valueInstance.getValue(),_value);
-
- }
-
- /**
- * Test setValue
- */
- @Test
- public void testSetValue() {
- _valueInstance.setValue(_value);
- verify(_valueInstance).setValue(_value);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java
deleted file mode 100644
index fdfd5a16bc..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.apihandlerinfra.taskbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.Variables;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.Value;
-
-public class VariablesTest {
-
- Variables _variables;
- protected Value _source;
- protected Value _responseValue;
- protected Value _requestorId;
-
- @Before
- public void setUp() {
- _variables = mock(Variables.class);
- _source = mock(Value.class);
- _responseValue = mock(Value.class);
- _requestorId = mock(Value.class);
-
- when(_variables.getSource()).thenReturn(_source);
- when(_variables.getRequestorId()).thenReturn(_requestorId);
- when(_variables.getResponseValue()).thenReturn(_responseValue);
-
- }
-
- @After
- public void tearDown() {
- _variables = null;
- _source = null;
- _responseValue = null;
- _requestorId = null;
- }
-
- @Test
- public void testGetSource() {
- _variables.setSource(_source);
- assertTrue(_variables.getSource().equals(_source));
- }
-
- @Test
- public void testSetSource(){
- _variables.setSource(_source);
- verify(_variables).setSource(_source);
- }
-
- @Test
- public void testGetResponseValue() {
- _variables.setResponseValue(_responseValue);
- assertTrue(_variables.getResponseValue().equals(_responseValue));
- }
-
- @Test
- public void testSetResponseValue(){
- _variables.setResponseValue(_responseValue);
- verify(_variables).setResponseValue(_responseValue);
- }
-
- @Test
- public void testGetRequestorId() {
- _variables.setRequestorId(_requestorId);
- assertTrue(_variables.getRequestorId().equals(_requestorId));
- }
-
- @Test
- public void testSetRequestorId(){
- _variables.setRequestorId(_requestorId);
- verify(_variables).setRequestorId(_requestorId);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
deleted file mode 100644
index 30db50c9b9..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.CharEncoding;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-
-public class CloudOrchestrationTest {
-
- @Test
- public void testCreateOpEnvObjectMapperError() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- Response response = co.createOperationEnvironment(null, null);
- String body = response.getEntity().toString();
-
- assertTrue(body.contains("Mapping of request to JSON object failed."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testCreateOpEnvError() throws IOException {
- String request = "{\"requestDetails\":{\"requestInfo\":{\"resourceType\":\"operationalEnvironment\",\"instanceName\": \"myOpEnv\",\"source\": \"VID\",\"requestorId\": \"az2017\"},"
- + " \"requestParameters\": {\"tenantContext\": \"Test\",\"workloadContext\": \"ECOMP_E2E-IST\"}}}";
- CloudOrchestration co = new CloudOrchestration();
- Response response = co.createOperationEnvironment(request, null);
- String body = response.getEntity().toString();
-
- assertTrue(body.contains("Error parsing request."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testCreateOpEnvReqRecord() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/ECOMPOperationEnvironmentCreate.json"), CharEncoding.UTF_8);
- Response response = co.createOperationEnvironment(request, null);
- assertEquals(500, response.getStatus());
- }
-
- @Test
- public void testCreateOperationalEnvironment() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- co.setRequestsDatabase(reqDB);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/ECOMPOperationEnvironmentCreate.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(new HashMap<String, String>(), "myOpEnv", "create")).thenReturn(null);
- doNothing().when(tenantIsolationRequest).createRequestRecord(Status.IN_PROGRESS, Action.create);
-
- Response response = co.createOperationEnvironment(request, null);
- assertEquals(200, response.getStatus());
- }
-
- @Test
- public void testCreateVNFDuplicateCheck() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- Response res = Response.status(409).entity("already has a request being worked with a status of").build();
-
- co.setRequestsDatabase(reqDB);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/VNFOperationEnvironmentCreate.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(new InfraActiveRequests());
- doNothing().when(tenantIsolationRequest).createRequestRecord(Status.FAILED, Action.create);
- when(tenantIsolationRequest.buildServiceErrorResponse(any(Integer.class), any(MsoException.class), any(String.class), any(String.class), any(List.class))).thenReturn(res);
-
- Response response = co.createOperationEnvironment(request, null);
- assertEquals(409, response.getStatus());
- }
-
- @Test
- public void testCreateVNF() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- TenantIsolationRunnable thread = mock(TenantIsolationRunnable.class);
-
- co.setRequestsDatabase(reqDB);
- co.setThread(thread);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/VNFOperationEnvironmentCreate.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(null);
- doNothing().when(tenantIsolationRequest).createRequestRecord(Status.IN_PROGRESS, Action.create);
- doNothing().when(thread).run();
-
- Response response = co.createOperationEnvironment(request, null);
- assertEquals(200, response.getStatus());
- }
-
- @Test
- public void testActivate() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- TenantIsolationRunnable thread = mock(TenantIsolationRunnable.class);
-
- co.setRequestsDatabase(reqDB);
- co.setThread(thread);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/ActivateOperationEnvironment.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(null);
- doNothing().when(tenantIsolationRequest).createRequestRecord(Status.IN_PROGRESS, Action.activate);
- doNothing().when(thread).run();
-
- Response response = co.activateOperationEnvironment(request, null, "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(200, response.getStatus());
- }
-
- @Test
- public void testDeactivate() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- TenantIsolationRunnable thread = mock(TenantIsolationRunnable.class);
-
- co.setRequestsDatabase(reqDB);
- co.setThread(thread);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironment.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(null);
- doNothing().when(tenantIsolationRequest).createRequestRecord(Status.IN_PROGRESS, Action.deactivate);
- doNothing().when(thread).run();
-
- Response response = co.activateOperationEnvironment(request, null, "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(200, response.getStatus());
- }
-
- @Ignore // 1802 merge
- @Test
- public void testDeactivateThreadException() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- TenantIsolationRunnable thread = mock(TenantIsolationRunnable.class);
- Response res = Response.status(500).entity("Failed creating a Thread").build();
-
- co.setRequestsDatabase(reqDB);
- co.setThread(thread);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironment.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(null);
- doNothing().when(tenantIsolationRequest).createRequestRecord(Status.IN_PROGRESS, Action.deactivate);
- doThrow(Exception.class).when(thread).run();
- when(tenantIsolationRequest.buildServiceErrorResponse(any(Integer.class), any(MsoException.class), any(String.class), any(String.class), any(List.class))).thenReturn(res);
-
- Response response = co.activateOperationEnvironment(request, null, "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(500, response.getStatus());
- }
-
- @Test
- public void testDeactivateDupCheck() throws IOException {
- CloudOrchestration co = new CloudOrchestration();
- TenantIsolationRequest tenantIsolationRequest = mock(TenantIsolationRequest.class);
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- Response res = Response.status(409).entity("Failed creating a Thread").build();
-
- co.setRequestsDatabase(reqDB);
- co.setTenantIsolationRequest(tenantIsolationRequest);
- String request = IOUtils.toString(ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironment.json"), CharEncoding.UTF_8);
- when(reqDB.checkInstanceNameDuplicate(null, "myVnfOpEnv", "operationalEnvironment")).thenReturn(null);
- when(reqDB.checkVnfIdStatus(null)).thenReturn(new InfraActiveRequests());
- when(tenantIsolationRequest.buildServiceErrorResponse(any(Integer.class), any(MsoException.class), any(String.class), any(String.class), any(List.class))).thenReturn(res);
-
- Response response = co.deactivateOperationEnvironment(request, null, "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(409, response.getStatus());
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
deleted file mode 100644
index 3e19489f5d..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import org.jboss.resteasy.spi.ResteasyUriInfo;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-
-public class CloudResourcesOrchestrationTest {
-
- private String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"VID\",\"requestorId\":\"zz9999\" } } }";
-
- @Test
- public void testUnlockFailObjectMapping() {
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- Response response = cor.unlockOrchestrationRequest(null, null, null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Mapping of request to JSON object failed."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testUnlockFailObjectMapping2() {
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- Response response = cor.unlockOrchestrationRequest(null, "requestId", null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Mapping of request to JSON object failed."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testParseOrchestrationError1() {
- String requestJSON = "{\"requestDetails\": null }";
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Error parsing request."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testParseOrchestrationError2() {
- String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"\",\"requestorId\":\"zz9999\" } } }";
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Error parsing request."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testParseOrchestrationError3() {
- String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"VID\",\"requestorId\":\"\" } } }";
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Error parsing request."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testGetInfraActiveRequestNull() {
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getRequestFromInfraActive("requestId")).thenReturn(null);
-
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Orchestration RequestId requestId is not found in DB"));
- assertEquals(404, response.getStatus());
- }
-
- @Test
- public void testUnlockError() {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvironmentId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("IN_PROGRESS");
-
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getRequestFromInfraActive("requestId")).thenReturn(iar);
- when(reqDB.updateInfraStatus("requestId", "UNLOCKED", "APIH")).thenReturn(1);
-
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- assertEquals(404, response.getStatus());
- }
-
- @Test
- public void testUnlock() throws ParseException {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvironmentId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("IN_PROGRESS");
-
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateFormat.parse("23/09/2007");
- long time = date.getTime();
- iar.setStartTime(new Timestamp(time));
-
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getRequestFromInfraActive("requestId")).thenReturn(iar);
- when(reqDB.updateInfraStatus("requestId", "UNLOCKED", "APIH")).thenReturn(1);
-
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- assertEquals(204, response.getStatus());
- }
-
- @Test
- public void testUnlockComplete() throws ParseException {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvironmentId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("COMPLETE");
-
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateFormat.parse("23/09/2007");
- long time = date.getTime();
- iar.setStartTime(new Timestamp(time));
-
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getRequestFromInfraActive("requestId")).thenReturn(iar);
- when(reqDB.updateInfraStatus("requestId", "UNLOCKED", "APIH")).thenReturn(1);
-
- Response response = cor.unlockOrchestrationRequest(requestJSON, "requestId", null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Orchestration RequestId requestId has a status of COMPLETE and can not be unlocked"));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testGetOperationalEnvFilter() {
- ResteasyUriInfo uriInfo = new ResteasyUriInfo("", "requestId=89c56827-1c78-4827-bc4d-6afcdb37a51f", "");
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getRequestFromInfraActive("89c56827-1c78-4827-bc4d-6afcdb37a51f")).thenReturn(null);
-
- Response response = cor.getOperationEnvironmentStatusFilter(uriInfo, null);
- String body = response.getEntity().toString();
-
- assertTrue(body.contains("Orchestration RequestId 89c56827-1c78-4827-bc4d-6afcdb37a51f is not found in DB"));
- assertEquals(204, response.getStatus());
- }
-
- @Test
- public void testGetOperationalEnvFilterException() {
- ResteasyUriInfo uriInfo = new ResteasyUriInfo("", "requestId=89c56827-1c78-4827-bc4d-6afcdb37a51f", "");
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
-
- Response response = cor.getOperationEnvironmentStatusFilter(uriInfo, null);
- assertEquals(404, response.getStatus());
- }
-
- @Test
- public void testGetOperationalEnvSuccess() throws ParseException {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvironmentId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("COMPLETE");
-
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateFormat.parse("23/09/2007");
- long time = date.getTime();
- iar.setStartTime(new Timestamp(time));
-
- ResteasyUriInfo uriInfo = new ResteasyUriInfo("", "requestId=89c56827-1c78-4827-bc4d-6afcdb37a51f", "");
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getRequestFromInfraActive("89c56827-1c78-4827-bc4d-6afcdb37a51f")).thenReturn(iar);
-
- Response response = cor.getOperationEnvironmentStatusFilter(uriInfo, null);
- assertEquals(200, response.getStatus());
- }
-
- @Test
- public void testGetOperationalEnvFilterSuccess() throws ParseException {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvironmentId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("COMPLETE");
- iar.setStatusMessage("status Message");
- iar.setProgress(20L);
-
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateFormat.parse("23/09/2007");
- long time = date.getTime();
- iar.setStartTime(new Timestamp(time));
- iar.setEndTime(new Timestamp(time));
-
- List<InfraActiveRequests> requests = new ArrayList<>();
- requests.add(iar);
-
- Map<String, String> map = new HashMap<>();
- map.put("operationalEnvironmentName", "myVnfOpEnv");
-
- ResteasyUriInfo uriInfo = new ResteasyUriInfo("", "operationalEnvironmentName=myVnfOpEnv&requestorId=test", "");
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getCloudOrchestrationFiltersFromInfraActive(map)).thenReturn(requests);
-
- Response response = cor.getOperationEnvironmentStatusFilter(uriInfo, null);
- assertEquals(200, response.getStatus());
- }
-
- @Ignore // 1802 merge
- @Test
- public void testGetOperationalEnvFilterException1() throws ParseException {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvironmentId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("COMPLETE");
-
- List<InfraActiveRequests> requests = new ArrayList<>();
- requests.add(iar);
-
- Map<String, String> map = new HashMap<>();
- map.put("operationalEnvironmentName", "myVnfOpEnv");
-
- ResteasyUriInfo uriInfo = new ResteasyUriInfo("", "filter=operationalEnvironmentName:EQUALS:myVnfOpEnv", "");
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getCloudOrchestrationFiltersFromInfraActive(map)).thenReturn(requests);
-
- Response response = cor.getOperationEnvironmentStatusFilter(uriInfo, null);
- assertEquals(500, response.getStatus());
- }
-
- @Test
- public void testGetOperationalEnvFilterException2() throws ParseException {
- InfraActiveRequests iar = new InfraActiveRequests();
- iar.setRequestId("requestId");
- iar.setRequestScope("requestScope");
- iar.setRequestType("requestType");
- iar.setOperationalEnvId("operationalEnvId");
- iar.setOperationalEnvName("operationalEnvName");
- iar.setRequestorId("ma920e");
- iar.setRequestBody("");
- iar.setRequestStatus("COMPLETE");
-
- List<InfraActiveRequests> requests = new ArrayList<>();
- requests.add(iar);
-
- Map<String, String> map = new HashMap<>();
- map.put("operationalEnvironmentName", "myVnfOpEnv");
-
- ResteasyUriInfo uriInfo = new ResteasyUriInfo("", "operationalEnvironmentName=", "");
- CloudResourcesOrchestration cor = new CloudResourcesOrchestration();
- RequestsDatabase reqDB = mock(RequestsDatabase.class);
- cor.setRequestsDB(reqDB);
- when(reqDB.getCloudOrchestrationFiltersFromInfraActive(map)).thenReturn(requests);
-
- Response response = cor.getOperationEnvironmentStatusFilter(uriInfo, null);
- assertEquals(500, response.getStatus());
- assertTrue(response.getEntity().toString().contains("No valid operationalEnvironmentName value is specified"));
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
deleted file mode 100644
index c02557314d..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class ModelDistributionRequestTest {
-
- private static final String requestJSON = "{\"status\": \"DISTRIBUTION_COMPLETE_ERROR\", \"errorReason\": \"Distribution failed in AAI\" }";
-
- @Test
- public void testUpdateModelDistributionStatus() {
- final Response okResponse = Response.status(HttpStatus.SC_OK).build();
-
- try {
- ModelDistributionRequest mdr = Mockito.mock(ModelDistributionRequest.class);
- Mockito.when(mdr.updateModelDistributionStatus(requestJSON, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff")).thenReturn(okResponse);
- Response resp = mdr.updateModelDistributionStatus(requestJSON, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
- }
- }
-
- @Test
- public void testObjectMapperError() {
- ModelDistributionRequest request = new ModelDistributionRequest();
- Response response = request.updateModelDistributionStatus(null, null, null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Mapping of request to JSON object failed."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testParseError1() {
- String requestErrorJSON = "{\"errorReason\": \"Distribution failed in AAI\" }";
-
- ModelDistributionRequest request = new ModelDistributionRequest();
- Response response = request.updateModelDistributionStatus(requestErrorJSON, null, null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Error parsing request."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testParseError2() {
- String requestErrorJSON = "{\"status\": \"DISTRIBUTION_COMPLETE_ERROR\"}";
-
- ModelDistributionRequest request = new ModelDistributionRequest();
- Response response = request.updateModelDistributionStatus(requestErrorJSON, null, null);
- String body = response.getEntity().toString();
- assertTrue(body.contains("Error parsing request."));
- assertEquals(400, response.getStatus());
- }
-
- @Test
- public void testSuccess() {
- ModelDistributionRequest request = new ModelDistributionRequest();
- TenantIsolationRunnable thread = mock(TenantIsolationRunnable.class);
- request.setThread(thread);
-
- Response response = request.updateModelDistributionStatus(requestJSON, null, null);
-
- assertEquals(200, response.getStatus());
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
deleted file mode 100644
index 3b8bf3f19e..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.helpers;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.doThrow;
-
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.mock.MockTest;
-import org.openecomp.mso.client.aai.AAIResourcesClient;
-import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-
-
-public class AAIClientHelperTest extends MockTest {
-
- @Mock private AAIResourcesClient aaiResourceClientMock;
- private AAIClientHelper clientHelper;
-
- @Before
- public void testSetUp() {
- MockitoAnnotations.initMocks(this);
- AAIClientHelper aaiHelper = new AAIClientHelper();
- clientHelper = spy(aaiHelper);
- when(clientHelper.getClient()).thenReturn(aaiResourceClientMock);
- }
-
- @Test
- public void testGetAaiOperationalEnvironmentSuccess() throws Exception {
- clientHelper.getAaiOperationalEnvironment("123");
- verify(aaiResourceClientMock, times(1)).get(any(AAIResourceUri.class));
- }
-
- @Test(expected = AAIClientCallFailed.class)
- public void testGetAaiOperationalEnvironmentRainyDay() throws Exception {
- when(aaiResourceClientMock.get(any(AAIResourceUri.class))).thenThrow(new RuntimeException());
- clientHelper.getAaiOperationalEnvironment("123");
- }
-
- @Test
- public void testCreateOperationalEnvironmentSuccess() throws Exception {
- AAIOperationalEnvironment env = AAIClientObjectBuilder.createAAIOperationalEnvironment("123", "Test Env", "ECOMP", "ACTIVE", "Test", "PVT");
- clientHelper.createOperationalEnvironment(env);
- verify(aaiResourceClientMock, times(1)).create(any(AAIResourceUri.class), eq(env));
- }
-
- @Test(expected = AAIClientCallFailed.class)
- public void testCreateOperationalEnvironmentRainyDay() throws Exception {
- AAIOperationalEnvironment env = AAIClientObjectBuilder.createAAIOperationalEnvironment("123", "Test Env", "ECOMP", "ACTIVE", "Test", "PVT");
- doThrow(RuntimeException.class).when(aaiResourceClientMock).create(any(AAIResourceUri.class), eq(env));
- clientHelper.createOperationalEnvironment(env);
- }
-
- @Test
- public void testCreateRelationshipSuccess() throws Exception {
- clientHelper.createRelationship("VOE-001", "MEOE-002");
- verify(aaiResourceClientMock, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test(expected = AAIClientCallFailed.class)
- public void testCreateRelationshipRainyDay() throws Exception {
- doThrow(RuntimeException.class).when(aaiResourceClientMock).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- clientHelper.createRelationship("VOE-001", "MEOE-002");
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelperTest.java
deleted file mode 100644
index fbeb448227..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelperTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.helpers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.rest.RESTClient;
-import org.openecomp.mso.rest.RESTConfig;
-
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class AsdcClientHelperTest {
-
- MsoJavaProperties properties = MsoPropertiesUtils.loadMsoProperties();
- AsdcClientHelper asdcClientUtils = new AsdcClientHelper(properties);
-
- String serviceModelVersionId = "TEST_uuid1";
- String operationalEnvironmentId = "TEST_operationalEnvironmentId";
- String workloadContext = "TEST_workloadContext";
-
- @Rule
- public final WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.wireMockConfig().port(28090)); //.extensions(transformerArray));
-
- @BeforeClass
- public static void setUp() throws Exception {
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void getPropertiesTest() {
-
- String asdcInstanceId = asdcClientUtils.getAsdcInstanceId();
- Assert.assertEquals("Asdc InstanceId - " , "test", asdcInstanceId);
-
- String asdcEndpoint = asdcClientUtils.getAsdcEndpoint();
- Assert.assertEquals("Asdc Endpoint - " , "http://localhost:28090", asdcEndpoint);
-
- String userid = asdcClientUtils.getAsdcUserId();
- Assert.assertEquals("userid - " , "cs0008", userid);
-
- }
-
- @Test
- public void buildUriBuilderTest() {
-
- try {
- String url = asdcClientUtils.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId);
- assertEquals("http://localhost:28090/sdc/v1/catalog/services/TEST_uuid1/distribution/TEST_operationalEnvironmentId/activate", url);
-
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
-
- }
- }
-
- @Test
- public void buildJsonWorkloadContextTest() {
-
- try {
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
- assertEquals("{\"workloadContext\":\"TEST_workloadContext\"}", jsonPayload);
-
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
-
- }
- }
-
- @Test
- public void setRestClientTest() {
-
- try {
- String url = asdcClientUtils.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId);
- RESTConfig config = new RESTConfig(url);
- RESTClient client = asdcClientUtils.setRestClient(config);
- LinkedHashMap<String, List<String>> headers = client.getHeaders();
- assertEquals("[cs0008]", headers.get("USER_ID").toString());
-
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
-
- }
- }
-
- @Test
- public void enhanceJsonResponseTest_Success() {
-
- try {
- // build success response data
- JSONObject asdcResponseJsonObj = new JSONObject();
- asdcResponseJsonObj.put("distributionId", "TEST_distributionId");
-
- int statusCode = 202;
- asdcResponseJsonObj = asdcClientUtils.enhanceJsonResponse(asdcResponseJsonObj, statusCode);
-
- assertEquals("202", asdcResponseJsonObj.getString("statusCode"));
- assertEquals("", asdcResponseJsonObj.getString("messageId"));
- assertEquals("Success", asdcResponseJsonObj.getString("message"));
- assertEquals("TEST_distributionId", asdcResponseJsonObj.getString("distributionId"));
-
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
-
- }
- }
-
- @Test
- public void enhanceJsonResponseTest_Error() {
-
- try {
-
- // build error response data
- JSONObject jsonMessages = new JSONObject();
- jsonMessages.put("messageId", "SVC4675");
- jsonMessages.put("text", "Error: Service state is invalid for this action.");
- JSONObject jsonServException = new JSONObject();
- jsonServException.put("serviceException", jsonMessages);
- JSONObject jsonErrorRequest = new JSONObject();
- jsonErrorRequest.put("requestError", jsonServException);
-
- String responseData = jsonErrorRequest.toString();
-
- JSONObject asdcResponseJsonObj = new JSONObject(responseData);
- int statusCode = 409;
- asdcResponseJsonObj = asdcClientUtils.enhanceJsonResponse(asdcResponseJsonObj, statusCode);
-
- assertEquals("409", asdcResponseJsonObj.getString("statusCode"));
- assertEquals("SVC4675", asdcResponseJsonObj.getString("messageId"));
- assertEquals("Error: Service state is invalid for this action.", asdcResponseJsonObj.getString("message"));
-
-
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
-
- }
- }
-
- @Test
- public void enhanceJsonResponseTest_Error_policyException() {
-
- try {
-
- // build error response data
- JSONObject jsonMessages = new JSONObject();
- jsonMessages.put("messageId", "POL5003");
- jsonMessages.put("text", "Error: Not authorized to use the API.");
- JSONObject jsonServException = new JSONObject();
- jsonServException.put("policyException", jsonMessages);
- JSONObject jsonErrorRequest = new JSONObject();
- jsonErrorRequest.put("requestError", jsonServException);
-
- String responseData = jsonErrorRequest.toString();
-
- JSONObject asdcResponseJsonObj = new JSONObject(responseData);
- int statusCode = 403;
- asdcResponseJsonObj = asdcClientUtils.enhanceJsonResponse(asdcResponseJsonObj, statusCode);
-
- assertEquals("403", asdcResponseJsonObj.getString("statusCode"));
- assertEquals("POL5003", asdcResponseJsonObj.getString("messageId"));
- assertEquals("Error: Not authorized to use the API.", asdcResponseJsonObj.getString("message"));
-
-
- } catch (Exception e) {
- fail("Exception caught: " + e.getMessage());
-
- }
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/AaiStubResponse.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/AaiStubResponse.java
deleted file mode 100644
index b89da737f7..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/AaiStubResponse.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.mock;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-
-import javax.ws.rs.core.MediaType;
-
-public class AaiStubResponse {
-
- public static String DEFAULT_ERROR_RESPONSE = "{ \"requestError\":{ \"serviceException\" : {\"messageId\": \"500\",\"text\": \"Test error message!\"}}}";
-
- public static void setupAllMocks() {}
-
- public static void MockGetRequest(String link, int returnCode, String response) {
- stubFor(get(urlPathEqualTo(link))
- .willReturn(aResponse()
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withHeader("Accept", MediaType.APPLICATION_JSON)
- .withStatus(returnCode)
- .withBody(response)));
- }
-
- public static void MockPutRequest(String link, int returnCode, String response) {
- stubFor(put(urlPathEqualTo(link))
- .willReturn(aResponse()
- .withStatus(returnCode)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody(response)));
- }
-
- public static void MockPostRequest(String link, int returnCode) {
- stubFor(post(urlPathEqualTo(link))
- .willReturn(aResponse()
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withHeader("X-HTTP-Method-Override", "PATCH")
- .withStatus(returnCode)));
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/MockTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/MockTest.java
deleted file mode 100644
index 36cab4fa61..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/mock/MockTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.mock;
-
-import java.io.File;
-import java.nio.file.Files;
-
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class MockTest {
-
- @Rule
- public final WireMockRule wireMockRule;
-
- public MockTest() {
- wireMockRule = new WireMockRule(WireMockConfiguration.wireMockConfig().port(28090)); //.extensions(transformerArray));
- }
-
- @BeforeClass
- public static void setUp() throws Exception {
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
- }
-
- public String getFileContentsAsString(String fileName) {
-
- String content = "";
- try {
- ClassLoader classLoader = this.getClass().getClassLoader();
- File file = new File(classLoader.getResource(fileName).getFile());
- content = new String(Files.readAllBytes(file.toPath()));
- }
- catch(Exception e) {
- e.printStackTrace();
- System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage() + ". Make sure to specify the correct path.");
- }
- return content;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
deleted file mode 100644
index 49fea2a8d9..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AsdcClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Manifest;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RecoveryAction;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestParameters;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatusDb;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatusDb;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient;
-import org.openecomp.mso.rest.RESTConfig;
-
-public class ActivateVnfOperationalEnvironmentTest {
-
- MsoJavaProperties properties = MsoPropertiesUtils.loadMsoProperties();
- AsdcClientHelper asdcClientUtils = new AsdcClientHelper(properties);
-
- String requestId = "TEST_requestId";
- String operationalEnvironmentId = "TEST_operationalEnvironmentId";
- CloudOrchestrationRequest request = new CloudOrchestrationRequest();
- String workloadContext = "TEST_workloadContext";
- String recoveryAction = "RETRY";
- String serviceModelVersionId = "TEST_serviceModelVersionId";
- int retryCount = 3;
- String distributionId = "TEST_distributionId";
-
- @BeforeClass
- public static void setUp() throws Exception {
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- public void getAAIClientHelperTest() throws Exception {
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfOperationalEnvironment activateVnf = new ActivateVnfOperationalEnvironment(request, requestId);
- AAIClientHelper aaiHelper = activateVnf.getAaiHelper();
-
- Assert.assertNotNull(aaiHelper);
-
- }
-
- @Test
- public void getAAIOperationalEnvironmentTest() throws Exception {
-
- // prepare return data
- JSONObject aaiJsonResponse = new JSONObject();
- aaiJsonResponse.put("operational-environment-id", "testASDCDistributionId");
- aaiJsonResponse.put("operational-environment-name", "testASDCDistributionIName");
- aaiJsonResponse.put("operational-environment-type", "VNF");
- aaiJsonResponse.put("operational-environment-status", "ACTIVE");
- aaiJsonResponse.put("tenant-context", "Test");
- aaiJsonResponse.put("workload-context", "PVT");
- aaiJsonResponse.put("resource-version", "1505228226913");
- String mockGetResponseJson = aaiJsonResponse.toString();
-
- AAIResultWrapper aaiREsultWrapperObj = new AAIResultWrapper(mockGetResponseJson);
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- AAIClientHelper aaiClientHelperMock = Mockito.mock(AAIClientHelper.class);
-
- ActivateVnfOperationalEnvironment activateVnfMock = Mockito.mock(ActivateVnfOperationalEnvironment.class);
- ActivateVnfOperationalEnvironment activateVnf = new ActivateVnfOperationalEnvironment(request, requestId);
-
- Mockito.when(aaiClientHelperMock.getAaiOperationalEnvironment(operationalEnvironmentId)).thenReturn(aaiREsultWrapperObj);
-
- activateVnfMock = spy(activateVnf);
- activateVnfMock.setAaiHelper(aaiClientHelperMock);
- activateVnfMock.getAAIOperationalEnvironment(operationalEnvironmentId);
-
- verify(activateVnfMock, times(1)).getAaiHelper();
- verify(aaiClientHelperMock, times(1)).getAaiOperationalEnvironment( any(String.class) );
-
- }
-
- @Test
- public void processActivateASDCRequestTest() throws Exception {
-
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
- String distributionId = "TEST_distributionId";
-
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("statusCode", "202");
- jsonObject.put("message", "Success");
- jsonObject.put("distributionId", distributionId);
-
- List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
- ServiceModelList serviceModelList1 = new ServiceModelList();
- serviceModelList1.setRecoveryAction(RecoveryAction.retry);
- serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
- serviceModelVersionIdList.add(serviceModelList1);
-
- ActivateVnfOperationalEnvironment activate = new ActivateVnfOperationalEnvironment(request, requestId);
- ActivateVnfOperationalEnvironment activateVnfMock = spy(activate);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- AsdcClientHelper asdcClientHelperMock = Mockito.mock(AsdcClientHelper.class);
- RESTConfig configMock = Mockito.mock(RESTConfig.class);
- RESTClient clientMock = Mockito.mock(RESTClient.class);
- APIResponse apiResponseMock = Mockito.mock(APIResponse.class);
-
- activateVnfMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfMock.setAsdcClientHelper(asdcClientHelperMock);
-
- Mockito.when(asdcClientHelperMock.setRestClient(configMock)).thenReturn(clientMock);
- Mockito.when(asdcClientHelperMock.setHttpPostResponse(clientMock, jsonPayload)).thenReturn(apiResponseMock);
- Mockito.when(asdcClientHelperMock.enhanceJsonResponse(jsonObject, 202)).thenReturn(jsonObject);
- Mockito.when(asdcClientHelperMock.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext)).thenReturn(jsonObject);
-
- activateVnfMock.processActivateASDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
-
- verify(serviceModelDb, times(1)).insertOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, serviceModelVersionId, "SENT", "RETRY", retryCount, workloadContext);
-
- }
-
- @Test
- public void executionTest() throws Exception {
-
- // prepare request detail
- List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>();
- ServiceModelList serviceModelList1 = new ServiceModelList();
- serviceModelList1.setRecoveryAction(RecoveryAction.retry);
- serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
- serviceModelVersionIdList.add(serviceModelList1);
-
- RequestDetails requestDetails = new RequestDetails();
- RequestParameters requestParameters = new RequestParameters();
- Manifest manifest = new Manifest();
- manifest.setServiceModelList(serviceModelVersionIdList);
- requestParameters.setManifest(manifest);
- requestParameters.setWorkloadContext(workloadContext);
- requestDetails.setRequestParameters(requestParameters);
-
- // prepare aai return data
- JSONObject aaiJsonResponse = new JSONObject();
- aaiJsonResponse.put("operational-environment-id", "testASDCDistributionId");
- aaiJsonResponse.put("operational-environment-name", "testASDCDistributionIName");
- aaiJsonResponse.put("operational-environment-type", "VNF");
- aaiJsonResponse.put("operational-environment-status", "ACTIVE");
- aaiJsonResponse.put("tenant-context", "Test");
- aaiJsonResponse.put("workload-context", workloadContext);
- aaiJsonResponse.put("resource-version", "1505228226913");
- String mockGetResponseJson = aaiJsonResponse.toString();
- AAIResultWrapper aaiREsultWrapperObj = new AAIResultWrapper(mockGetResponseJson);
-
- // prepare asdc return data
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
-
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("statusCode", "202");
- jsonObject.put("message", "Success");
- jsonObject.put("distributionId", distributionId);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AsdcClientHelper asdcClientHelperMock = Mockito.mock(AsdcClientHelper.class);
- RESTConfig configMock = Mockito.mock(RESTConfig.class);
- RESTClient clientMock = Mockito.mock(RESTClient.class);
- APIResponse apiResponseMock = Mockito.mock(APIResponse.class);
-
- Mockito.when(asdcClientHelperMock.setRestClient(configMock)).thenReturn(clientMock);
- Mockito.when(asdcClientHelperMock.setHttpPostResponse(clientMock, jsonPayload)).thenReturn(apiResponseMock);
- Mockito.when(asdcClientHelperMock.enhanceJsonResponse(jsonObject, 202)).thenReturn(jsonObject);
-
- AAIClientHelper aaiClientHelperMock = Mockito.mock(AAIClientHelper.class);
- Mockito.when(aaiClientHelperMock.getAaiOperationalEnvironment(operationalEnvironmentId)).thenReturn(aaiREsultWrapperObj);
- Mockito.when(asdcClientHelperMock.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext)).thenReturn(jsonObject);
-
- doNothing().when(serviceModelDb).insertOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, serviceModelVersionId, "SENT", recoveryAction, retryCount, workloadContext);
- doNothing().when(distributionDb).insertOperationalEnvDistributionStatus(distributionId, operationalEnvironmentId, serviceModelVersionId, "SENT", requestId);
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- request.setRequestDetails(requestDetails);
- ActivateVnfOperationalEnvironment activate = new ActivateVnfOperationalEnvironment(request, requestId);
- ActivateVnfOperationalEnvironment activateVnfMock = spy(activate);
- activateVnfMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfMock.setRequestsDBHelper(dbUtils);
- activateVnfMock.setAsdcClientHelper(asdcClientHelperMock);
- activateVnfMock.setAaiHelper(aaiClientHelperMock);
-
- activateVnfMock.execute();
-
- verify(serviceModelDb, times(1)).insertOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, serviceModelVersionId, "SENT", recoveryAction, retryCount, workloadContext);
- verify(distributionDb, times(1)).insertOperationalEnvDistributionStatus(distributionId, operationalEnvironmentId, serviceModelVersionId, "SENT", requestId);
-
-
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
deleted file mode 100644
index 535d67e776..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
+++ /dev/null
@@ -1,670 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AsdcClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.DistributionStatus;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Status;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatusDb;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatusDb;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient;
-import org.openecomp.mso.rest.RESTConfig;
-
-public class ActivateVnfStatusOperationalEnvironmentTest {
-
- MsoJavaProperties properties = MsoPropertiesUtils.loadMsoProperties();
- AsdcClientHelper asdcClientUtils = new AsdcClientHelper(properties);
-
- String requestId = "TEST_requestId";
- String operationalEnvironmentId = "TEST_operationalEnvironmentId";
- CloudOrchestrationRequest request = new CloudOrchestrationRequest();
- String workloadContext = "TEST_workloadContext";
- String recoveryAction = "RETRY";
- String serviceModelVersionId = "TEST_serviceModelVersionId";
- int retryCount = 3;
- String asdcDistributionId = "TEST_distributionId";
-
- @BeforeClass
- public static void setUp() throws Exception {
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
-
- @Ignore // 1802 merge
- @Test
- public void checkOrUpdateOverallStatusTest_Ok() throws Exception {
-
- int retryCount = 0;
-
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = spy(new ActivateVnfStatusOperationalEnvironment(request, requestId));
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper requestDb = mock(RequestsDBHelper.class);
-
- // Prepare data
- OperationalEnvServiceModelStatus modelStatus = new OperationalEnvServiceModelStatus();
- modelStatus.setWorkloadContext(workloadContext);
- modelStatus.setRecoveryAction(recoveryAction);
- modelStatus.setOperationalEnvId(operationalEnvironmentId);
- modelStatus.setRetryCount(retryCount);
- modelStatus.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString());
-
- OperationalEnvServiceModelStatus modelStatus1 = new OperationalEnvServiceModelStatus();
- modelStatus1.setWorkloadContext(workloadContext);
- modelStatus1.setRecoveryAction(recoveryAction);
- modelStatus1.setOperationalEnvId(operationalEnvironmentId);
- modelStatus1.setRetryCount(retryCount);
- modelStatus1.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString());
-
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(modelStatus);
- queryServiceModelResponseList.add(modelStatus1);
-
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
- doNothing().when(requestDb).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- activateVnfStatus.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatus.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatus.setRequestsDBHelper(requestDb);
- activateVnfStatus.checkOrUpdateOverallStatus(requestId, operationalEnvironmentId);
-
- verify(requestDb, times(0)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
- verify(requestDb, times(1)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- }
-
- @Test
- public void checkOrUpdateOverallStatusTest_Error() throws Exception {
-
-
- int retryCount = 0; // no more retry
-
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = spy(new ActivateVnfStatusOperationalEnvironment(request, requestId));
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper requestDb = mock(RequestsDBHelper.class);
-
- // Prepare data
- OperationalEnvServiceModelStatus modelStatus = new OperationalEnvServiceModelStatus();
- modelStatus.setWorkloadContext(workloadContext);
- modelStatus.setRecoveryAction(recoveryAction);
- modelStatus.setOperationalEnvId(operationalEnvironmentId);
- modelStatus.setRetryCount(retryCount);
- modelStatus.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString());
-
- OperationalEnvServiceModelStatus modelStatus1 = new OperationalEnvServiceModelStatus();
- modelStatus1.setWorkloadContext(workloadContext);
- modelStatus1.setRecoveryAction(recoveryAction);
- modelStatus1.setOperationalEnvId(operationalEnvironmentId);
- modelStatus1.setRetryCount(retryCount);
- modelStatus1.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString());
-
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(modelStatus);
- queryServiceModelResponseList.add(modelStatus1);
-
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
- doNothing().when(requestDb).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- activateVnfStatus.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatus.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatus.setRequestsDBHelper(requestDb);
- activateVnfStatus.checkOrUpdateOverallStatus(requestId, operationalEnvironmentId);
-
- verify(requestDb, times(0)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- verify(requestDb, times(1)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
-
- }
-
- @Test
- public void checkOrUpdateOverallStatusTest_Waiting() throws Exception {
-
- int retryCount = 2; // 2 more retry
-
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = spy(new ActivateVnfStatusOperationalEnvironment(request, requestId));
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper requestDb = mock(RequestsDBHelper.class);
-
- OperationalEnvServiceModelStatus modelStatus1 = spy(new OperationalEnvServiceModelStatus());
- modelStatus1.setWorkloadContext(workloadContext);
- modelStatus1.setRecoveryAction(recoveryAction);
- modelStatus1.setOperationalEnvId(operationalEnvironmentId);
- modelStatus1.setRetryCount(0);
- modelStatus1.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString());
-
- OperationalEnvServiceModelStatus modelStatus2 = spy(new OperationalEnvServiceModelStatus());
- modelStatus2.setWorkloadContext(workloadContext);
- modelStatus2.setRecoveryAction(recoveryAction);
- modelStatus2.setOperationalEnvId(operationalEnvironmentId);
- modelStatus2.setRetryCount(retryCount);
- modelStatus2.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString());
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(modelStatus1);
- queryServiceModelResponseList.add(modelStatus2);
-
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
- doNothing().when(requestDb).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- activateVnfStatus.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatus.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatus.setRequestsDBHelper(requestDb);
- activateVnfStatus.checkOrUpdateOverallStatus(requestId, operationalEnvironmentId);
-
- verify(requestDb, times(0)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- verify(requestDb, times(0)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
-
- }
-
- @Test
- public void executionTest() throws Exception {
-
- // Prepare db query mock response data
- OperationalEnvDistributionStatus operEnvDistStatusObj = new OperationalEnvDistributionStatus();
- operEnvDistStatusObj.setServiceModelVersionId(serviceModelVersionId);
- operEnvDistStatusObj.setDistributionId(asdcDistributionId);
- operEnvDistStatusObj.setOperationalEnvId( operationalEnvironmentId);
- operEnvDistStatusObj.setDistributionIdStatus(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString());
- operEnvDistStatusObj.setRequestId(requestId);
-
- // ServiceModelStatus - getOperationalEnvServiceModelStatus
- OperationalEnvServiceModelStatus operEnvServiceModelStatusObj = new OperationalEnvServiceModelStatus();
- operEnvServiceModelStatusObj.setRequestId(requestId);
- operEnvServiceModelStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvServiceModelStatusObj.setServiceModelVersionDistrStatus(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString());
- operEnvServiceModelStatusObj.setRecoveryAction(recoveryAction);
- operEnvServiceModelStatusObj.setRetryCount(retryCount);
- operEnvServiceModelStatusObj.setWorkloadContext(workloadContext);
- operEnvServiceModelStatusObj.setServiceModelVersionId(serviceModelVersionId);
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(operEnvServiceModelStatusObj);
-
- // prepare distribution obj
- Distribution distribution = new Distribution();
- distribution.setStatus(Status.DISTRIBUTION_COMPLETE_OK);
- request.setDistribution(distribution);
- request.setDistributionId(asdcDistributionId);
-
- // prepare asdc return data
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
-
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("statusCode", "202");
- jsonObject.put("message", "Success");
- jsonObject.put("distributionId", asdcDistributionId);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AsdcClientHelper asdcClientHelperMock = Mockito.mock(AsdcClientHelper.class);
- RESTConfig configMock = Mockito.mock(RESTConfig.class);
- RESTClient clientMock = Mockito.mock(RESTClient.class);
- APIResponse apiResponseMock = Mockito.mock(APIResponse.class);
-
- Mockito.when(asdcClientHelperMock.setRestClient(configMock)).thenReturn(clientMock);
- Mockito.when(asdcClientHelperMock.setHttpPostResponse(clientMock, jsonPayload)).thenReturn(apiResponseMock);
- Mockito.when(asdcClientHelperMock.enhanceJsonResponse(jsonObject, 202)).thenReturn(jsonObject);
- Mockito.when(asdcClientHelperMock.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext)).thenReturn(jsonObject);
-
- Mockito.when(distributionDb.getOperationalEnvDistributionStatus(asdcDistributionId)).thenReturn(operEnvDistStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId)).thenReturn(operEnvServiceModelStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
-
- int row = 1;
- Mockito.when(distributionDb.updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId)).thenReturn(row);
- Mockito.when(serviceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0)).thenReturn(row);
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = new ActivateVnfStatusOperationalEnvironment(request, requestId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatusMock = spy(activateVnfStatus);
- activateVnfStatusMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatusMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatusMock.setRequestsDBHelper(dbUtils);
- activateVnfStatusMock.setAsdcClientHelper(asdcClientHelperMock);
-
- activateVnfStatusMock.execute();
-
- verify(distributionDb, times(1)).updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
- verify(serviceModelDb, times(1)).updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0);
-
-
- }
-
- @Test
- public void executionTest_ERROR_Status_And_RETRY() throws Exception {
-
- int retryCnt = 3;
- String distributionStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
- String recoverAction = "RETRY";
-
- // Prepare db query mock response data
- OperationalEnvDistributionStatus operEnvDistStatusObj = new OperationalEnvDistributionStatus();
- operEnvDistStatusObj.setServiceModelVersionId(serviceModelVersionId);
- operEnvDistStatusObj.setDistributionId(asdcDistributionId);
- operEnvDistStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvDistStatusObj.setDistributionIdStatus(distributionStatus);
- operEnvDistStatusObj.setRequestId(requestId);
-
- // ServiceModelStatus - getOperationalEnvServiceModelStatus
- OperationalEnvServiceModelStatus operEnvServiceModelStatusObj = new OperationalEnvServiceModelStatus();
- operEnvServiceModelStatusObj.setRequestId(requestId);
- operEnvServiceModelStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvServiceModelStatusObj.setServiceModelVersionDistrStatus(distributionStatus);
- operEnvServiceModelStatusObj.setRecoveryAction(recoverAction);
- operEnvServiceModelStatusObj.setRetryCount(retryCnt);
- operEnvServiceModelStatusObj.setWorkloadContext(workloadContext);
- operEnvServiceModelStatusObj.setServiceModelVersionId(serviceModelVersionId);
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(operEnvServiceModelStatusObj);
-
- // prepare distribution obj
- Distribution distribution = new Distribution();
- distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
- request.setDistribution(distribution);
- request.setDistributionId(asdcDistributionId);
-
- // prepare asdc return data
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
-
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("statusCode", "202");
- jsonObject.put("message", "Success");
- jsonObject.put("distributionId", asdcDistributionId);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AsdcClientHelper asdcClientHelperMock = Mockito.mock(AsdcClientHelper.class);
- RESTConfig configMock = Mockito.mock(RESTConfig.class);
- RESTClient clientMock = Mockito.mock(RESTClient.class);
- APIResponse apiResponseMock = Mockito.mock(APIResponse.class);
-
- Mockito.when(asdcClientHelperMock.setRestClient(configMock)).thenReturn(clientMock);
- Mockito.when(asdcClientHelperMock.setHttpPostResponse(clientMock, jsonPayload)).thenReturn(apiResponseMock);
- Mockito.when(asdcClientHelperMock.enhanceJsonResponse(jsonObject, 202)).thenReturn(jsonObject);
- Mockito.when(asdcClientHelperMock.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext)).thenReturn(jsonObject);
-
- Mockito.when(distributionDb.getOperationalEnvDistributionStatus(asdcDistributionId)).thenReturn(operEnvDistStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId)).thenReturn(operEnvServiceModelStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
-
- int row = 1;
- Mockito.when(distributionDb.updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId)).thenReturn(row);
- Mockito.when(serviceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0)).thenReturn(row);
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = new ActivateVnfStatusOperationalEnvironment(request, requestId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatusMock = spy(activateVnfStatus);
- activateVnfStatusMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatusMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatusMock.setRequestsDBHelper(dbUtils);
- activateVnfStatusMock.setAsdcClientHelper(asdcClientHelperMock);
-
- activateVnfStatusMock.execute();
-
- // waiting
- verify(dbUtils, times(0)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- verify(dbUtils, times(0)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
- assertEquals(false, activateVnfStatusMock.isSuccess());
-
- }
-
- @Test
- public void executionTest_ERROR_Status_And_RETRY_And_RetryZero() throws Exception {
-
- int retryCnt = 0;
- String distributionStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
- String recoverAction = "RETRY";
-
- // Prepare db query mock response data
- OperationalEnvDistributionStatus operEnvDistStatusObj = new OperationalEnvDistributionStatus();
- operEnvDistStatusObj.setServiceModelVersionId(serviceModelVersionId);
- operEnvDistStatusObj.setDistributionId(asdcDistributionId);
- operEnvDistStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvDistStatusObj.setDistributionIdStatus(distributionStatus);
- operEnvDistStatusObj.setRequestId(requestId);
-
- // ServiceModelStatus - getOperationalEnvServiceModelStatus
- OperationalEnvServiceModelStatus operEnvServiceModelStatusObj = new OperationalEnvServiceModelStatus();
- operEnvServiceModelStatusObj.setRequestId(requestId);
- operEnvServiceModelStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvServiceModelStatusObj.setServiceModelVersionDistrStatus(distributionStatus);
- operEnvServiceModelStatusObj.setRecoveryAction(recoverAction);
- operEnvServiceModelStatusObj.setRetryCount(retryCnt);
- operEnvServiceModelStatusObj.setWorkloadContext(workloadContext);
- operEnvServiceModelStatusObj.setServiceModelVersionId(serviceModelVersionId);
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(operEnvServiceModelStatusObj);
-
- // prepare distribution obj
- Distribution distribution = new Distribution();
- distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
- request.setDistribution(distribution);
- request.setDistributionId(asdcDistributionId);
-
- // prepare asdc return data
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
-
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("statusCode", "202");
- jsonObject.put("message", "Success");
- jsonObject.put("distributionId", asdcDistributionId);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AsdcClientHelper asdcClientHelperMock = Mockito.mock(AsdcClientHelper.class);
- RESTConfig configMock = Mockito.mock(RESTConfig.class);
- RESTClient clientMock = Mockito.mock(RESTClient.class);
- APIResponse apiResponseMock = Mockito.mock(APIResponse.class);
-
- Mockito.when(asdcClientHelperMock.setRestClient(configMock)).thenReturn(clientMock);
- Mockito.when(asdcClientHelperMock.setHttpPostResponse(clientMock, jsonPayload)).thenReturn(apiResponseMock);
- Mockito.when(asdcClientHelperMock.enhanceJsonResponse(jsonObject, 202)).thenReturn(jsonObject);
- Mockito.when(asdcClientHelperMock.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext)).thenReturn(jsonObject);
-
- Mockito.when(distributionDb.getOperationalEnvDistributionStatus(asdcDistributionId)).thenReturn(operEnvDistStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId)).thenReturn(operEnvServiceModelStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
-
- int row = 1;
- Mockito.when(distributionDb.updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId)).thenReturn(row);
- Mockito.when(serviceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0)).thenReturn(row);
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = new ActivateVnfStatusOperationalEnvironment(request, requestId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatusMock = spy(activateVnfStatus);
- activateVnfStatusMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatusMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatusMock.setRequestsDBHelper(dbUtils);
- activateVnfStatusMock.setAsdcClientHelper(asdcClientHelperMock);
-
- activateVnfStatusMock.execute();
-
- // waiting
- verify(dbUtils, times(0)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- verify(dbUtils, times(1)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
- assertEquals(false, activateVnfStatusMock.isSuccess());
-
- }
-
- @Test
- public void executionTest_ERROR_Status_And_RETRY_And_ErrorAsdc() throws Exception {
-
- int retryCnt = 3;
- String distributionStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
- String recoverAction = "RETRY";
-
- // Prepare db query mock response data
- OperationalEnvDistributionStatus operEnvDistStatusObj = new OperationalEnvDistributionStatus();
- operEnvDistStatusObj.setServiceModelVersionId(serviceModelVersionId);
- operEnvDistStatusObj.setDistributionId(asdcDistributionId);
- operEnvDistStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvDistStatusObj.setDistributionIdStatus(distributionStatus);
- operEnvDistStatusObj.setRequestId(requestId);
-
- // ServiceModelStatus - getOperationalEnvServiceModelStatus
- OperationalEnvServiceModelStatus operEnvServiceModelStatusObj = new OperationalEnvServiceModelStatus();
- operEnvServiceModelStatusObj.setRequestId(requestId);
- operEnvServiceModelStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvServiceModelStatusObj.setServiceModelVersionDistrStatus(distributionStatus);
- operEnvServiceModelStatusObj.setRecoveryAction(recoverAction);
- operEnvServiceModelStatusObj.setRetryCount(retryCnt);
- operEnvServiceModelStatusObj.setWorkloadContext(workloadContext);
- operEnvServiceModelStatusObj.setServiceModelVersionId(serviceModelVersionId);
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(operEnvServiceModelStatusObj);
-
- // prepare distribution obj
- Distribution distribution = new Distribution();
- distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
- request.setDistribution(distribution);
- request.setDistributionId(asdcDistributionId);
-
- // prepare asdc return data
- String jsonPayload = asdcClientUtils.buildJsonWorkloadContext(workloadContext);
-
- // ERROR in asdc
- JSONObject jsonMessages = new JSONObject();
- jsonMessages.put("statusCode", "409");
- jsonMessages.put("message", "Undefined Error Message!");
- jsonMessages.put("messageId", "SVC4675");
- jsonMessages.put("text", "Error: Service state is invalid for this action.");
- JSONObject jsonServException = new JSONObject();
- jsonServException.put("serviceException", jsonMessages);
- JSONObject jsonErrorRequest = new JSONObject();
- jsonErrorRequest.put("requestError", jsonServException);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AsdcClientHelper asdcClientHelperMock = Mockito.mock(AsdcClientHelper.class);
- RESTConfig configMock = Mockito.mock(RESTConfig.class);
- RESTClient clientMock = Mockito.mock(RESTClient.class);
- APIResponse apiResponseMock = Mockito.mock(APIResponse.class);
-
- Mockito.when(asdcClientHelperMock.setRestClient(configMock)).thenReturn(clientMock);
- Mockito.when(asdcClientHelperMock.setHttpPostResponse(clientMock, jsonPayload)).thenReturn(apiResponseMock);
- Mockito.when(asdcClientHelperMock.enhanceJsonResponse(jsonMessages, 202)).thenReturn(jsonMessages);
- Mockito.when(asdcClientHelperMock.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext)).thenReturn(jsonMessages);
-
- Mockito.when(distributionDb.getOperationalEnvDistributionStatus(asdcDistributionId)).thenReturn(operEnvDistStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId)).thenReturn(operEnvServiceModelStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
-
- int row = 1;
- Mockito.when(distributionDb.updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId)).thenReturn(row);
- Mockito.when(serviceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0)).thenReturn(row);
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = new ActivateVnfStatusOperationalEnvironment(request, requestId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatusMock = spy(activateVnfStatus);
- activateVnfStatusMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatusMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatusMock.setRequestsDBHelper(dbUtils);
- activateVnfStatusMock.setAsdcClientHelper(asdcClientHelperMock);
-
- activateVnfStatusMock.execute();
-
- // waiting
- verify(dbUtils, times(0)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- verify(dbUtils, times(1)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
- assertEquals(false, activateVnfStatusMock.isSuccess());
-
- }
-
- @Test
- public void executionTest_ERROR_Status_And_SKIP() throws Exception {
-
- int retryCnt = 3;
- String distributionStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
- String recoverAction = "SKIP";
-
- // Prepare db query mock response data
- OperationalEnvDistributionStatus operEnvDistStatusObj = new OperationalEnvDistributionStatus();
- operEnvDistStatusObj.setServiceModelVersionId(serviceModelVersionId);
- operEnvDistStatusObj.setDistributionId(asdcDistributionId);
- operEnvDistStatusObj.setOperationalEnvId( operationalEnvironmentId);
- operEnvDistStatusObj.setDistributionIdStatus(distributionStatus);
- operEnvDistStatusObj.setRequestId(requestId);
-
- // ServiceModelStatus - getOperationalEnvServiceModelStatus
- OperationalEnvServiceModelStatus operEnvServiceModelStatusObj = new OperationalEnvServiceModelStatus();
- operEnvServiceModelStatusObj.setRequestId(requestId);
- operEnvServiceModelStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvServiceModelStatusObj.setServiceModelVersionDistrStatus(distributionStatus);
- operEnvServiceModelStatusObj.setRecoveryAction(recoverAction);
- operEnvServiceModelStatusObj.setRetryCount(retryCnt);
- operEnvServiceModelStatusObj.setWorkloadContext(workloadContext);
- operEnvServiceModelStatusObj.setServiceModelVersionId(serviceModelVersionId);
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(operEnvServiceModelStatusObj);
-
- // prepare distribution obj
- Distribution distribution = new Distribution();
- distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
- request.setDistribution(distribution);
- request.setDistributionId(asdcDistributionId);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
-
- Mockito.when(distributionDb.getOperationalEnvDistributionStatus(asdcDistributionId)).thenReturn(operEnvDistStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId)).thenReturn(operEnvServiceModelStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
-
- int row = 1;
- Mockito.when(distributionDb.updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId)).thenReturn(row);
- Mockito.when(serviceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0)).thenReturn(row);
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = new ActivateVnfStatusOperationalEnvironment(request, requestId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatusMock = spy(activateVnfStatus);
- activateVnfStatusMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatusMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatusMock.setRequestsDBHelper(dbUtils);
-
- activateVnfStatusMock.execute();
-
- // waiting
- verify(dbUtils, times(0)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- verify(dbUtils, times(0)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
- assertEquals(false, activateVnfStatusMock.isSuccess());
-
- }
-
- @Test
- public void executionTest_ERROR_Status_And_ABORT() throws Exception {
-
- int retryCnt = 3;
- String distributionStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
- String recoverAction = "ABORT";
-
- // Prepare db query mock response data
- OperationalEnvDistributionStatus operEnvDistStatusObj = new OperationalEnvDistributionStatus();
- operEnvDistStatusObj.setServiceModelVersionId(serviceModelVersionId);
- operEnvDistStatusObj.setDistributionId(asdcDistributionId);
- operEnvDistStatusObj.setOperationalEnvId( operationalEnvironmentId);
- operEnvDistStatusObj.setDistributionIdStatus(distributionStatus);
- operEnvDistStatusObj.setRequestId(requestId);
-
- // ServiceModelStatus - getOperationalEnvServiceModelStatus
- OperationalEnvServiceModelStatus operEnvServiceModelStatusObj = new OperationalEnvServiceModelStatus();
- operEnvServiceModelStatusObj.setRequestId(requestId);
- operEnvServiceModelStatusObj.setOperationalEnvId(operationalEnvironmentId);
- operEnvServiceModelStatusObj.setServiceModelVersionDistrStatus(distributionStatus);
- operEnvServiceModelStatusObj.setRecoveryAction(recoverAction);
- operEnvServiceModelStatusObj.setRetryCount(retryCnt);
- operEnvServiceModelStatusObj.setWorkloadContext(workloadContext);
- operEnvServiceModelStatusObj.setServiceModelVersionId(serviceModelVersionId);
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = new ArrayList<OperationalEnvServiceModelStatus>();
- queryServiceModelResponseList.add(operEnvServiceModelStatusObj);
-
- // prepare distribution obj
- Distribution distribution = new Distribution();
- distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR);
- request.setDistribution(distribution);
- request.setDistributionId(asdcDistributionId);
-
- // Mockito mock
- OperationalEnvDistributionStatusDb distributionDb = Mockito.mock(OperationalEnvDistributionStatusDb.class);
- OperationalEnvServiceModelStatusDb serviceModelDb = Mockito.mock(OperationalEnvServiceModelStatusDb.class);
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
-
- Mockito.when(distributionDb.getOperationalEnvDistributionStatus(asdcDistributionId)).thenReturn(operEnvDistStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId)).thenReturn(operEnvServiceModelStatusObj);
- Mockito.when(serviceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, requestId)).thenReturn(queryServiceModelResponseList);
-
- int row = 1;
- Mockito.when(distributionDb.updateOperationalEnvDistributionStatus(distribution.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId)).thenReturn(row);
- Mockito.when(serviceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, distribution.getStatus().toString(), 0)).thenReturn(row);
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
-
- request.setOperationalEnvironmentId(operationalEnvironmentId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatus = new ActivateVnfStatusOperationalEnvironment(request, requestId);
- ActivateVnfStatusOperationalEnvironment activateVnfStatusMock = spy(activateVnfStatus);
- activateVnfStatusMock.setOperationalEnvDistributionStatusDb(distributionDb);
- activateVnfStatusMock.setOperationalEnvServiceModelStatusDb(serviceModelDb);
- activateVnfStatusMock.setRequestsDBHelper(dbUtils);
- activateVnfStatusMock.execute();
-
- assertEquals(false, activateVnfStatusMock.isSuccess());
-
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
deleted file mode 100644
index e7b9db0657..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestInfo;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestParameters;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-public class CreateEcompOperationalEnvironmentTest {
-
- @Mock private AAIClientHelper mockAaiClientHelper;
- @Mock private DmaapOperationalEnvClient mockDmaapClient;
- @Mock private RequestsDBHelper mockRequestsDBHelper;
-
- private CloudOrchestrationRequest request;
- private CreateEcompOperationalEnvironment spyProcess;
-
- public CreateEcompOperationalEnvironmentTest() {
- super();
- }
-
- @Before
- public void testSetUp() {
- MockitoAnnotations.initMocks(this);
- request = getCloudOrchestrationRequest();
- CreateEcompOperationalEnvironment process = new CreateEcompOperationalEnvironment(request, "123");
- spyProcess = spy(process);
- when(spyProcess.getAaiHelper()).thenReturn(mockAaiClientHelper);
- when(spyProcess.getDmaapClient()).thenReturn(mockDmaapClient);
- when(spyProcess.getRequestDb()).thenReturn(mockRequestsDBHelper);
- }
-
- public CloudOrchestrationRequest getCloudOrchestrationRequest() {
- CloudOrchestrationRequest cor = new CloudOrchestrationRequest();
- RequestDetails reqDetails = new RequestDetails();
- RequestInfo reqInfo = new RequestInfo();
- RequestParameters reqParams = new RequestParameters();
- reqParams.setTenantContext("TEST");
- reqParams.setWorkloadContext("ECOMP_TEST");
- reqParams.setOperationalEnvironmentType(OperationalEnvironment.ECOMP);
- reqInfo.setInstanceName("TEST_ECOMP_ENVIRONMENT");
- reqDetails.setRequestInfo(reqInfo);
- reqDetails.setRequestParameters(reqParams);
- cor.setRequestDetails(reqDetails);
- return cor;
- }
-
- @Test
- public void testProcess() throws Exception {
- spyProcess.execute();
- verify(mockAaiClientHelper, times(1)).createOperationalEnvironment(any(AAIOperationalEnvironment.class));
- verify(mockDmaapClient, times(1)).dmaapPublishOperationalEnvRequest(any(String.class), any(String.class), any(String.class), any(String.class), any(String.class), any(String.class) );
- verify(mockRequestsDBHelper, times(1)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
deleted file mode 100644
index ad8a5ba245..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.client.grm.beans.Property;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class CreateVnfOperationalEnvironmentTest {
-
- private ObjectMapper mapper = new ObjectMapper();
- private CloudOrchestrationRequest request;
- private ServiceEndPointList serviceEndpoints;
- private CreateVnfOperationalEnvironment spyProcess;
-
- @Before
- public void testSetUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- String jsonRequest = getFileContentsAsString("__files/vnfoperenv/createVnfOperationalEnvironmentRequest.json");
- request = mapper.readValue(jsonRequest, CloudOrchestrationRequest.class);
- String jsonServiceEndpoints = getFileContentsAsString("__files/vnfoperenv/endpoints.json");
- serviceEndpoints = mapper.readValue(jsonServiceEndpoints, ServiceEndPointList.class);
- CreateVnfOperationalEnvironment process = new CreateVnfOperationalEnvironment(request, "9876543210");
- spyProcess = spy(process);
- }
-
-
- @Test
- public void testGetEcompManagingEnvironmentId() throws Exception {
- when(spyProcess.getRequest()).thenReturn(request);
- assertEquals("ff305d54-75b4-431b-adb2-eb6b9e5ff000", spyProcess.getEcompManagingEnvironmentId());
- }
-
- @Test
- public void testGetTenantContext() throws Exception {
- when(spyProcess.getRequest()).thenReturn(request);
- assertEquals("Test", spyProcess.getTenantContext());
- }
-
- @Test
- public void testGetEnvironmentName() throws Exception {
- List<Property> props = serviceEndpoints.getServiceEndPointList().get(0).getProperties();
- assertEquals("DEV", spyProcess.getEnvironmentName(props));
- }
-
- @Test
- public void testBuildServiceNameForVnf() throws Exception {
- when(spyProcess.getRequest()).thenReturn(request);
- assertEquals("Test.VNF_E2E-IST.Inventory", spyProcess.buildServiceNameForVnf("TEST.ECOMP_PSL.Inventory"));
- }
-
- @Test
- public void testGetSearchKey() {
- AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment();
- ecompEnv.setTenantContext("Test");
- ecompEnv.setWorkloadContext("ECOMPL_PSL");
- assertEquals("Test.ECOMPL_PSL.*", spyProcess.getSearchKey(ecompEnv));
- }
-
- public String getFileContentsAsString(String fileName) {
- String content = "";
- try {
- ClassLoader classLoader = this.getClass().getClassLoader();
- File file = new File(classLoader.getResource(fileName).getFile());
- content = new String(Files.readAllBytes(file.toPath()));
- }
- catch(Exception e) {
- e.printStackTrace();
- System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
- }
- return content;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
deleted file mode 100644
index ee07a53f74..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Optional;
-
-import org.junit.Test;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-public class DeactivateVnfOperationalEnvironmentTest {
-
- @Test
- public void testDeactivateOperationalEnvironment() throws Exception {
- String operationlEnvironmentId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
- CloudOrchestrationRequest request = new CloudOrchestrationRequest();
- request.setOperationalEnvironmentId(operationlEnvironmentId);
- request.setRequestDetails(null);
-
- DeactivateVnfOperationalEnvironment deactivate = spy(new DeactivateVnfOperationalEnvironment(request, "ff3514e3-5a33-55df-13ab-12abad84e7fe"));
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AAIClientHelper helper = mock(AAIClientHelper.class);
- AAIResultWrapper wrapper = mock(AAIResultWrapper.class);
- AAIOperationalEnvironment operationalEnv = new AAIOperationalEnvironment();
- operationalEnv.setOperationalEnvironmentStatus("ACTIVE");
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- when(helper.getAaiOperationalEnvironment(any(String.class))).thenReturn(wrapper);
- when(wrapper.asBean(AAIOperationalEnvironment.class)).thenReturn(Optional.of((AAIOperationalEnvironment)operationalEnv));
-
- deactivate.setRequestsDBHelper(dbUtils);
- deactivate.setAaiHelper(helper);
- deactivate.execute();
-
- verify(dbUtils, times(1)).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- }
-
- @Test
- public void testDeactivateInvalidStatus() throws Exception {
- String operationlEnvironmentId = "ff3514e3-5a33-55df-13ab-12abad84e7ff";
- CloudOrchestrationRequest request = new CloudOrchestrationRequest();
- request.setOperationalEnvironmentId(operationlEnvironmentId);
- request.setRequestDetails(null);
-
- DeactivateVnfOperationalEnvironment deactivate = spy(new DeactivateVnfOperationalEnvironment(request, "ff3514e3-5a33-55df-13ab-12abad84e7fe"));
- RequestsDBHelper dbUtils = mock(RequestsDBHelper.class);
- AAIClientHelper helper = mock(AAIClientHelper.class);
- AAIResultWrapper wrapper = mock(AAIResultWrapper.class);
- AAIOperationalEnvironment operationalEnv = new AAIOperationalEnvironment();
- operationalEnv.setOperationalEnvironmentStatus("SUCCESS");
-
- doNothing().when(dbUtils).updateInfraSuccessCompletion(any(String.class), any(String.class), any(String.class));
- when(helper.getAaiOperationalEnvironment(any(String.class))).thenReturn(wrapper);
- when(wrapper.asBean(AAIOperationalEnvironment.class)).thenReturn(Optional.of((AAIOperationalEnvironment)operationalEnv));
-
- deactivate.setRequestsDBHelper(dbUtils);
- deactivate.setAaiHelper(helper);
- deactivate.execute();
-
- verify(dbUtils, times(1)).updateInfraFailureCompletion(any(String.class), any(String.class), any(String.class));
- }
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationTest.java
deleted file mode 100644
index 74ff9078b5..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestration;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-public class CloudOrchestrationTest {
-
- private static final String requestJSONCreate = "{\"requestDetails\": {\"requestInfo\": {\"resourceType\": \"operationalEnvironment\",\"instanceName\": "
- + "\"myOpEnv\",\"source\": \"VID\",\"requestorId\": \"az2017\"},\"requestParameters\": {\"operationalEnvironmentType\": \"ECOMP\", "
- + "\"tenantContext\": \"Test\",\"workloadContext\": \"ECOMP_E2E-IST\"}}} ";
-
- private static final String requestJsonActivate = "{\"requestDetails\": {\"requestInfo\": {\"resourceType\": \"operationalEnvironment\","
- + "\"instanceName\": \"myVnfOpEnv\",\"source\": \"VID\",\"requestorId\": \"az2017\"},"
- + "\"relatedInstanceList\": [{\"relatedInstance\": {\"resourceType\": \"operationalEnvironment\","
- + "\"instanceId\": \"ff305d54-75b4-431b-adb2-eb6b9e5ff000\",\"instanceName\": \"name\"}}],"
- + "\"requestParameters\": { \"operationalEnvironmentType\": \"VNF\",\"workloadContext\": \"VNF_E2E-IST\","
- + "\"manifest\": {\"serviceModelList\": [{\"serviceModelVersionId\": \"ff305d54-75b4-431b-adb2-eb6b9e5ff000\","
- + "\"recoveryAction\": \"abort\"},{\"serviceModelVersionId\": \"ff305d54-75b4-431b-adb2-eb6b9e5ff000\","
- + "\"recoveryAction\": \"retry\"}]} }}}";
-
- private static final String requestJsonDeactivate = "{\"requestDetails\": {\"requestInfo\": {\"resourceType\": \"operationalEnvironment\","
- + "\"source\": \"VID\",\"requestorId\": \"az2017\"},\"requestParameters\": "
- + "{\"operationalEnvironmentType\": \"VNF\"}}}";
-
- @Test
- public void testCreateOperationEnvironment()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String response = "{\"requestId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\","
- + "\"instanceId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\"}";
- final Response okResponse = Response.status(HttpStatus.SC_OK).entity(response).build();
-
- try {
- CloudOrchestration cor = Mockito.mock(CloudOrchestration.class);
- cor.createOperationEnvironment(requestJSONCreate, "v1");
- Mockito.when(cor.createOperationEnvironment(requestJSONCreate, "v1")).thenReturn(okResponse);
- Response resp = cor.createOperationEnvironment(requestJSONCreate, "v1");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testActivateOperationEnvironment()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String response = "{\"requestId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\","
- + "\"instanceId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\"}";
- final Response okResponse = Response.status(HttpStatus.SC_OK).entity(response).build();
-
- try {
- CloudOrchestration cor = Mockito.mock(CloudOrchestration.class);
- cor.activateOperationEnvironment(requestJsonActivate, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- Mockito.when(cor.activateOperationEnvironment(requestJsonActivate, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff")).thenReturn(okResponse);
- Response resp = cor.activateOperationEnvironment(requestJsonActivate, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-
- @Test
- public void testDeactivateOperationEnvironment()
- throws JsonParseException, JsonMappingException, IOException, ValidationException {
- final String response = "{\"requestId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\","
- + "\"instanceId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\"}";
- final Response okResponse = Response.status(HttpStatus.SC_OK).entity(response).build();
-
- try {
- CloudOrchestration cor = Mockito.mock(CloudOrchestration.class);
- cor.deactivateOperationEnvironment(requestJsonDeactivate, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- Mockito.when(cor.deactivateOperationEnvironment(requestJsonDeactivate, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff")).thenReturn(okResponse);
- Response resp = cor.deactivateOperationEnvironment(requestJsonDeactivate, "v1", "ff3514e3-5a33-55df-13ab-12abad84e7ff");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
-}