OrganizationalUnitController { public boolean canUpdateOrgUnit(OrganizationalUnit organizationalUnit) { final boolean securityPermission = authorizationManager.authorize(organizationalUnit, OrganizationalUnitAction.UPDATE, user); return securityPermission || userIsAtLeast(ContributorType.ADMIN, 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 userCanUpdateOrganizationalUnitTest() { doReturn(true).when(organizationalUnitController).canUpdateOrgUnit(any()); assertTrue(organizationalUnitController.canUpdateOrgUnit(mock(OrganizationalUnit.class))); }
@Test public void userCanNotUpdateOrganizationalUnitTest() { doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(any()); assertFalse(organizationalUnitController.canUpdateOrgUnit(mock(OrganizationalUnit.class))); }