diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-30 15:56:09 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-31 11:09:25 -0400 |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp')
57 files changed, 0 insertions, 9001 deletions
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/BeansTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeansTest.java deleted file mode 100644 index 43f3b59e4d..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/BeansTest.java +++ /dev/null @@ -1,76 +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 org.junit.Test; - -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 { - - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - private PojoClassFilter enumFilter = new FilterEnum(); - - - @Test - public void pojoStructure() { - test("org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans"); - test("org.openecomp.mso.apihandlerinfra.tasksbeans"); - test("org.openecomp.mso.apihandlerinfra.vnfbeans"); - } - - 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 static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} 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/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ManualTasksTest.java deleted file mode 100644 index e18bc5e911..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ManualTasksTest.java +++ /dev/null @@ -1,38 +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 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); - } -} 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/NodeHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandlerTest.java deleted file mode 100644 index c115b7c44b..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandlerTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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 org.junit.Test; - -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(); - } -} 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/RequestActionMapTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RequestActionMapTest.java deleted file mode 100644 index debaa9b3cd..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RequestActionMapTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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 org.junit.Test; - -public class RequestActionMapTest { - // TODO: currently test case is done for coverage - // later, it should be modified properly. - - RequestActionMap test = new RequestActionMap(); - - @Test - public void getMappedRequestActionTest() throws Exception { - - test.getMappedRequestAction("action"); - } - -} 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/TasksHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/TasksHandlerTest.java deleted file mode 100644 index 91225190a3..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/TasksHandlerTest.java +++ /dev/null @@ -1,41 +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.text.ParseException; - -import javax.ws.rs.core.Response; - -import org.junit.Test; - -public class TasksHandlerTest { - - TasksHandler handler = new TasksHandler(); - - @Test - public void queryFiltersTest() throws ParseException{ - Response resp = handler.queryFilters("10020", "399495", "test", "nfRole", "buildingBlockName", "originalRequestDate", "originalRequestorId", "v2"); - assertTrue(resp.getEntity().toString() != null); - } - -} 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/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java deleted file mode 100644 index e501bf06ca..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcRespTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.e2eserviceinstancebeans; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class DelE2ESvcRespTest { - - DelE2ESvcResp test = new DelE2ESvcResp(); - - @Test - public void verifyDelE2ESvcResp() throws Exception { - test.setOperationId("operationId"); - assertEquals(test.getOperationId(),"operationId"); - } - - -} 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/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java deleted file mode 100644 index 489991162c..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequestTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.e2eserviceinstancebeans; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class E2ERequestTest { - - E2ERequest test = new E2ERequest(); - - @Test - public void verifyE2ERequest() throws Exception { - - test.setOperationId("operationId"); - assertEquals(test.getOperationId(),"operationId"); - test.setOperation("operation"); - assertEquals(test.getOperation(),"operation"); - test.setResult("result"); - assertEquals(test.getResult(),"result"); - test.setReason("test"); - assertEquals(test.getReason(),"test"); - test.setUserId("userId"); - assertEquals(test.getUserId(),"userId"); - test.setOperationContent("operation"); - assertEquals(test.getOperationContent(),"operation"); - test.setProgress(123); - assertEquals(test.getProgress(),123); - test.setOperateAt("operate"); - assertEquals(test.getOperateAt(),"operate"); - test.setFinishedAt("finished"); - assertEquals(test.getFinishedAt(),"finished"); - } - -} 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/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java deleted file mode 100644 index 808c701606..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequestTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.e2eserviceinstancebeans; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class E2EServiceInstanceDeleteRequestTest { - - - E2EServiceInstanceDeleteRequest test = new E2EServiceInstanceDeleteRequest(); - - @Test - public void verifyE2ESerInstanceDelReq() throws Exception { - - test.setGlobalSubscriberId("id"); - assertEquals(test.getGlobalSubscriberId(),"id"); - test.setServiceType("type"); - assertEquals(test.getServiceType(),"type"); - } - -} 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/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java deleted file mode 100644 index 23676c0bba..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParamTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.e2eserviceinstancebeans; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class E2EUserParamTest { - - E2EUserParam test = new E2EUserParam(); - - @Test - public void verifyE2EParam() throws Exception { - - test.setName("name"); - assertEquals(test.getName(),"name"); - test.setValue("value"); - assertEquals(test.getValue(),"value"); - Map<String, Object> additionalProperties = new HashMap<>(); - additionalProperties.put("name", test); - test.setAdditionalProperty("name",test); - assertEquals(test.getAdditionalProperties(),additionalProperties); - - } - -} 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/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java deleted file mode 100644 index 87f9315bc9..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParametersTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.e2eserviceinstancebeans; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class NsParametersTest { - - NsParameters test = new NsParameters(); - - - @Test - public void verifyNsParameters() throws Exception { - - LocationConstraint obj =new LocationConstraint(); - List<LocationConstraint> locationConstraints = new ArrayList<LocationConstraint>(); - locationConstraints.add(obj); - test.setLocationConstraints(locationConstraints); - assertEquals(test.getLocationConstraints(),locationConstraints); - Map<String, Object> additionalParamForNs = new HashMap<String,Object>(); - additionalParamForNs.put("1",test); - test.setAdditionalParamForNs(additionalParamForNs); - assertEquals(test.getAdditionalParamForNs(),additionalParamForNs); - } - - -} 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/tasksbeans/RequestDetailsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetailsTest.java deleted file mode 100644 index bfe1ff67e8..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetailsTest.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.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/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfoTest.java deleted file mode 100644 index 96a1f9e04d..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfoTest.java +++ /dev/null @@ -1,118 +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.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);
- }
-}
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/openecomp/mso/apihandlerinfra/tasksbeans/TaskListTest.java deleted file mode 100644 index 4909407722..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskListTest.java +++ /dev/null @@ -1,246 +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.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);
- }
-
-
-}
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/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java deleted file mode 100644 index 6d9df82f87..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.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.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/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValueTest.java deleted file mode 100644 index 692cdab877..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValueTest.java +++ /dev/null @@ -1,113 +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.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/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariablesTest.java deleted file mode 100644 index 08a9669889..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariablesTest.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.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/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponseTest.java deleted file mode 100644 index 9a9756994c..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponseTest.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.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/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequestTest.java deleted file mode 100644 index 12aa8ef735..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequestTest.java +++ /dev/null @@ -1,70 +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.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/openecomp/mso/apihandlerinfra/tasksbeans/ValueTest.java deleted file mode 100644 index 8affd08529..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValueTest.java +++ /dev/null @@ -1,68 +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.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/openecomp/mso/apihandlerinfra/tasksbeans/VariablesTest.java deleted file mode 100644 index ad61675bbc..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tasksbeans/VariablesTest.java +++ /dev/null @@ -1,95 +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.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/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/TenantIsolationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java deleted file mode 100644 index d2d7959622..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequestTest.java +++ /dev/null @@ -1,130 +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.assertNotNull; -import static org.junit.Assert.fail; - -import java.util.HashMap; - -import org.apache.commons.io.IOUtils; -import com.fasterxml.jackson.databind.ObjectMapper; -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; - -public class TenantIsolationRequestTest { - - @Test - public void testParseCloudResourceECOMP() throws Exception{ - try { - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/ECOMPOperationEnvironmentCreate.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - request.parse(cor, instanceIdMap, Action.create); - assertNotNull(request.getRequestId()); - } catch(ValidationException e) { - fail(e.getMessage()); - } - } - - @Test - public void testParseCloudResourceVNF() throws Exception{ - try { - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/VNFOperationEnvironmentCreate.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - request.parse(cor, instanceIdMap, Action.create); - assertNotNull(request.getRequestId()); - } catch(ValidationException e) { - fail(e.getMessage()); - } - } - - @Test(expected=ValidationException.class) - public void testParseCloudResourceVNFInvalid() throws Exception { - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/VNFOperationEnvironmentCreateInvalid.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - request.parse(cor, instanceIdMap, Action.create); - assertNotNull(request.getRequestId()); - } - - @Test - public void testParseActivateCloudResource() throws Exception{ - try { - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/ActivateOperationEnvironment.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - request.parse(cor, instanceIdMap, Action.activate); - assertNotNull(request.getRequestId()); - } catch(ValidationException e) { - fail(e.getMessage()); - } - } - - @Test(expected = ValidationException.class) - public void testParseActivateCloudResourceInvalid() throws Exception{ - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/ActivateOperationEnvironmentInvalid.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - request.parse(cor, instanceIdMap, Action.activate); - assertNotNull(request.getRequestId()); - } - - @Test - public void testParseDeactivateCloudResource() throws Exception{ - try { - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironment.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - request.parse(cor, instanceIdMap, Action.deactivate); - assertNotNull(request.getRequestId()); - } catch(ValidationException e) { - fail(e.getMessage()); - } - } - - @Test(expected= ValidationException.class) - public void testParseDeactivateCloudResourceInvalid() throws Exception{ - String requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/DeactivateOperationEnvironmentInvalid.json")); - ObjectMapper mapper = new ObjectMapper(); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - CloudOrchestrationRequest cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - TenantIsolationRequest request = new TenantIsolationRequest ("1234"); - 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/AsdcDmaapClientTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/AsdcDmaapClientTest.java deleted file mode 100644 index f62b360071..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/AsdcDmaapClientTest.java +++ /dev/null @@ -1,69 +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.dmaap; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.text.ParseException; - -import org.junit.Test; -import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.CreateEcompOperationEnvironmentBean; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AsdcDmaapClientTest { - - private final String fileLocation = "src/test/resources/org/openecomp/mso/client/asdc/create-ecompoe/"; - - private static final String operationalEnvironmentId = "28122015552391"; - private static final String operationalEnvironmentName = "Operational Environment Name"; - private static final String operationalEnvironmentType = "ECOMP"; - private static final String tenantContext = "TEST"; - private static final String workloadContext = "ECOMP_E2E-IST"; - private static final String action = "Create" ; - - - - @Test - public void verifyasdcCreateoeRequest() throws IOException, ParseException{ - - ObjectMapper mapper = new ObjectMapper(); - - String expected = "{\"operationalEnvironmentId\":\"28122015552391\",\"operationalEnvironmentName\":\"Operational Environment Name\",\"operationalEnvironmentType\":\"ECOMP\",\"tenantContext\":\"TEST\",\"workloadContext\":\"ECOMP_E2E-IST\",\"action\":\"Create\"}"; - - - CreateEcompOperationEnvironmentBean cBean = new CreateEcompOperationEnvironmentBean(); - cBean.setOperationalEnvironmentId(operationalEnvironmentId); - cBean.setoperationalEnvironmentName(operationalEnvironmentName); - cBean.setoperationalEnvironmentType(operationalEnvironmentType); - cBean.settenantContext(tenantContext); - cBean.setworkloadContext(workloadContext); - cBean.setaction(action); - - String actual = mapper.writeValueAsString(cBean); - - assertEquals("payloads are equal", expected, actual); - } - - - -} 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/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java deleted file mode 100644 index 539b1816bd..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClientTest.java +++ /dev/null @@ -1,68 +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.dmaap; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.spy; - -import java.io.IOException; -import java.nio.file.Files; -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 com.fasterxml.jackson.databind.ObjectMapper; - -public class DmaapOperationalEnvClientTest { - - private final String fileLocation = "src/test/resources/org/openecomp/mso/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"; - - - @Test - public void verifyCreateEcompOperationEnvironmentRequest() throws IOException, ParseException{ - 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, - tenantContext, workloadContext, action); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} - 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/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java deleted file mode 100644 index a9763f1d39..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisherTest.java +++ /dev/null @@ -1,55 +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.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; - -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); - } - - @Test - public void getProperties() throws FileNotFoundException, IOException { - OperationalEnvironmentPublisher publisher = new OperationalEnvironmentPublisher(); - - assertEquals("m97898@mso.ecomp.att.com", 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()); - } -} 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/AAIClientObjectBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java deleted file mode 100644 index 12312764c3..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java +++ /dev/null @@ -1,68 +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 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 com.fasterxml.jackson.databind.ObjectMapper; - -public class AAIClientObjectBuilderTest { - - 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; - private ObjectMapper mapper = new ObjectMapper(); - - @Before - public void testSetUp() { - request = getCloudOrchestrationRequest(); - } - - 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 testGetAaiClientObjectBuilder() throws Exception { - AAIClientObjectBuilder builder = new AAIClientObjectBuilder(request); - assertEquals(expectedAAIObject, mapper.writeValueAsString(builder.buildAAIOperationalEnvironment("Active"))); - } - - -} 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(); - } - } -} 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/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java deleted file mode 100644 index 7cf60d339d..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationBeansTest.java +++ /dev/null @@ -1,61 +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 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());
- }
-}
|