summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java')
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java185
1 files changed, 0 insertions, 185 deletions
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java
deleted file mode 100644
index ae6eb975..00000000
--- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/service/LoginExternalAuthServiceImplTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal SDK
- * ===================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the "License");
- * you may not use this software except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ============LICENSE_END============================================
- *
- *
- */
-package org.onap.portalsdk.external.authorization.service;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.portalsdk.core.command.LoginBean;
-import org.onap.portalsdk.core.domain.App;
-import org.onap.portalsdk.core.domain.Role;
-import org.onap.portalsdk.core.domain.RoleFunction;
-import org.onap.portalsdk.core.domain.User;
-import org.onap.portalsdk.core.domain.UserApp;
-import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.portalsdk.core.web.support.AppUtils;
-import org.onap.portalsdk.core.web.support.UserUtils;
-import org.onap.portalsdk.external.framework.MockitoTestSuite;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@SuppressWarnings({ "unchecked", "rawtypes" })
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({AppUtils.class, UserUtils.class, SystemProperties.class})
-public class LoginExternalAuthServiceImplTest {
-
- @InjectMocks
- private LoginExternalAuthServiceImpl loginExternalAuthServiceImpl;
-
- @Mock
- private DataAccessService dataAccessService;
-
- @Mock
- private UserApiService userApiService;
-
- MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
-
- HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
- HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
-
- @Before
- public void setup() {
- PowerMockito.mockStatic(AppUtils.class);
- PowerMockito.mockStatic(UserUtils.class);
- PowerMockito.mockStatic(SystemProperties.class);
- }
-
- private User userObj() {
- User user = new User();
- user.setEmail("test@mail.com");
- user.setFirstName("Test_firstname");
- user.setHrid("test_hrid");
- user.setJobTitle("test_jobtitle");
- user.setLastName("test_lastname");
- user.setLoginId("test123");
- user.setOrgManagerUserId("test456");
- user.setMiddleInitial("test_middlename");
- user.setOrgCode("testcode");
- user.setOrgId(1l);
- user.setOrgUserId("test123");
- user.setActive(true);
- user.setLastLoginDate(new Date());
- RoleFunction roleFunction = new RoleFunction();
- roleFunction.setId(12L);
- roleFunction.setName("Role Function");
-
- Set roleFunctions = new TreeSet();
- roleFunctions.add(roleFunction);
-
- Role role = new Role();
- role.setName("Role");
- role.setActive(true);
- role.setRoleFunctions(roleFunctions);
- Set userApps = new TreeSet();
- UserApp userApp = new UserApp();
- userApp.setUserId(1L);
- userApp.setApp(getApp());
- userApp.setRole(role);
- userApps.add(userApp);
- user.setUserApps(userApps);
- return user;
- }
-
- public App getApp() {
- App app = new App();
- app.setId(new Long(1));
- app.setName("Default");
- return app;
- }
-
- @Test
- public void findUserTest() throws Exception {
- LoginBean bean = new LoginBean();
- bean.setUserid("test123");
- Map additionalParams = new HashMap<>();
- User user = userObj();
- user.setId(1l);
- List usersId = new ArrayList<>();
- usersId.add(user.getId());
- List users = new ArrayList<>();
- users.add(user);
- Mockito.when(userApiService.getUser(bean.getUserid(), mockedRequest)).thenReturn(user);
- Map<String, String> params = new HashMap<>();
- params.put("orgUserId", "test123");
- Mockito.when(dataAccessService.executeNamedQuery("getUserIdByorgUserId", params, null)).thenReturn(usersId);
- Map<String, String> params2 = new HashMap<>();
- params.put("org_user_id", "test123");
- Mockito.when(dataAccessService.executeNamedQuery("getUserByOrgUserId", params2, new HashMap())).thenReturn(users);
- LoginBean expected = loginExternalAuthServiceImpl.findUser(bean, "menu", additionalParams, mockedRequest);
- assertNotNull(expected);
- }
-
- @Test
- public void findUserForNewUserTest() throws Exception {
- LoginBean bean = new LoginBean();
- bean.setUserid("test123");
- Map additionalParams = new HashMap<>();
- User user = userObj();
- List usersId = new ArrayList<>();
- usersId.add(user.getId());
- List users = new ArrayList<>();
- users.add(user);
- Mockito.when(userApiService.getUser(bean.getUserid(), mockedRequest)).thenReturn(user);
- Map<String, String> params = new HashMap<>();
- params.put("orgUserId", "test123");
- Mockito.when(dataAccessService.executeNamedQuery("getUserIdByorgUserId", params, null)).thenReturn(usersId);
- Map<String, String> params2 = new HashMap<>();
- params.put("org_user_id", "test123");
- Mockito.when(dataAccessService.executeNamedQuery("getUserByOrgUserId", params2, new HashMap())).thenReturn(null);
- LoginBean expected = loginExternalAuthServiceImpl.findUser(bean, "menu", additionalParams, mockedRequest);
- assertNotNull(expected);
- }
-}