2  * ============LICENSE_START==========================================
 
   4  * ===================================================================
 
   5  * Copyright (C) 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.onap.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.onap.portalapp.portal.controller.SchedulerController;
 
  52 import org.onap.portalapp.portal.core.MockEPUser;
 
  53 import org.onap.portalapp.portal.framework.MockitoTestSuite;
 
  54 import org.onap.portalapp.portal.scheduler.SchedulerProperties;
 
  55 import org.onap.portalapp.portal.scheduler.SchedulerRestInterface;
 
  56 import org.onap.portalsdk.core.util.SystemProperties;
 
  57 import org.onap.portalsdk.core.web.support.UserUtils;
 
  58 import org.powermock.api.mockito.PowerMockito;
 
  59 import org.powermock.core.classloader.annotations.PrepareForTest;
 
  60 import org.powermock.modules.junit4.PowerMockRunner;
 
  62 @RunWith(PowerMockRunner.class)
 
  63 @PrepareForTest({UserUtils.class,SystemProperties.class})
 
  65 public class SchedulerControllerTest {
 
  68         SchedulerRestInterface schedulerRestInterface;
 
  73         SchedulerController schedulerController = new SchedulerController();
 
  77                 MockitoAnnotations.initMocks(this);
 
  80         MockEPUser mockUser = new MockEPUser();
 
  81         MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
 
  83         HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
 
  84         HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
 
  85         NullPointerException nullPointerException = new NullPointerException();
 
  88         public void  getTimeSlotsTest() throws Exception{
 
  89                 schedulerController.getTimeSlots(mockedRequest, "12");
 
  94         public void postCreateNewVNFChangeTest() throws Exception{
 
  95                 //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\"]}]}}";
 
  96                 JSONObject jsonObject =Mockito.mock(JSONObject.class);
 
  98                 schedulerController.postCreateNewVNFChange(mockedRequest, jsonObject);
 
 102         public void postSubmitVnfChangeTimeslotsTest() throws Exception{
 
 103                 JSONObject jsonObject =Mockito.mock(JSONObject.class);
 
 104                 Mockito.when(jsonObject.get("scheduleId")).thenReturn("12");
 
 105         PowerMockito.mockStatic(SystemProperties.class);
 
 106                 PowerMockito.when(SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SUBMIT_NEW_VNF_CHANGE)).thenReturn("/v1/ChangeManagement/schedules/{scheduleId}/approvals");
 
 107                 schedulerController.postSubmitVnfChangeTimeslots(mockedRequest, jsonObject);