use of org.motechproject.mds.domain.Field in project motech by motech.
the class UserPreferencesServiceTest method getField2.
private Field getField2() {
Field field = new Field(null, "sampleField2", "Display Name 2", true, false, false, false, false, false, "default 2", "tooltip 2", "placeholder 2", new HashSet<Lookup>());
field.setUIDisplayable(true);
return field;
}
use of org.motechproject.mds.domain.Field in project motech by motech.
the class UserPreferencesServiceTest method shouldMergeFieldsInformation.
@Test
public void shouldMergeFieldsInformation() {
Set<Field> selectedFields = new HashSet<>();
selectedFields.add(getField3());
Set<Field> unselectedFields = new HashSet<>();
unselectedFields.add(getField2());
UserPreferences preferences = new UserPreferences(USERNAME, CLASS_NAME, 20, selectedFields, unselectedFields);
when(allUserPreferences.retrieveByClassNameAndUsername(CLASS_NAME, USERNAME)).thenReturn(preferences);
UserPreferencesDto userPreferencesDto = userPreferencesService.getUserPreferences(15l, USERNAME);
assertNotNull(userPreferencesDto);
assertEquals(1, userPreferencesDto.getSelectedFields().size());
assertEquals(1, userPreferencesDto.getUnselectedFields().size());
assertEquals(2, userPreferencesDto.getVisibleFields().size());
assertTrue(userPreferencesDto.getSelectedFields().contains("sampleField3"));
assertTrue(userPreferencesDto.getUnselectedFields().contains("sampleField2"));
assertTrue(userPreferencesDto.getVisibleFields().contains("sampleField1"));
assertTrue(userPreferencesDto.getVisibleFields().contains("sampleField3"));
}
use of org.motechproject.mds.domain.Field in project motech by motech.
the class TrashServiceTest method shouldMoveObjectToTrash.
@Test
public void shouldMoveObjectToTrash() throws Exception {
doReturn(Record__Trash.class).when(classLoader).loadClass(Record__Trash.class.getName());
Entity entity = mock(Entity.class);
Field field = mock(Field.class);
Type type = mock(Type.class);
doReturn(17L).when(entity).getEntityVersion();
doReturn(field).when(entity).getField("id");
doReturn(field).when(entity).getField("value");
doReturn(type).when(field).getType();
doReturn(false).when(type).isRelationship();
doReturn(entity).when(allEntities).retrieveByClassName(anyString());
Record instance = new Record();
trashService.moveToTrash(instance, 1L);
verify(manager).makePersistent(trashCaptor.capture());
Record__Trash trash = trashCaptor.getValue();
assertEquals(instance.getValue(), trash.getValue());
}
use of org.motechproject.mds.domain.Field in project motech by motech.
the class FieldTestHelper method fieldWithComboboxSettings.
public static Field fieldWithComboboxSettings(Entity entity, String name, String displayName, Class<?> typeClass, boolean allowsMultipleSelections, boolean allowsUserSupplied, List<String> items) {
Type type = new Type();
type.setTypeClass(typeClass);
type.setDisplayName(Constants.DisplayNames.COMBOBOX);
Field field = new Field();
field.setName(name);
field.setDisplayName(displayName);
field.setType(type);
field.setEntity(entity);
setAllowUserSupplied(field, allowsUserSupplied);
setAllowMultipleSelections(field, allowsMultipleSelections);
setComboboxValues(field, items);
return field;
}
use of org.motechproject.mds.domain.Field in project motech by motech.
the class FieldTestHelper method field.
public static Field field(String name, Class<?> typeClass, boolean required, boolean exposedViaRest, boolean autoGenerated) {
Field field = field(name, name + " Display", typeClass);
field.setRequired(required);
field.setExposedViaRest(exposedViaRest);
field.addMetadata(new FieldMetadata(field, Constants.Util.AUTO_GENERATED, String.valueOf(autoGenerated)));
return field;
}
Aggregations