use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class EntityServiceContextIT method shouldSaveEntityWithGivenLookups.
@Test
public void shouldSaveEntityWithGivenLookups() throws IOException {
EntityDto entityDto = new EntityDto();
entityDto.setName("myEntity");
Map<String, Object> values = new HashMap<>();
values.put("path", DraftData.ADD_NEW_INDEX);
values.put("advanced", true);
values.put("value", asList("Lookup 1"));
DraftData draftData = new DraftData();
draftData.setEdit(true);
draftData.setValues(values);
entityDto = entityService.createEntity(entityDto);
entityService.saveDraftEntityChanges(entityDto.getId(), draftData);
entityService.commitChanges(entityDto.getId());
assertTrue(containsLookup("Lookup 1", entityDto.getId()));
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class MdsLookupServiceTest method setUp.
@Before
public void setUp() {
MotechClassPool.registerServiceInterface(Record.class.getName(), TestDataService.class.getName());
EntityDto entity = new EntityDto(ENTITY_ID, ENTITY_CLASS_NAME);
FieldDto strField = FieldTestHelper.fieldDto(STR_FIELD_ID, STR_PARAM, String.class.getName(), "strDisp", null);
FieldDto intField = FieldTestHelper.fieldDto(INT_FIELD_ID, INT_PARAM, Integer.class.getName(), "strDisp", null);
LookupFieldDto strLookupField = new LookupFieldDto(STR_FIELD_ID, STR_PARAM, LookupFieldType.VALUE);
LookupFieldDto intLookupField = new LookupFieldDto(INT_FIELD_ID, INT_PARAM, LookupFieldType.VALUE);
LookupDto firstLookup = new LookupDto(FIRST_LOOKUP_NAME, true, false, asList(strLookupField, intLookupField), false);
LookupDto secondLookup = new LookupDto(SECOND_LOOKUP_NAME, false, false, asList(strLookupField, intLookupField), false);
when(entityService.getEntityByClassName(ENTITY_CLASS_NAME)).thenReturn(entity);
when(entityService.getEntityFields(ENTITY_ID)).thenReturn(asList(intField, strField));
when(entityService.getLookupByName(ENTITY_ID, FIRST_LOOKUP_NAME)).thenReturn(firstLookup);
when(entityService.getLookupByName(ENTITY_ID, SECOND_LOOKUP_NAME)).thenReturn(secondLookup);
Map<String, FieldDto> mapping = new HashMap<>();
mapping.put(STR_PARAM, strField);
mapping.put(INT_PARAM, intField);
when(entityService.getLookupFieldsMapping(ENTITY_ID, FIRST_LOOKUP_NAME)).thenReturn(mapping);
when(entityService.getLookupFieldsMapping(ENTITY_ID, SECOND_LOOKUP_NAME)).thenReturn(mapping);
when(bundleContext.getServiceReference(TestDataService.class.getName())).thenReturn(serviceReference);
when(bundleContext.getService(serviceReference)).thenReturn(dataService);
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class JarGeneratorServiceContextIT method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
MotechClassPool.clearEnhancedData();
EntityDto entitySAMPLE = new EntityDto(null, SAMPLE);
entitySAMPLE.setRecordHistory(true);
EntityDto entityEXAMPLE = new EntityDto(null, EXAMPLE);
entityEXAMPLE.setRecordHistory(true);
EntityDto entityFOO = new EntityDto(null, FOO);
entityFOO.setRecordHistory(true);
// Entity without history
EntityDto entityBAR = new EntityDto(null, BAR);
entityBAR.setRecordHistory(false);
entityService.createEntity(entitySAMPLE);
entityService.createEntity(entityEXAMPLE);
entityService.createEntity(entityFOO);
entityService.createEntity(entityBAR);
bundleHeaders = new BundleHeaders(bundleContext);
Path path = Paths.get(monitor.bundleLocation());
Files.deleteIfExists(path);
setProperty(monitor, "bundleStarted", true);
setProperty(monitor, "bundleInstalled", true);
setProperty(monitor, "contextInitialized", true);
SchemaHolder schemaHolder = entityService.getSchema();
constructor.constructEntities(schemaHolder);
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class EditableLookupsLoaderTest method prepareEntityDto.
private EntityDto prepareEntityDto() {
EntityDto entity = new EntityDto();
entity.setClassName(CLASS_NAME);
return entity;
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class MdsDummyDataGeneratorImpl method makeInstances.
private void makeInstances(MotechDataService service, Long entityId, int numberOfInstances, int numberOfHistoricalRevisions, int numberOfTrashInstances) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
EntityDto entityDto = entityService.getEntity(entityId);
for (int i = 0; i < numberOfInstances; i++) {
Object obj = makeDummyInstance(entityDto.getId());
service.create(obj);
for (int j = 0; j < numberOfHistoricalRevisions; j++) {
service.update(obj);
}
}
for (int i = 0; i < numberOfTrashInstances; i++) {
Object obj = makeDummyInstance(entityDto.getId());
obj = service.create(obj);
service.delete(obj);
}
}
Aggregations