From c9d63f49af5455f503ca63395121b7cd4d8c8c88 Mon Sep 17 00:00:00 2001 From: "Sonsino, Ofir (os0695)" Date: Wed, 14 Mar 2018 12:04:50 +0200 Subject: Unit tests Change-Id: I9c63fd607757bbec095c26341af593d9afd73886 Issue-ID: VID-197 Signed-off-by: Sonsino, Ofir (os0695) --- .../services/ChangeManagementServiceImplTest.java | 153 ++++++++++++++------- .../vid/services/RoleGenaratorServiceImplTest.java | 26 ++++ .../onap/vid/services/WorkflowServiceImplTest.java | 33 +++++ 3 files changed, 159 insertions(+), 53 deletions(-) create mode 100644 vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/services/WorkflowServiceImplTest.java (limited to 'vid-app-common/src/test/java/org/onap/vid/services') diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java index e73838c9..85b88a0d 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java @@ -6,64 +6,111 @@ import java.util.*; import org.json.simple.JSONArray; import org.junit.Assert; import org.junit.Test; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.service.DataAccessServiceImpl; import org.onap.vid.changeManagement.ChangeManagementRequest; +import org.onap.vid.changeManagement.GetVnfWorkflowRelationRequest; import org.onap.vid.changeManagement.RequestDetails; +import org.onap.vid.changeManagement.VnfWorkflowRelationAllResponse; +import org.onap.vid.changeManagement.VnfWorkflowRelationRequest; +import org.onap.vid.changeManagement.VnfWorkflowRelationResponse; +import org.onap.vid.mso.MsoBusinessLogic; +import org.onap.vid.mso.MsoBusinessLogicImpl; +import org.onap.vid.mso.rest.MsoRestClientNew; import org.onap.vid.mso.rest.Request; import org.springframework.http.ResponseEntity; +import org.springframework.web.multipart.MultipartFile; public class ChangeManagementServiceImplTest { - /*TODO: fix private ChangeManagementServiceImpl createTestSubject() { - return new ChangeManagementServiceImpl(); - }*/ - - - /*@Test - public void testGetMSOChangeManagements() throws Exception { - ChangeManagementServiceImpl testSubject; - Collection result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMSOChangeManagements(); - } - - - @Test - public void testFindRequestByVnfName() throws Exception { - ChangeManagementServiceImpl testSubject;List requests = null; - String vnfName = ""; - RequestDetails result; - - // test 1 - testSubject=createTestSubject();requests = null; - result=Deencapsulation.invoke(testSubject, "findRequestByVnfName", new Object[]{List.class, vnfName}); - Assert.assertEquals(null, result); - }*/ -/* - - @Test - public void testDoChangeManagement() throws Exception { - ChangeManagementServiceImpl testSubject; - ChangeManagementRequest request = null; - String vnfName = ""; - ResponseEntity result; - - // test 1 - testSubject = createTestSubject(); - request = null; - result = testSubject.doChangeManagement(request, vnfName); - Assert.assertEquals(null, result); - } - - - @Test - public void testGetSchedulerChangeManagements() throws Exception { - ChangeManagementServiceImpl testSubject; - JSONArray result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSchedulerChangeManagements(); - }*/ + private ChangeManagementServiceImpl createTestSubject() { + return new ChangeManagementServiceImpl(new DataAccessServiceImpl(), new MsoBusinessLogicImpl(new MsoRestClientNew())); + } + + @Test + public void testGetMSOChangeManagements() throws Exception { + ChangeManagementServiceImpl testSubject; + Collection result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMSOChangeManagements(); + } + + @Test + public void testDoChangeManagement() throws Exception { + ChangeManagementServiceImpl testSubject; + ChangeManagementRequest request = null; + String vnfName = ""; + ResponseEntity result; + + // test 1 + testSubject = createTestSubject(); + request = null; + result = testSubject.doChangeManagement(request, vnfName); + Assert.assertEquals(null, result); + } + + + @Test + public void testGetSchedulerChangeManagements() throws Exception { + ChangeManagementServiceImpl testSubject; + JSONArray result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSchedulerChangeManagements(); + } + + @Test + public void testDeleteSchedule() throws Exception { + ChangeManagementServiceImpl testSubject; + String scheduleId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.deleteSchedule(scheduleId); + } + + + + /* + * TODO: fix private ChangeManagementServiceImpl createTestSubject() { + * return new ChangeManagementServiceImpl(); } + */ + + /* + * @Test public void testGetMSOChangeManagements() throws Exception { + * ChangeManagementServiceImpl testSubject; Collection result; + * + * // default test testSubject = createTestSubject(); result = + * testSubject.getMSOChangeManagements(); } + * + * + * @Test public void testFindRequestByVnfName() throws Exception { + * ChangeManagementServiceImpl testSubject;List requests = + * null; String vnfName = ""; RequestDetails result; + * + * // test 1 testSubject=createTestSubject();requests = null; + * result=Deencapsulation.invoke(testSubject, "findRequestByVnfName", new + * Object[]{List.class, vnfName}); Assert.assertEquals(null, + * result); } + */ + /* + * + * @Test public void testDoChangeManagement() throws Exception { + * ChangeManagementServiceImpl testSubject; ChangeManagementRequest request + * = null; String vnfName = ""; ResponseEntity result; + * + * // test 1 testSubject = createTestSubject(); request = null; result = + * testSubject.doChangeManagement(request, vnfName); + * Assert.assertEquals(null, result); } + * + * + * @Test public void testGetSchedulerChangeManagements() throws Exception { + * ChangeManagementServiceImpl testSubject; JSONArray result; + * + * // default test testSubject = createTestSubject(); result = + * testSubject.getSchedulerChangeManagements(); } + */ } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java new file mode 100644 index 00000000..544a799a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java @@ -0,0 +1,26 @@ +package org.onap.vid.services; + +import static org.junit.Assert.*; +import java.util.*; +import org.junit.Assert; +import org.junit.Test; + +public class RoleGenaratorServiceImplTest { + + private RoleGenaratorServiceImpl createTestSubject() { + return new RoleGenaratorServiceImpl(); + } + + @Test + public void testGenerateRoleScript() throws Exception { + RoleGenaratorServiceImpl testSubject; + Boolean firstRun = null; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.generateRoleScript(firstRun); + } + + +} \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/services/WorkflowServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/WorkflowServiceImplTest.java new file mode 100644 index 00000000..36f8c0b2 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/WorkflowServiceImplTest.java @@ -0,0 +1,33 @@ +package org.onap.vid.services; + +import java.util.*; + +import org.junit.Test; + +public class WorkflowServiceImplTest { + + private WorkflowServiceImpl createTestSubject() { + return new WorkflowServiceImpl(); + } + + @Test + public void testGetWorkflowsForVNFs() throws Exception { + WorkflowServiceImpl testSubject; + Collection vnfNames = new ArrayList(); + Collection result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getWorkflowsForVNFs(vnfNames); + } + + @Test + public void testGetAllWorkflows() throws Exception { + WorkflowServiceImpl testSubject; + Collection result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAllWorkflows(); + } +} \ No newline at end of file -- cgit 1.2.3-korg