diff options
Diffstat (limited to 'bpmn/so-bpmn-building-blocks/src/test/java/org/onap')
-rw-r--r-- | bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java | 50 | ||||
-rw-r--r-- | bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java (renamed from bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2BBTest.java) | 33 | ||||
-rw-r--r-- | bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/SDNCHandlerTest.java | 77 |
3 files changed, 115 insertions, 45 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index f5fc8b091c..f9ff28a023 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,6 +34,7 @@ import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; import org.onap.so.TestApplication; +import org.onap.so.bpmn.buildingblock.SniroHomingV2; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.common.validation.BuildingBlockValidatorRunner; import org.onap.so.bpmn.infrastructure.aai.tasks.AAICommonTasks; @@ -72,6 +73,7 @@ import org.onap.so.bpmn.sdno.tasks.SDNOHealthCheckTasks; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.bpmn.servicedecomposition.tasks.ExecuteBuildingBlockRainyDay; +import org.onap.so.client.sdnc.SDNCClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.web.server.LocalServerPort; @@ -91,9 +93,9 @@ public abstract class BaseBPMNTest { @Autowired private RepositoryService repositoryService; - + protected Map<String, Object> variables = new HashMap<>(); - + protected List<String> mockedSubprocessList = new ArrayList<>(); protected TestRestTemplate restTemplate = new TestRestTemplate(); @@ -111,11 +113,11 @@ public abstract class BaseBPMNTest { @MockBean protected AAIDeleteTasks aaiDeleteTasks; - + @MockBean protected AAIFlagTasks aaiFlagTasks; - - + + @MockBean protected AppcRunTasks appcRunTasks; @@ -154,7 +156,7 @@ public abstract class BaseBPMNTest { @MockBean protected AssignNetworkBBUtils assignNetworkBBUtils; - + @MockBean protected AssignNetwork assignNetwork; @@ -181,37 +183,43 @@ public abstract class BaseBPMNTest { @MockBean protected OrchestrationStatusValidator orchestrationStatusValidator; - + @MockBean protected BBInputSetup bbInputSetup; - + @MockBean protected BBInputSetupUtils bbInputSetupUtils; - + @MockBean protected ExecuteBuildingBlockRainyDay executeBuildingBlockRainyDay; - + @MockBean protected WorkflowAction workflowAction; @MockBean protected WorkflowActionBBTasks workflowActionBBTasks; - + @MockBean protected GenericVnfHealthCheck genericVnfHealthCheck; - + @MockBean protected ConfigurationScaleOut configurationScaleOut; - + @MockBean protected FlowCompletionTasks flowCompletionTasks; - + @MockBean protected BuildingBlockValidatorRunner buildingBlockValidatorRunner; - + @MockBean protected SDNOHealthCheckTasks sdnoHealthCheckTasks; - + + @MockBean + protected SDNCClient sdncClient; + + @MockBean + protected SniroHomingV2 sniroHoming; + @LocalServerPort protected int port; @@ -223,7 +231,7 @@ public abstract class BaseBPMNTest { public void baseBefore() { variables.put("gBuildingBlockExecution", new DelegateExecutionImpl(new HashMap<>())); } - + @After public void baseAfter() { for (String deploymentId : mockedSubprocessList) { @@ -231,7 +239,7 @@ public abstract class BaseBPMNTest { } mockedSubprocessList.clear(); } - + /** * Create and deploy a process model with one logger delegate as service task. * @@ -268,7 +276,7 @@ public abstract class BaseBPMNTest { for (String key : outParam.keySet()) { builder.camundaOutputParameter(key, outParam.get(key)); } - + BpmnModelInstance modelInstance = builder.endEvent().name("End_Event").done(); mockedSubprocessList.add(repositoryService.createDeployment().addModelInstance(fileName + ".bpmn", modelInstance).deploy().getId()); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2BBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java index a90d309630..0dde361b7e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2BBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.buildingblock; +package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -29,44 +29,29 @@ import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Ignore; import org.junit.Test; import org.onap.so.bpmn.BaseBPMNTest; +import org.onap.so.bpmn.buildingblock.SniroHomingV2; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.springframework.boot.test.mock.mockito.MockBean; - //these test run locally but fail when ran in conjunction with others in jenkins -@Ignore -public class SniroHomingV2BBTest extends BaseBPMNTest{ - - @MockBean - protected SniroHomingV2 sniroHoming; +public class HomingBBTest extends BaseBPMNTest{ @Test public void testHomingV2_success(){ mockSubprocess("ReceiveWorkflowMessage", "Mock ReceiveWorkflowMessage", "GenericStub"); - ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingBB", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("start", "callSniro", "callReceiveAsync", "processSolution", "end"); + assertThat(pi).isStarted().hasPassedInOrder("start", "sniroOofCheck", "callSniro", "ExclusiveGateway_1ckp059", "receiveAsyncCallback", "sniroOofCheck2", "processSniroSolution", "ExclusiveGateway_1kvzxpb", "end"); assertThat(pi).isEnded(); } @Test public void testHomingV2_error_bpmnError(){ doThrow(new BpmnError("MSOWorkflowException")).when(sniroHoming).callSniro(any(BuildingBlockExecution.class)); - ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables); - assertThat(pi).isNotNull(); - assertThat(pi).isStarted() - .hasPassedInOrder("start", "catchBpmnError", "processBpmnError", "endBpmnError") - .hasNotPassed("callReceiveAsync"); - assertThat(pi).isEnded(); - } - - @Test - public void testHomingV2_error_javaException(){ - doThrow(new RuntimeException("Test")).when(sniroHoming).callSniro(any(BuildingBlockExecution.class)); - ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("start", "catchJavaException", "processJavaException", "endJavaException") + .hasPassedInOrder("start", "sniroOofCheck", "startBpmnError", "bpmnErrorSubprocess", "processMsoWorkflowException", "endBpmnError") .hasNotPassed("callReceiveAsync"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/SDNCHandlerTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/SDNCHandlerTest.java new file mode 100644 index 0000000000..ad9f97f951 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/SDNCHandlerTest.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; +import static org.mockito.Mockito.doReturn; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Test; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.so.bpmn.BaseBPMNTest; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNCHandlerTest extends BaseBPMNTest{ + @Test + public void sunnyDay_SDNCHandler_Sync_Final_Test() throws InterruptedException, MapperException, BadResponseException, IOException { + final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/SDNCClientPut200Response.json"))); + doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION); + Map<String, Object> startVariables = new HashMap<>(); + startVariables.put("SDNCRequest", createSDNCRequest()); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("SDNCHandler", startVariables); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("SDNC_Start","SNDC_SetupCallback","Call_SDNC","isAsync_Gateway","SDNC_End").isEnded(); + } + + + public SDNCRequest createSDNCRequest(){ + SDNCRequest request = new SDNCRequest(); + request.setCorrelationName("correlationName"); + request.setCorrelationValue("correlationValue"); + request.setTopology(SDNCTopology.CONFIGURATION); + ObjectMapper mapper = new ObjectMapper(); + try { + GenericResourceApiServiceOperationInformation sdncReq = + mapper.readValue(Files.readAllBytes(Paths.get("src/test/resources/SDNC_Client_Request.json")), GenericResourceApiServiceOperationInformation.class); + request.setSDNCPayload(sdncReq); + } catch (JsonParseException e) { + + } catch (JsonMappingException e) { + + } catch (IOException e) { + + } + + return request; + } +} |