summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/test/java/org
diff options
context:
space:
mode:
authorRamesh Parthasarathy <ramesh.parthasarathy@att.com>2019-05-16 21:15:29 -0700
committerRamesh Parthasarathy <ramesh.parthasarathy@att.com>2019-05-16 21:15:29 -0700
commit2fcd0d81688ca3dbde9c3853a0eca5aed9e4da7d (patch)
tree8fbda97d1a5bde30f3a5def8e529b309f56bd179 /asdc-controller/src/test/java/org
parentc0650e43c4228596831e5c49934a26ba4c221099 (diff)
Addressed vCPE-Infra processing issue ASDC Controller
code was modified to address vCPE-infra notification received from SDC. Also added unit tests to ensure that the code works as expected. Change-Id: I217e2dfed9548bfb0e9b93c96aaf75afc1d4171c Issue-ID: SO-1861 Signed-off-by: Ramesh Parthasarathy(rp6768)<ramesh.parthasarathy@att.com>
Diffstat (limited to 'asdc-controller/src/test/java/org')
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index ac107f6449..2c520a3bba 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -27,11 +27,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
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.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
import java.util.Set;
import javax.transaction.Transactional;
import javax.ws.rs.core.Response;
@@ -45,11 +49,15 @@ import org.onap.so.asdc.client.test.emulators.DistributionClientEmulator;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
import org.onap.so.db.catalog.beans.AllottedResource;
import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.ToscaCsar;
import org.onap.so.db.catalog.beans.Workflow;
import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
import org.onap.so.db.catalog.data.repository.WorkflowRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -75,6 +83,9 @@ public class ASDCRestInterfaceTest extends BaseTest {
private WorkflowRepository workflowRepo;
@Autowired
+ private ToscaCsarRepository toscaCsarRepo;
+
+ @Autowired
private ASDCRestInterface asdcRestInterface;
private TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
@@ -244,6 +255,41 @@ public class ASDCRestInterfaceTest extends BaseTest {
}
+
+ @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());
+ }
+
protected String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}