2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the “License”);
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38 package org.openecomp.portalapp.portal.controller;
40 import javax.servlet.http.HttpServletRequest;
41 import javax.servlet.http.HttpServletResponse;
43 import org.json.simple.JSONObject;
44 import org.junit.Before;
45 import org.junit.Test;
46 import org.junit.runner.RunWith;
47 import org.mockito.InjectMocks;
48 import org.mockito.Mock;
49 import org.mockito.Mockito;
50 import org.mockito.MockitoAnnotations;
51 import org.openecomp.portalapp.portal.core.MockEPUser;
52 import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
53 import org.openecomp.portalapp.portal.scheduler.SchedulerProperties;
54 import org.openecomp.portalapp.portal.scheduler.SchedulerRestInterface;
55 import org.openecomp.portalsdk.core.util.SystemProperties;
56 import org.openecomp.portalsdk.core.web.support.UserUtils;
57 import org.powermock.api.mockito.PowerMockito;
58 import org.powermock.core.classloader.annotations.PrepareForTest;
59 import org.powermock.modules.junit4.PowerMockRunner;
61 @RunWith(PowerMockRunner.class)
62 @PrepareForTest({UserUtils.class,SystemProperties.class})
64 public class SchedulerControllerTest {
67 SchedulerRestInterface schedulerRestInterface;
72 SchedulerController schedulerController = new SchedulerController();
76 MockitoAnnotations.initMocks(this);
79 MockEPUser mockUser = new MockEPUser();
80 MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
82 HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
83 HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
84 NullPointerException nullPointerException = new NullPointerException();
87 public void getTimeSlotsTest() throws Exception{
88 schedulerController.getTimeSlots(mockedRequest, "12");
93 public void postCreateNewVNFChangeTest() throws Exception{
94 //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\"]}]}}";
95 JSONObject jsonObject =Mockito.mock(JSONObject.class);
97 schedulerController.postCreateNewVNFChange(mockedRequest, jsonObject);
101 public void postSubmitVnfChangeTimeslotsTest() throws Exception{
102 JSONObject jsonObject =Mockito.mock(JSONObject.class);
103 Mockito.when(jsonObject.get("scheduleId")).thenReturn("12");
104 PowerMockito.mockStatic(SystemProperties.class);
105 PowerMockito.when(SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SUBMIT_NEW_VNF_CHANGE)).thenReturn("/v1/ChangeManagement/schedules/{scheduleId}/approvals");
106 schedulerController.postSubmitVnfChangeTimeslots(mockedRequest, jsonObject);