summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@att.com>2017-09-20 14:08:19 +0300
committerOfir Sonsino <os0695@att.com>2017-09-20 14:14:56 +0300
commit1ba64a4a45f26e8bdb58e866e540aa58f32e2e52 (patch)
treedac3ada662bb141fe986526d13b2436032e5012e /vid-app-common/src/test/java
parentcbdd17f586a4914890bd2b26ee91be135568f38c (diff)
Change management and PNF support
Issue-ID: VID-44, VID-48, VID-49, VID-50, VID-51, VID-52 Change-Id: I83e940aad2e4e294a0927b546c4c08ca8e539a65 Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/test/java')
-rw-r--r--vid-app-common/src/test/java/org/opencomp/vid/controller/MsoControllerTest.java112
-rw-r--r--vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java16
-rw-r--r--vid-app-common/src/test/java/org/openecomp/vid/services/ChangeManagementServiceTest.java29
3 files changed, 157 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/opencomp/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/opencomp/vid/controller/MsoControllerTest.java
new file mode 100644
index 00000000..9333ac9b
--- /dev/null
+++ b/vid-app-common/src/test/java/org/opencomp/vid/controller/MsoControllerTest.java
@@ -0,0 +1,112 @@
+package org.opencomp.vid.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.openecomp.vid.controller.MsoConfig;
+import org.openecomp.vid.controller.MsoController;
+import org.openecomp.vid.domain.mso.RequestInfo;
+import org.openecomp.vid.factories.MsoRequestFactory;
+import org.openecomp.vid.mso.rest.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(classes = {SystemProperties.class , MsoConfig.class})
+public class MsoControllerTest {
+
+ @Autowired
+ MsoRequestFactory msoRequestFactory;
+
+ @Test
+ public void testInstanceCreationNew() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController();
+ ResponseEntity<String> responseEntityNew = msoController.createSvcInstanceNew(null, requestDetails);
+ ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails);
+ assertEquals(responseEntityNew, responseEntity);
+
+ }
+
+ @Test
+ public void testInstanceCreationLocalWithRest() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController();
+ ResponseEntity<String> responseEntityNew = msoController.createSvcInstance(null, requestDetails);
+ ResponseEntity<String> responseEntityRest = msoController.createSvcInstanceNewRest(null, requestDetails);
+
+ assertEquals(responseEntityNew.getBody(), responseEntityRest.getBody());
+
+ }
+
+ @Test
+ public void testInstanceCreation() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController();
+ ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails);
+
+
+ assertEquals(responseEntity.getBody(), "{ \"status\": 200, \"entity\": {\n" +
+ " \"requestReferences\": {\n" +
+ " \"instanceId\": \"ba00de9b-3c3e-4b0a-a1ad-0c5489e711fb\",\n" +
+ " \"requestId\": \"311cc766-b673-4a50-b9c5-471f68914586\"\n" +
+ " }\n" +
+ "}}");
+
+ }
+
+ @Test
+ public void testGetOrchestrationRequestsForDashboard() throws Exception{
+ MsoController msoController = new MsoController();
+ List<Request> orchestrationRequestsForDashboard = msoController.getOrchestrationRequestsForDashboard();
+
+ assertEquals(orchestrationRequestsForDashboard.size() , 2);
+ }
+
+ @Test
+ public void testGetManualTasksByRequestId() throws Exception{
+ MsoController msoController = new MsoController();
+ List<Task> orchestrationRequestsForDashboard = msoController.getManualTasksByRequestId("za1234d1-5a33-55df-13ab-12abad84e335");
+
+ assertEquals(orchestrationRequestsForDashboard.get(0).getTaskId() , "daf4dd84-b77a-42da-a051-3239b7a9392c");
+ }
+
+
+ public void testCompleteManualTask() throws Exception{ // TODO not done yet
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setResponseValue("rollback");
+ requestInfo.setRequestorId("abc");
+ requestInfo.setSource("VID");
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(requestInfo);
+ MsoController msoController = new MsoController();
+ ResponseEntity<String> responseEntity = msoController.manualTaskComplete("daf4dd84-b77a-42da-a051-3239b7a9392c" , requestDetails);
+ String assertString = "{ \\\"status\\\": 200, \\\"entity\\\": {\\n\" +\n" +
+ " \" \\\"taskRequestReference\\\": {\\n\" +\n" +
+ " \" \\\"taskId\\\": \\\"daf4dd84-b77a-42da-a051-3239b7a9392c\\\"\\n\" +\n" +
+ " \" }\\n\" +\n" +
+ " \"}\\n\" +\n" +
+ " \"}";
+ assertEquals(responseEntity.getBody() , StringEscapeUtils.unescapeJava(assertString));
+ }
+
+
+
+
+
+}
diff --git a/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java b/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java
index abf44bf7..f89d9cba 100644
--- a/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java
+++ b/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java
@@ -11,6 +11,8 @@ import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
+import org.openecomp.vid.aai.AaiClient;
+import org.openecomp.vid.aai.AaiResponse;
import org.openecomp.vid.asdc.AsdcCatalogException;
import org.openecomp.vid.asdc.AsdcClient;
import org.openecomp.vid.asdc.parser.ToscaParserImpl2;
@@ -41,6 +43,7 @@ public class VidControllerTest {
@Autowired
private AsdcClient asdcClient;
+
@Autowired
ServletContext context;
public class Constants{
@@ -55,6 +58,19 @@ public class VidControllerTest {
private ToscaParserImpl2 p2 = new ToscaParserImpl2();
private ObjectMapper om = new ObjectMapper();
+
+ @Test
+ public void test() {
+ AaiClient client = new AaiClient(context);
+ AaiResponse<?> response = client.getVNFData();
+ try {
+ System.out.println(new ObjectMapper().writeValueAsString(response));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
@Test
public void checkPNFFieldsExist() throws SdcToscaParserException {
String serviceRoleString = "serviceRole";
diff --git a/vid-app-common/src/test/java/org/openecomp/vid/services/ChangeManagementServiceTest.java b/vid-app-common/src/test/java/org/openecomp/vid/services/ChangeManagementServiceTest.java
new file mode 100644
index 00000000..f770ab2a
--- /dev/null
+++ b/vid-app-common/src/test/java/org/openecomp/vid/services/ChangeManagementServiceTest.java
@@ -0,0 +1,29 @@
+package org.openecomp.vid.services;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.vid.changeManagement.ChangeManagementRequest;
+import org.openecomp.vid.changeManagement.ChangeManagementResponse;
+import org.springframework.http.ResponseEntity;
+
+import junit.framework.Assert;
+
+import static org.junit.Assert.*;
+
+
+public class ChangeManagementServiceTest {
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void doChangeManagement_requestTypeIsUpdateVnfNotFound_doUpdateAndReturnNull() throws Exception {
+
+ }
+
+} \ No newline at end of file