use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCControllerITTest method treatNotification_verifyRequestID.
/**
* 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());
}
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCControllerITTest method treatNotification_ValidPnfResource_With_Default_Software_Version_ExpectedOutput.
/**
* Test with service-Ericservice-csar.csar to test default_software_version field.
*/
@Test
public void treatNotification_ValidPnfResource_With_Default_Software_Version_ExpectedOutput() {
/**
* service UUID/invariantUUID from global metadata in service-PnfServiceTestCds-template.yml.
*/
// "77cf276e-905c-43f6-8d54-dda474be2f2e";
String serviceUuid = "8e7b2bd7-6901-4cc2-b3fb-3b6a1d5631e3";
// "913e6776-4bc3-49b9-b399-b5bb4690f0c7";
String serviceInvariantUuid = "9a5f99c8-0492-4691-b29a-7360d9c3aae3";
initMockAaiServer(serviceUuid, serviceInvariantUuid);
NotificationDataImpl notificationData = new NotificationDataImpl();
notificationData.setServiceUUID(serviceUuid);
notificationData.setDistributionID(distributionId);
notificationData.setServiceInvariantUUID(serviceInvariantUuid);
notificationData.setServiceVersion("1.0");
ResourceInfoImpl resourceInfo = constructPnfResourceInfoWithSWV();
List<ResourceInfoImpl> resourceInfoList = new ArrayList<>();
resourceInfoList.add(resourceInfo);
notificationData.setResources(resourceInfoList);
ArtifactInfoImpl artifactInfo = constructPnfServiceArtifactWithSWV();
List<ArtifactInfoImpl> artifactInfoList = new ArrayList<>();
artifactInfoList.add(artifactInfo);
notificationData.setServiceArtifacts(artifactInfoList);
try {
asdcController.treatNotification(notificationData);
logger.info("Checking the database for PNF ingestion");
/**
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid).orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-Ericservice-csar.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
assertNull("tosca csar descrption", toscaCsar.getDescription());
assertEquals("tosca csar checksum", "MANUAL_RECORD", toscaCsar.getArtifactChecksum());
assertEquals("toscar csar URL", "/download/service-Ericservice-csar.csar", toscaCsar.getUrl());
/**
* Check the service entity, it should be the same as global metadata information in
* service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid).orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
/**
* Check PNF resource, it should be the same as metadata in the topology template in
* service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
*/
String pnfResourceKey = "7a90f80b-a6f6-4597-8c48-80bda26b4823";
/**
* Check PNF resource customization, it should be the same as metadata in the topology template in
* service-PnfServiceTestCds-template.yml OR global metadata in the resource-PnfServiceTestCds-template.yml
*/
// "9f01263a-eaf7-4d98-a37b-3785f751903e";
String pnfCustomizationKey = "c850a53b-b63e-4043-ab10-53aabda78d37";
PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey).orElseThrow(() -> new EntityNotFoundException("PNF resource customization: " + pnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "demo-PNF 1", pnfCustomization.getModelInstanceName());
assertEquals("NF type", "", pnfCustomization.getNfType());
assertEquals("NF Role", "", pnfCustomization.getNfRole());
assertEquals("NF function", "", pnfCustomization.getNfFunction());
assertEquals("NF naming code", "", pnfCustomization.getNfNamingCode());
assertEquals("PNF resource model UUID", pnfResourceKey, pnfCustomization.getPnfResources().getModelUUID());
assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
assertNull("resource input", pnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", "pm_control", pnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0", pnfCustomization.getBlueprintVersion());
assertEquals("default software version", "4.0.0", pnfCustomization.getDefaultSoftwareVersion());
assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf());
assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor());
/**
* Check the pnf resource customization with service mapping
*/
List<PnfResourceCustomization> pnfCustList = service.getPnfCustomizations();
assertEquals("PNF resource customization entity", 1, pnfCustList.size());
assertEquals(pnfCustomizationKey, pnfCustList.get(0).getModelCustomizationUUID());
/**
* Check the watchdog for component distribution status
*/
List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
assertEquals("COMPONENT_DONE_OK", distributionStatus.getComponentDistributionStatus());
assertEquals("SO", distributionStatus.getComponentName());
} catch (Exception e) {
logger.info(e.getMessage(), e);
fail(e.getMessage());
}
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ToscaResourceInstallerTest method before.
@Before
public void before() {
MockitoAnnotations.initMocks(this);
notificationData = new NotificationDataImpl();
statusData = new JsonStatusData();
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method testServiceBasicNetwork.
@Test
public void testServiceBasicNetwork() throws Exception {
wireMockServer.stubFor(post(urlPathMatching("/aai/.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.ACCEPTED.value())));
String resourceLocation = "src/test/resources/resource-examples/service-BasicNetwork/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "service-BasicNetwork-notification.json"), NotificationDataImpl.class);
headers.add("resource-location", resourceLocation);
HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, String.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
Optional<Service> service = serviceRepo.findById("9ff42123-ff24-41dc-9f41-a956c9328699");
assertTrue(service.isPresent());
assertEquals("basic_network", service.get().getModelName());
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method testWorkflowDistribution.
@Test
@Transactional
public void testWorkflowDistribution() throws Exception {
wireMockServer.stubFor(post(urlPathMatching("/aai/.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.ACCEPTED.value())));
wireMockServer.stubFor(post(urlPathEqualTo("/sobpmnengine/deployment/create")).willReturn(aResponse().withStatus(200)));
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File("src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json"), NotificationDataImpl.class);
headers.add("resource-location", "src/test/resources/resource-examples/WorkflowBpmn/");
HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, String.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
Workflow actualResponse = workflowRepo.findByArtifactUUID("a90f8eaa-7c20-422f-8c81-aacbca6fb9e7");
if (actualResponse == null)
throw new Exception("No Workflow Written to database");
String expectedBody = new String(Files.readAllBytes(Paths.get("src/test/resources/resource-examples/WorkflowBpmn/TestWF2-1_0.bpmn")));
assertEquals(actualResponse.getArtifactChecksum(), "ZjUzNjg1NDMyMTc4MWJmZjFlNDcyOGQ0Zjc1YWQwYzQ\u003d");
assertEquals(actualResponse.getArtifactName(), "TestWF2-1_0.bpmn");
assertEquals(actualResponse.getDescription(), "Workflow Artifact Description");
assertEquals(actualResponse.getBody(), expectedBody);
Workflow shouldNotBeFound = workflowRepo.findByArtifactUUID("f27066a1-c3a7-4672-b02e-1251b74b7b71");
assertNull(shouldNotBeFound);
}
Aggregations