use of org.motechproject.mds.domain.Entity in project motech by motech.
the class InstancesWriterTest method shouldWriteNullForNullManyRefIdRelationshipProperty.
@Test
public void shouldWriteNullForNullManyRefIdRelationshipProperty() throws Exception {
Entity entity = EntitySchemaBuilder.eude(ENTITY).field(PROPERTY, "mds.field.relationship.oneToMany").metadata(RELATED_CLASS, EntityWithProperty.class.getName()).metadata(RELATED_FIELD, PROPERTY).done().build();
EntityWithProperty<ArrayList<EntityWithProperty>> instance = new EntityWithProperty<>(1L, null);
assertInstanceWrittenCorrectly(entity, instance, NULL_PROPERTY_JSON);
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class InstancesWriterTest method shouldWriteMapProperty.
@Test
public void shouldWriteMapProperty() throws Exception {
Entity entity = EntitySchemaBuilder.eude(ENTITY).field(PROPERTY, "mds.field.map").done().build();
Map<String, String> map = new HashMap<>();
map.put("keyOne", "valOne");
map.put("keyTwo", "valTwo");
assertInstanceWrittenCorrectly(entity, new EntityWithProperty<>(1L, map), "{\"refId\":1,\"property\":{\"keyOne\":\"valOne\",\"keyTwo\":\"valTwo\"}}");
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class InstancesWriterTest method shouldWritePlainBooleanProperty.
@Test
public void shouldWritePlainBooleanProperty() throws Exception {
Entity entity = EntitySchemaBuilder.eude(ENTITY).field(PROPERTY, "mds.field.boolean").done().build();
Boolean bool = true;
assertInstanceWrittenCorrectly(entity, new EntityWithProperty<>(1L, bool), "{\"refId\":1,\"property\":true}");
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class InstancesWriterTest method shouldWriteNullForNullOneRefIdRelationshipProperty.
@Test
public void shouldWriteNullForNullOneRefIdRelationshipProperty() throws Exception {
Entity entity = EntitySchemaBuilder.eude(ENTITY).field(PROPERTY, "mds.field.relationship.oneToOne").metadata(RELATED_CLASS, EntityWithProperty.class.getName()).metadata(RELATED_FIELD, PROPERTY).done().build();
EntityWithProperty<EntityWithProperty> instance = new EntityWithProperty<>(1L, null);
assertInstanceWrittenCorrectly(entity, instance, NULL_PROPERTY_JSON);
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class EntityValidator method validateEntityComboboxesValues.
private void validateEntityComboboxesValues(EntityDraft draft) {
Entity parent = draft.getParentEntity();
List<Field> oldComboboxFields = draft.getParentEntity().getStringComboboxFields();
List<Field> comboboxFields = draft.getStringComboboxFields();
for (Field field : substract(oldComboboxFields, comboboxFields)) {
String tableName;
String fieldName;
if (!field.isMultiSelectCombobox()) {
fieldName = field.getName();
tableName = ClassTableName.getTableName(parent);
} else {
fieldName = "ELEMENT";
tableName = ClassTableName.getTableName(parent) + "_" + field.getName().toUpperCase();
}
List<?> values = executeSQLQuery(prepareSelectDistincQuery(tableName, fieldName));
validateUserSuppliedValuesUsageForField(values, draft.getField(field.getName()));
}
}
Aggregations