use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method test_Vcpe_Infra_Distribution.
@Test
public void test_Vcpe_Infra_Distribution() 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/vcpe-infra/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demovcpeinfra-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<ToscaCsar> toscaCsar = toscaCsarRepo.findById("144606d8-a505-4ba0-90a9-6d1c6219fc6b");
assertTrue(toscaCsar.isPresent());
assertEquals("service-Demovcpeinfra-csar.csar", toscaCsar.get().getName());
Optional<Service> service = serviceRepo.findById("8a77cbbb-9850-40bb-a42f-7aec8e3e6ab7");
assertTrue(service.isPresent());
assertEquals("demoVCPEInfra", service.get().getModelName());
Optional<NetworkResource> networkResource = networkRepo.findById("89789b26-a46b-4cee-aed0-d46e21f93a5e");
assertTrue(networkResource.isPresent());
assertEquals("Generic NeutronNet", networkResource.get().getModelName());
List<VnfResourceCustomization> vnfCustomizationResources = vnfCustRepo.findByModelCustomizationUUID("01564fe7-0541-4d92-badc-464cc35f83ba");
for (VnfResourceCustomization vnfResourceCustomization : vnfCustomizationResources) {
assertTrue(vnfResourceCustomization.getVfModuleCustomizations().stream().anyMatch(vfModuleCust -> "354b1e83-47db-4af1-8af4-9c14b03b482d".equals(vfModuleCust.getModelCustomizationUUID())));
}
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method test_Vcperescust_Distribution.
@Test
public void test_Vcperescust_Distribution() 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/vcpe-rescust/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demo-vcpe-rescust-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("d3aac917-543d-4421-b6d7-ba2b65884eb7");
assertTrue(service.isPresent());
assertEquals("vCPEResCust 2019-10-01 _2364", service.get().getModelName());
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method test_CCVPN_Distribution.
@Test
public void test_CCVPN_Distribution() 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/ccvpn/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demo-ccvpn-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("317887d3-a4e4-45cb-8971-2a78426fefac");
assertTrue(service.isPresent());
assertEquals("CCVPNService", service.get().getModelName());
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method testAllottedResourceService.
@Test
@Transactional
public void testAllottedResourceService() 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())));
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File("src/test/resources/resource-examples/allottedresource/notif-portm.json"), NotificationDataImpl.class);
headers.add("resource-location", "src/test/resources/resource-examples/allottedresource/");
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());
AllottedResource expectedService = new AllottedResource();
expectedService.setDescription("rege1802pnf");
expectedService.setModelInvariantUUID("b8f83c3f-077c-4e2c-b489-c66382060436");
expectedService.setModelName("rege1802pnf");
expectedService.setModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
expectedService.setModelVersion("1.0");
expectedService.setSubcategory("Contrail Route");
expectedService.setToscaNodeType("org.openecomp.resource.pnf.Rege1802pnf");
Set<AllottedResourceCustomization> arCustomizationSet = new HashSet<AllottedResourceCustomization>();
AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
arCustomization.setModelInstanceName("rege1802pnf 0");
arCustomizationSet.add(arCustomization);
arCustomization.setAllottedResource(expectedService);
expectedService.setAllotedResourceCustomization(arCustomizationSet);
AllottedResource actualResponse = allottedRepo.findResourceByModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
if (actualResponse == null)
throw new Exception("No Allotted Resource Written to database");
assertThat(actualResponse, sameBeanAs(expectedService).ignoring("0x1.created").ignoring("0x1.allotedResourceCustomization.created"));
}
use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.
the class ASDCRestInterfaceTest method testServiceBasicCnf.
@Test
public void testServiceBasicCnf() 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-BasicCnf/";
ObjectMapper mapper = new ObjectMapper();
NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "service-BasicCnf-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("31e0cd50-0a84-42b4-a7a8-dd5d82e6907d");
assertTrue(service.isPresent());
assertEquals("basic_cnf", service.get().getModelName());
}
Aggregations