@Test public void shouldReturnFalseIfUserDoesNotHaveRequiredPermissionOnRnr() throws Exception { Rnr rnr = new Rnr(); rnr.setProgram(new Program(programId)); rnr.setFacility(new Facility(facilityId)); RequisitionPermissionService rnrPermissionEvaluationServiceSpy = spy(requisitionPermissionService); doReturn(false).when(rnrPermissionEvaluationServiceSpy).hasPermission(userId, rnr, CREATE_REQUISITION); assertThat(requisitionPermissionService.hasPermission(userId, rnr, CREATE_REQUISITION), is(false)); }
public Boolean hasPermission(Long userId, Facility facility, Program program, String rightName) { ProgramSupported programSupported = programSupportedService.getByFacilityIdAndProgramId(facility.getId(), program.getId()); if (!(programSupported != null && programSupported.getActive() && programSupported.getProgram().getActive())) { return false; } List<Right> userRights = roleRightsService.getRightsForUserAndFacilityProgram(userId, facility, program); return any(userRights, with(rightName)); }
RequisitionPermissionService { public Boolean hasPermission(Long userId, Facility facility, Program program, String rightName) { ProgramSupported programSupported = programSupportedService.getByFacilityIdAndProgramId(facility.getId(), program.getId()); if (!(programSupported != null && programSupported.getActive() && programSupported.getProgram().getActive())) { return false; } List<Right> userRights = roleRightsService.getRightsForUserAndFacilityProgram(userId, facility, program); return any(userRights, with(rightName)); } }
RequisitionPermissionService { public Boolean hasPermission(Long userId, Facility facility, Program program, String rightName) { ProgramSupported programSupported = programSupportedService.getByFacilityIdAndProgramId(facility.getId(), program.getId()); if (!(programSupported != null && programSupported.getActive() && programSupported.getProgram().getActive())) { return false; } List<Right> userRights = roleRightsService.getRightsForUserAndFacilityProgram(userId, facility, program); return any(userRights, with(rightName)); }  }
RequisitionPermissionService { public Boolean hasPermission(Long userId, Facility facility, Program program, String rightName) { ProgramSupported programSupported = programSupportedService.getByFacilityIdAndProgramId(facility.getId(), program.getId()); if (!(programSupported != null && programSupported.getActive() && programSupported.getProgram().getActive())) { return false; } List<Right> userRights = roleRightsService.getRightsForUserAndFacilityProgram(userId, facility, program); return any(userRights, with(rightName)); }  Boolean hasPermission(Long userId, Facility facility, Program program, String rightName); Boolean hasPermission(Long userId, Rnr rnr, String rightName); boolean hasPermissionToSave(Long userId, Rnr rnr); boolean hasPermission(Long userId, String rightName); }
RequisitionPermissionService { public Boolean hasPermission(Long userId, Facility facility, Program program, String rightName) { ProgramSupported programSupported = programSupportedService.getByFacilityIdAndProgramId(facility.getId(), program.getId()); if (!(programSupported != null && programSupported.getActive() && programSupported.getProgram().getActive())) { return false; } List<Right> userRights = roleRightsService.getRightsForUserAndFacilityProgram(userId, facility, program); return any(userRights, with(rightName)); }  Boolean hasPermission(Long userId, Facility facility, Program program, String rightName); Boolean hasPermission(Long userId, Rnr rnr, String rightName); boolean hasPermissionToSave(Long userId, Rnr rnr); boolean hasPermission(Long userId, String rightName);  }