OrganizationalUnitController { public boolean canDeleteOrgUnit(OrganizationalUnit organizationalUnit) { final boolean securityPermission = authorizationManager.authorize(organizationalUnit, OrganizationalUnitAction.DELETE, user); return securityPermission || userIsAtLeast(ContributorType.OWNER, organizationalUnit.getContributors()); } @Inject  OrganizationalUnitController(AuthorizationManager authorizationManager,
                                        User user); boolean canCreateOrgUnits(); boolean canReadOrgUnits(); boolean canReadOrgUnit(final OrganizationalUnit organizationalUnit); boolean canUpdateOrgUnit(OrganizationalUnit organizationalUnit); boolean canDeleteOrgUnit(OrganizationalUnit organizationalUnit); static final String ORG_UNIT_TYPE; static final String ORG_UNIT_CREATE; static final String ORG_UNIT_READ; static final String ORG_UNIT_UPDATE; static final String ORG_UNIT_DELETE; }
@Test public void userCanDeleteOrganizationalUnitTest() { doReturn(true).when(organizationalUnitController).canDeleteOrgUnit(any()); assertTrue(organizationalUnitController.canDeleteOrgUnit(mock(OrganizationalUnit.class))); }
@Test public void userCanNotDeleteOrganizationalUnitTest() { doReturn(false).when(organizationalUnitController).canDeleteOrgUnit(any()); assertFalse(organizationalUnitController.canDeleteOrgUnit(mock(OrganizationalUnit.class))); }