1 package org.openecomp.portalapp.portal.test.controller;
3 import java.sql.DriverManager;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
8 import org.json.simple.JSONObject;
9 import org.junit.Before;
10 import org.junit.Test;
11 import org.junit.runner.RunWith;
12 import org.mockito.InjectMocks;
13 import org.mockito.Mock;
14 import org.mockito.Mockito;
15 import org.mockito.MockitoAnnotations;
16 import org.openecomp.portalapp.portal.controller.SchedulerController;
17 import org.openecomp.portalapp.portal.scheduler.SchedulerProperties;
18 import org.openecomp.portalapp.portal.scheduler.SchedulerRestInterface;
19 import org.openecomp.portalapp.portal.test.core.MockEPUser;
20 import org.openecomp.portalapp.test.framework.MockitoTestSuite;
21 import org.openecomp.portalsdk.core.util.SystemProperties;
22 import org.openecomp.portalsdk.core.web.support.UserUtils;
23 import org.powermock.api.mockito.PowerMockito;
24 import org.powermock.core.classloader.annotations.PrepareForTest;
25 import org.powermock.modules.junit4.PowerMockRunner;
27 @RunWith(PowerMockRunner.class)
28 @PrepareForTest({UserUtils.class,SystemProperties.class})
30 public class SchedulerControllerTest {
33 SchedulerRestInterface schedulerRestInterface;
38 SchedulerController schedulerController = new SchedulerController();
42 MockitoAnnotations.initMocks(this);
45 MockEPUser mockUser = new MockEPUser();
46 MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
48 HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
49 HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
50 NullPointerException nullPointerException = new NullPointerException();
53 public void getTimeSlotsTest() throws Exception{
54 schedulerController.getTimeSlots(mockedRequest, "12");
59 public void postCreateNewVNFChangeTest() throws Exception{
60 //String testJsonData="{\"domain\":\"ChangeManagement\",\"scheduleName\":\"VnfUpgrade/DWF\",\"userId\":\"su7376\",\"domainData\":[{\"WorkflowName\":\"HEAT Stack Software Update for vNFs\",\"CallbackUrl\":\"http://127.0.0.1:8989/scheduler/v1/loopbacktest/vid\",\"CallbackData\":\"testing\"}],\"schedulingInfo\":{\"normalDurationInSeconds\":60,\"additionalDurationInSeconds\":60,\"concurrencyLimit\":60,\"policyId\":\"SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_zone_localTime.1.xml\",\"vnfDetails\":[{\"groupId\":\"group1\",\"node\":[\"satmo415vbc\",\"satmo455vbc\"]}]}}";
61 JSONObject jsonObject =Mockito.mock(JSONObject.class);
63 schedulerController.postCreateNewVNFChange(mockedRequest, jsonObject);
67 public void postSubmitVnfChangeTimeslotsTest() throws Exception{
68 JSONObject jsonObject =Mockito.mock(JSONObject.class);
69 Mockito.when(jsonObject.get("scheduleId")).thenReturn("12");
70 PowerMockito.mockStatic(SystemProperties.class);
71 PowerMockito.when(SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SUBMIT_NEW_VNF_CHANGE)).thenReturn("/v1/ChangeManagement/schedules/{scheduleId}/approvals");
72 schedulerController.postSubmitVnfChangeTimeslots(mockedRequest, jsonObject);