aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@att.com>2018-01-31 17:19:00 +0200
committerOfir Sonsino <os0695@att.com>2018-01-31 17:19:00 +0200
commit1cfb08779ea0e00be69e072a940b3063e049fe6b (patch)
tree6602a900387c8393ed0dcd81c0539381632903c6 /vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java
parent2f20b001b9243e0f8b44aecc768ec265fd538732 (diff)
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d Issue-ID: VID-86 Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java
new file mode 100644
index 000000000..4a0685786
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java
@@ -0,0 +1,71 @@
+package org.onap.vid.mso;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.controller.MsoConfig;
+import org.onap.vid.mso.MsoBusinessLogicImpl;
+import org.onap.vid.mso.MsoInterface;
+import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.net.URL;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+@Test
+@ContextConfiguration(classes = { SystemProperties.class, MsoConfig.class })
+@WebAppConfiguration
+public class MsoBusinessLogicTest extends AbstractTestNGSpringContextTests {
+
+ @InjectMocks
+ private MsoBusinessLogicImpl msoBusinessLogic;
+
+ @Mock
+ private MsoInterface msoClient;
+
+ @BeforeMethod
+ public void initMocks(){
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testCreateInstance() throws Exception {
+ String instanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
+ final RequestDetails requestDetails = setRequestDetails("mso_request_create_configuration.json");
+ Mockito.doReturn(getOkResponse(instanceId)).when(msoClient).createConfigurationInstance(requestDetails, "/serviceInstances/v6/3f93c7cb-2fd0-4557-9514-e189b7b04f9d/configurations");
+ final MsoResponseWrapper msoResponseWrapper = msoBusinessLogic.createConfigurationInstance(requestDetails, instanceId);
+
+ assertNotNull(msoResponseWrapper);
+ assertEquals(202, msoResponseWrapper.getStatus());
+ }
+
+ private MsoResponseWrapper getOkResponse(String instanceId){
+ MsoResponseWrapper responseWrapper = new MsoResponseWrapper();
+ String entity = " \"body\": {\n" +
+ " \"requestReferences\": {\n" +
+ " \"instanceId\": \""+instanceId+"\",\n" +
+ " \"requestId\": \"b6dc9806-b094-42f7-9386-a48de8218ce8\"\n" +
+ " }";
+ responseWrapper.setEntity(entity);
+ responseWrapper.setStatus(202);
+ return responseWrapper;
+ }
+
+ private RequestDetails setRequestDetails(String bodyFileName)throws Exception {
+ final URL resource = this.getClass().getResource("/payload_jsons/" + bodyFileName);
+ ObjectMapper mapper = new ObjectMapper();
+ RequestDetails requestDetails = mapper.readValue(resource, RequestDetails.class);
+ return requestDetails;
+
+ }
+}