diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
45 files changed, 1543 insertions, 843 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 deleted file mode 100644 index 05b1c5e6ed..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy +++ /dev/null @@ -1,168 +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 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.rules.ExpectedException -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 - -@RunWith(MockitoJUnitRunner.class) -@Ignore -class AaiUtilTest extends MsoGroovyTest { - - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - @Rule - public ExpectedException thrown = ExpectedException.none - - - def aaiPaylod = "<allotted-resource xmlns=\"http://org.openecomp.aai.inventory/v9\">\n" + - "\t\t\t\t<id>allottedResourceId</id>\n" + - "\t\t\t\t<description></description>\n" + - "\t\t\t\t<type>allottedResourceType</type>\n" + - "\t\t\t\t<role>allottedResourceRole</role>\n" + - "\t\t\t\t<selflink></selflink>\n" + - "\t\t\t\t<model-invariant-id></model-invariant-id>\n" + - "\t\t\t\t<model-version-id></model-version-id>\n" + - "\t\t\t\t<model-customization-id></model-customization-id>\n" + - "\t\t\t\t<orchestration-status>PendingCreate</orchestration-status>\n" + - "\t\t\t\t<operation-status></operation-status>\n" + - "\t\t\t\t<relationship-list>\n" + - "\t\t\t\t\t<relationship>\n" + - " \t\t\t<related-to>service-instance</related-to>\n" + - " \t\t\t<related-link>CSI_resourceLink</related-link>\n" + - "\t\t\t\t\t</relationship>\n" + - "\t\t\t\t</relationship-list>\n" + - "\t\t\t</allotted-resource>"; - - @Test - public void testGetVersionDefault() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('8', version) - } - - @Test - public void testGetVersionResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('7', version) - } - - @Test - public void testGetVersionFlowSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.custom.CreateAAIVfModule.aai.version")).thenReturn('6') - when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('6', version) - } - - @Test - public void testGetVersionNotDefined() { - thrown.expect(Exception.class) - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("") - - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - - } - - @Test - public void testExecuteAAIGetCall() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f") - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.executeAAIGetCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId") - } - - - @Test - public void testExecuteAAIPutCall() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f") - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.executeAAIPutCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId",aaiPaylod) - } - - @Test - public void testGetNamespaceFromUri_twoArguments() { // (execution, uri) - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10') - when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def ns = aaiUtil.getNamespaceFromUri(mockExecution, '/aai/v10/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v10', ns) - } -} 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..3c3e4aca91 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 @@ -1,22 +1,22 @@ -/*- - * ============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========================================================= - */ +/*- + * ============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 @@ -30,9 +30,8 @@ import org.onap.so.bpmn.core.WorkflowException; 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.junit.MockitoJUnitRunner; import org.mockito.internal.debugging.MockitoDebuggerImpl import org.junit.Before import org.onap.so.bpmn.common.scripts.AaiUtil; @@ -58,7 +57,8 @@ class AbstractServiceTaskProcessorImpl extends AbstractServiceTaskProcessor{ } } -@RunWith(MockitoJUnitRunner.class) + +@RunWith(MockitoJUnitRunner.Silent.class) public class AbstractServiceTaskProcessorTest extends MsoGroovyTest { @Captor @@ -171,12 +171,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 index 5058961992..3da126f7a9 100644 --- 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 @@ -1,39 +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.mockito.Matchers.eq +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 -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake -import org.junit.Test -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.client.aai.entities.uri.AAIResourceUri -import org.springframework.core.env.Environment - -class AllottedResourceUtilsTest { - - - @Test - public void createARUrlTest() { - AllottedResourceUtils utils = new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)) - DelegateExecution execution = new DelegateExecutionFake() - String allottedResourceId = "my-id" - UrnPropertiesReader reader = new UrnPropertiesReader() - Environment env = mock(Environment.class); - - when(env.getProperty(eq("mso.workflow.global.default.aai.version"))).thenReturn("14") - when(env.getProperty(eq("aai.endpoint"))).thenReturn("http://localhost:8080") - - - reader.setEnvironment(env) - - - AAIResourceUri uri = mock(AAIResourceUri.class) - when(uri.build()).thenReturn(new URI("/business/customers/customer/1/service-subscriptions/service-subscription/2/service-instances/service-instance/3")) - String actual = utils.createARUrl(execution, uri, allottedResourceId) - - assertEquals("http://localhost:8080/aai/v14/business/customers/customer/1/service-subscriptions/service-subscription/2/service-instances/service-instance/3/allotted-resources/allotted-resource/my-id", actual) - } + +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 new file mode 100644 index 0000000000..886e92bd45 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy @@ -0,0 +1,341 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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. + * 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.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 + +class CreateAAIVfModuleTest extends MsoGroovyTest{ + + 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 + 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() + executionFake.setVariable("vnfId", VNF_ID) + executionFake.setVariable("vnfType", VNF_TYPE) + executionFake.setVariable("vnfName", VNF_NAME) + executionFake.setVariable("serviceId", SERVICE_ID) + executionFake.setVariable("personaModelId", PERSONAL_MODEL_ID) + executionFake.setVariable("personaModelVersion", PERSONAL_MODEL_VERSION) + executionFake.setVariable("modelCustomizationId", MODEL_CUST_ID) + executionFake.setVariable("vnfPersonaModelId", VNF_PERSONAL_MODEL_ID) + executionFake.setVariable("vnfPersonaModelVersion", VNF_PERSONAL_MODEL_VER) + executionFake.setVariable("isBaseVfModule", "true") + executionFake.setVariable("vfModuleName", VF_MODULE_NAME) + executionFake.setVariable("vfModuleModelName", VF_MODULE_MODEL_NAME) + //when + createAAIVfModule.preProcessRequest(executionFake) + //then + assertThat(executionFake.getVariable("CAAIVfMod_vnfId")).isEqualTo(VNF_ID) + assertThat(executionFake.getVariable("CAAIVfMod_vnfName")).isEqualTo(VNF_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_vnfType")).isEqualTo(VNF_TYPE) + assertThat(executionFake.getVariable("CAAIVfMod_serviceId")).isEqualTo(SERVICE_ID) + assertThat(executionFake.getVariable("CAAIVfMod_personaId")).isEqualTo(PERSONAL_MODEL_ID) + assertThat(executionFake.getVariable("CAAIVfMod_personaVer")).isEqualTo(PERSONAL_MODEL_VERSION) + assertThat(executionFake.getVariable("CAAIVfMod_modelCustomizationId")).isEqualTo(MODEL_CUST_ID) + assertThat(executionFake.getVariable("CAAIVfMod_vnfPersonaId")).isEqualTo(VNF_PERSONAL_MODEL_ID) + assertThat(executionFake.getVariable("CAAIVfMod_vnfPersonaVer")).isEqualTo(VNF_PERSONAL_MODEL_VER) + assertThat(executionFake.getVariable("CAAIVfMod_isBaseVfModule")).isEqualTo(true) + assertThat(executionFake.getVariable("CAAIVfMod_moduleName")).isEqualTo(VF_MODULE_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_moduleModelName")).isEqualTo(VF_MODULE_MODEL_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_aaiNamespace")) + .isEqualTo(DEFAULT_AAI_NAMESPACE + "v" + DEFAULT_AAI_VERSION) + } + + @Test + void processAAIGenericVnfQuery_setVnfResponse() { + executionFake.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 200) + executionFake.setVariable("CAAIVfMod_vnfId", "") + executionFake.setVariable("CAAIVfMod_vnfName", VNF_NAME) + + createAAIVfModule.processAAIGenericVnfQuery(executionFake) + + assertThat(executionFake.getVariable("CAAIVfMod_queryGenericVnfResponse")) + .isEqualTo("Invalid request for new Generic VNF which already exists, Vnf Name=" + VNF_NAME) + } + + @Test + void processAAIGenericVnfQuery_setVfModuleResponse() { + executionFake.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 500) + executionFake.setVariable("CAAIVfMod_vnfId", VNF_ID) + + 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) + } + + @Test + void parseForAddOnModule_moduleNameFound() { + + 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) + + createAAIVfModule.parseForAddOnModule(executionFake) + + assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(true) + assertThat(executionFake.getVariable("CAAIVfMod_parseModuleResponse")) + .isEqualTo("VF Module " + VF_MODULE_NAME + " already exists for Generic VNF " + VNF_NAME) + } + + @Test + void parseForAddOnModule_moduleNameNotFound() { + 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) + + createAAIVfModule.parseForAddOnModule(executionFake) + + assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false) + assertThat(executionFake.getVariable("CAAIVfMod_parseModuleResponse")) + .isEqualTo("VF Module " + VF_MODULE_NAME + " does not exist for Generic VNF " + VNF_NAME) + } + + @Test + void parseForBaseModule_moduleNameFound() { + 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) + + createAAIVfModule.parseForBaseModule(executionFake) + + assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false) + assertThat(executionFake.getVariable("CAAIVfMod_baseModuleConflict")).isEqualTo(true) + assertThat(executionFake.getVariable("CAAIVfMod_parseModuleResponse")) + .isEqualTo("VF Module " + VF_MODULE_NAME + " already exists for Generic VNF " + VNF_NAME) + } + + @Test + void parseForBaseModule_isBaseVfModule() { + 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) + + createAAIVfModule.parseForBaseModule(executionFake) + + assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false) + assertThat(executionFake.getVariable("CAAIVfMod_baseModuleConflict")).isEqualTo(true) + assertThat(executionFake.getVariable("CAAIVfMod_parseModuleResponse")) + .isEqualTo("Base VF Module already exists for Generic VNF " + VNF_NAME) + } + + @Test + void parseForBaseModule_baseModuleConflictIsFalse() { + 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) + + createAAIVfModule.parseForBaseModule(executionFake) + + assertThat(executionFake.getVariable("CAAIVfMod_vnfNameFromAAI")).isEqualTo(VNF_NAME) + assertThat(executionFake.getVariable("CAAIVfMod_moduleExists")).isEqualTo(false) + assertThat(executionFake.getVariable("CAAIVfMod_parseModuleResponse")) + .isEqualTo("VF Module " + VF_MODULE_NAME + " does not exist for Generic VNF " + VNF_NAME) + } + + private void prepareUrnPropertiesReader() { + Environment mockEnvironment = mock(Environment.class) + when(mockEnvironment.getProperty("mso.workflow.global.default.aai.version")).thenReturn(DEFAULT_AAI_VERSION) + when(mockEnvironment.getProperty("mso.workflow.global.default.aai.namespace")).thenReturn(DEFAULT_AAI_NAMESPACE) + 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 3a2673c9ee..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 @@ -29,7 +29,7 @@ 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 @@ -41,9 +41,9 @@ 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() 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..fc2de4307b 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 @@ -20,11 +20,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.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; @@ -34,13 +32,13 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Before; import org.junit.Test; +import org.onap.so.BaseTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.BaseTest; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -77,14 +75,14 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { public void setRetryTimerTest() throws Exception{ delegateExecution.setVariable("retryCount", 2); executeBuildingBlockRainyDay.setRetryTimer(delegateExecution); - assertEquals("PT25M",delegateExecution.getVariable("RetryDuration")); + assertEquals("PT40S",delegateExecution.getVariable("RetryDuration")); } @Test 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); } @@ -93,7 +91,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - + delegateExecution.setVariable("aLaCarte", true); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -104,7 +102,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")); } @@ -114,7 +112,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - + delegateExecution.setVariable("aLaCarte", true); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode(ASTERISK); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -126,7 +124,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")); } @@ -136,20 +134,90 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { customer.getServiceSubscription().getServiceInstances().add(serviceInstance); serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); - + delegateExecution.setVariable("aLaCarte", true); 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)); + delegateExecution.setVariable("aLaCarte", true); + 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"); + delegateExecution.setVariable("aLaCarte", true); + + 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); + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,false); assertEquals("Abort", delegateExecution.getVariable("handlingCode")); } + + @Test + public void queryRainyDayTableRollbackToAssignedMacro() throws Exception{ + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", false); + + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToAssigned"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); + + assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + } + + @Test + public void queryRainyDayTableRollbackToAssignedALaCarte() throws Exception{ + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToAssigned"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true); + + assertEquals("RollbackToAssigned", 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/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json deleted file mode 100644 index f05449a96f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, - "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : {"licenseDemands":[]} -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json deleted file mode 100644 index 6977224ffa..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, - "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedModelInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedModelInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedModelInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : {"licenseDemands":[]} -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json deleted file mode 100644 index 877c6e7e74..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, - "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : {"licenseDemands":[]} -}
\ No newline at end of file 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..1651f4f1fc 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 @@ -107,6 +108,8 @@ mso: db: endpoint: http://localhost:${wiremock.server.port}/ rollback: 'true' + rainyDay: + retryDurationMultiplier: '2' site-name: localDevEnv workflow: default: @@ -177,7 +180,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 +198,16 @@ mariaDB4j: dataDir: port: 3307 databaseName: camundabpmn + camunda: bpm: metrics: enabled: false db-reporter-activate: false + +org: + onap: + so: + adapters: + network: + encryptionKey: aa3871669d893c7fb8abbcda31b88b4f |