blob: 84096f130c18657e30eafc5b4032f30f418d6c47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package org.openecomp.portalapp.portal.service;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.portalapp.portal.domain.EPUser;
import org.openecomp.portalapp.portal.domain.GetAccessResult;
import org.openecomp.portalapp.portal.service.GetAccessServiceImpl;
import org.openecomp.portalapp.portal.core.MockEPUser;
import org.openecomp.portalsdk.core.service.DataAccessService;
import org.openecomp.portalsdk.core.service.DataAccessServiceImpl;
public class GetAccessServiceImplTest {
@Mock
DataAccessService dataAccessService = new DataAccessServiceImpl();
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@InjectMocks
GetAccessServiceImpl getAccessServiceImpl = new GetAccessServiceImpl();
MockEPUser mockUser = new MockEPUser();
@Test
public void getAppAccessListTest()
{
EPUser user = mockUser.mockEPUser();
Map<String, Long> params = new HashMap<>();
params.put("userId", user.getId());
List<GetAccessResult> appAccessList = new ArrayList<>();
Mockito.when(dataAccessService.executeNamedQuery("getAppAccessFunctionRole", params, null)).thenReturn(appAccessList);
List<GetAccessResult> expectedAppAccessList = getAccessServiceImpl.getAppAccessList(user);
assertEquals(expectedAppAccessList, appAccessList);
}
}
|