2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
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.portalapp.portal.service;
22 import static org.junit.Assert.*;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.InjectMocks;
29 import org.mockito.Mock;
30 import org.mockito.Mockito;
31 import org.mockito.MockitoAnnotations;
32 import org.onap.portalapp.portal.core.MockEPUser;
33 import org.onap.portalapp.portal.domain.EPUser;
34 import org.onap.portalapp.service.EPProfileServiceImpl;
35 import org.onap.portalsdk.core.dao.ProfileDao;
36 import org.onap.portalsdk.core.domain.Profile;
37 import org.onap.portalsdk.core.service.DataAccessService;
38 import org.onap.portalsdk.core.service.DataAccessServiceImpl;
40 public class EPProfileServiceImplTest {
43 DataAccessService dataAccessService = new DataAccessServiceImpl();
46 ProfileDao profileDao;
50 MockitoAnnotations.initMocks(this);
54 EPProfileServiceImpl epProfileServiceImpl = new EPProfileServiceImpl();
56 MockEPUser mockUser = new MockEPUser();
59 public void findAllTest() {
60 List<Profile> profileList = new ArrayList<>();
61 Mockito.when(dataAccessService.getList(Profile.class, null)).thenReturn(profileList);
62 List<Profile> expectedRoleList = epProfileServiceImpl.findAll();
63 assertEquals(expectedRoleList, profileList);
66 @Test(expected = java.lang.NumberFormatException.class)
67 public void getUserTest() {
68 EPUser epUser = new EPUser();
69 Mockito.when(dataAccessService.getDomainObject(EPUser.class, Long.parseLong("test"), null)).thenReturn(epUser);
70 epProfileServiceImpl.getUser("test");
74 public void saveUserTest() {
75 EPUser user = mockUser.mockEPUser();
76 Mockito.doNothing().when(dataAccessService).saveDomainObject(user, null);
77 epProfileServiceImpl.saveUser(user);
81 public void getProfileTest() {
82 epProfileServiceImpl.getProfile(1);