Search in sources :

Example 16 with NotificationDataImpl

use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.

the class ASDCRestInterfaceTest method test_E2ESlicing_Distribution.

@Test
public void test_E2ESlicing_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/e2eSlicing/";
    ObjectMapper mapper = new ObjectMapper();
    NotificationDataImpl request;
    HttpEntity<NotificationDataImpl> entity;
    ResponseEntity<String> response;
    headers.add("resource-location", resourceLocation);
    request = mapper.readValue(new File(resourceLocation + "nsst-notification.json"), NotificationDataImpl.class);
    entity = new HttpEntity<NotificationDataImpl>(request, headers);
    response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST, entity, String.class);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
    request = mapper.readValue(new File(resourceLocation + "nst-notification.json"), NotificationDataImpl.class);
    entity = new HttpEntity<NotificationDataImpl>(request, headers);
    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("7981375e-5e0a-4bf5-93fa-f3e3c02f2b11");
    assertTrue(service.isPresent());
    assertEquals("EmbbNst", service.get().getModelName());
    service = serviceRepo.findById("637e9b93-208b-4b06-80f2-a2021c228174");
    assertTrue(service.isPresent());
    assertEquals("EmbbCn", service.get().getModelName());
}
Also used : NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) Service(org.onap.so.db.catalog.beans.Service) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Example 17 with NotificationDataImpl

use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.

the class ASDCRestInterfaceTest method testServiceUbuntu16Test.

@Test
public void testServiceUbuntu16Test() 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-ubuntu16test/";
    ObjectMapper mapper = new ObjectMapper();
    NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "service-ubuntu16test-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("ed0391da-b963-4c45-bf3a-b49cc7a94fab");
    assertTrue(service.isPresent());
    assertEquals("ubuntu16test", service.get().getModelName());
}
Also used : NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) HttpEntity(org.springframework.http.HttpEntity) Service(org.onap.so.db.catalog.beans.Service) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Example 18 with NotificationDataImpl

use of org.onap.so.asdc.client.test.emulators.NotificationDataImpl in project so by onap.

the class ASDCRestInterfaceTest method test_PublicNS_Distribution.

@Test
public void test_PublicNS_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/public-ns/";
    ObjectMapper mapper = new ObjectMapper();
    NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demo-public-ns-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("da28696e-d4c9-4df4-9f91-465c6c09a81e");
// assertTrue(service.isPresent());
// assertEquals("PublicNS", service.get().getModelName());
}
Also used : NotificationDataImpl(org.onap.so.asdc.client.test.emulators.NotificationDataImpl) HttpEntity(org.springframework.http.HttpEntity) Service(org.onap.so.db.catalog.beans.Service) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Aggregations

NotificationDataImpl (org.onap.so.asdc.client.test.emulators.NotificationDataImpl)18 Test (org.junit.Test)16 BaseTest (org.onap.so.asdc.BaseTest)16 Service (org.onap.so.db.catalog.beans.Service)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 File (java.io.File)11 HttpEntity (org.springframework.http.HttpEntity)10 ArrayList (java.util.ArrayList)5 EntityNotFoundException (javax.persistence.EntityNotFoundException)5 ToscaCsar (org.onap.so.db.catalog.beans.ToscaCsar)5 WatchdogComponentDistributionStatus (org.onap.so.db.request.beans.WatchdogComponentDistributionStatus)5 Transactional (javax.transaction.Transactional)4 ASDCControllerException (org.onap.so.asdc.client.exceptions.ASDCControllerException)4 ArtifactInfoImpl (org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl)3 ResourceInfoImpl (org.onap.so.asdc.client.test.emulators.ResourceInfoImpl)3 HashSet (java.util.HashSet)2 Before (org.junit.Before)2 AllottedResource (org.onap.so.db.catalog.beans.AllottedResource)2 AllottedResourceCustomization (org.onap.so.db.catalog.beans.AllottedResourceCustomization)2 PnfResourceCustomization (org.onap.so.db.catalog.beans.PnfResourceCustomization)2