X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fservice%2FEPRoleServiceImplTest.java;h=32bd649980aae0f05acb48ad5da958779fd3fdb3;hb=012d8970a7e08b2397b7b90d0a293118e254b021;hp=4c97b6dd7f778cfb5505c69cb6153459180322c8;hpb=21a8761f684745bb300e075c7e98ad897ace9eed;p=portal.git diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java index 4c97b6dd..32bd6499 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalapp.portal.service; @@ -49,6 +49,7 @@ import javax.servlet.http.HttpServletResponse; 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; @@ -56,6 +57,7 @@ import org.onap.portalapp.portal.core.MockEPUser; 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; @@ -69,6 +71,8 @@ public class EPRoleServiceImplTest { MockitoAnnotations.initMocks(this); } + @Mock + ExternalAccessRolesService externalAccessRolesService; @InjectMocks EPRoleServiceImpl ePRoleServiceImpl = new EPRoleServiceImpl(); @@ -89,35 +93,34 @@ public class EPRoleServiceImplTest { @Test public void getAvailableChildRolesIfRoleIdIsNullTest() { + Long roleId = (long)123; List 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 expectedRoleList = ePRoleServiceImpl.getAvailableChildRoles(null); assertEquals(roleList, expectedRoleList); } - // @Test - // public void getAvailableChildRolesIfRoleIdNotNullTest() - // { - // List 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 expectedRoleList = - // ePRoleServiceImpl.getAvailableChildRoles((long) 1); - // System.out.println(expectedRoleList); - // assertEquals(roleList,expectedRoleList); - // } - // + @Test + public void getAvailableChildRolesIfRoleIdTest() { + Long roleId = (long)123; + List 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 expectedRoleList = ePRoleServiceImpl.getAvailableChildRoles(roleId); + assertEquals(roleList, expectedRoleList); + } + @Test public void getRoleFunctionTest() { RoleFunction roleFunction = new RoleFunction(); @@ -216,6 +219,7 @@ public class EPRoleServiceImplTest { final Map portalParams = null; List 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)); } @@ -232,8 +236,6 @@ public class EPRoleServiceImplTest { Mockito.when((List) dataAccessService.executeNamedQuery("getAppRoles", params, null)) .thenReturn(roleList); List expectedRoleList = (List) ePRoleServiceImpl.getAppRole("test", (long) 10); - System.out.println(expectedRoleList); - } @Test