Search in sources :

Example 16 with DraftData

use of org.motechproject.mds.dto.DraftData 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

DraftData (org.motechproject.mds.dto.DraftData)16 Test (org.junit.Test)11 HashMap (java.util.HashMap)6 EntityDto (org.motechproject.mds.dto.EntityDto)5 FieldDto (org.motechproject.mds.dto.FieldDto)5 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)4 EntityDraft (org.motechproject.mds.domain.EntityDraft)3 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)3 SchemaHolder (org.motechproject.mds.dto.SchemaHolder)2 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Field (org.motechproject.mds.domain.Field)1 FieldMetadata (org.motechproject.mds.domain.FieldMetadata)1 FieldSetting (org.motechproject.mds.domain.FieldSetting)1 Lookup (org.motechproject.mds.domain.Lookup)1