use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class EntityControllerTest method shouldThrowExceptionIfNotFoundEntity.
@Test
public void shouldThrowExceptionIfNotFoundEntity() throws Exception {
doThrow(new EntityNotFoundException(10L)).when(entityService).getEntityForEdit(10L);
controller.perform(get("/entities/10")).andExpect(status().isConflict()).andExpect(content().string(ENTITY_NOT_FOUND));
}
use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class EntityControllerTest method shouldNotSaveTemporaryChangeIfEntityNotExists.
@Test
public void shouldNotSaveTemporaryChangeIfEntityNotExists() throws Exception {
doThrow(new EntityNotFoundException(100L)).when(entityService).saveDraftEntityChanges(eq(100L), any(DraftData.class));
controller.perform(post("/entities/100/draft").body(new ObjectMapper().writeValueAsString(new DraftData()).getBytes()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isConflict()).andExpect(content().string(ENTITY_NOT_FOUND));
}
use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class EntityControllerTest method shouldNotAbandonChangesIfEntityNotExists.
@Test
public void shouldNotAbandonChangesIfEntityNotExists() throws Exception {
doThrow(new EntityNotFoundException(10000L)).when(entityService).abandonChanges(10000L);
controller.perform(post("/entities/10000/abandon").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isConflict()).andExpect(content().string(ENTITY_NOT_FOUND));
verify(entityService).abandonChanges(10000L);
}
use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class EntityControllerTest method shouldNotGetEntityFieldsIfEntityNotExists.
@Test
public void shouldNotGetEntityFieldsIfEntityNotExists() throws Exception {
doThrow(new EntityNotFoundException(10000L)).when(entityService).getFields(10000L);
controller.perform(get("/entities/10000/fields")).andExpect(status().isConflict()).andExpect(content().string(ENTITY_NOT_FOUND));
}
use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class InstanceController method getPreviousInstance.
@RequestMapping(value = "/instances/{entityId}/{instanceId}/previousVersion/{historyId}", method = RequestMethod.GET)
@ResponseBody
public HistoryRecord getPreviousInstance(@PathVariable Long entityId, @PathVariable Long instanceId, @PathVariable Long historyId) {
HistoryRecord historyRecord = instanceService.getHistoryRecord(entityId, instanceId, historyId);
if (historyRecord == null) {
throw new EntityNotFoundException(entityId);
}
processFieldsForUIInHistoryRecord(historyRecord.getFields());
return historyRecord;
}
Aggregations