2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.policy.admin;
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assert.fail;
24 import static org.mockito.Mockito.mock;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpSession;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.Mockito;
32 import org.openecomp.portalsdk.core.domain.User;
33 import org.openecomp.portalsdk.core.util.SystemProperties;
34 import org.springframework.mock.web.MockHttpServletResponse;
36 public class PolicyUserInfoControllerTest {
38 private HttpServletRequest request;
39 private MockHttpServletResponse response;
42 public void setUp() throws Exception {
43 HttpSession mockSession = mock(HttpSession.class);
44 request = mock(HttpServletRequest.class);
45 response = new MockHttpServletResponse();
46 User user = new User();
47 user.setOrgUserId("Test");
48 Mockito.when(mockSession.getAttribute(SystemProperties.getProperty("user_attribute_name"))).thenReturn(user);
49 Mockito.when(request.getSession(false)).thenReturn(mockSession);
53 public final void testGetPolicyUserInfo() {
54 PolicyUserInfoController controller = new PolicyUserInfoController();
55 controller.getPolicyUserInfo(request, response);
57 assertTrue(response.getStatus() == 200);