Search in sources :

Example 1 with EntityReadOnlyException

use of org.motechproject.mds.exception.entity.EntityReadOnlyException in project motech by motech.

the class EntityControllerTest method shouldThrowExceptionIfEntityToDeleteisReadonly.

@Test
public void shouldThrowExceptionIfEntityToDeleteisReadonly() throws Exception {
    doThrow(new EntityReadOnlyException("EntityName")).when(entityService).deleteEntity(9001L);
    controller.perform(delete("/entities/9001")).andExpect(status().isConflict()).andExpect(content().string(ENTITY_READ_ONLY));
}
Also used : EntityReadOnlyException(org.motechproject.mds.exception.entity.EntityReadOnlyException) Test(org.junit.Test)

Example 2 with EntityReadOnlyException

use of org.motechproject.mds.exception.entity.EntityReadOnlyException in project motech by motech.

the class EntityControllerTest method shouldNotSaveTemporaryChangeIfEntityIsReadonly.

@Test
public void shouldNotSaveTemporaryChangeIfEntityIsReadonly() throws Exception {
    doThrow(new EntityReadOnlyException("EntityName")).when(entityService).saveDraftEntityChanges(eq(9001L), any(DraftData.class));
    controller.perform(post("/entities/9001/draft").body(new ObjectMapper().writeValueAsString(new DraftData()).getBytes()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isConflict()).andExpect(content().string(ENTITY_READ_ONLY));
}
Also used : EntityReadOnlyException(org.motechproject.mds.exception.entity.EntityReadOnlyException) DraftData(org.motechproject.mds.dto.DraftData) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 EntityReadOnlyException (org.motechproject.mds.exception.entity.EntityReadOnlyException)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 DraftData (org.motechproject.mds.dto.DraftData)1