diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
3 files changed, 52 insertions, 377 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index b538718bd0..1aa7640492 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -44,7 +44,9 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.ModelInfo; @@ -53,6 +55,7 @@ import org.springframework.core.env.Environment; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -528,6 +531,55 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { assertEquals(2, ebbs.size()); } + @Test + public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException { + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + + WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds(); + resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id"); + resourceIdsActivateVfModule.setVnfId("test-vnf-id"); + resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id"); + resourceIdsActivateVfModule.setConfigurationId(""); + + RequestDetails requestDetails = new RequestDetails(); + + ebbActivateVfModule.setApiVersion("7"); + ebbActivateVfModule.setaLaCarte(true); + ebbActivateVfModule.setRequestAction("createInstance"); + ebbActivateVfModule.setVnfType("test-vnf-type"); + ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12"); + ebbActivateVfModule.setRequestDetails(requestDetails); + ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule); + + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb"); + configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76"); + configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c"); + configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001"); + + ExecuteBuildingBlock ebbAddFabricConfig = + workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule, + "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys); + + assertEquals("7", ebbAddFabricConfig.getApiVersion()); + assertTrue(ebbAddFabricConfig.isaLaCarte()); + assertEquals("createInstance", ebbAddFabricConfig.getRequestAction()); + assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType()); + assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId()); + assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails()); + assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4", + ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()); + assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId()); + assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId()); + assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId()); + + assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys); + assertThat(ebbAddFabricConfig.getWorkflowResourceIds()) + .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds()); + assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()) + .isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId()); + } @Test public void checkRetryStatusTest() { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java deleted file mode 100644 index 3ae0db627a..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Intel Corp. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.oof; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.oof.beans.LicenseInfo; -import org.onap.so.client.oof.beans.ModelInfo; -import org.onap.so.client.oof.beans.OofRequest; -import org.onap.so.client.oof.beans.OofRequestParameters; -import org.onap.so.client.oof.beans.PlacementDemand; -import org.onap.so.client.oof.beans.PlacementInfo; -import org.onap.so.client.oof.beans.RequestInfo; -import org.onap.so.client.oof.beans.ResourceModelInfo; -import org.onap.so.client.oof.beans.ServiceInfo; -import org.onap.so.client.oof.beans.SubscriberInfo; -import org.skyscreamer.jsonassert.JSONAssert; -import org.springframework.beans.factory.annotation.Autowired; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.util.ArrayList; -import java.util.List; - - -public class OofClientTestIT extends BaseIntegrationTest { - - @Autowired - private OofClient client; - - @Test - public void testPostDemands_success() throws BadResponseException, JsonProcessingException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}"; - - ModelInfo modelInfo = new ModelInfo(); - modelInfo.setModelCustomizationName("modelCustomizationName-Service"); - modelInfo.setModelInvariantId("modelInvariantId-Service"); - modelInfo.setModelName("modelName-Service"); - modelInfo.setModelType("modelType-Service"); - modelInfo.setModelVersion("modelVersion-Service"); - modelInfo.setModelVersionId("modelVersionId-Service"); - - ServiceInfo serviceInfo = new ServiceInfo(); - serviceInfo.setModelInfo(modelInfo); - serviceInfo.setServiceInstanceId("serviceInstanceId"); - serviceInfo.setServiceName("serviceName"); - - SubscriberInfo subscriberInfo = new SubscriberInfo(); - subscriberInfo.setGlobalSubscriberId("globalSubscriberId"); - subscriberInfo.setSubscriberCommonSiteId("subscriberCommonSiteId"); - subscriberInfo.setSubscriberName("subscriberName"); - - ResourceModelInfo resourceModelInfo = new ResourceModelInfo(); - resourceModelInfo.setModelType("modelType"); - resourceModelInfo.setModelCustomizationName("modelCustomizationName"); - resourceModelInfo.setModelInvariantId("invarianteId"); - resourceModelInfo.setModelName("modelName"); - resourceModelInfo.setModelVersion("version"); - resourceModelInfo.setModelVersionId("versionId"); - - PlacementDemand placementDemand = new PlacementDemand(); - placementDemand.setResourceModelInfo(resourceModelInfo); - placementDemand.setResourceModuleName("resourceModuleName"); - placementDemand.setServiceResourceId("serviceResourceId"); - placementDemand.setTenantId("tenantId"); - - OofRequestParameters oofRequestParameters = new OofRequestParameters(); - oofRequestParameters.setCustomerLatitude("customerLatitude"); - oofRequestParameters.setCustomerLongitude("customerLongitude"); - oofRequestParameters.setCustomerName("customerName"); - - ArrayList<PlacementDemand> placementDemands = new ArrayList<>(); - placementDemands.add(placementDemand); - - PlacementInfo placementInfo = new PlacementInfo(); - placementInfo.setPlacementDemands(placementDemands); - placementInfo.setRequestParameters(oofRequestParameters); - placementInfo.setSubscriberInfo(subscriberInfo); - - RequestInfo requestInfo = new RequestInfo(); - requestInfo.setTransactionId("transactionId"); - List<String> optimizer = new ArrayList<>(); - optimizer.add("optimizer1"); - optimizer.add("optimizer2"); - requestInfo.setOptimizers(optimizer); - requestInfo.setCallbackUrl("callBackUrl"); - requestInfo.setNumSolutions(1); - requestInfo.setRequestId("requestId"); - requestInfo.setSourceId("sourceId"); - requestInfo.setTimeout(30L); - requestInfo.setRequestType("requestType"); - - OofRequest oofRequest = new OofRequest(); - oofRequest.setRequestInformation(requestInfo); - oofRequest.setPlacementInformation(placementInfo); - oofRequest.setServiceInformation(serviceInfo); - oofRequest.setLicenseInformation(new LicenseInfo()); - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postDemands(oofRequest); - - String oofRequestOutput = oofRequest.toJsonString(); - JSONAssert.assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n" - + " \"requestId\" : \"requestId\",\n" + " \"callbackUrl\" : \"callBackUrl\",\n" - + " \"sourceId\" : \"sourceId\",\n" + " \"requestType\" : \"requestType\",\n" - + " \"numSolutions\" : 1,\n" + " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" - + " \"timeout\" : 30\n" + " },\n" + " \"serviceInfo\" : {\n" - + " \"serviceInstanceId\" : \"serviceInstanceId\",\n" + " \"serviceName\" : \"serviceName\",\n" - + " \"modelInfo\" : {\n" + " \"modelType\" : \"modelType-Service\",\n" - + " \"modelInvariantId\" : \"modelInvariantId-Service\",\n" - + " \"modelVersionId\" : \"modelVersionId-Service\",\n" - + " \"modelName\" : \"modelName-Service\",\n" - + " \"modelVersion\" : \"modelVersion-Service\",\n" - + " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" + " }\n" + " },\n" - + " \"placementInfo\" : {\n" + " \"requestParameters\" : {\n" - + " \"customerLatitude\" : \"customerLatitude\",\n" - + " \"customerLongitude\" : \"customerLongitude\",\n" - + " \"customerName\" : \"customerName\"\n" + " },\n" + " \"subscriberInfo\" : {\n" - + " \"globalSubscriberId\" : \"globalSubscriberId\",\n" - + " \"subscriberName\" : \"subscriberName\",\n" - + " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" + " },\n" - + " \"placementDemands\" : [ {\n" + " \"resourceModuleName\" : \"resourceModuleName\",\n" - + " \"serviceResourceId\" : \"serviceResourceId\",\n" + " \"tenantId\" : \"tenantId\",\n" - + " \"resourceModelInfo\" : {\n" + " \"modelType\" : \"modelType\",\n" - + " \"modelInvariantId\" : \"invarianteId\",\n" + " \"modelVersionId\" : \"versionId\",\n" - + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n" - + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n" - + " },\n" + " \"licenseInfo\" : { \n" + " \"licenseDemands\" : [ ]\n" + "}\n" + "}", - oofRequestOutput, false); - } - - @Test - public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postDemands(new OofRequest()); - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - - // TODO assertEquals("missing data", ); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException { - String mockResponse = "{ }"; - - wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new OofRequest()); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java deleted file mode 100644 index 56c52388f8..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sniro; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.sniro.beans.SniroConductorRequest; -import org.onap.so.client.sniro.beans.SniroManagerRequest; -import org.springframework.beans.factory.annotation.Autowired; -import com.fasterxml.jackson.core.JsonProcessingException; - - -public class SniroClientTestIT extends BaseIntegrationTest { - - @Autowired - private SniroClient client; - - - @Test(expected = Test.None.class) - public void testPostDemands_success() throws BadResponseException, JsonProcessingException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postDemands(new SniroManagerRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - - // TODO assertEquals("missing data", ); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException { - String mockResponse = - "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException { - String mockResponse = "{ }"; - - wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - - client.postDemands(new SniroManagerRequest()); - } - - @Test(expected = Test.None.class) - public void testPostRelease_success() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"success\", \"message\": \"corys cool\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_failed() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"failure\", \"message\": \"corys cool\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_noStatus() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"\", \"message\": \"corys cool\"}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_noMessage() throws BadResponseException, JsonProcessingException { - String mockResponse = "{\"status\": \"failure\", \"message\": null}"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - - } - - @Test(expected = BadResponseException.class) - public void testPostRelease_error_empty() throws BadResponseException, JsonProcessingException { - String mockResponse = "{ }"; - - wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); - - client.postRelease(new SniroConductorRequest()); - - } - -} |