diff options
Diffstat (limited to 'asdc-controller/src/test/java')
-rw-r--r-- | asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java | 31 | ||||
-rw-r--r-- | asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java | 10 |
2 files changed, 38 insertions, 3 deletions
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java index 0681cd8aed..055968cc95 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java @@ -33,6 +33,7 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.asdc.BaseTest; import org.onap.so.asdc.client.exceptions.ASDCControllerException; import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl; @@ -55,6 +56,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -277,6 +279,35 @@ public class ASDCControllerITTest extends BaseTest { } } + /** + * Test to check RequestId is being set using the DistributionID. + */ + @Test + public void treatNotification_verifyRequestID() { + + String serviceUuid = "efaea486-561f-4159-9191-a8d3cb346728"; + String serviceInvariantUuid = "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23"; + distributionId = "bb15de12-166d-4e45-9e5f-4b3f25200d7b"; + + initMockAaiServer(serviceUuid, serviceInvariantUuid); + + NotificationDataImpl notificationData = new NotificationDataImpl(); + notificationData.setServiceUUID(serviceUuid); + notificationData.setDistributionID(distributionId); + notificationData.setServiceInvariantUUID(serviceInvariantUuid); + notificationData.setServiceVersion("1.0"); + + try { + asdcController.treatNotification(notificationData); + logger.info("Verify RequestId : {}", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + assertEquals("bb15de12-166d-4e45-9e5f-4b3f25200d7b", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + + } catch (Exception e) { + logger.info(e.getMessage(), e); + fail(e.getMessage()); + } + } + private ArtifactInfoImpl constructPnfServiceArtifact() { ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl(); artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java index 846eaf47e2..da99efadea 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; +import org.onap.sdc.tosca.parser.api.IEntityDetails; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.Property; @@ -49,6 +50,9 @@ public class ToscaResourceInputTest { NodeTemplate nodeTemplate; @Mock + IEntityDetails entityDetails; + + @Mock Property property; @Mock @@ -65,16 +69,16 @@ public class ToscaResourceInputTest { Map<String, Object> map = new HashMap<>(); map.put("customizationUUID", "69df3303-d2b3-47a1-9d04-41604d3a95fd"); Metadata metadata = new Metadata(map); - when(nodeTemplate.getProperties()).thenReturn(hashMap); + when(entityDetails.getProperties()).thenReturn(hashMap); when(property.getValue()).thenReturn(getInput); when(getInput.getInputName()).thenReturn("nameKey"); when(input.getName()).thenReturn("nameKey"); when(input.getDefault()).thenReturn("defaultValue"); when(getInput.toString()).thenReturn("getinput:[sites,INDEX,role]"); - when(nodeTemplate.getMetaData()).thenReturn(metadata); + when(entityDetails.getMetadata()).thenReturn(metadata); List<Input> inputs = new ArrayList<>(); inputs.add(input); - String resourceInput = toscaResourceInstaller.getVnfcResourceInput(nodeTemplate, inputs); + String resourceInput = toscaResourceInstaller.getVnfcResourceInput(entityDetails, inputs); assertEquals("{\\\"key1\\\":\\\"[sites,INDEX,role]|defaultValue\\\"}", resourceInput); } |