*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalapp.portal.service;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.portalapp.portal.domain.EPRole;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
import org.onap.portalapp.portal.service.EPRoleServiceImpl;
+import org.onap.portalapp.portal.utils.PortalConstants;
import org.onap.portalsdk.core.domain.RoleFunction;
import org.onap.portalsdk.core.service.DataAccessService;
MockitoAnnotations.initMocks(this);
}
+ @Mock
+ ExternalAccessRolesService externalAccessRolesService;
@InjectMocks
EPRoleServiceImpl ePRoleServiceImpl = new EPRoleServiceImpl();
@Test
public void getAvailableChildRolesIfRoleIdIsNullTest() {
+ Long roleId = (long)123;
List<EPRole> roleList = new ArrayList<>();
+ EPRole epRole = new EPRole();
EPRole role = new EPRole();
EPRole role1 = new EPRole();
role.addChildRole(role1);
roleList.add(role);
Mockito.when(dataAccessService.getList(EPRole.class, null)).thenReturn(roleList);
+ Mockito.when(dataAccessService.getDomainObject(EPRole.class, roleId, null)).thenReturn(epRole);
List<EPRole> expectedRoleList = ePRoleServiceImpl.getAvailableChildRoles(null);
assertEquals(roleList, expectedRoleList);
}
- // @Test
- // public void getAvailableChildRolesIfRoleIdNotNullTest()
- // {
- // List<EPRole> roleList = new ArrayList<>();
- // EPRole role = new EPRole();
- // EPRole role1= new EPRole();
- // role.addChildRole(role1);
- // roleList.add(role);
- // Mockito.when(dataAccessService.getDomainObject(EPRole.class, 1,
- // null)).thenReturn(role);
- // Mockito.when(dataAccessService.getList(EPRole.class,
- // null)).thenReturn(roleList);
- //
- // List<EPRole> expectedRoleList =
- // ePRoleServiceImpl.getAvailableChildRoles((long) 1);
- // System.out.println(expectedRoleList);
- // assertEquals(roleList,expectedRoleList);
- // }
- //
+ @Test
+ public void getAvailableChildRolesIfRoleIdTest() {
+ Long roleId = (long)123;
+ List<EPRole> roleList = new ArrayList<>();
+ EPRole epRole = new EPRole();
+ EPRole role = new EPRole();
+ EPRole role1 = new EPRole();
+ role.addChildRole(role1);
+ roleList.add(role);
+ Mockito.when(dataAccessService.getList(EPRole.class, null)).thenReturn(roleList);
+ Mockito.when(dataAccessService.getDomainObject(EPRole.class, roleId, null)).thenReturn(epRole);
+ List<EPRole> expectedRoleList = ePRoleServiceImpl.getAvailableChildRoles(roleId);
+ assertEquals(roleList, expectedRoleList);
+ }
+
@Test
public void getRoleFunctionTest() {
RoleFunction roleFunction = new RoleFunction();
final Map<String, String> portalParams = null;
List<EPRole> roleList = new ArrayList<>();
Mockito.when(dataAccessService.executeNamedQuery("getPortalAppRoles", portalParams, null)).thenReturn(roleList);
+ Mockito.when(externalAccessRolesService.getPortalAppRoleInfo(Matchers.anyLong())).thenReturn(roleList);
assertNull(ePRoleServiceImpl.getAppRole("test", (long) 1));
}
Mockito.when((List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", params, null))
.thenReturn(roleList);
List<EPRole> expectedRoleList = (List<EPRole>) ePRoleServiceImpl.getAppRole("test", (long) 10);
- System.out.println(expectedRoleList);
-
}
@Test