use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteActivity.
@Test
public void testDeleteActivity() throws CommandException {
SchemaDTO schema = execute(new GetSchema());
execute(new Delete(schema.getActivityById(1)));
execute(new Delete("Activity", 4));
schema = execute(new GetSchema());
Assert.assertNull("delete by entity reference", schema.getActivityById(1));
Assert.assertNull("delete by id", schema.getActivityById(4));
}
use of org.activityinfo.shared.dto.SchemaDTO 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
SchemaDTO schema = execute(new GetSchema());
ActivityDTO activity = schema.getActivityById(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.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method deleteActivity.
@Test
public void deleteActivity() {
synchronizeFirstTime();
SchemaDTO schema = executeLocally(new GetSchema());
assertThat(schema.getActivityById(2), is(not(nullValue())));
executeRemotely(new Delete("Activity", 2));
synchronize();
schema = executeLocally(new GetSchema());
assertThat(schema.getActivityById(2), is(nullValue()));
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class ProjectTest method updateProject.
@Test
public void updateProject() {
setUser(1);
SchemaDTO schema = execute(new GetSchema());
ProjectDTO project = schema.getProjectById(2);
project.setName("RRMP II");
project.setDescription("RRMP The Next Generation");
execute(RequestChange.update(project, "name", "description"));
schema = execute(new GetSchema());
assertThat(schema.getProjectById(2).getName(), equalTo("RRMP II"));
assertThat(schema.getProjectById(2).getDescription(), equalTo("RRMP The Next Generation"));
project.setName("RRMP III");
project.setDescription(null);
execute(RequestChange.update(project, "name", "description"));
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class ProjectTest method deleteProject.
@Test
public void deleteProject() {
setUser(1);
long originalDatabaseVersion = lookupDbVersion(1);
int projectId = 2;
execute(RequestChange.delete("Project", projectId));
SchemaDTO schema = execute(new GetSchema());
assertThat(schema.getProjectById(projectId), nullValue());
// make sure it's gone from sites
Filter filter = new Filter();
filter.addRestriction(DimensionType.Site, 3);
SiteResult sites = execute(new GetSites(filter));
assertThat(sites.getData().get(0).getProject(), is(nullValue()));
// and doesn't show up in pivoting...
PivotSites pivot = new PivotSites();
Dimension projectDimension = new Dimension(DimensionType.Project);
pivot.setDimensions(projectDimension);
pivot.setFilter(filter);
PivotResult buckets = execute(pivot);
assertThat(buckets.getBuckets().size(), equalTo(1));
assertThat(buckets.getBuckets().get(0).getCategory(projectDimension), is(nullValue()));
// make sure the version number of the database is updated
assertThat(lookupDbVersion(1), not(equalTo(originalDatabaseVersion)));
}
Aggregations