[Policy-17] Removed the sql scripts from sdk app
[policy/engine.git] / POLICY-SDK-APP / src / test / java / org / openecomp / policy / controller / AdminTabControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.policy.controller;
21
22 import static org.junit.Assert.assertTrue;
23 import static org.mockito.Mockito.mock;
24 import static org.mockito.Mockito.when;
25
26 import java.io.UnsupportedEncodingException;
27 import java.util.ArrayList;
28 import java.util.List;
29
30 import javax.servlet.http.HttpServletRequest;
31
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
35 import org.openecomp.policy.common.logging.flexlogger.Logger;
36 import org.openecomp.policy.rest.dao.CommonClassDao;
37 import org.openecomp.policy.rest.jpa.GlobalRoleSettings;
38 import org.springframework.mock.web.MockHttpServletResponse;
39
40 public class AdminTabControllerTest {
41
42         private static Logger logger = FlexLogger.getLogger(AdminTabControllerTest.class);
43         private static CommonClassDao commonClassDao;
44         
45         @Before
46         public void setUp() throws Exception {
47
48                 logger.info("setUp: Entering");
49         commonClassDao = mock(CommonClassDao.class);
50         GlobalRoleSettings globalRole = new GlobalRoleSettings();
51         globalRole.setLockdown(true);
52         globalRole.setRole("super-admin");
53         List<Object> globalRoles = new ArrayList<>();
54         globalRoles.add(globalRole);
55         when(commonClassDao.getData(GlobalRoleSettings.class)).thenReturn(globalRoles);
56         } 
57         
58         @Test
59         public void testGetAdminRole(){
60                 HttpServletRequest request = mock(HttpServletRequest.class);       
61                 MockHttpServletResponse response =  new MockHttpServletResponse();
62                 
63                 AdminTabController admin = new AdminTabController();
64                 AdminTabController.setCommonClassDao(commonClassDao);
65                 admin.getAdminTabEntityData(request, response);
66                 
67                 try {
68                         assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("lockdowndata"));
69                 } catch (UnsupportedEncodingException e) {
70                         logger.error("Exception Occured"+e);
71                 }
72         }
73         
74 }