use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.
the class SchemaImporterV2Test method syria.
@Test
public void syria() throws IOException {
UserDatabaseDTO syria = doImport("schema_1064.csv");
int activityId = syria.getActivities().get(0).getId();
ActivityFormDTO cash = execute(new GetActivityForm(activityId));
for (AttributeGroupDTO group : cash.getAttributeGroups()) {
System.out.println(group.getName());
}
assertThat(cash.getName(), equalTo("1.Provision of urgent cash assistance"));
assertThat(cash.getAttributeGroups().size(), equalTo(3));
SchemaCsvWriter writer = new SchemaCsvWriter(getDispatcherSync());
writer.write(syria.getId());
Files.write(writer.toString(), TestOutput.getFile(getClass(), "syria", ".csv"), Charsets.UTF_8);
}
use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.
the class AttributeGroupTest method testCreate.
@Test
public void testCreate() throws Exception {
// execute the command
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("name", "Type de Conflit");
properties.put("multipleAllowed", true);
properties.put("activityId", 1);
CreateEntity cmd = new CreateEntity("AttributeGroup", properties);
CreateResult result = execute(cmd);
// check if it has been added
ActivityFormDTO activity = execute(new GetActivityForm(1));
AttributeGroupDTO group = activity.getAttributeGroupById(result.getNewId());
Assert.assertNotNull("attribute group is created", group);
Assert.assertEquals("name is correct", group.getName(), "Type de Conflit");
Assert.assertTrue("multiple allowed is set to true", group.isMultipleAllowed());
}
use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.
the class CloneDatabaseTest method assertFormClassesCloned.
private void assertFormClassesCloned(UserDatabaseDTO sourceDb, UserDatabaseDTO targetDb) {
assertEquals(sourceDb.getActivities().size(), targetDb.getActivities().size());
for (ActivityDTO activityDTO : sourceDb.getActivities()) {
ActivityFormDTO sourceActivity = execute(new GetActivityForm(activityDTO.getId()));
ActivityFormDTO targetActivity = execute(new GetActivityForm(entityByName(targetDb.getActivities(), sourceActivity.getName()).getId()));
// legacy level
assertActivityClone(sourceActivity, targetActivity);
// form class level
FormClass sourceFormClass = assertResolves(locator.getFormClass(sourceActivity.getResourceId()));
FormClass targetFormClass = assertResolves(locator.getFormClass(targetActivity.getResourceId()));
assertFormClass(sourceFormClass, targetFormClass);
}
}
use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteActivity.
@Test
public void testDeleteActivity() throws CommandException {
ActivityFormDTO form = execute(new GetActivityForm(1));
execute(new Delete(form));
execute(new Delete("Activity", 4));
SchemaDTO schema = execute(new GetSchema());
assertNull("delete by entity reference", schema.getActivityById(1));
assertNull("delete by id", schema.getActivityById(4));
}
use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteAttribute.
@Test
public void testDeleteAttribute() throws CommandException {
ActivityFormDTO form = execute(new GetActivityForm(1));
execute(new Delete(form.getAttributeById(1)));
form = execute(new GetActivityForm(1));
assertNull(form.getAttributeById(1));
}
Aggregations