use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method createActivity.
@Test
public void createActivity() {
synchronizeFirstTime();
SchemaDTO schema = executeLocally(new GetSchema());
ActivityDTO activity = new ActivityDTO();
activity.setName("New Activity");
activity.setReportingFrequency(0);
activity.setLocationTypeId(1);
CreateResult createResult = executeRemotely(CreateEntity.Activity(schema.getDatabaseById(1), activity));
synchronize();
schema = executeLocally(new GetSchema());
ActivityDTO createdActivity = schema.getActivityById(createResult.getNewId());
assertThat(createdActivity, is(not(nullValue())));
assertThat(createdActivity.getName(), equalTo(activity.getName()));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method createIndicator.
@Test
public void createIndicator() {
synchronizeFirstTime();
SchemaDTO schema = executeLocally(new GetSchema());
Map<String, Object> indicator = Maps.newHashMap();
indicator.put("name", "New Indicator");
indicator.put("units", "bricks");
indicator.put("activityId", 2);
CreateResult createResult = executeRemotely(new CreateEntity("Indicator", indicator));
synchronize();
schema = executeLocally(new GetSchema());
IndicatorDTO createdIndicator = schema.getIndicatorById(createResult.getNewId());
assertThat(createdIndicator, is(not(nullValue())));
assertThat(createdIndicator.getName(), equalTo("New Indicator"));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class GetSchemaTest method testDatabaseVisibilityNone.
@Test
public void testDatabaseVisibilityNone() throws CommandException {
// Stefan
setUser(3);
SchemaDTO schema = execute(new GetSchema());
assertTrue("STEFAN does not have access to RRM", schema.getDatabaseById(2) == null);
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class GetSchemaTest method testIndicators.
@Test
public void testIndicators() throws CommandException {
// Alex
setUser(1);
SchemaDTO schema = execute(new GetSchema());
assertTrue("no indicators case", schema.getActivityById(2).getIndicators().size() == 0);
ActivityDTO nfi = schema.getActivityById(1);
assertThat("indicators are present", nfi.getIndicators().size(), equalTo(4));
IndicatorDTO test = nfi.getIndicatorById(2);
assertThat("property:name", test.getName(), equalTo("baches"));
assertThat("property:units", test.getUnits(), equalTo("menages"));
assertThat("property:aggregation", test.getAggregation(), equalTo(IndicatorDTO.AGGREGATE_SUM));
assertThat("property:category", test.getCategory(), equalTo("outputs"));
assertThat("property:listHeader", test.getListHeader(), equalTo("header"));
assertThat("property:description", test.getDescription(), equalTo("desc"));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class GetSchemaTest method testDatabasePublished.
@Test
@OnDataSet("/dbunit/sites-public.db.xml")
public void testDatabasePublished() throws CommandException {
// Anonymouse user should fetch schema database with pulished
// activities.
setUser(0);
SchemaDTO schema = execute(new GetSchema());
assertThat(schema.getDatabases().size(), equalTo(1));
}
Aggregations