2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file 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.
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.admin;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
27 import static org.mockito.Mockito.mock;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpSession;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.mockito.Mockito;
35 import org.onap.portalsdk.core.domain.User;
36 import org.onap.portalsdk.core.util.SystemProperties;
37 import org.springframework.mock.web.MockHttpServletResponse;
39 public class PolicyUserInfoControllerTest {
41 private HttpServletRequest request;
42 private MockHttpServletResponse response;
45 public void setUp() throws Exception {
46 HttpSession mockSession = mock(HttpSession.class);
47 request = mock(HttpServletRequest.class);
48 response = new MockHttpServletResponse();
49 User user = new User();
50 user.setOrgUserId("Test");
51 Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
52 Mockito.when(request.getSession(false)).thenReturn(mockSession);
56 public final void testGetPolicyUserInfo() {
57 PolicyUserInfoController controller = new PolicyUserInfoController();
58 controller.getPolicyUserInfo(request, response);
60 assertTrue(response.getStatus() == 200);
61 } catch (Exception e) {