use of org.openlmis.stockmanagement.exception.PermissionMessageException in project openlmis-stockmanagement by OpenLMIS.
the class StockEventsControllerrIntegrationTest method shouldReturn403WhenUserHomeFacilityDoesNotSupportProvidedProgram.
@Test
public void shouldReturn403WhenUserHomeFacilityDoesNotSupportProvidedProgram() throws Exception {
// given
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
Mockito.doThrow(new PermissionMessageException(new Message(ERROR_PROGRAM_NOT_SUPPORTED))).when(homeFacilityPermissionService).checkProgramSupported(eventDto.getProgramId());
shouldReject(eventDto);
}
use of org.openlmis.stockmanagement.exception.PermissionMessageException in project openlmis-stockmanagement by OpenLMIS.
the class StockCardServiceIntegrationTest method shouldThrowPermissionExceptionIfUserHasNoPermissionToViewCard.
@Test(expected = PermissionMessageException.class)
public void shouldThrowPermissionExceptionIfUserHasNoPermissionToViewCard() throws Exception {
// given
StockEvent savedEvent = save(createStockEventDto(), randomUUID());
doThrow(new PermissionMessageException(new Message("some error"))).when(permissionService).canViewStockCard(savedEvent.getProgramId(), savedEvent.getFacilityId());
// when
UUID savedCardId = stockCardRepository.findByOriginEvent(savedEvent).getId();
stockCardService.findStockCardById(savedCardId);
}
use of org.openlmis.stockmanagement.exception.PermissionMessageException in project openlmis-stockmanagement by OpenLMIS.
the class ReasonConfigurationOptionsControllerIntegrationTest method shouldThrow403.
private void shouldThrow403(String api) throws Exception {
// given
doThrow(new PermissionMessageException(new Message("some error"))).when(permissionService).canManageReasons();
// when
ResultActions resultActions = mvc.perform(get(api).param(ACCESS_TOKEN, ACCESS_TOKEN_VALUE));
// then
resultActions.andExpect(status().isForbidden());
}
use of org.openlmis.stockmanagement.exception.PermissionMessageException in project openlmis-stockmanagement by OpenLMIS.
the class StockCardControllerIntegrationTest method shouldReturn403WhenUserDoesNotHavePermissionToViewCardSummaries.
@Test
public void shouldReturn403WhenUserDoesNotHavePermissionToViewCardSummaries() throws Exception {
// given
UUID programId = UUID.randomUUID();
UUID facilityId = UUID.randomUUID();
doThrow(new PermissionMessageException(new Message("no permission"))).when(permissionService).canViewStockCard(programId, facilityId);
// when
ResultActions resultActions = mvc.perform(get(API_STOCK_CARD_SUMMARIES).param(ACCESS_TOKEN, ACCESS_TOKEN_VALUE).param("program", programId.toString()).param("facility", facilityId.toString()));
// then
resultActions.andExpect(status().isForbidden());
}
use of org.openlmis.stockmanagement.exception.PermissionMessageException in project openlmis-stockmanagement by OpenLMIS.
the class StockEventsControllerrIntegrationTest method shouldReturn403WhenUserHasNoPermissionToAdjustStock.
@Test
public void shouldReturn403WhenUserHasNoPermissionToAdjustStock() throws Exception {
// given
Mockito.doThrow(new PermissionMessageException(new Message(ERROR_NO_FOLLOWING_PERMISSION, STOCK_ADJUST))).when(permissionService).canAdjustStock(any(UUID.class), any(UUID.class));
StockEventDto eventDto = createNoSourceDestinationStockEventDto();
shouldReject(eventDto);
}
Aggregations