@@ -34,9 +34,9 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.core.UriBuilder import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue -import static org.mockito.Matchers.any -import static org.mockito.Matchers.anyObject -import static org.mockito.Matchers.isA +import static org.mockito.ArgumentMatchers.any +import static org.mockito.ArgumentMatchers.anyObject +import static org.mockito.ArgumentMatchers.isA import static org.mockito.Mockito.atLeastOnce import static org.mockito.Mockito.doNothing import static org.mockito.Mockito.doThrow @@ -33,7 +33,7 @@ import org.onap.so.bpmn.core.WorkflowException import static org.assertj.core.api.Assertions.assertThat import static org.assertj.core.api.Assertions.assertThatThrownBy -import static org.mockito.Matchers.eq +import static org.mockito.ArgumentMatchers.eq import static org.mockito.Mockito.* @RunWith(MockitoJUnitRunner.class) @@ -40,8 +40,8 @@ import org.onap.so.bpmn.mock.FileUtil import org.onap.so.bpmn.mock.StubResponseAAI import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Matchers.any -import static org.mockito.Matchers.refEq +import static org.mockito.ArgumentMatchers.any +import static org.mockito.ArgumentMatchers.refEq import static org.mockito.Mockito.* @RunWith(MockitoJUnitRunner.class) @@ -25,7 +25,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.contains; +import static org.mockito.ArgumentMatchers.contains; import static org.mockito.Mockito.mock; import java.io.Serializable; @@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -47,7 +47,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; @@ -25,7 +25,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -24,7 +24,7 @@ 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.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import java.io.File; @@ -21,7 +21,7 @@ package org.onap.so.bpmn.core.internal; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.*; -import static org.mockito.Matchers.contains; +import static org.mockito.ArgumentMatchers.contains; import java.util.Optional; import org.junit.Test; @@ -20,7 +20,7 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; import org.camunda.bpm.engine.delegate.BpmnError; @@ -21,7 +21,7 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; import org.camunda.bpm.engine.delegate.BpmnError; @@ -34,7 +34,7 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException import static org.junit.Assert.assertEquals -import static org.mockito.Matchers.isA +import static org.mockito.ArgumentMatchers.isA import static org.mockito.Mockito.doNothing import static org.mockito.Mockito.doThrow import static org.mockito.Mockito.when @@ -43,7 +43,7 @@ import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputation import javax.ws.rs.NotFoundException -import static org.mockito.Matchers.eq +import static org.mockito.ArgumentMatchers.eq import static org.mockito.Mockito.doNothing import static org.mockito.Mockito.doThrow import static org.mockito.Mockito.times @@ -37,7 +37,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException import static org.junit.Assert.assertEquals -import static org.mockito.Matchers.isA +import static org.mockito.ArgumentMatchers.isA import static org.mockito.Mockito.doNothing import static org.mockito.Mockito.doThrow import static org.mockito.Mockito.when @@ -46,7 +46,7 @@ import org.onap.so.constants.Defaults import static org.junit.Assert.assertEquals import static org.junit.Assert.assertNotNull -import static org.mockito.Matchers.anyObject +import static org.mockito.ArgumentMatchers.anyObject import static org.mockito.Mockito.spy import static org.mockito.Mockito.times import static org.mockito.Mockito.verify @@ -34,7 +34,7 @@ import org.onap.so.bpmn.mock.FileUtil import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase import static org.assertj.core.api.Assertions.assertThatThrownBy -import static org.mockito.Matchers.anyString +import static org.mockito.ArgumentMatchers.anyString import static org.mockito.Mockito.verify import static org.mockito.Mockito.when import static org.mockito.Mockito.eq @@ -34,7 +34,7 @@ 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 org.mockito.Matchers.isA +import static org.mockito.ArgumentMatchers.isA import static org.mockito.Mockito.doThrow import static org.mockito.Mockito.spy import static org.mockito.Mockito.when @@ -24,7 +24,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; @@ -30,7 +30,7 @@ import org.mockito.InOrder; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; public class InformDmaapClientTest { @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; @@ -23,6 +23,7 @@ package org.onap.so.client.adapter.vnf.mapper; import static java.util.Arrays.asList; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -35,6 +36,7 @@ import java.util.Optional; import javax.annotation.PostConstruct; +import org.apache.commons.lang3.StringUtils; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiSubInterfaceNetworkData; @@ -443,7 +445,6 @@ public class VnfAdapterVfModuleObjectMapper { } } } - } private void buildVfModuleNetworkInformation(Map<String,String> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) { @@ -780,16 +781,26 @@ public class VnfAdapterVfModuleObjectMapper { deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId()); deleteVfModuleRequest.setVnfId(genericVnf.getVnfId()); deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId()); - deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());//DoDVfMod_heatStackId - deleteVfModuleRequest.setSkipAAI(true); - String messageId = vnfAdapterObjectMapperUtils.getRandomUuid(); - deleteVfModuleRequest.setMessageId(messageId); - deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId)); + if (!StringUtils.isEmpty(vfModule.getHeatStackId())){ + deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());//DoDVfMod_heatStackId + } else + { + deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName()); + } + + deleteVfModuleRequest.setSkipAAI(true); + setIdAndUrl(deleteVfModuleRequest); MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance); deleteVfModuleRequest.setMsoRequest(msoRequest); return deleteVfModuleRequest; } + protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException{ + String messageId = vnfAdapterObjectMapperUtils.getRandomUuid(); + deleteVfModuleRequest.setMessageId(messageId); + deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId)); + } + private String convertToString(Object obj) { String json; try { @@ -814,4 +825,4 @@ public class VnfAdapterVfModuleObjectMapper { } return baseVfModule; } -} +}
\ No newline at end of file @@ -20,7 +20,7 @@ package org.onap.so.bpmn.common.aai.tasks; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -21,7 +21,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -21,7 +21,7 @@ package org.onap.so.bpmn.sdno.tasks; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -22,7 +22,7 @@ package org.onap.so.client.adapter.network.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.*; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import java.io.UnsupportedEncodingException; @@ -20,19 +20,38 @@ package org.onap.so.client.adapter.vnf.mapper; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.junit.Before; import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.entity.MsoRequest; public class VnfAdapterVfModuleObjectMapperTest{ + @Spy private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper(); + + @Before + public void before() { + MockitoAnnotations.initMocks(this); + } @Test public void createVnfcSubInterfaceKeyTest() { @@ -64,4 +83,42 @@ public class VnfAdapterVfModuleObjectMapperTest{ } + @Test + public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception { + DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest(); + + CloudRegion cloudRegion = new CloudRegion(); + cloudRegion.setLcpCloudRegionId("lcpCloudRegionId"); + expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); + + cloudRegion.setTenantId("tenantId"); + expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId()); + + GenericVnf genericVnf = new GenericVnf(); + VfModule vfModule = new VfModule(); + vfModule.setHeatStackId("heatStackId"); + expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId"); + expectedDeleteVfModuleRequest.setSkipAAI(true); + + MsoRequest msoRequest = new MsoRequest(); + RequestContext requestContext = new RequestContext(); + requestContext.setMsoRequestId("msoRequestId"); + msoRequest.setRequestId(requestContext.getMsoRequestId()); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + expectedDeleteVfModuleRequest.setMsoRequest(msoRequest); + + String messageId = "messageId"; + String endpoint = "endpoint"; + doNothing().when(mapper).setIdAndUrl(any()); + expectedDeleteVfModuleRequest.setMessageId(messageId); + expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId); + + DeleteVfModuleRequest actualDeleteVfModuleRequest = mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, + serviceInstance, genericVnf, vfModule); + + assertThat(actualDeleteVfModuleRequest, sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl")); + } + } @@ -21,7 +21,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -21,7 +21,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -20,7 +20,7 @@ package org.onap.so.client.orchestration; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -22,7 +22,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -22,7 +22,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -21,7 +21,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.ArgumentMatchers.any; @@ -2,7 +2,8 @@ "cloudSiteId" : "cloudRegionId", "tenantId" : "tenantId", "vnfId" : "vnfId", - "vfModuleId" : "vfModuleId", + "vfModuleId" : "vfModuleId", + "vfModuleStackId" : "vfModuleName", "skipAAI" : true, "msoRequest" : { "requestId" : "requestId", |