aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-09-29 10:41:54 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-11-05 10:22:41 -0500
commit6fa3d2b80d2384b830e3231fe69a8daf7884a35e (patch)
tree565014596071f8b57919d762dc4d9733de7ea92f /bpmn/MSOCommonBPMN/src/test
parent6b4910cc194286bccb2a63f63d12bfefcdb7fb3f (diff)
Springboot 2.0 upgrade
corrected typo in CloudConfiguration class removed files which should not have been merged updated gr api test cases with dynamic cloud owner updated groovy files to allow for dynamic cloud owner values moved VFModularity folder to mso-infrastructure bpmn updated GR API layer to include cloud owner added enum for default cloud owner - fixing junit test cases for using catalogDb client r2 - fixing junit test cases for using catalogDb client - Internal review comments incorporated for merging mocking into BaseTest - Internal review comments incorporated for removing direct repo calls - CLONE - Key Management Hardcoded encryption key | fixing junits - CLONE - Key Management Hardcoded encryption key Updated builder to use String.format Added exception specifically for issues interacting with requestdbadapter Updated exception message and added junit test case removed useless error handling test case from workflow changed method name and added junit coverage to errors added max retry and success status after completed bb Added case to handle when homing is not called during assign vnf. Fixing fortify issues | Implementing review comments - Key Management Hardcoded encryption key - fixing prop files - Key Management Hardcoded encryption key include network ID for completion handler Added exception handling for saving to requestdb - Adding a check on the predicate availability on the repository before firing the query with default conditions. This ensures that the api returns data only when there is an input against which it was able to form some conditions Modify UT to show that the API does not behave - adding negative test case for checkInstanceNameDuplicate added assertion that global count var was reset to 0 updated rollback to reset current sequence count var workflowaction calls rollback is complete before error workflowaction will set failure on successful rollback added check for isrollback to know which complete to call removed file which should not have been added add fabric check before running vf module a la carte Enhance UCPEMigrateService junits and add them to Jenkins build.. Added back removed test case for ManualTasks Added test case for response error Added rainy day test cases for ManualTasks revert the other change and fix the rollback logic instead fixed current sequence and updated rollback code added network cloud heat template parameters to mapper Generate a unique subRequestId for each request to APP-C. reverted conditional logic for determining fabric Fix Bean scanning so it picks up the resttemplate removed unnecessary RestTemplate Bean configurations removed file which should not have been added workflowaction calls rollback is complete before error workflowaction will set failure on successful rollback added check for isrollback to know which complete to call add fabric check before running vf module a la carte added assertion that global count var was reset to 0 updated rollback to reset current sequence count var include network ID for completion handler Revert Application.yaml change accidentally checked in Added exception handling for saving to requestdb Added case to handle when homing is not called during assign vnf. removed useless error handling test case from workflow changed method name and added junit coverage to errors ... add cloud owner variable to camunda in mapping Revert "Pass cloudOwner to subflow DoCreateVfModuleVolumeV2. Added juint test to verify variables are set in the execution. Set default cloudOwner in main module CreateVfModuleVolumeInfraV2" updated cloud configuration pojo to inlcude defaults Revert "Test to verify ServiceInstance object mapping" Test to verify ServiceInstance object mapping Pass cloudOwner to subflow DoCreateVfModuleVolumeV2. Added juint test to verify variables are set in the execution. Set default cloudOwner in main module CreateVfModuleVolumeInfraV2 Pass cloudOwner to subflow DoCreateVfModuleVolumeV2. Set default cloudOwner 'att-aic' if null per old requirements. removed references to att-aic from BBInputSetup Changes done in encryption decryption logic | used DelegateExecutionFake in Tests Changes done in encryption decryption logic | used DelegateExecutionFake in Tests Changes done in encryption decryption logic Changes done in encryption decryption logic | removed Default Auth Constant as per the comments Changes done in encryption decryption logic | Fixed UT Changes done in encryption decryption logic | Added XmlComparator assertion for verifying XML Changes done in encryption decryption logic | Reverted as per the review comment Changes done in encryption decryption logic | Fixed UTs Changes done in encryption decryption logic | Fixed UTs Changes done in encryption decryption logic | modified related encrypted properties in test yaml files Changes done in encryption decryption logic for fortify issue resolution | Fixed UTs Changes done in encryption decryption logic | modified related encrypted properties in yaml files Changes done in encryption decryption logic for fortify issue resolution. Fixed Property fetching issue in required file Added TasksBeansTest using openpojo Removed renamed test file from tasksbeans Updated imports on TasksBeansTest Added openpojo test to replace the individual tests Removed tests that provided no coverage script clean up -Update reference data to support distinct recreate and replace requests with their own sequences Update reference data to support distinct recreate and replace requests with their own sequences- Fix seq number Update reference data to support distinct recreate and replace requests with their own sequences added null check to mdc and interceptors to sdnc cxf validations can now match against multiple BBs reverted changes to BBInputSetup class added support for pre and post validation for BBs initial commit of generic building block validator converted test to no longer be a springboot test Remove cosmetic changes from BPMN files to be consistent. Remove minor changes that are not related to functionality. Rework to implement the functionality as part of Validator Combine the verification methods into one based on the flow's name; change the logging. Add verification of status of other VF Modules in the VNF for the delete/deactivate/unassign. added network-technology validation for CreateNetworkBB Sonar Issue Fix | Changes done in encryption decryption logic | Refactoring Changes done in encryption decryption logic| Used AES/GCM/NoPadding algorithm | fixed sonar issues added network-type and network-technology to mapper Continue the fight to make JUNITS work properly Update ASDC ATT to be springboot 2.0 compliant Continue to fix Unit tests for springboot 2.0 port removed autowired from workflowactionbbtaskstest fixed workflowactiontest and reduced size by 500 lines Update last of UT for mockito upgrade to 2.0 Fix more JUNITS due to mockito 2.0 upgrade Unit Test fixes to use proper mockito not spring Update Base Test to import proper packages for compile Additional Springboot 2.0 changes, for tests Additional springboot 2.0 fixes and upgrades Update Migration to be Flyway 5 Compliant Fix MSOBPMN Infrastructure common tests Fix Groovy Unit Tests in CommonBPMN Project Update MSO common BPMN to Springboot 2.0 Upgrade ASDC controller to SpringBoot 2.0 Port Openstack adapters to springboot 2.0 Fix VFC Adapter to be springboot 2 compatible Port CatalogDB adapter code to springboot 2 Port SDNC Adapter to Springboot 2.0 ... added update scripts to macro data instead of v12 sql added secondarypolicy to rainy day handling table confirm subnet map is not null in adapter response shallow copy subnet before AAI udpate update AAIObjectType to use uriTemplate extract subnet data from adapter response update correct AAIObjectType for subnet query update subnet(s) in AAI on network create completion confirm subnet map is not null in adapter response shallow copy subnet before AAI udpate update AAIObjectType to use uriTemplate extract subnet data from adapter response update correct AAIObjectType for subnet query update subnet(s) in AAI on network create completion fixed test http entity unit test to remove testing appid and transaction id added unit test for querySubsystemHealth method. also added resttemplate mock to implement healthcheck endpoint fixed unit test to use mock instead of actually goes out to health check endpoint added code to extend globalhealthcheck to include pinging other components and consolidate the responses converted test to no longer be a springboot test Remove cosmetic changes from BPMN files to be consistent. Remove minor changes that are not related to functionality. added update scripts to macro data instead of v12 sql Rework to implement the functionality as part of Validator added secondarypolicy to rainy day handling table added network-type and network-technology to mapper Combine the verification methods into one based on the flow's name; change the logging. Add verification of status of other VF Modules in the VNF for the delete/deactivate/unassign. updated how request db is set to failure in workflowA corrected code to match existing unit tests corrected tests after springboot 2 upgrade Added Required UTs in UpdateConfigurationStateTest and also fixed some UTs. added in missing parenthesis on method call added back execution variable for allotted uri addressed comments on pull request refactor AAI Rest calls from groovy files - Changes as per review comments checkin to refactor AAI rest | Fixing AAIResourceClient.update call refactor AAI Rest calls from groovy files - UpdateConfiguration refactor AAI Rest calls from groovy file - DeleteConfiguration refactor AAI Rest calls from groovy file - UpdateConfiguration refactor AAI Rest calls from groovy file - CreateConfiguration & ConfigurationUtils refactor AAI Rest calls from groovy files - Fix getARByID issue checkin to refactor AAI rest | Adding Junits checkin to refactor AAI rest | Adding few more classes checkin to refactor AAI rest of DoCreateVfModuleVolumeV2 checkin to refactor AAI rest | Update junit checkin to refactor AAI rest of DoCreateVfModuleVolumeV2 | Adding junits checkin to refactor AAI rest of DoCreateVfModuleVolumeV2 | Adding junits checkin to refactor AAI rest of DoCreateVfModuleVolumeV2.groovy ... updated in and out mapping to be generalBuildingBlock change source out mapping to generalBuildingBlock Change-Id: I122f1ebe3e15b77da0a55af201d89d47e326bf83 Issue-ID: SO-1098 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy11
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy99
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy98
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy24
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy124
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy238
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy119
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy208
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy97
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy26
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy174
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java21
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java57
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java13
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java90
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java (renamed from bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java)27
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java43
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java42
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java45
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java33
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java88
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java39
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java99
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnf.json57
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnfVfModule.json62
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroup.json10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithTenant.json20
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithVfModule.json26
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/aai/searchResults.json8
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml17
42 files changed, 1418 insertions, 653 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy
index 05b1c5e6ed..1165bbbc71 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy
@@ -44,8 +44,6 @@ import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
import org.camunda.bpm.engine.repository.ProcessDefinition
-@RunWith(MockitoJUnitRunner.class)
-@Ignore
class AaiUtilTest extends MsoGroovyTest {
@@ -53,7 +51,7 @@ class AaiUtilTest extends MsoGroovyTest {
public WireMockRule wireMockRule = new WireMockRule(8090);
@Rule
- public ExpectedException thrown = ExpectedException.none
+ public ExpectedException thrown = ExpectedException.none()
def aaiPaylod = "<allotted-resource xmlns=\"http://org.openecomp.aai.inventory/v9\">\n" +
@@ -128,6 +126,7 @@ class AaiUtilTest extends MsoGroovyTest {
}
@Test
+ @Ignore
public void testExecuteAAIGetCall() {
ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
@@ -140,6 +139,7 @@ class AaiUtilTest extends MsoGroovyTest {
@Test
+ @Ignore
public void testExecuteAAIPutCall() {
ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy
index 86a175d811..459b18b7f1 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy
@@ -32,7 +32,7 @@ import static org.mockito.Mockito.*
import org.onap.so.rest.HttpHeader
import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.internal.debugging.MockitoDebuggerImpl
import org.junit.Before
import org.onap.so.bpmn.common.scripts.AaiUtil;
@@ -58,7 +58,8 @@ class AbstractServiceTaskProcessorImpl extends AbstractServiceTaskProcessor{
}
}
-@RunWith(MockitoJUnitRunner.class)
+
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AbstractServiceTaskProcessorTest extends MsoGroovyTest {
@Captor
@@ -171,12 +172,12 @@ public class AbstractServiceTaskProcessorTest extends MsoGroovyTest {
@Test
public void testSetBasicDBAuthHeader_Success() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn('9B2278E8B8E95F256A560719055F4DF3')
- when(mockExecution.getVariable("mso.msoKey")).thenReturn('aa3871669d893c7fb8abbcda31b88b4f')
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn('5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C')
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn('07a7159d3bf51a0e53be7a8f89699be7')
AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
serviceTaskProcessor.setBasicDBAuthHeader(mockExecution, "true")
- verify(mockExecution).setVariable("BasicAuthHeaderValueDB",'Basic dXAyMTE4OnVwMjExOA==')
+ verify(mockExecution).setVariable("BasicAuthHeaderValueDB",'Basic dGVzdDp0ZXN0')
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy
new file mode 100644
index 0000000000..3da126f7a9
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy
@@ -0,0 +1,99 @@
+/*-
+ * ============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.common.scripts
+
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Test
+import org.mockito.Mockito
+import org.mockito.internal.stubbing.answers.DoesNothing
+import org.onap.aai.domain.yang.AllottedResource
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import javax.ws.rs.core.UriBuilder
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertTrue
+import static org.mockito.Matchers.any
+import static org.mockito.Matchers.anyObject
+import static org.mockito.Matchers.isA
+import static org.mockito.Mockito.atLeastOnce
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.doThrow
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.verify
+import static org.mockito.Mockito.when
+
+
+class AllottedResourceUtilsTest extends MsoGroovyTest{
+
+ private static final String ALLOTTED_RESOURSE_URI = "/aai/v11/business/customers/customer/MSO-MUX-User/service-subscriptions/service-subscription/MSO-vCB/service-instances/service-instance/a1f53c6a-81a3-4e44-a900-d64f3b131d35/allotted-resources/allotted-resource/ID"
+
+ AllottedResourceUtils allottedResourceUtils
+
+ @Before
+ void init(){
+ super.init("AllottedResourceUtils")
+ allottedResourceUtils = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)))
+ when(allottedResourceUtils.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ @Ignore
+ void getARbyId() {
+ String allottedResourceId = "allottedResourceId"
+ AllottedResource expectedAllottedResource = new AllottedResource()
+ expectedAllottedResource.setId("ID")
+ expectedAllottedResource.setResourceVersion("1.2")
+ when(client.get(any(AAIResourceUri.class))).thenReturn(new AAIResultWrapper(expectedAllottedResource))
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
+ when(allottedResourceUtils.setExecutionVariables(mockExecution,expectedAllottedResource,resourceUri)).thenAnswer(new DoesNothing())
+ boolean allottedResource = allottedResourceUtils.ifExistsAR(mockExecution,allottedResourceId)
+ assertTrue(allottedResource)
+ }
+
+ @Test
+ void getARbyLink() {
+ println "************ testGetARbyLink ************* "
+
+ AllottedResource expectedAllottedResource = new AllottedResource()
+ expectedAllottedResource.setId("ID")
+ AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(ALLOTTED_RESOURSE_URI).build())
+ when(client.get(AllottedResource.class, uri)).thenReturn(Optional.of(expectedAllottedResource))
+ Optional<AllottedResource> allottedResource = allottedResourceUtils.getARbyLink(mockExecution, ALLOTTED_RESOURSE_URI,"")
+ assertEquals(expectedAllottedResource.getId(),allottedResource.get().getId())
+ }
+
+ @Test
+ void updateAROrchStatus() {
+ allottedResourceUtils.updateAROrchStatus(mockExecution,"PENDING",ALLOTTED_RESOURSE_URI)
+ }
+
+ @Test
+ void deleteAR() {
+ allottedResourceUtils.deleteAR(mockExecution,ALLOTTED_RESOURSE_URI)
+ verify(mockExecution,atLeastOnce()).setVariable("wasDeleted","true")
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy
deleted file mode 100644
index 39064caa28..0000000000
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy
+++ /dev/null
@@ -1,98 +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.onap.so.bpmn.common.scripts
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.junit.Assert
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mockito
-import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.mock.FileUtil
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
-import static com.github.tomakehurst.wiremock.client.WireMock.get
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.mockito.Mockito.mock
-import static org.mockito.Mockito.mock
-import static org.mockito.Mockito.mock
-import static org.mockito.Mockito.mock
-import static org.mockito.Mockito.when
-import static org.mockito.Mockito.when
-import static org.mockito.Mockito.when
-import static org.mockito.Mockito.when
-import static org.mockito.Mockito.when
-import static org.mockito.Mockito.when
-import static org.mockito.Mockito.when
-
-@RunWith(MockitoJUnitRunner.class)
-class CatalogDbUtilsTest {
-
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8090)
-
- @Test
- public void testGetResponseFromCatalogDb() {
- ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("mso.catalog.db.endpoint")).thenReturn('http://localhost:8090')
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn('757A94191D685FD2092AC1490730A4FC')
- when(mockExecution.getVariable("mso.msoKey")).thenReturn('07a7159d3bf51a0e53be7a8f89699be7')
-
- stubFor(get(urlMatching(".*/serviceNetworks[?]serviceModelUuid=12345"))
- .willReturn(aResponse()
- .withStatus(200)
- .withBodyFile("catalogDbFiles/DoCreateServiceInstance_request.json")))
-
- CatalogDbUtils obj = new CatalogDbUtils()
- String str = obj.getResponseFromCatalogDb(mockExecution, "/serviceNetworks?serviceModelUuid=12345")
- String expectedValue =
- FileUtil.readResourceFile("__files/catalogDbFiles/DoCreateServiceInstance_request.json");
- Assert.assertEquals(expectedValue, str)
-
- }
-
- private ExecutionEntity setupMock() {
-
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("GenericGetService")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("GenericGetService")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("GenericGetService")
- when(mockExecution.getProcessInstanceId()).thenReturn("GenericGetService")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
- return mockExecution
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
index 4b0c33ab99..70068c849b 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
@@ -76,7 +76,7 @@ class CompleteMsoProcessTest {
ExecutionEntity mockExecution = mock(ExecutionEntity.class)
when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoProcessRequest)
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC");
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C");
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess()
@@ -155,28 +155,6 @@ class CompleteMsoProcessTest {
<sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out>
</sdncadapterworkflow:MsoCompletionResponse>"""
- @Test
- void testBuildDataError() {
- // given
- def message = "Some-Message"
-
- def mockExecution = mock ExecutionEntity.class
- when mockExecution.getVariable("CMSO_mso-bpel-name") thenReturn "BPEL-NAME"
- when mockExecution.getVariable("testProcessKey") thenReturn "CompleteMsoProcess"
-
- def completeMsoProcess = new CompleteMsoProcess()
- // when
- assertThatThrownBy { completeMsoProcess.buildDataError(mockExecution, message) } isInstanceOf BpmnError
- // then
- verify mockExecution setVariable("CompleteMsoProcessResponse", msoCompletionResponse)
- def argumentCaptor = ArgumentCaptor.forClass WorkflowException.class
- verify mockExecution setVariable(eq("WorkflowException"), argumentCaptor.capture())
- def capturedException = argumentCaptor.value
-
- assertThat capturedException.processKey isEqualTo "CompleteMsoProcess"
- assertThat capturedException.errorCode isEqualTo 500
- assertThat capturedException.errorMessage isEqualTo message
- }
@Test
void postProcessResponse_successful() {
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy
index 5a01c83a80..e40b877177 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy
@@ -20,106 +20,72 @@
package org.onap.so.bpmn.common.scripts
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+import static com.shazam.shazamcrest.MatcherAssert.assertThat
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*
-
-import org.onap.so.rest.HttpHeader
-import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-import org.mockito.internal.debugging.MockitoDebuggerImpl
-import org.junit.Before
-import org.onap.so.bpmn.common.scripts.AaiUtil;
-import org.junit.Rule;
-import org.junit.Test
-import org.junit.Ignore
-import org.junit.runner.RunWith
-import org.junit.Before;
-import org.junit.Test;
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.junit.Assert
import org.junit.Before
-import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
-import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupTenant
-import org.onap.so.bpmn.core.WorkflowException
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipData
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.constants.Defaults
-import static com.github.tomakehurst.wiremock.client.WireMock.*
-import static org.mockito.Mockito.*
-
-@RunWith(MockitoJUnitRunner.class)
-@Ignore
class ConfirmVolumeGroupTenantTest extends MsoGroovyTest {
@Captor
- ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class);
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8090);
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+ @Before
+ public void init(){
+ super.init("ConfirmVolumeGroupTenant")
+ }
@Test
- public void testpreProcessRequest() {
- ExecutionEntity mockExecution = setupMock()
+ void testpreProcessRequest() {
+ VolumeGroup expectedVolumeGroup = new VolumeGroup();
+ expectedVolumeGroup.setVolumeGroupId("VolumeGroupId")
+ RelationshipList relationshipList = new RelationshipList();
+ Relationship relationship = new Relationship();
+ relationship.setRelatedTo("tenant")
+ RelationshipData data = new RelationshipData();
+ data.setRelationshipKey("tenant.tenant-id")
+ data.setRelationshipValue("tenantId")
+ relationship.setRelatedLink("/cloud-infrastructure/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER.toString() + "/cloudRegionId/tenants/tenant/tenantId")
+ relationship.getRelationshipData().add(data)
+ relationshipList.getRelationship().add(relationship)
+ expectedVolumeGroup.setRelationshipList(relationshipList)
+
+
+ expectedVolumeGroup.setRelationshipList(relationshipList)
+ ConfirmVolumeGroupTenant confirmVolumeGroupTenant = spy(ConfirmVolumeGroupTenant.class)
+ when(confirmVolumeGroupTenant.getAAIClient()).thenReturn(client)
+ when(mockExecution.getVariable("aicCloudRegion")).thenReturn("aicCloudRegionId");
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn("volumeGroupId");
when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090')
- when(mockExecution.getVariable("volumeGroupId")).thenReturn('testVolumeGroupId')
when(mockExecution.getVariable("volumeGroupName")).thenReturn('testVolumeGroupName')
when(mockExecution.getVariable("tenantId")).thenReturn('tenantId')
- when(mockExecution.getVariable("aicCloudRegion")).thenReturn('aicCloudRegion')
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner')
when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
-
-
- mockData()
-
-
- ConfirmVolumeGroupTenant confirmVolumeGroupTenant = new ConfirmVolumeGroupTenant()
+ AAIResourceUri arURI = AAIUriFactory. createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), "aicCloudRegionId","volumeGroupId")
+ AAIResultWrapper wrapper = new AAIResultWrapper(expectedVolumeGroup)
+ when(client.get(arURI)).thenReturn(wrapper)
confirmVolumeGroupTenant.preProcessRequest(mockExecution)
- /* Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture())*/
- verify(mockExecution).setVariable("prefix", "CVGT_")
- verify(mockExecution).setVariable("queryVolumeGroupResponseCode", 200)
- verify(mockExecution).setVariable("queryAAIVolumeGroupResponse", "<volume-group xmlns=\"http://org.openecomp.aai.inventory/v10\"><volume-group-id>17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c</volume-group-id><volume-group-name>MSOTESTVOL103a-vSAMP12_base_module-0_vol</volume-group-name><heat-stack-id>9d1f53e3-3158-44f8-8032-a6bf40bbc9db</heat-stack-id><vnf-type>pcrf-capacity</vnf-type><orchestration-status>Active</orchestration-status><resource-version>0000020</resource-version><relationship-list><relationship><related-to>tenant</related-to><relationship-data><relationship-key>cloud-region.cloud-owner</relationship-key><relationship-value>CloudOwner</relationship-value></relationship-data><relationship-data><relationship-key>cloud-region.cloud-region-id</relationship-key><relationship-value>RegionOne</relationship-value></relationship-data><relationship-data><relationship-key>tenant.tenant-id</relationship-key><relationship-value>22eb191dd41a4f3c9be370fc638322f4</relationship-value></relationship-data></relationship></relationship-list></volume-group>")
- verify(mockExecution).setVariable("tenantIdsMatch", false)
- verify(mockExecution).setVariable("groupNamesMatch", false)
- }
-
-
- private void mockData() {
- stubFor(get(urlMatching("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/aicCloudRegion/volume-groups/volume-group/testVolumeGroupId"))
- .willReturn(aResponse()
- .withStatus(200)
- .withBody("<volume-group xmlns=\"http://org.openecomp.aai.inventory/v10\"><volume-group-id>17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c</volume-group-id><volume-group-name>MSOTESTVOL103a-vSAMP12_base_module-0_vol</volume-group-name><heat-stack-id>9d1f53e3-3158-44f8-8032-a6bf40bbc9db</heat-stack-id><vnf-type>pcrf-capacity</vnf-type><orchestration-status>Active</orchestration-status><resource-version>0000020</resource-version><relationship-list><relationship><related-to>tenant</related-to><relationship-data><relationship-key>cloud-region.cloud-owner</relationship-key><relationship-value>CloudOwner</relationship-value></relationship-data><relationship-data><relationship-key>cloud-region.cloud-region-id</relationship-key><relationship-value>RegionOne</relationship-value></relationship-data><relationship-data><relationship-key>tenant.tenant-id</relationship-key><relationship-value>22eb191dd41a4f3c9be370fc638322f4</relationship-value></relationship-data></relationship></relationship-list></volume-group>")))
- }
-
- private ExecutionEntity setupMock() {
-
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("ConfirmVolumeGroupTenant")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("ConfirmVolumeGroupTenant")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("ConfirmVolumeGroupTenant")
- when(mockExecution.getProcessInstanceId()).thenReturn("ConfirmVolumeGroupTenant")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture())
+ List<ExecutionEntity> executionEntities = captor.getAllValues()
- return mockExecution
+ assertThat(executionEntities.get(3), sameBeanAs(expectedVolumeGroup))
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy
index 999a12c869..886e92bd45 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy
@@ -2,16 +2,17 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2018 Nokia.
* ================================================================================
+ *
* 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.
@@ -22,43 +23,160 @@
package org.onap.so.bpmn.common.scripts
-import joptsimple.internal.Strings
+import static org.assertj.core.api.Assertions.assertThat
+import static org.mockito.ArgumentMatchers.any
+import static org.mockito.ArgumentMatchers.anyObject
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.when
+
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake
import org.junit.Before
import org.junit.Test
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.Spy
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.VfModule
+import org.onap.aai.domain.yang.VfModules
import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.springframework.core.env.Environment
-import static org.assertj.core.api.Assertions.assertThat
-import static org.mockito.Mockito.mock
-import static org.mockito.Mockito.when
+class CreateAAIVfModuleTest extends MsoGroovyTest{
-class CreateAAIVfModuleTest {
-
- private static final String VNF_ID = "vnfIdTest"
- private static final String VNF_TYPE = "vnfTypeTest"
- private static final String VNF_NAME = "testVnf"
- private static final String SERVICE_ID = "123"
- private static final String PERSONAL_MODEL_ID = "modelTest"
- private static final String PERSONAL_MODEL_VERSION = "12"
- private static final String MODEL_CUST_ID = "modelCustIdTest"
- private static final String VNF_PERSONAL_MODEL_ID = "perModIdTest"
- private static final String VNF_PERSONAL_MODEL_VER = "14"
- private static final String VF_MODULE_NAME = "modTestName"
- private static final String VF_MODULE_MODEL_NAME = "modModelNameTest"
- private static final String DEFAULT_AAI_VERSION = "9"
- private static final String DEFAULT_AAI_NAMESPACE = "defaultTestNamespace"
-
- private CreateAAIVfModule testedObject
- private DelegateExecutionFake executionFake
+ private static final String VNF_ID = "vnfIdTest"
+ private static final String VNF_TYPE = "vnfTypeTest"
+ private static final String VNF_NAME = "testVnf"
+ private static final String SERVICE_ID = "123"
+ private static final String PERSONAL_MODEL_ID = "modelTest"
+ private static final String PERSONAL_MODEL_VERSION = "12"
+ private static final String MODEL_CUST_ID = "modelCustIdTest"
+ private static final String VNF_PERSONAL_MODEL_ID = "perModIdTest"
+ private static final String VNF_PERSONAL_MODEL_VER = "14"
+ private static final String VF_MODULE_NAME = "modTestName"
+ private static final String VF_MODULE_MODEL_NAME = "modModelNameTest"
+ private static final String DEFAULT_AAI_VERSION = "9"
+ private static final String DEFAULT_AAI_NAMESPACE = "defaultTestNamespace"
+
+ @Spy
+ CreateAAIVfModule createAAIVfModule ;
+ private DelegateExecutionFake executionFake;
+
@Before
- void setupTest() {
- testedObject = new CreateAAIVfModule()
+ public void init() throws IOException {
+ super.init("CreateAAIVfModule")
+ MockitoAnnotations.initMocks(this);
executionFake = new DelegateExecutionFake()
+ when(createAAIVfModule.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ void testQueryAAIForGenericVnf(){
+ when(mockExecution.getVariable("CAAIVfMod_vnfId")).thenReturn("vnfId1")
+ when(mockExecution.getVariable("CAAIVfMod_vnfName")).thenReturn("vnfName")
+ Optional<GenericVnf> expectedResponse = mockAAIGenericVnf("vnfId1")
+ createAAIVfModule.queryAAIForGenericVnf(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_queryGenericVnfResponseCode", 200)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_queryGenericVnfResponse", expectedResponse.get())
+ }
+
+ @Test
+ void testQueryAAIForGenericVnfNotFound(){
+ when(mockExecution.getVariable("CAAIVfMod_vnfId")).thenReturn("vnfIdNotFound")
+ when(mockExecution.getVariable("CAAIVfMod_vnfName")).thenReturn("vnfName")
+ mockAAIGenericVnfNotFound("vnfIdNotFound")
+ createAAIVfModule.queryAAIForGenericVnf(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_queryGenericVnfResponseCode", 404)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_queryGenericVnfResponse", "Generic Vnf not Found!")
}
+
+ @Test
+ void testCreateGenericVnf(){
+ when(mockExecution.getVariable("CAAIVfMod_vnfName")).thenReturn("vnfName")
+ Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject())
+ createAAIVfModule.createGenericVnf(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_createGenericVnfResponseCode", 201)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_createGenericVnfResponse","Vnf Created")
+ }
+
+
+
@Test
+ void testCreateVfModule(){
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+
+ when(mockExecution.getVariable("CAAIVfMod_personaId")).thenReturn("model1")
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("vfModuleName")
+ Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject())
+ createAAIVfModule.createVfModule(mockExecution,false)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponseCode", 201)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponse","Vf Module Created")
+ }
+
+ @Test
+ void testParseForAddOnModule(){
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("newVfModule")
+ createAAIVfModule.parseForAddOnModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_moduleExists", false)
+ }
+
+ @Test
+ void testParseForAddOnModuleTrue(){
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("testVfModuleNameGWPrim")
+ createAAIVfModule.parseForAddOnModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_moduleExists", true)
+ }
+
+ @Test
+ void testParseForBaseModule(){
+ Optional<GenericVnf> genericVnfOps = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json")
+ GenericVnf genericVnf = genericVnfOps.get()
+ genericVnf.getVfModules().getVfModule().remove(0)
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf)
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("newVfModule")
+ createAAIVfModule.parseForBaseModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_moduleExists", false)
+ }
+
+ @Test
+ void testParseForBaseModuleConflict(){
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("testVfModuleNameGWPrim")
+ when(mockExecution.getVariable("CAAIVfMod_baseModuleConflict")).thenReturn(true)
+ createAAIVfModule.parseForBaseModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_baseModuleConflict", true)
+ }
+
+ @Test
+ void testParseForBaseModuleExists(){
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("newVfModule")
+ when(mockExecution.getVariable("CAAIVfMod_baseModuleConflict")).thenReturn(false)
+ createAAIVfModule.parseForBaseModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_moduleExists", false)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_baseModuleConflict", true)
+ }
+
+ @Test
+ void testCreateVfModuleBase(){
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("vfModuleName")
+ Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject())
+ createAAIVfModule.createVfModule(mockExecution,true)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponseCode", 201)
+ Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponse","Vf Module Created")
+ }
+ @Test
void preProcessRequest_successful() {
//given
prepareUrnPropertiesReader()
@@ -75,7 +193,7 @@ class CreateAAIVfModuleTest {
executionFake.setVariable("vfModuleName", VF_MODULE_NAME)
executionFake.setVariable("vfModuleModelName", VF_MODULE_MODEL_NAME)
//when
- testedObject.preProcessRequest(executionFake)
+ createAAIVfModule.preProcessRequest(executionFake)
//then
assertThat(executionFake.getVariable("CAAIVfMod_vnfId")).isEqualTo(VNF_ID)
assertThat(executionFake.getVariable("CAAIVfMod_vnfName")).isEqualTo(VNF_NAME)
@@ -96,10 +214,10 @@ class CreateAAIVfModuleTest {
@Test
void processAAIGenericVnfQuery_setVnfResponse() {
executionFake.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 200)
- executionFake.setVariable("CAAIVfMod_vnfId", Strings.EMPTY)
+ executionFake.setVariable("CAAIVfMod_vnfId", "")
executionFake.setVariable("CAAIVfMod_vnfName", VNF_NAME)
- testedObject.processAAIGenericVnfQuery(executionFake)
+ createAAIVfModule.processAAIGenericVnfQuery(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_queryGenericVnfResponse"))
.isEqualTo("Invalid request for new Generic VNF which already exists, Vnf Name=" + VNF_NAME)
@@ -110,7 +228,7 @@ class CreateAAIVfModuleTest {
executionFake.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 500)
executionFake.setVariable("CAAIVfMod_vnfId", VNF_ID)
- testedObject.processAAIGenericVnfQuery(executionFake)
+ createAAIVfModule.processAAIGenericVnfQuery(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_createVfModuleResponse"))
.isEqualTo("Invalid request for Add-on Module requested for non-existant Generic VNF, VNF Id=" + VNF_ID)
@@ -118,12 +236,18 @@ class CreateAAIVfModuleTest {
@Test
void parseForAddOnModule_moduleNameFound() {
- String xml = "<CAAIVfMod_queryGenericVnfResponse><vnf-name>" + VNF_NAME + "</vnf-name>" +
- "<vf-module-name>" + VF_MODULE_NAME + "</vf-module-name></CAAIVfMod_queryGenericVnfResponse>"
- executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", xml)
+
+ GenericVnf vnf = new GenericVnf();
+ VfModule module = new VfModule();
+ VfModules modules = new VfModules();
+ vnf.setVnfName(VNF_NAME)
+ vnf.setVfModules(modules)
+ modules.getVfModule().add(module)
+ module.setVfModuleName(VF_MODULE_NAME)
+ executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", vnf)
executionFake.setVariable("CAAIVfMod_moduleName", VF_MODULE_NAME)
- testedObject.parseForAddOnModule(executionFake)
+ createAAIVfModule.parseForAddOnModule(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME)
assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(true)
@@ -133,13 +257,13 @@ class CreateAAIVfModuleTest {
@Test
void parseForAddOnModule_moduleNameNotFound() {
- String xml = "<CAAIVfMod_queryGenericVnfResponse><vnf-name>" + VNF_NAME + "</vnf-name>" +
- "</CAAIVfMod_queryGenericVnfResponse>"
- executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", xml)
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfName(VNF_NAME)
+ executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", vnf)
executionFake.setVariable("CAAIVfMod_moduleName", VF_MODULE_NAME)
executionFake.setVariable("CAAIVfMod_moduleExists", false)
- testedObject.parseForAddOnModule(executionFake)
+ createAAIVfModule.parseForAddOnModule(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME)
assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false)
@@ -149,12 +273,17 @@ class CreateAAIVfModuleTest {
@Test
void parseForBaseModule_moduleNameFound() {
- String xml = "<CAAIVfMod_queryGenericVnfResponse><vnf-name>" + VNF_NAME + "</vnf-name>" +
- "<vf-module-name>" + VF_MODULE_NAME + "</vf-module-name></CAAIVfMod_queryGenericVnfResponse>"
- executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", xml)
+ GenericVnf vnf = new GenericVnf();
+ VfModule module = new VfModule();
+ VfModules modules = new VfModules();
+ vnf.setVnfName(VNF_NAME)
+ vnf.setVfModules(modules)
+ modules.getVfModule().add(module)
+ module.setVfModuleName(VF_MODULE_NAME)
+ executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", vnf)
executionFake.setVariable("CAAIVfMod_moduleName", VF_MODULE_NAME)
- testedObject.parseForBaseModule(executionFake)
+ createAAIVfModule.parseForBaseModule(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME)
assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false)
@@ -165,12 +294,19 @@ class CreateAAIVfModuleTest {
@Test
void parseForBaseModule_isBaseVfModule() {
- String xml = "<CAAIVfMod_queryGenericVnfResponse><vnf-name>" + VNF_NAME + "</vnf-name>" +
- "<is-base-vf-module>true</is-base-vf-module></CAAIVfMod_queryGenericVnfResponse>"
- executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", xml)
+ GenericVnf vnf = new GenericVnf();
+ VfModule module = new VfModule();
+ VfModules modules = new VfModules();
+ vnf.setVfModules(modules)
+ vnf.setVnfName(VNF_NAME)
+ modules.getVfModule().add(module)
+ module.setVfModuleName(VF_MODULE_NAME)
+ module.setIsBaseVfModule(true)
+
+ executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", vnf)
executionFake.setVariable("CAAIVfMod_baseModuleConflict", false)
- testedObject.parseForBaseModule(executionFake)
+ createAAIVfModule.parseForBaseModule(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME)
assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false)
@@ -181,12 +317,13 @@ class CreateAAIVfModuleTest {
@Test
void parseForBaseModule_baseModuleConflictIsFalse() {
- String xml = "<CAAIVfMod_queryGenericVnfResponse><vnf-name>" + VNF_NAME + "</vnf-name></CAAIVfMod_queryGenericVnfResponse>"
- executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", xml)
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfName(VNF_NAME)
+ executionFake.setVariable("CAAIVfMod_queryGenericVnfResponse", vnf)
executionFake.setVariable("CAAIVfMod_baseModuleConflict", false)
executionFake.setVariable("CAAIVfMod_moduleName", VF_MODULE_NAME)
- testedObject.parseForBaseModule(executionFake)
+ createAAIVfModule.parseForBaseModule(executionFake)
assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME)
assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false)
@@ -201,5 +338,4 @@ class CreateAAIVfModuleTest {
UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader()
urnPropertiesReader.setEnvironment(mockEnvironment)
}
-
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy
new file mode 100644
index 0000000000..ea38ed8c83
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy
@@ -0,0 +1,119 @@
+/*-
+ * ============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.common.scripts
+
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.doThrow
+import static org.mockito.Mockito.when
+
+import org.junit.Before
+import org.junit.Test
+import org.mockito.Mockito
+import org.mockito.Spy
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.constants.Defaults
+
+class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{
+
+ @Spy
+ CreateAAIVfModuleVolumeGroup createAAIVfModuleVolumeGroup;
+
+ @Before
+ void init(){
+ super.init("CreateAAIVfModuleVolumeGroup")
+ when(createAAIVfModuleVolumeGroup.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ void testGetVfModule (){
+ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123")
+ when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123")
+ org.onap.aai.domain.yang.VfModule vfModuleExpected = new org.onap.aai.domain.yang.VfModule()
+ vfModuleExpected.setVfModuleId("VfModule123")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123");
+ when(client.get(org.onap.aai.domain.yang.VfModule.class,resourceUri)).thenReturn(Optional.of(vfModuleExpected))
+ createAAIVfModuleVolumeGroup.getVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponseCode", 200)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponse", vfModuleExpected)
+ }
+
+ @Test
+ void testGetVfModuleNotFound (){
+ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123")
+ when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123");
+ when(client.get(org.onap.aai.domain.yang.VfModule.class,resourceUri)).thenReturn(Optional.empty())
+ createAAIVfModuleVolumeGroup.getVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponseCode", 404)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponse", "VF-Module Not found!!")
+ }
+
+ @Test
+ void testGetVfModuleException (){
+ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123")
+ when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123");
+ when(client.get(org.onap.aai.domain.yang.VfModule.class,resourceUri)).thenThrow(new NullPointerException("Error in AAI client"))
+ createAAIVfModuleVolumeGroup.getVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponseCode", 500)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponse", "AAI GET Failed:Error in AAI client")
+ }
+
+ @Test
+ void testUpdateVfModule (){
+ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123")
+ when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123")
+ when(mockExecution.getVariable("CAAIVfModVG_aicCloudRegion")).thenReturn("CloudRegion1")
+ when(mockExecution.getVariable("CAAIVfModVG_volumeGroupId")).thenReturn("VolumeGroup1")
+ when(mockExecution.getVariable("CAAIVfModVG_cloudOwner")).thenReturn("cloudOwner")
+ org.onap.aai.domain.yang.VfModule vfModuleExpected = new org.onap.aai.domain.yang.VfModule()
+ vfModuleExpected.setVfModuleId("VfModule123")
+ vfModuleExpected.setResourceVersion("12345")
+ when(mockExecution.getVariable("CAAIVfModVG_getVfModuleResponse")).thenReturn(vfModuleExpected)
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123");
+ AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(),"CloudRegion1", "VolumeGroup1")
+ doNothing().when(client).connect(resourceUri ,resourceUri1 )
+ createAAIVfModuleVolumeGroup.updateVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_updateVfModuleResponseCode", 200)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_updateVfModuleResponse", "Success")
+ }
+
+ @Test
+ void testUpdateVfModuleAAIException (){
+ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123")
+ when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123")
+ when(mockExecution.getVariable("CAAIVfModVG_aicCloudRegion")).thenReturn("CloudRegion1")
+ when(mockExecution.getVariable("CAAIVfModVG_volumeGroupId")).thenReturn("VolumeGroup1")
+ org.onap.aai.domain.yang.VfModule vfModuleExpected = new org.onap.aai.domain.yang.VfModule()
+ vfModuleExpected.setVfModuleId("VfModule123")
+ vfModuleExpected.setResourceVersion("12345")
+ when(mockExecution.getVariable("CAAIVfModVG_cloudOwner")).thenReturn("cloudOwner")
+ when(mockExecution.getVariable("CAAIVfModVG_getVfModuleResponse")).thenReturn(vfModuleExpected)
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123");
+ AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, 'cloudOwner',"CloudRegion1", "VolumeGroup1")
+ doThrow(new NullPointerException("Error in AAI client")).when(client).connect(resourceUri ,resourceUri1 )
+ createAAIVfModuleVolumeGroup.updateVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_updateVfModuleResponseCode", 500)
+ Mockito.verify(mockExecution).setVariable("CAAIVfModVG_updateVfModuleResponse", 'AAI PUT Failed:'+ "Error in AAI client")
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
index 025bea5325..4b6f8aa918 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
@@ -20,125 +20,157 @@
package org.onap.so.bpmn.common.scripts
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+import static org.mockito.Mockito.*
+
+import javax.ws.rs.NotFoundException
+
import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake
import org.junit.Assert
import org.junit.Before
-import org.junit.Ignore
-import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
-import org.mockito.Mock
import org.mockito.Mockito
-import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.Spy
+import org.onap.aai.domain.yang.GenericVnf
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.mock.StubResponseAAI
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*
-import static org.mockito.Mockito.*
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
-@RunWith(MockitoJUnitRunner.class)
-@Ignore
-class DeleteAAIVfModuleTest {
+class DeleteAAIVfModuleTest extends MsoGroovyTest{
def prefix = "DAAIVfMod_"
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
+ @Spy
+ DeleteAAIVfModule deleteAAIVfModule ;
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
@Before
void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ super.init("DeleteAAIVfModule")
+ when(deleteAAIVfModule.getAAIClient()).thenReturn(client)
}
@Test
void testQueryAAIForGenericVnf() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("prefix")).thenReturn(prefix)
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf/skask")
- when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
-
- StubResponseAAI.MockAAIVfModule()
- DeleteAAIVfModule obj = new DeleteAAIVfModule()
- obj.queryAAIForGenericVnf(mockExecution)
-
+ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
+ mockAAIGenericVnf("vnfId1")
+ deleteAAIVfModule.queryAAIForGenericVnf(mockExecution)
Mockito.verify(mockExecution).setVariable(prefix + "queryGenericVnfResponseCode", 200)
}
@Test
- void testQueryAAIForGenericVnfEndpointNull() {
+ void testQueryAAIForGenericVnfNotFound() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf/skask")
- when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
- when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
-
- StubResponseAAI.MockAAIVfModule()
+ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
+ mockAAIGenericVnfNotFound("vnfId1")
+ deleteAAIVfModule.queryAAIForGenericVnf(mockExecution)
+ Mockito.verify(mockExecution).setVariable(prefix + "queryGenericVnfResponseCode", 404)
+ }
+ @Test
+ void testQueryAAIForGenericVnfEndpointNull() {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("DAAIVfMod_vnfId", "vnfId1")
try {
- DeleteAAIVfModule obj = new DeleteAAIVfModule()
- obj.queryAAIForGenericVnf(mockExecution)
+ deleteAAIVfModule.queryAAIForGenericVnf(execution)
} catch (Exception ex) {
println " Test End - Handle catch-throw BpmnError()! "
}
- Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture())
- WorkflowException workflowException = captor.getValue()
- Assert.assertEquals(5000, workflowException.getErrorCode())
- Assert.assertEquals("Internal Error - Occured during queryAAIForGenericVnf", workflowException.getErrorMessage())
+ Assert.assertEquals(404, execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode"))
+ Assert.assertEquals("Vnf Not Found!", execution.getVariable("DAAIVfMod_queryGenericVnfResponse"))
}
@Test
void testDeleteGenericVnf() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
- when(mockExecution.getVariable(prefix + "genVnfRsrcVer")).thenReturn("0000020")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
-
- stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987/[?]resource-version=0000020"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("")))
-
- StubResponseAAI.MockAAIVfModule()
- DeleteAAIVfModule obj = new DeleteAAIVfModule()
- obj.deleteGenericVnf(mockExecution)
-
+ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
+ doNothing().when(client).delete(isA(AAIResourceUri.class))
+ deleteAAIVfModule.deleteGenericVnf(mockExecution)
Mockito.verify(mockExecution).setVariable(prefix + "deleteGenericVnfResponseCode", 200)
}
@Test
+ void testParseForVfModule() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("testVfModuleIdGWSec")
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("DAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ deleteAAIVfModule.parseForVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_moduleExists", true)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isBaseModule", false)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isLastModule", false)
+ }
+
+ @Test
+ void testParseForVfModuleNotFound() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("notFound")
+ when(mockExecution.getVariable("DAAIVfMod_moduleExists")).thenReturn(false)
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("DAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ deleteAAIVfModule.parseForVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_moduleExists", false)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isBaseModule", false)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isLastModule", false)
+ }
+
+ @Test
+ void testParseForVfModuleBase() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("lukewarm")
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ when(mockExecution.getVariable("DAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
+ deleteAAIVfModule.parseForVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_moduleExists", true)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isBaseModule", true)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isLastModule", false)
+ }
+
+ @Test
+ void testParseForVfModuleLast() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("testVfModuleIdGWSec")
+ Optional<GenericVnf> genericVnfOps = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ GenericVnf genericVnf = genericVnfOps.get();
+ genericVnf.getVfModules().getVfModule().remove(0)
+ when(mockExecution.getVariable("DAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf)
+ deleteAAIVfModule.parseForVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_moduleExists", true)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isBaseModule", false)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isLastModule", true)
+ }
+
+ @Test
+ void testParseForVfModuleBaseLast() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("lukewarm")
+ Optional<GenericVnf> genericVnfOps = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
+ GenericVnf genericVnf = genericVnfOps.get();
+ genericVnf.getVfModules().getVfModule().remove(1)
+ when(mockExecution.getVariable("DAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf)
+ deleteAAIVfModule.parseForVfModule(mockExecution)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_moduleExists", true)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isBaseModule", true)
+ Mockito.verify(mockExecution).setVariable("DAAIVfMod_isLastModule", true)
+ }
+
+
+
+ @Test
void testDeleteGenericVnfEndpointNull() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
- when(mockExecution.getVariable(prefix + "genVnfRsrcVer")).thenReturn("0000020")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
- when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
-
- StubResponseAAI.MockAAIVfModule()
+ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
try {
- DeleteAAIVfModule obj = new DeleteAAIVfModule()
- obj.deleteGenericVnf(mockExecution)
+ doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class))
+ deleteAAIVfModule.deleteGenericVnf(mockExecution)
} catch (Exception ex) {
println " Test End - Handle catch-throw BpmnError()! "
}
@@ -152,39 +184,21 @@ class DeleteAAIVfModuleTest {
@Test
void testDeleteVfModule() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable(prefix + "vfModuleEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
- when(mockExecution.getVariable(prefix + "vfModRsrcVer")).thenReturn("0000020")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
-
- stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987/[?]resource-version=0000020"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("")))
-
- DeleteAAIVfModule obj = new DeleteAAIVfModule()
- obj.deleteVfModule(mockExecution)
-
+ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("vfModuleId1")
+ doNothing().when(client).delete(isA(AAIResourceUri.class))
+ deleteAAIVfModule.deleteVfModule(mockExecution)
Mockito.verify(mockExecution).setVariable(prefix + "deleteVfModuleResponseCode", 200)
}
@Test
void testDeleteVfModuleEndpointNull() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable(prefix + "vfModuleEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
- when(mockExecution.getVariable(prefix + "vfModRsrcVer")).thenReturn("0000020")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
- when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
-
- StubResponseAAI.MockAAIVfModule()
+ when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
+ when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("vfModuleId1")
try {
- DeleteAAIVfModule obj = new DeleteAAIVfModule()
- obj.deleteVfModule(mockExecution)
+ doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class))
+ deleteAAIVfModule.deleteVfModule(mockExecution)
} catch (Exception ex) {
println " Test End - Handle catch-throw BpmnError()! "
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
index 016d968a12..25f62a6555 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
@@ -72,7 +72,7 @@ class FalloutHandlerTest {
ExecutionEntity mockExecution = mock(ExecutionEntity.class)
when(mockExecution.getVariable("FalloutHandlerRequest")).thenReturn(falloutHandlerRequest)
- when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC");
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C");
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
FalloutHandler falloutHandler = new FalloutHandler()
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
index 19638f42da..de44caa120 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common.scripts
@@ -29,16 +29,30 @@ import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Rule
import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
-import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.junit.MockitoJUnitRunner
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.entities.uri.Depth
+import org.onap.so.constants.Defaults
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
abstract class MsoGroovyTest {
@Rule
public ExpectedException thrown = ExpectedException.none()
+
protected ExecutionEntity mockExecution
protected AAIResourcesClient client
+ protected AllottedResourceUtils allottedResourceUtils_MOCK
+ protected final String SEARCH_RESULT_AAI_WITH_RESULTDATA =
+ FileUtil.readResourceFile("__files/aai/searchResults.json")
+ protected static final String CLOUD_OWNER = Defaults.CLOUD_OWNER.toString();
protected void init(String procName){
mockExecution = setupMock(procName)
@@ -49,14 +63,91 @@ abstract class MsoGroovyTest {
protected ExecutionEntity setupMock(String procName) {
ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
when(mockProcessDefinition.getKey()).thenReturn(procName)
+
RepositoryService mockRepositoryService = mock(RepositoryService.class)
when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName)
when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+
ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+
ExecutionEntity mockExecution = mock(ExecutionEntity.class)
when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+
+ return mockExecution
+ }
+
+ protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class)
+ RepositoryService repositoryService = mock(RepositoryService.class)
+ ProcessDefinition processDefinition = mock(ProcessDefinition.class)
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices)
+ when(processEngineServices.getRepositoryService()).thenReturn(repositoryService)
+ when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition)
+ when(processDefinition.getKey()).thenReturn(procName)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
return mockExecution
}
+
+ protected <T> Optional<T> getAAIObjectFromJson(Class<T> clazz , String file){
+ String json = FileUtil.readResourceFile(file)
+ AAIResultWrapper resultWrapper = new AAIResultWrapper(json)
+ return resultWrapper.asBean(clazz)
+ }
+
+ protected Optional<GenericVnf> mockAAIGenericVnf(String vnfId){
+ return mockAAIGenericVnf(vnfId,"__files/aai/GenericVnf.json")
+ }
+
+ protected Optional<GenericVnf> mockAAIGenericVnf(String vnfId,String file){
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,file);
+ when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf)
+ when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf)
+ return genericVnf
+ }
+
+ protected Optional<GenericVnf> mockAAIGenericVnfByName(String vnfName){
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)
+ AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE)
+ Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnf.json");
+ when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf)
+ when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf)
+ return genericVnf
+ }
+
+ protected void mockAAIGenericVnfNotFound(String vnfId){
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
+ AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
+ when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty())
+ when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty())
+ }
+
+ protected void mockAAIGenericVnfByNameNotFound(String vnfName){
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)
+ AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE)
+ when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty())
+ when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty())
+ }
+
+ protected AAIResultWrapper mockVolumeGroupWrapper(String region, String volumeGroupId, String file){
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, region,volumeGroupId)
+ String json = FileUtil.readResourceFile(file)
+ AAIResultWrapper resultWrapper = new AAIResultWrapper(json)
+ when(client.get(resourceUri)).thenReturn(resultWrapper)
+ return resultWrapper
+ }
+
+ void initAR(String procName){
+ init(procName)
+ allottedResourceUtils_MOCK = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)))
+ when(allottedResourceUtils_MOCK.getAAIClient()).thenReturn(client)
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
index dfcf69a931..dfaf5d2140 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
@@ -20,23 +20,15 @@
package org.onap.so.bpmn.common.scripts
-// JUnit 4
-import org.junit.Test
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-
-import static groovy.test.GroovyAssert.shouldFail
-
import groovy.util.slurpersupport.NodeChild
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Test
+import org.onap.so.bpmn.common.scripts.MsoUtils
-import static groovy.test.GroovyAssert.assertTrue
import static groovy.test.GroovyAssert.assertEquals
-import static groovy.test.GroovyAssert.assertNotNull;
-
-import org.onap.so.bpmn.common.scripts.MsoUtils;
-import org.apache.commons.lang3.*
+// JUnit 4
class MsoUtilsTest {
@@ -198,22 +190,20 @@ class MsoUtilsTest {
@Test
public void testGetBasicAuth(){
- def encodedAuth = utils.getBasicAuth("3E3CFA7BE2F6107AAD4AAA65F8976690","07a7159d3bf51a0e53be7a8f89699be7")
+ def encodedAuth = utils.getBasicAuth(utils.encrypt("myString","07a7159d3bf51a0e53be7a8f89699be7"),"07a7159d3bf51a0e53be7a8f89699be7")
assertEquals("Basic bXlTdHJpbmc=", encodedAuth)
}
@Test
public void testEncrypt(){
def encrypted = utils.encrypt("myString","07a7159d3bf51a0e53be7a8f89699be7")
- assertEquals("3E3CFA7BE2F6107AAD4AAA65F8976690", encrypted)
+ assertEquals("myString", utils.decrypt(encrypted,"07a7159d3bf51a0e53be7a8f89699be7"))
- //use to get value for urn properties
- //println(utils.encrypt("password"))
}
@Test
public void testDecrypt(){
- def decrypted = utils.decrypt("3E3CFA7BE2F6107AAD4AAA65F8976690", "07a7159d3bf51a0e53be7a8f89699be7")
+ def decrypted = utils.decrypt(utils.encrypt("myString","07a7159d3bf51a0e53be7a8f89699be7"), "07a7159d3bf51a0e53be7a8f89699be7")
assertEquals("myString", decrypted)
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy
index 1079bb48b3..e79075a1a1 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy
@@ -51,7 +51,7 @@ public class SDNCAdapterRestV1Test {
when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
- when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
@@ -88,7 +88,7 @@ public class SDNCAdapterRestV1Test {
when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
- when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy
index d7fe0ee208..c9e3fead67 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy
@@ -51,7 +51,7 @@ public class SDNCAdapterRestV2Test {
when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
- when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
@@ -88,7 +88,7 @@ public class SDNCAdapterRestV2Test {
when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
- when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
index 18d65d00d8..bf0f2d20c0 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
@@ -31,13 +31,13 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.internal.debugging.MockitoDebuggerImpl
import org.onap.so.bpmn.common.scripts.SDNCAdapter;
import org.onap.so.bpmn.mock.FileUtil
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCAdapterTest {
@Before
@@ -821,7 +821,7 @@ def sdncAdapterResponseError =
String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1/sdncadapterworkflowrequest.xml");
ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("sdncAdapterWorkflowRequest")).thenReturn(sdncAdapterWorkflowRequest)
when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://someurl.someting.com:28080/mso/sdncAdapterCallbackServiceImpl")
@@ -842,12 +842,12 @@ def sdncAdapterResponseError =
verify(mockExecution).setVariable("sdncAdapterResponse","")
verify(mockExecution).setVariable("asynchronousResponseTimeout",false)
verify(mockExecution).setVariable("continueListening",false)
- verify(mockExecution).setVariable("BasicAuthHeaderValue","Basic cGFzc3dvcmQ=")
verify(mockExecution).setVariable("serviceConfigActivate",false)
verify(mockExecution).setVariable("SDNCA_requestId", "745b1b50-e39e-4685-9cc8-c71f0bde8bf0")
verify(mockExecution).setVariable("SDNCA_SuccessIndicator",false)
- verify(mockExecution).setVariable("source","")
verify(mockExecution).setVariable("SDNCA_InterimNotify",false)
+ verify(mockExecution).setVariable("BasicAuthHeaderValue","Basic dGVzdDp0ZXN0")
+ verify(mockExecution).setVariable("source","")
verify(mockExecution).setVariable("sdncAdapterRequest", sdncAdapterRequest)
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
index 803e2b03a3..ef71e9073b 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.*
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
+import org.junit.runner.RunWith
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.delegate.DelegateExecution
@@ -34,6 +35,9 @@ import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.mock.FileUtil
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCAdapterUtilsTest {
private def map
@@ -59,14 +63,14 @@ public class SDNCAdapterUtilsTest {
// svcex gets its variables from "map"
when(svcex.getVariable(any())).thenAnswer(
{ invocation ->
- return map.get(invocation.getArgumentAt(0, String.class)) })
+ return map.get(invocation.getArgument(0)) })
// svcex puts its variables into "map"
when(svcex.setVariable(any(), any())).thenAnswer(
{ invocation ->
return map.put(
- invocation.getArgumentAt(0, String.class),
- invocation.getArgumentAt(1, String.class)) })
+ invocation.getArgument(0),
+ invocation.getArgument(1)) })
map.put("isDebugLogEnabled", "true")
map.put("prefix", "mypfx-")
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
index 407ffa2915..cb9bb5c541 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
@@ -20,34 +20,37 @@
package org.onap.so.bpmn.common.scripts
-import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import org.junit.rules.ExpectedException
+
+import static org.mockito.Mockito.*
+
+import javax.ws.rs.NotFoundException
+
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.junit.Assert
import org.junit.Before
-import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
-import org.mockito.Mockito
import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.mock.FileUtil
-import org.onap.so.bpmn.mock.StubResponseAAI
+import org.mockito.Spy
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.aai.domain.yang.VfModule
-import static org.mockito.Mockito.*
+import com.github.tomakehurst.wiremock.junit.WireMockRule
-@RunWith(MockitoJUnitRunner.class)
-@Ignore
-class UpdateAAIVfModuleTest {
+class UpdateAAIVfModuleTest extends MsoGroovyTest {
def prefix = "UAAIVfMod_"
@Rule
+ public ExpectedException thrown = ExpectedException.none();
+ @Spy
+ UpdateAAIVfModule updateAAIVfModule;
+
+ @Rule
public WireMockRule wireMockRule = new WireMockRule(28090)
@Captor
@@ -55,121 +58,92 @@ class UpdateAAIVfModuleTest {
@Before
void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ super.init("UpdateAAIVfModule")
+ when(updateAAIVfModule.getAAIClient()).thenReturn(client)
}
@Test
void testGetVfModule() {
- ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
-
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
- when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
-
- StubResponseAAI.MockAAIVfModule()
- UpdateAAIVfModule obj = new UpdateAAIVfModule()
- obj.getVfModule(mockExecution)
-
+ VfModule vfModule = new VfModule()
+ vfModule.setVfModuleId("supercool")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "skask", "supercool");
+ when(client.get(VfModule.class,resourceUri)).thenReturn(Optional.of(vfModule))
+ updateAAIVfModule.getVfModule(mockExecution)
verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 200)
+ verify(mockExecution).setVariable(prefix + "getVfModuleResponse", vfModule)
}
@Test
- void testGetVfModuleEndpointNull() {
- ExecutionEntity mockExecution = setupMock()
+ void testGetVfModuleNotFound() {
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "skask", "supercool");
+ when(client.get(VfModule.class,resourceUri)).thenReturn(Optional.empty())
+ updateAAIVfModule.getVfModule(mockExecution)
+ verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 404)
+ verify(mockExecution).setVariable(prefix + "getVfModuleResponse", "VF Module not found in AAI")
+ }
- when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
- when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
-
- StubResponseAAI.MockAAIVfModule()
- try {
- UpdateAAIVfModule obj = new UpdateAAIVfModule()
- obj.getVfModule(mockExecution)
- } catch (Exception ex) {
- println " Test End - Handle catch-throw BpmnError()! "
- }
-
- Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
- WorkflowException workflowException = captor.getAllValues().get(1)
- Assert.assertEquals(9999, workflowException.getErrorCode())
- Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ @Test
+ void testGetVfModuleException() {
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "skask", "supercool");
+ when(client.get(VfModule.class,resourceUri)).thenThrow(new NullPointerException("Error from AAI client"))
+ updateAAIVfModule.getVfModule(mockExecution)
+ verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 500)
+ verify(mockExecution).setVariable(prefix + "getVfModuleResponse", "AAI GET Failed:"+"Error from AAI client")
}
+
@Test
void testUpdateVfModule() {
- ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
-
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
- when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
-
- String getVfModuleResponse = FileUtil.readResourceFile("__files/VfModularity/GenericVnf.xml")
- when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(getVfModuleResponse)
- StubResponseAAI.MockAAIVfModule()
- UpdateAAIVfModule obj = new UpdateAAIVfModule()
- obj.updateVfModule(mockExecution)
-
- verify(mockExecution).setVariable(prefix + "updateVfModuleResponseCode", 200)
+ VfModule vfModule = new VfModule()
+ vfModule.setVfModuleId("supercool")
+ vfModule.setResourceVersion("12345")
+ when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
+ doNothing().when(client).update(isA(AAIResourceUri.class), anyObject())
+ updateAAIVfModule.updateVfModule(mockExecution)
}
@Test
- void testUpdateVfModuleEndpointNull() {
- ExecutionEntity mockExecution = setupMock()
+ void testUpdateVfModuleNotFound() throws BpmnError {
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
-
- when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
- when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
-
- String getVfModuleResponse = FileUtil.readResourceFile("__files/VfModularity/GenericVnf.xml")
- when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(getVfModuleResponse)
- StubResponseAAI.MockAAIVfModule()
- try {
- UpdateAAIVfModule obj = new UpdateAAIVfModule()
- obj.updateVfModule(mockExecution)
- } catch (Exception ex) {
- println " Test End - Handle catch-throw BpmnError()! "
- }
-
- Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
- WorkflowException workflowException = captor.getAllValues().get(1)
- Assert.assertEquals(9999, workflowException.getErrorCode())
- Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ VfModule vfModule = new VfModule()
+ vfModule.setVfModuleId("supercool")
+ vfModule.setResourceVersion("12345")
+ when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
+ doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class), anyObject())
+ thrown.expect(BpmnError.class)
+ updateAAIVfModule.updateVfModule(mockExecution)
}
- private static ExecutionEntity setupMock() {
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("UpdateAAIVfModule")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateAAIVfModule")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- // Initialize prerequisite variables
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("UpdateAAIVfModule")
- when(mockExecution.getProcessInstanceId()).thenReturn("UpdateAAIVfModule")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
-
- return mockExecution
+
+ @Test
+ void testUpdateVfModuleException() {
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ VfModule vfModule = new VfModule()
+ vfModule.setVfModuleId("supercool")
+ vfModule.setResourceVersion("12345")
+ when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
+ doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class), anyObject())
+ thrown.expect(BpmnError.class)
+ updateAAIVfModule.updateVfModule(mockExecution)
+
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
index 22c8e297ca..77edd2dc6d 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
@@ -50,7 +50,7 @@ public class VnfAdapterRestV1Test {
when(mockExecution.getVariable("prefix")).thenReturn("VNFREST_")
when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
when(mockExecution.getVariable("VNFREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
- when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("mso.adapters.vnf.rest.endpoint")).thenReturn("http://localhost:18080/vnfs/rest/v1/vnfs")
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
index 119d3b1e2d..5d6f98c907 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
@@ -29,13 +29,10 @@ import java.util.Map;
import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.model.bpmn.Bpmn;
-import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.junit.Before;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.common.InjectionHelper;
-import org.onap.so.bpmn.common.MockLoggerDelegate;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupMapperLayer;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
@@ -44,7 +41,7 @@ import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.test.categories.SpringAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
@@ -146,21 +143,5 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup {
protected String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
- /**
- * Create and deploy a process model with one logger delegate as service task.
- *
- * @param origProcessKey
- * key to call
- * @param mockProcessName
- * process name
- * @param fileName
- * file name without extension
- */
- protected void mockSubprocess(String origProcessKey, String mockProcessName, String fileName) {
- BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(origProcessKey).name(mockProcessName)
- .startEvent().name("Start Point").serviceTask().name("Log Something for Test")
- .camundaClass(MockLoggerDelegate.class.getName()).endEvent().name("End Point").done();
- repositoryService.createDeployment().addModelInstance(fileName + ".bpmn", modelInstance).deploy();
- }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
index 5be879560f..0398c87d69 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
@@ -168,7 +168,11 @@ public class BuildingBlockTestDataSetup{
dataMap.put("vpnRegion","testVpnRegion");
dataMap.put("vpnRt","testVpnRt");
dataMap.put("vpnName","vpnName");
- dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"}));
+ ArrayList<String> vpnRegions = new ArrayList<String>();
+ vpnRegions.add("USA");
+ vpnRegions.add("EMEA");
+ vpnRegions.add("APAC");
+ dataMap.put("vpnRegion", vpnRegions);
HashMap<String,Object> userParams = new HashMap<>();
userParams.put("vpnData",dataMap);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
index a29df9cbcf..fb08e5e830 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -23,7 +23,7 @@ import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
new file mode 100644
index 0000000000..85507afd3f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.recipe;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.onap.so.BaseTest;
+import org.springframework.beans.factory.annotation.Autowired;
+import java.io.IOException;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class BpmnRestClientTest extends BaseTest{
+
+ @Autowired
+ private BpmnRestClient bpmnRestClient;
+
+ @Test
+ public void postTest() throws IOException, Exception{
+ stubFor(post(urlPathMatching("/testRecipeUri"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.OK.value()).withBody("{}")));
+
+ HttpResponse httpResponse = bpmnRestClient.post(
+ "http://localhost:" + wireMockPort +"/testRecipeUri",
+ "test-req-id",
+ 1000,
+ "testRequestAction",
+ "1234",
+ "testServiceType",
+ "testRequestDetails",
+ "testRecipeparamXsd");
+
+ assertNotNull(httpResponse);
+ assertEquals(HttpStatus.SC_OK,httpResponse.getStatusLine().getStatusCode());
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java
index cbde63e933..76bc830d26 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java
@@ -20,21 +20,22 @@
package org.onap.so.bpmn.common.util;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.onap.so.BaseTest;
+
+import static org.junit.Assert.assertEquals;
public class CryptoHandlerTest {
private static final String plainPswd = "mso0206";
- private static final String encryptPwd = "C1FC4A39E16419DD41DFC1212843F440";
private CryptoHandler cryptoHandler;
-
+ private static String encryptPwd;
+
+
@Before
public void setup() {
cryptoHandler = new CryptoHandler();
+ encryptPwd = cryptoHandler.encryptMsoPassword(plainPswd);
}
@Test
@@ -45,7 +46,7 @@ public class CryptoHandlerTest {
@Test
public void encryptMsoPasswordTest() {
- assertEquals(encryptPwd, cryptoHandler.encryptMsoPassword(plainPswd));
+ assertEquals(plainPswd,cryptoHandler.decryptMsoPassword(cryptoHandler.encryptMsoPassword(plainPswd)));
}
@Test
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
new file mode 100644
index 0000000000..9478b8f1f6
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============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.common.validation;
+
+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 java.util.Arrays;
+import java.util.List;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ValidationConfig.class})
+public class BuildingBlockValidatorRunnerTest {
+
+ @Rule
+ public ExpectedException thrown= ExpectedException.none();
+
+ @Autowired
+ private BuildingBlockValidatorRunner runner;
+
+ @Test
+ public void filterValidatorTest() {
+
+ MyPreValidatorOne one = new MyPreValidatorOne();
+ MyPreValidatorTwo two = new MyPreValidatorTwo();
+ MyPreValidatorThree three = new MyPreValidatorThree();
+ List<BuildingBlockValidator> validators = Arrays.asList(one, two, three);
+
+ List<BuildingBlockValidator> result = runner.filterValidators(validators, "test");
+
+ List<BuildingBlockValidator> expected = Arrays.asList(two, one);
+
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testValidate() {
+
+ BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ execution.setVariable("testProcessKey", "1234");
+ try {
+ runner.preValidate("test", execution);
+ fail("exception not thrown");
+ } catch (BpmnError e) {
+ WorkflowException workflowException = execution.getVariable("WorkflowException");
+ assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo\norg.onap.so.bpmn.common.validation.MyPreValidatorOne", workflowException.getErrorMessage());
+ }
+ runner.preValidate("test2", mock(BuildingBlockExecution.class));
+ }
+
+ @Test
+ public void testEmptyList() {
+ boolean result = runner.preValidate("test3", mock(BuildingBlockExecution.class));
+
+ assertTrue(result);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
index 6a9ff2a4a8..1b52f049b3 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
@@ -18,18 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.common;
+package org.onap.so.bpmn.common.validation;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
+import java.util.Collections;
+import java.util.Set;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MyPreValidatorFour implements PreBuildingBlockValidator {
+
+ @Override
+ public Set<String> forBuildingBlock() {
+ return Collections.singleton("test2");
+ }
-public class MockLoggerDelegate implements JavaDelegate {
@Override
- public void execute(DelegateExecution execution) throws Exception {
- System.out.println("\n\n ..." + MockLoggerDelegate.class.getName() + " invoked by " + "processDefinitionId="
- + execution.getProcessDefinitionId() + ", activtyId=" + execution.getCurrentActivityId()
- + ", activtyName='" + execution.getCurrentActivityName() + "'" + ", processInstanceId="
- + execution.getProcessInstanceId() + ", businessKey=" + execution.getProcessBusinessKey()
- + ", executionId=" + execution.getId() + " \n\n");
+ public boolean validate(BuildingBlockExecution exeuction) {
+ return true;
}
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
new file mode 100644
index 0000000000..d6afea9b19
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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.common.validation;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MyPreValidatorOne implements PreBuildingBlockValidator {
+
+ @Override
+ public Set<String> forBuildingBlock() {
+
+ return Collections.singleton("test");
+ }
+
+ @Override
+ public boolean validate(BuildingBlockExecution exeuction) {
+ return false;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
new file mode 100644
index 0000000000..f7e93d5bd2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.common.validation;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MyPreValidatorThree implements PreBuildingBlockValidator {
+
+ @Override
+ public Set<String> forBuildingBlock() {
+ return Collections.singleton("test2");
+ }
+
+ @Override
+ public boolean validate(BuildingBlockExecution exeuction) {
+ return true;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
new file mode 100644
index 0000000000..0c15fd8589
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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.common.validation;
+
+import java.util.Collections;
+import java.util.Set;
+
+import javax.annotation.Priority;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.springframework.stereotype.Component;
+
+@Priority(1)
+@Component
+public class MyPreValidatorTwo implements PreBuildingBlockValidator {
+
+ @Override
+ public Set<String> forBuildingBlock() {
+ return Collections.singleton("test");
+ }
+
+ @Override
+ public boolean validate(BuildingBlockExecution exeuction) {
+ return false;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java
new file mode 100644
index 0000000000..7570e4c915
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.common.validation;
+
+import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+@Configuration
+@ComponentScan(basePackages = {"org.onap.so.bpmn.common.validation"}, basePackageClasses = {ExceptionBuilder.class}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class)
+public class ValidationConfig {
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index 0db2f9fc12..23524f4e7d 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -25,9 +25,9 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -45,10 +45,12 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
@@ -232,9 +234,6 @@ public class BBInputSetupTest {
requestDetails.setSubscriberInfo(null);
- doReturn(null).when(this.SPY_bbInputSetup).getServiceSubscription(requestDetails, expected);
- doReturn(expected).when(this.SPY_bbInputSetup).getCustomerFromURI(resourceId);
- doReturn(serviceSubscription).when(this.SPY_bbInputSetup).getServiceSubscriptionFromURI(resourceId, expected);
assertThat(actual, sameBeanAs(expected));
@@ -295,7 +294,7 @@ public class BBInputSetupTest {
String requestAction = "createInstance";
doReturn(expected).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, resourceId);
- doNothing().when(SPY_bbInputSetup).populateLookupKeyMapWithIds(any(WorkflowResourceIds.class), any());
+ doNothing().when(SPY_bbInputSetup).populateLookupKeyMapWithIds(executeBB.getWorkflowResourceIds(),lookupKeyMap);
boolean aLaCarte = true;
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBB(executeBB, lookupKeyMap, requestAction, aLaCarte,
resourceId, null);
@@ -321,14 +320,11 @@ public class BBInputSetupTest {
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("myRegionId");
requestDetails.setCloudConfiguration(cloudConfiguration);
- doReturn(requestDetails).when(SPY_bbInputSetupUtils).getRequestDetails(executeBB.getRequestId());
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String resourceId = "123";
String requestAction = "createInstance";
- doReturn(expected).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
- doNothing().when(SPY_bbInputSetup).populateLookupKeyMapWithIds(any(WorkflowResourceIds.class), any());
- doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(any(org.onap.aai.domain.yang.GenericVnf.class));
+
+ doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isNull());
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction,
resourceId);
@@ -355,7 +351,6 @@ public class BBInputSetupTest {
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
serviceInstance, lookupKeyMap, resourceId, vnfType);
@@ -381,9 +376,7 @@ public class BBInputSetupTest {
aaiServiceInstance.setModelVersionId("modelVersionId");
String resourceId = "123";
String vnfType = "vnfType";
- doReturn(null).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
-
+
SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
vnfType);
}
@@ -408,7 +401,6 @@ public class BBInputSetupTest {
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
serviceInstance, lookupKeyMap, resourceId, vnfType);
@@ -452,7 +444,6 @@ public class BBInputSetupTest {
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject());
doReturn(owningEntity).when(bbInputSetupMapperLayer)
.mapRequestOwningEntity(requestDetails.getOwningEntity());
@@ -501,13 +492,11 @@ public class BBInputSetupTest {
.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelVersionAndModelInvariantUUID(
requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject());
doReturn(owningEntity).when(bbInputSetupMapperLayer)
.mapRequestOwningEntity(requestDetails.getOwningEntity());
doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
- doReturn(serviceSubscription).when(SPY_bbInputSetup).getServiceSubscription(requestDetails, customer);
doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
executeBB.getBuildingBlock().getBpmnFlowName());
@@ -543,14 +532,12 @@ public class BBInputSetupTest {
Map<String, String> uriKeys = new HashMap<>();
uriKeys.put("global-customer-id", "globalCustomerId");
uriKeys.put("service-type", "serviceType");
- doReturn(uriKeys).when(SPY_bbInputSetupUtils)
- .getURIKeysFromServiceInstance(resourceId);
+
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
- doReturn(serviceSubscription).when(SPY_bbInputSetup).getServiceSubscription(requestDetails, customer);
+
doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
null, null, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
executeBB.getBuildingBlock().getBpmnFlowName());
@@ -660,9 +647,7 @@ public class BBInputSetupTest {
differentService.setModelUUID("modelUUIDDifferent");
doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
- doReturn(differentService).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
- doReturn(expected).when(SPY_bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+
ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
@@ -888,7 +873,6 @@ public class BBInputSetupTest {
doReturn(expected).when(bbInputSetupMapperLayer)
.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
- doNothing().when(SPY_bbInputSetup).addRelationshipsToSI(serviceInstanceAAI, expected);
ServiceInstance actual = SPY_bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
assertThat(actual, sameBeanAs(expected));
@@ -909,8 +893,7 @@ public class BBInputSetupTest {
doReturn(collection).when(SPY_bbInputSetup).createCollection(resourceId);
doReturn(instanceGroup).when(SPY_bbInputSetup).createInstanceGroup();
doNothing().when(SPY_bbInputSetup).mapCatalogCollection(service, collection, key);
- doNothing().when(SPY_bbInputSetup).mapCatalogNetworkCollectionInstanceGroup(service,
- collection.getInstanceGroup(), key);
+
NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
networkCollection.setModelCustomizationUUID(key);
networkCollection.setCollectionResource(new CollectionResource());
@@ -1059,7 +1042,6 @@ public class BBInputSetupTest {
instanceName = "networkName2";
L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null);
- doReturn(network2).when(SPY_bbInputSetup).createNetwork(lookupKeyMap, instanceName, resourceId, null);
SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
resourceId, null);
verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service);
@@ -1269,8 +1251,7 @@ public class BBInputSetupTest {
instanceName = "vnfName2";
GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
resourceId, vnfType, null);
- doReturn(vnf2).when(SPY_bbInputSetup).createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null);
+
org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf();
vnfAAI.setModelCustomizationId("modelCustId2");
doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId());
@@ -1348,8 +1329,7 @@ public class BBInputSetupTest {
doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust,
collectionResource);
- doReturn(instanceGroupCustList).when(SPY_bbInputSetupUtils)
- .getCollectionResourceInstanceGroupCustomization(collectionCust.getModelCustomizationUUID());
+
doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(collectionCust,
catalogInstanceGroup);
@@ -1376,8 +1356,7 @@ public class BBInputSetupTest {
uriKeys.put("global-customer-id", "globalCustomerId");
uriKeys.put("service-type", "serviceType");
- doReturn(uriKeys).when(SPY_bbInputSetupUtils)
- .getURIKeysFromServiceInstance(serviceInstanceAAI.getServiceInstanceId());
+
doNothing().when(SPY_bbInputSetup).mapProject(any(), eq(serviceInstance));
doNothing().when(SPY_bbInputSetup).mapOwningEntity(any(), eq(serviceInstance));
doNothing().when(SPY_bbInputSetup).mapL3Networks(any(), eq(serviceInstance.getNetworks()));
@@ -1524,7 +1503,6 @@ public class BBInputSetupTest {
CollectionResource collectionResource = new CollectionResource();
doReturn(collection).when(bbInputSetupMapperLayer)
.mapAAICollectionIntoCollection(isA(org.onap.aai.domain.yang.Collection.class));
- doReturn(instanceGroup).when(SPY_bbInputSetup).mapInstanceGroup(isA(AAIResultWrapper.class));
doReturn(instanceGroupsList).when(SPY_bbInputSetup).mapInstanceGroups(any());
doReturn(networkCollectionCust).when(SPY_bbInputSetupUtils).getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
doReturn(collectionResource).when(networkCollectionCust).getCollectionResource();
@@ -1745,7 +1723,7 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class),ArgumentMatchers.isNull(),ArgumentMatchers.isNull(),
any(String.class), any());
Configuration configuration = new Configuration();
@@ -1757,13 +1735,13 @@ public class BBInputSetupTest {
doReturn(configurationCustList).when(service).getConfigurationCustomizations();
configurationCustList.add(configurationCust);
doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(String.class), isA(ConfigurationResourceKeys.class));
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class));
executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB");
executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(String.class), isA(ConfigurationResourceKeys.class));
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class),ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class));
}
@Test
@@ -1831,10 +1809,7 @@ public class BBInputSetupTest {
requestAction, resourceId);
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
executeBB.getBuildingBlock().setIsVirtualLink(Boolean.FALSE);
@@ -1858,9 +1833,7 @@ public class BBInputSetupTest {
String requestAction = "createInstance";
doReturn(null).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, resourceId);
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
-
+
executeBB.getBuildingBlock().setBpmnFlowName("Network");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
@@ -1909,7 +1882,7 @@ public class BBInputSetupTest {
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any());
+ isA(ServiceInstance.class), any(),ArgumentMatchers.isNull(), any(String.class), ArgumentMatchers.isNull(), any());
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -1923,8 +1896,8 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class),
- any(String.class), any());
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), ArgumentMatchers.isNull(),
+ ArgumentMatchers.isNull(), any());
}
@Test
@@ -1984,7 +1957,7 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), ArgumentMatchers.isNull(),
any(String.class), any());
}
@@ -2014,8 +1987,6 @@ public class BBInputSetupTest {
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
String generatedId = "12131";
- doReturn(generatedId).when(SPY_bbInputSetup).generateRandomUUID();
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
executeBB.getBuildingBlock().setBpmnFlowName("DeactivateServiceInstanceBB");
executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
@@ -2056,8 +2027,7 @@ public class BBInputSetupTest {
String requestAction = "createInstance";
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
requestAction, resourceId);
- doReturn(null).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
@@ -2122,7 +2092,7 @@ public class BBInputSetupTest {
requestAction, resourceId);
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+ //doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
@@ -2193,10 +2163,7 @@ public class BBInputSetupTest {
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
String generatedId = "12131";
- doReturn(generatedId).when(SPY_bbInputSetup).generateRandomUUID();
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
}
@@ -2276,7 +2243,6 @@ public class BBInputSetupTest {
any(Service.class), any(String.class));
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index e1efe1c9c5..f70912f725 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -24,9 +24,9 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -44,7 +44,7 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.GenericVnf;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
index 0c2a95f5d1..8fe20de5f0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
@@ -22,9 +22,9 @@ package org.onap.so.bpmn.servicedecomposition.tasks;
import static org.hamcrest.CoreMatchers.any;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -84,7 +84,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
public void setRetryTimerExceptionTest() {
expectedException.expect(BpmnError.class);
DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(eq("retryCount"))).thenThrow(Exception.class);
+ when(execution.getVariable(eq("retryCount"))).thenThrow(BpmnError.class);
executeBuildingBlockRainyDay.setRetryTimer(execution);
}
@@ -104,7 +104,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
}
@@ -126,7 +126,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", ASTERISK);
doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", ASTERISK, ASTERISK, ASTERISK, ASTERISK);
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
}
@@ -139,17 +139,40 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
}
@Test
public void queryRainyDayTableExceptionTest() {
- doThrow(Exception.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
+ doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
}
+
+ @Test
+ public void queryRainyDayTableSecondaryPolicyExists() throws Exception{
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+
+ RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
+ rainyDayHandlerStatus.setErrorCode("7000");
+ rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
+ rainyDayHandlerStatus.setServiceType("st1");
+ rainyDayHandlerStatus.setVnfType("vnft1");
+ rainyDayHandlerStatus.setPolicy("Retry");
+ rainyDayHandlerStatus.setWorkStep(ASTERISK);
+ rainyDayHandlerStatus.setSecondaryPolicy("Abort");
+
+ doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,false);
+
+ assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java
index c8e1266b90..2df4b0bfdb 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java
@@ -20,8 +20,6 @@
package org.onap.so.client;
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,59 +39,67 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.onap.so.BaseTest;
+
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@RunWith(JUnitParamsRunner.class)
public class ResponseExceptionMapperImplTest{
- private static final ResponseExceptionMapperImpl mapper = new ResponseExceptionMapperImpl();
+ private static final ResponseExceptionMapperImpl mapper = new ResponseExceptionMapperImpl();
- public static Object[][] statusesAndCorrespondingExceptions() {
- return new Object[][]{
- {Status.BAD_REQUEST, BadRequestException.class},
- {Status.UNAUTHORIZED, NotAuthorizedException.class},
- {Status.FORBIDDEN, ForbiddenException.class},
- {Status.NOT_FOUND, NotFoundException.class},
- {Status.METHOD_NOT_ALLOWED, NotAllowedException.class},
- {Status.NOT_ACCEPTABLE, NotAcceptableException.class},
- {Status.PRECONDITION_FAILED, PreconditionFailedException.class},
- {Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class},
- {Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class},
- {Status.SERVICE_UNAVAILABLE, WebApplicationException.class},
- {Status.BAD_GATEWAY, WebApplicationException.class},
- };
- }
+ public static Object[][] statusesAndCorrespondingExceptions() {
+ return new Object[][]{
+ {Status.BAD_REQUEST, BadRequestException.class},
+ {Status.UNAUTHORIZED, NotAuthorizedException.class},
+ {Status.FORBIDDEN, ForbiddenException.class},
+ {Status.NOT_FOUND, NotFoundException.class},
+ {Status.METHOD_NOT_ALLOWED, NotAllowedException.class},
+ {Status.NOT_ACCEPTABLE, NotAcceptableException.class},
+ {Status.PRECONDITION_FAILED, PreconditionFailedException.class},
+ {Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class},
+ {Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class},
+ {Status.SERVICE_UNAVAILABLE, WebApplicationException.class},
+ {Status.BAD_GATEWAY, WebApplicationException.class},
+ };
+ }
- @Test
- @Parameters(method = "statusesAndCorrespondingExceptions")
- public void shouldThrowExceptionWhenStatusIsNotOk(Status status, Class<Exception> expectedException) {
- // given
- Response response = createMockResponse(status);
- // when, then
- assertThatThrownBy(() -> mapper.map(response)).isInstanceOf(expectedException);
- }
+ @Rule
+ public ExpectedException expectedExceptionTest = ExpectedException.none();
- @Test
- public void shouldNotThrowExceptionWhenStatusIsOk() {
- // given
- Response response = createMockResponse(Status.OK);
- // when, then
- assertThatCode(() -> mapper.map(response)).doesNotThrowAnyException();
- }
+ @Test
+ @Parameters(method = "statusesAndCorrespondingExceptions")
+ public void shouldThrowExceptionWhenStatusIsNotOk(Status status, Class<Exception> expectedException) {
+ // given
+ Response response = createMockResponse(status);
+ // when, then
+ expectedExceptionTest.expect(expectedException);
+ mapper.map(response);
+ }
+ @Test
+ public void shouldNotThrowExceptionWhenStatusIsOk() {
+ // given
+ Response response = createMockResponse(Status.OK);
+ // when, then
+ expectedExceptionTest.none();
+ mapper.map(response);
+ }
+
@Test
public void shouldThrowExceptionWithCustomMessageWhenResponseHasEntity() throws UnsupportedEncodingException {
// given
Response response = createMockResponse(Status.BAD_REQUEST);
when(response.hasEntity()).thenReturn(true);
when(response.getEntity()).thenReturn(new ByteArrayInputStream("test message".getBytes(StandardCharsets.UTF_8)));
- // when, then
- assertThatThrownBy(() -> mapper.map(response)).isInstanceOf(BadRequestException.class)
- .hasMessage("test message");
+
+ expectedExceptionTest.expect(BadRequestException.class);
+ expectedExceptionTest.expectMessage("test message");
+ mapper.map(response);
}
@Test
@@ -102,14 +108,15 @@ public class ResponseExceptionMapperImplTest{
Response response = createMockResponse(Status.BAD_REQUEST);
when(response.hasEntity()).thenReturn(false);
// when, then
- assertThatThrownBy(() -> mapper.map(response)).isInstanceOf(BadRequestException.class)
- .hasMessage("empty message");
- }
-
- private static Response createMockResponse(Status status) {
- Response responseContext = mock(Response.class);
- when(responseContext.getStatusInfo()).thenReturn(status);
- when(responseContext.getStatus()).thenReturn(status.getStatusCode());
- return responseContext;
+ expectedExceptionTest.expect(BadRequestException.class);
+ expectedExceptionTest.expectMessage("");
+ mapper.map(response);
}
+
+ private static Response createMockResponse(Status status) {
+ Response responseContext = mock(Response.class);
+ when(responseContext.getStatusInfo()).thenReturn(status);
+ when(responseContext.getStatus()).thenReturn(status.getStatusCode());
+ return responseContext;
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java
index 6fad47d8bb..2f65f9ce66 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java
@@ -21,7 +21,7 @@
package org.onap.so.client.appc;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
index 0aeb3a2a04..77daee6050 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
@@ -27,7 +27,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.appc.client.lcm.model.Action;
import org.onap.appc.client.lcm.model.ActionIdentifiers;
import org.onap.appc.client.lcm.model.CheckLockInput;
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnf.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnf.json
new file mode 100644
index 0000000000..e997db3f69
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnf.json
@@ -0,0 +1,57 @@
+{
+ "closedLoopDisabled":false,
+ "vnf-id":"vnfId1",
+ "vnf-name":"vnfName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "vf-modules": {
+ "vf-module": [{
+ "vf-module-id": "lukewarm",
+ "vf-module-name": "testVfModuleNameGWPrim",
+ "heat-stack-id": "fastburn",
+ "is-base-vf-module": true,
+ "orchestration-status": "Created"
+ },
+ {
+ "vf-module-id": "testVfModuleIdGWSec",
+ "vf-module-name": "testVfModuleNameGWSec",
+ "heat-stack-id": "testHeatStackIdGWSec",
+ "orchestration-status": "Created"
+ }]
+ },
+ "volume-groups":[],
+ "line-of-business":null,
+ "platform":null,
+ "cascaded":false,
+ "cloud-params":{},
+ "cloud-context":null,
+ "solution":null,
+ "vnf-name-2":null,
+ "service-id":null,
+ "regional-resource-zone":null,
+ "prov-status":null,
+ "operational-status":null,
+ "equipment-role":null,
+ "management-option":null,
+ "ipv4-oam-address":null,
+ "ipv4-loopback0-address":null,
+ "nm-lan-v6-address":null,
+ "management-v6-address":null,
+ "vcpu":null,
+ "vcpu-units":null,
+ "vmemory":null,
+ "vmemory-units":null,
+ "vdisk":null,
+ "vdisk-units":null,
+ "in-maint":false,
+ "is-closed-loop-disabled":false,
+ "summary-status":null,
+ "encrypted-access-flag":null,
+ "as-number":null,
+ "regional-resource-subzone":null,
+ "self-link":null,
+ "ipv4-oam-gateway-address":null,
+ "ipv4-oam-gateway-address-prefix-length":null,
+ "vlan-id-outer":null,"nm-profile-name":null,
+ "model-info-generic-vnf":null
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnfVfModule.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnfVfModule.json
new file mode 100644
index 0000000000..488865c326
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/GenericVnfVfModule.json
@@ -0,0 +1,62 @@
+{
+ "closedLoopDisabled":false,
+ "vnf-id":"vnfId1",
+ "vnf-name":"vnfName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "model-invariant-id":"model1",
+ "vf-modules": {
+ "vf-module": [{
+ "vf-module-id": "lukewarm",
+ "vf-module-name": "testVfModuleNameGWPrim",
+ "heat-stack-id": "fastburn",
+ "is-base-vf-module": true,
+ "orchestration-status": "Created",
+ "module-index":0,
+ "model-invariant-id":"model1"
+ },
+ {
+ "vf-module-id": "testVfModuleIdGWSec",
+ "vf-module-name": "testVfModuleNameGWSec",
+ "heat-stack-id": "testHeatStackIdGWSec",
+ "orchestration-status": "Created",
+ "module-index":2,
+ "model-invariant-id":"model1"
+ }]
+ },
+ "volume-groups":[],
+ "line-of-business":null,
+ "platform":null,
+ "cascaded":false,
+ "cloud-params":{},
+ "cloud-context":null,
+ "solution":null,
+ "vnf-name-2":null,
+ "service-id":null,
+ "regional-resource-zone":null,
+ "prov-status":null,
+ "operational-status":null,
+ "equipment-role":null,
+ "management-option":null,
+ "ipv4-oam-address":null,
+ "ipv4-loopback0-address":null,
+ "nm-lan-v6-address":null,
+ "management-v6-address":null,
+ "vcpu":null,
+ "vcpu-units":null,
+ "vmemory":null,
+ "vmemory-units":null,
+ "vdisk":null,
+ "vdisk-units":null,
+ "in-maint":false,
+ "is-closed-loop-disabled":false,
+ "summary-status":null,
+ "encrypted-access-flag":null,
+ "as-number":null,
+ "regional-resource-subzone":null,
+ "self-link":null,
+ "ipv4-oam-gateway-address":null,
+ "ipv4-oam-gateway-address-prefix-length":null,
+ "vlan-id-outer":null,"nm-profile-name":null,
+ "model-info-generic-vnf":null
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroup.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroup.json
new file mode 100644
index 0000000000..7902bae83a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroup.json
@@ -0,0 +1,10 @@
+{
+ "volume-group-id":"VolumeGroup123",
+ "volume-group-name":"volumeGroupName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "cloud-params":{},
+ "cascaded":false,
+ "heat-stack-id":"heatStackId",
+ "resource-version":"12345"
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithTenant.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithTenant.json
new file mode 100644
index 0000000000..c43b2c8ed3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithTenant.json
@@ -0,0 +1,20 @@
+{
+ "volume-group-id":"volumeGroupId",
+ "volume-group-name":"volumeGroupName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "cloud-params":{},
+ "cascaded":false,
+ "heat-stack-id":"heatStackId",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "tenant",
+ "related-link": "/aai/v11/network/Test",
+ "relationship-data": [{
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "Tenant123"
+ }]
+ }]
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithVfModule.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithVfModule.json
new file mode 100644
index 0000000000..9a47c44751
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/VolumeGroupWithVfModule.json
@@ -0,0 +1,26 @@
+{
+ "volume-group-id":"volumeGroupId",
+ "volume-group-name":"volumeGroupName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "cloud-params":{},
+ "cascaded":false,
+ "heat-stack-id":"heatStackId",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vf-module",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/GENERIC-VNFSAT-vig30001vm001vig001/vf-modules/vf-module/a62d14f0-421e-4e64-980a-a368722819db",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "GENERIC-VNFSAT-vig30001vm001vig001"
+ },
+ {
+ "relationship-key": "vf-module.vf-module-id",
+ "relationship-value": "a62d14f0-421e-4e64-980a-a368722819db"
+ }
+ ]
+ }]
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/searchResults.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/searchResults.json
new file mode 100644
index 0000000000..0e8719bea8
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/searchResults.json
@@ -0,0 +1,8 @@
+{
+ "result-data": [
+ {
+ "resource-type": "service-instance",
+ "resource-link": "/aai/v11/business/customers/customer/MSO-MUX-User/service-subscriptions/service-subscription/MSO-vCB/service-instances/service-instance/a1f53c6a-81a3-4e44-a900-d64f3b131d35"
+ }
+ ]
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
index dea3f17f8e..2985505b46 100644
--- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
+++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
@@ -1,5 +1,5 @@
aai:
- auth: 26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764
+ auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7
endpoint: http://localhost:${wiremock.server.port}
appc:
client:
@@ -37,7 +37,7 @@ mso:
completemsoprocess:
endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess
db:
- auth: 757A94191D685FD2092AC1490730A4FC
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter
att-endpoint: http://localhost:${wiremock.server.port}/dbadapters/AttRequestsDbAdapter
spring:
@@ -50,7 +50,7 @@ mso:
db:
endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter
po:
- auth: 757A94191D685FD2092AC1490730A4FC
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
password: 3141634BF7E070AA289CF2892C986C0B
sdnc:
endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter
@@ -71,6 +71,7 @@ mso:
workflow:
message:
endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message
+ camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE
async:
core-pool-size: 50
@@ -177,7 +178,7 @@ sniro:
spring:
datasource:
- url: jdbc:mariadb://localhost:3307/camundabpmn
+ jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn
username: root
password: password
driver-class-name: org.mariadb.jdbc.Driver
@@ -195,8 +196,16 @@ mariaDB4j:
dataDir:
port: 3307
databaseName: camundabpmn
+
camunda:
bpm:
metrics:
enabled: false
db-reporter-activate: false
+
+org:
+ onap:
+ so:
+ adapters:
+ network:
+ encryptionKey: aa3871669d893c7fb8abbcda31b88b4f