use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class ComboboxValueServiceImpl method getAllValuesForCombobox.
@Override
@Transactional
public List<String> getAllValuesForCombobox(String entityClassName, String fieldName) {
EntityInfo entityInfo = entityInfoReader.getEntityInfo(entityClassName);
if (entityInfo == null) {
throw new EntityNotFoundException(entityClassName);
}
FieldDto field = entityInfo.getField(fieldName).getField();
if (field == null) {
throw new FieldNotFoundException(entityClassName, fieldName);
} else if (!field.getType().isCombobox()) {
throw new IllegalArgumentException("Field " + fieldName + "in entity " + entityClassName + " is not a combobx field");
}
return getAllValuesForCombobox(entityInfo.getEntity(), field);
}
use of org.motechproject.mds.exception.entity.EntityNotFoundException in project motech by motech.
the class EntityControllerTest method shouldNotFindFieldByNameIfEntityNotExists.
@Test
public void shouldNotFindFieldByNameIfEntityNotExists() throws Exception {
doThrow(new EntityNotFoundException(500L)).when(entityService).findFieldByName(500L, "ID");
controller.perform(get("/entities/500/fields/ID")).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 shouldNotComitChangesIfEntityNotExists.
@Test
public void shouldNotComitChangesIfEntityNotExists() throws Exception {
doThrow(new EntityNotFoundException(10000L)).when(entityService).commitChanges(10000L);
controller.perform(post("/entities/10000/commit").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 shouldThrowExceptionIfEntityToDeleteNotExists.
@Test
public void shouldThrowExceptionIfEntityToDeleteNotExists() throws Exception {
doThrow(new EntityNotFoundException(1000L)).when(entityService).deleteEntity(1000L);
controller.perform(delete("/entities/1000")).andExpect(status().isConflict()).andExpect(content().string(ENTITY_NOT_FOUND));
}
Aggregations