From 61affc6311906aee71b16ee8632c1e7468cd1990 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 5 Nov 2018 11:00:36 -0500 Subject: Catchup commits for Dublin added property for retry timer multiplier for testing Infra APIH table, fixed test assertNull condition. Infra APIH table, added tests for request-url = null. Infra APIH should write request_url to infra_active_requests. Return SelfLink URL on ServiceInstantiation SyncResponse. Added JUNITS. Added helper method to get AAI ResourceUri to faciliate unit test. Fixed code to correctly extract related generic vnf or vce id. updated unit test coverage for update network Handle REST NotFoundException for serviceInstance nodes query. Process should continue for new order request and throw exception only for SUPP request. Added disconnect functionality to the gw vnf test tool. Added conversion of vnf management option to dhv change speed sync subnet status with network update updated macroData vol assigned delete continue script Correct the name of DeleteVfModuleBB subprocess. fix the custom resolver to not convert int in string to int Write the returned value from Homing to gBBInput Use explicit conversion to JSON to read cloudConfiguration settings. added property for retry timer multiplier for testing avoid storing AAI yang models in execution added handlingCode to rollback test in workflowactionbb passed in alacarte flag to execute layer for rainy day added test cases for RollbackToAssigned rainy day hand added rollback to assign in catalog db rainy day hand Updated vnf adapter delete stubs to be a post for test. Added a javadoc to basic auth override method Added a check to not add blank headers to the headerMap in httpClient. Added check for if entity exist before calling readEntity. Fixed failing junits and updated way the body is obtained Added missing import statement for http client. Fixed mistakes and made updates caught during review. Removed post and httpPost methods from RESTClient and refactored references Refactored multiple http post references to use httpClient instead. Removed close connection method and randomized port in unit test Added http client unit test, coverage is currently at 90 percent Resolve conflict in sdnc adapter reste v1 method Began removing http delete and delete methods from RESTClient and aaiUtil. Removed http put method and executeput method, refactored references. fixed broken tests in the branch in jenkins build Fix Springboot 2.0 start up issues, and other issues added in implementation to generate self link if there isnt one removed dbcp2 from poms that still had them added rollbackstatusmessage to stub in testprocess added rollback_status_message to the schema sql file Added variable for rollbackStatusMessage Added rollbackStatusMessage to get response added rollback status message to archived infra request set rollback status message to successful on boolean added logic to split rollback and regular error message added rollback status message to infra active requests pushing the cloud config changes as well Added media type and fixed cast plural issue. Made various updated and fixes to code that was changed. Removed all no longer used RESTClient imports from classes Removed and refactored references for aaiUtil methods and all remaining RESTClient methods, removed RESTClient project and updated poms. Return canonical stack id on multicloud create Fix OOF Config Ingestion Fix variable to retrieve sdnc endpoint Prepare resources for service uuid req Fix swapped parameters for multicloud DELETE Update msb-java-sdk to resolve license issues cloud owner support for SDNC interface correlationId is now read from userParams Fix up request body of multicloud adapter body removed LinkedHashMap from java classes Cut over logging project to release not snapshot Update unit tests, revert test code, fix comments Fix remaining number of Unit Tests, on avpn flow Fix JUNITS add callback url, fix BPMN issues Update SDNC interaction to support a-sync updated bpm assert import and corrected tests updated test case to be mockito 2 compliant additional changes to import statements and tests Change the place where the data for multistage gets set Update treatment of PENDING_ACTIVATION VF_MODULE CREATE entries to SILENT_SUCCESS to support first stage of multistage. Implement second stage of multistage design VF Module Creation removed LinkedHashMap from java classes Removed SNAPSHOT from dependency Cut over logging project to release not snapshot Fixed failing BBInputSetup tests Update unit tests, revert test code, fix comments Updated apih tests to use networkInstanceGroup Updated ModelType enum and fixed compilation issues Fix remaining number of Unit Tests, on avpn flow Fix JUNITS add callback url, fix BPMN issues Implementation of the first stage of multistage design for VF Module creation. Update SDNC interaction to support a-sync no longer leave modified files after test runs Remove generated CSAR, that occurs during JUNIT Update Camunda Pods to use Flyway Migration in 1902 Updated hashcode method and removed comment. Added aggregate routes to the sdnw request and updated pom sdnw dependency. Began to set aggreagate route information for vrf configuration. modified remaining files with att-aic references Correct rollbackData setting and protect against potential null objects. correct AAIObjectPlurals enum value name Update POJO to use type URL for selfLink. Optional - construct SelfLink Url format. Construct SelfLink Url format from full Url. added missing properties to application-test.yaml fixed compliation error after merge of unit test restored files which should not have been deleted Fix SO vulnerabilities with cxf Fixing bpmn infra endpoint in so-monitoring yaml removed att-aic from codebase default cloud owner now configurable Set homingService in WorkflowAction Fix Java Ex in Homing Version should be 1.3.1 to release new dockers Pnf Spring Environment correction test property now has dynamic wiremock port removed test specific wiremock rule that was causing problems re-enabled and corrected integration tests for so-bpmn-tasks Test to get sniro homing v2 test working by splitting test suites for each spring application Reverted changes to old migration scripts.. Fixed spring context issue with test HomingV2. Removed unused import to fix compilation errors Fixed onap changes to homing, migrated homingV2 to homingBB, fixed broken junits again. - Updated isUseHttpsWithDmaapTest to check assertTrue rather than assertFalse. - Upgraded code to make the isUseHttpsWithDmaap configurable. It will default to true if no value is found in the config file. moved workflowaction test class to the test section added status message update for retry and rollback beefed up error message debug logging and req db msg added debug lines to workflowactionbbtasks reqdbcall Issue-ID: SO-1187 Change-Id: Iec1aff4ed30a43c0e0b2cdb06c28d8db8a99a830 Signed-off-by: Benjamin, Max (mb388a) --- .../subprocess/BuildingBlock/AssignVnfBB.bpmn | 3 +- .../subprocess/BuildingBlock/HomingBB.bpmn | 323 ++++++++++++++------- .../subprocess/BuildingBlock/SDNCHandler.bpmn | 259 +++++++++++++++++ .../subprocess/BuildingBlock/WorkflowActionBB.bpmn | 5 +- .../test/java/org/onap/so/bpmn/BaseBPMNTest.java | 50 ++-- .../so/bpmn/buildingblock/SniroHomingV2BBTest.java | 74 ----- .../bpmn/subprocess/HomingBBTest.java | 59 ++++ .../bpmn/subprocess/SDNCHandlerTest.java | 77 +++++ .../test/resources/SDNCClientPut200Response.json | 15 + .../SDNCClientPut200ResponseNotFinal.json | 15 + .../src/test/resources/SDNCFlowRequest.json | 11 + .../src/test/resources/SDNC_Client_Request.json | 28 ++ .../src/test/resources/application-test.yaml | 2 +- 13 files changed, 720 insertions(+), 201 deletions(-) create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn delete mode 100644 bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2BBTest.java create mode 100644 bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java create mode 100644 bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/SDNCHandlerTest.java create mode 100644 bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200Response.json create mode 100644 bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200ResponseNotFinal.json create mode 100644 bpmn/so-bpmn-building-blocks/src/test/resources/SDNCFlowRequest.json create mode 100644 bpmn/so-bpmn-building-blocks/src/test/resources/SDNC_Client_Request.json (limited to 'bpmn/so-bpmn-building-blocks/src') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index d2c7f17b19..0991ab5c36 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0zaz9o2 @@ -38,7 +38,6 @@ - SequenceFlow_1uiok7v SequenceFlow_0v8d14a diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn index 344b7d8761..1fdf2f3c66 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn @@ -1,72 +1,48 @@ - + - + SequenceFlow_1x9usa6 - - SequenceFlow_1x9usa6 - SequenceFlow_0lc15i7 - import org.onap.so.bpmn.common.scripts.* -if(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")).getVariable("homingService") == "oof"){ - OofHoming oofHoming = new OofHoming() - oofHoming.callOof(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution"))) -}else{ - SniroHomingV2 sniroHoming = new SniroHomingV2() - SniroHoming.callSniro(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution"))) -} - - + - + SequenceFlow_1rf4vs8 - + SequenceFlow_00nlh7l SequenceFlow_00nlh7l SequenceFlow_1rf4vs8 - import org.onap.so.bpmn.common.scripts.* + +ex.processSubflowsBPMNException(execution)]]> - - + + SequenceFlow_0kamg53 SequenceFlow_1o7154s - import org.onap.so.bpmn.common.scripts.* + +ex.processJavaException(execution)]]> - + SequenceFlow_0kamg53 - + SequenceFlow_1o7154s - - + + - - SequenceFlow_1fipbmk - SequenceFlow_01apjvo - import org.onap.so.bpmn.common.scripts.* -if(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")).getVariable("homingService") == "oof"){ - OofHoming oofHoming = new OofHoming() - oofHoming.processHomingSolution(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution"))) -}else{ - SniroHomingV2 sniroHoming = new SniroHomingV2 () - sniroHoming.processSolution(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), asyncResponse) -} - @@ -74,135 +50,280 @@ if(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecu - + - SequenceFlow_0lc15i7 + SequenceFlow_1qbnm82 SequenceFlow_1fipbmk - - - - SequenceFlow_01apjvo + + + + SequenceFlow_1urt5i6 - + + + + + + + + + + + + + + + SequenceFlow_1dtador + SequenceFlow_0lc15i7 + + + SequenceFlow_08k112s + SequenceFlow_01apjvo + + + SequenceFlow_0m6nhqg + SequenceFlow_0kvax6n + + + SequenceFlow_0oixz4g + SequenceFlow_0ph4paa + + + SequenceFlow_1x9usa6 + SequenceFlow_1dtador + SequenceFlow_0m6nhqg + + + SequenceFlow_0lc15i7 + SequenceFlow_0kvax6n + SequenceFlow_1qbnm82 + + + SequenceFlow_1fipbmk + SequenceFlow_08k112s + SequenceFlow_0oixz4g + + + SequenceFlow_01apjvo + SequenceFlow_0ph4paa + SequenceFlow_1urt5i6 + - - - - - - + + + + + + - - + + - + - + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - - + + - + - - - - + + + + - + - - + + - + - - + + - + - - - - + - - + + - + - - + + + - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn new file mode 100644 index 0000000000..d123153932 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn @@ -0,0 +1,259 @@ + + + + + SequenceFlow_1n0j3hz + + + SequenceFlow_0i4u8g4 + SequenceFlow_0puiqga + + + SequenceFlow_0flbj8a + SequenceFlow_07vnhri + + + SequenceFlow_0valp88 + + + + + SequenceFlow_0rh24pq + SequenceFlow_0yve6l6 + SequenceFlow_1ecej8g + + SequenceFlow_1qxm8ot + SequenceFlow_05eggbt + + + + SequenceFlow_1qxm8ot + + + SequenceFlow_0oh3ye4 + + + + + + SequenceFlow_05eggbt + SequenceFlow_0oh3ye4 + + + + SequenceFlow_1yifu46 + + + + + + + SequenceFlow_1ecej8g + SequenceFlow_0rh24pq + SequenceFlow_0i4u8g4 + + + + + + + + SequenceFlow_07vnhri + SequenceFlow_0yve6l6 + SequenceFlow_0puiqga + + + + + + + + + + SequenceFlow_1n0j3hz + SequenceFlow_0flbj8a + + + SequenceFlow_1yifu46 + + + SequenceFlow_0valp88 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 8cda1d7c7b..d4330290ea 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -17,6 +17,7 @@ + SequenceFlow_0mew9im SequenceFlow_07h9d4y @@ -98,7 +99,7 @@ - + @@ -562,4 +563,4 @@ - + \ No newline at end of file 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 variables = new HashMap<>(); - + protected List 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/buildingblock/SniroHomingV2BBTest.java deleted file mode 100644 index a90d309630..0000000000 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2BBTest.java +++ /dev/null @@ -1,74 +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.bpmn.buildingblock; - -import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doThrow; - -import org.camunda.bpm.engine.delegate.BpmnError; -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.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; - - @Test - public void testHomingV2_success(){ - mockSubprocess("ReceiveWorkflowMessage", "Mock ReceiveWorkflowMessage", "GenericStub"); - ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables); - assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("start", "callSniro", "callReceiveAsync", "processSolution", "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); - assertThat(pi).isNotNull(); - assertThat(pi).isStarted() - .hasPassedInOrder("start", "catchJavaException", "processJavaException", "endJavaException") - .hasNotPassed("callReceiveAsync"); - assertThat(pi).isEnded(); - } - -} diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java new file mode 100644 index 0000000000..0dde361b7e --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java @@ -0,0 +1,59 @@ +/*- + * ============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.bpmn.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doThrow; + +import org.camunda.bpm.engine.delegate.BpmnError; +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; + + +public class HomingBBTest extends BaseBPMNTest{ + + @Test + public void testHomingV2_success(){ + mockSubprocess("ReceiveWorkflowMessage", "Mock ReceiveWorkflowMessage", "GenericStub"); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingBB", variables); + assertThat(pi).isNotNull(); + 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("HomingBB", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted() + .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 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; + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200Response.json b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200Response.json new file mode 100644 index 0000000000..286ce4c844 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200Response.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "Y" + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200ResponseNotFinal.json b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200ResponseNotFinal.json new file mode 100644 index 0000000000..deb4de0219 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCClientPut200ResponseNotFinal.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "N" + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCFlowRequest.json b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCFlowRequest.json new file mode 100644 index 0000000000..41fdf98bd0 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNCFlowRequest.json @@ -0,0 +1,11 @@ +{ + "timeOut":"PT1H", + "URI": "http:llasdfasdf", + "CorrelationValue": "randomUUID", + "CorrelationName": "MyCallbackVariableName", + "SDNCPayLoad": { + "test":"test", + "test2":"test", + "test3":"test" + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/SDNC_Client_Request.json b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNC_Client_Request.json new file mode 100644 index 0000000000..f60767b85e --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/SDNC_Client_Request.json @@ -0,0 +1,28 @@ +: { + "input": { + "request-information": { + "request-action": "CreateServiceInstance", + "source": "MSO", + "request-id": "5a09ab96-032b-41cd-ad81-4fb9ec5fade7" + }, + "sdnc-request-header": { + "svc-request-id": "5a09ab96-032b-41cd-ad81-4fb9ec5fade7", + "svc-action": "assign" + }, + "service-information": { + "onap-model-information": { + "model-name": "Vf zrdm5bpxmc02092017-Service", + "model-version": "1.0", + "model-uuid": "bad955c3-29b2-4a27-932e-28e942cc6480", + "model-invariant-uuid": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b" + }, + "subscription-service-type": "Robot_Test_Service_Type", + "service-id": "48121c5e-dde0-42a6-a78a-89556ff355d0", + "global-customer-id": "Robot_Test_Subscriber_ID", + "service-instance-id": "48121c5e-dde0-42a6-a78a-89556ff355d0" + }, + "service-request-input": { + "service-instance-name": "Robot_SI_For_VolumeGroup" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml index 32d6435213..62e2c0a8c2 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml @@ -209,4 +209,4 @@ pnf: topicName: pnfReady consumerGroup: consumerGroup consumerId: consumerId - topicListenerDelayInSeconds: 5 \ No newline at end of file + topicListenerDelayInSeconds: 5 -- cgit 1.2.3-korg