use of org.openlmis.stockmanagement.util.Message in project openlmis-stockmanagement by OpenLMIS.
the class StockCardTemplatesControllerIntegrationTest method shouldReturn403WhenCreateTemplatePermissionNotFound.
@Test
public void shouldReturn403WhenCreateTemplatePermissionNotFound() throws Exception {
// given
Mockito.doThrow(new PermissionMessageException(new Message(ERROR_NO_FOLLOWING_PERMISSION, STOCK_CARD_TEMPLATES_MANAGE))).when(permissionService).canCreateStockCardTemplate();
// when
ResultActions resultActions = mvc.perform(post(STOCK_CARD_TEMPLATE_API).param(ACCESS_TOKEN, ACCESS_TOKEN_VALUE).contentType(MediaType.APPLICATION_JSON).content(objectToJsonString(new StockCardTemplate())));
// then
resultActions.andExpect(status().isForbidden());
}
use of org.openlmis.stockmanagement.util.Message in project openlmis-stockmanagement by OpenLMIS.
the class StockCardTemplatesControllerIntegrationTest method throwValidationExceptionWith.
private void throwValidationExceptionWith(String exceptionKey) throws Exception {
// given
Mockito.doThrow(new ValidationMessageException(new Message(exceptionKey, "some id"))).when(stockCardTemplateService).saveOrUpdate(any());
// when
ResultActions resultActions = mvc.perform(post(STOCK_CARD_TEMPLATE_API).param(ACCESS_TOKEN, ACCESS_TOKEN_VALUE).contentType(MediaType.APPLICATION_JSON).content(objectToJsonString(new StockCardTemplate())));
// then
resultActions.andExpect(status().isBadRequest());
}
use of org.openlmis.stockmanagement.util.Message in project openlmis-stockmanagement by OpenLMIS.
the class StockEventsControllerrIntegrationTest method shouldReturn403WhenUserHasNoPermissionToPerformPhysicalInventory.
@Test
public void shouldReturn403WhenUserHasNoPermissionToPerformPhysicalInventory() throws Exception {
// given
Mockito.doThrow(new PermissionMessageException(new Message(ERROR_NO_FOLLOWING_PERMISSION, STOCK_ADJUST))).when(permissionService).canEditPhysicalInventory(any(UUID.class), any(UUID.class));
StockEventDto dto = createNoSourceDestinationStockEventDto();
dto.getLineItems().get(0).setReasonId(null);
shouldReject(dto);
}
use of org.openlmis.stockmanagement.util.Message 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.util.Message 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);
}
Aggregations