use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandlerTest method testIndicatorLinked2.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void testIndicatorLinked2() throws CommandException {
/*
Database #1 > Activity #1 (once)
Site #2: Partner #1
I1=400
Database #2 > Activity #2 (once)
Site #1: Partner #1
I3=1500
Links
I3 -> I2
*/
// NRC
PartnerResult result = execute(DimensionType.Indicator, 2);
assertThat(result.getData().size(), equalTo(1));
assertThat(result.getData().get(0).getName(), equalTo("NRC"));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandlerTest method testIndicatorLinked12100.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void testIndicatorLinked12100() throws CommandException {
// NRC, NRC2
PartnerResult result = execute(DimensionType.Indicator, 1, 2, 100);
assertThat(result.getData().size(), equalTo(2));
assertThat(result.getData().get(0).getName(), equalTo("NRC"));
assertThat(result.getData().get(1).getName(), equalTo("NRC2"));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class ActivityFormClassBuilderTest method partnersFieldIsAlwaysVisible.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void partnersFieldIsAlwaysVisible() {
setUser(BAVON_USER_ID);
FormClass formClass = assertResolves(locator.getFormClass(CuidAdapter.activityFormClass(1)));
int databaseId = 1;
ResourceId partnerFieldId = CuidAdapter.field(formClass.getId(), CuidAdapter.PARTNER_FIELD);
FormField partnerField = formClass.getField(partnerFieldId);
// according to ai-1009 : partner field is always visible
assertThat(partnerField, hasProperty("visible", equalTo(true)));
// Make sure we can update if partner is not specified
FormInstance instance = new FormInstance(CuidAdapter.newLegacyFormInstanceId(formClass.getId()), formClass.getId());
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.START_DATE_FIELD), new LocalDate(2014, 1, 1));
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.END_DATE_FIELD), new LocalDate(2014, 1, 2));
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.LOCATION_FIELD), new ReferenceValue(new RecordRef(CuidAdapter.locationFormClass(1), CuidAdapter.locationInstanceId(1))));
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.PARTNER_FIELD), CuidAdapter.partnerRef(databaseId, 1));
assertResolves(locator.persist(instance));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class LocalGetSchemaHandlerIntTest method forDatabaseOwner.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void forDatabaseOwner() throws CommandException {
synchronize();
SchemaDTO schema = executeLocally(new GetSchema());
assertThat(schema.getDatabases().size(), equalTo(3));
assertThat(schema.getDatabaseById(1).isDesignAllowed(), equalTo(true));
assertThat(schema.getDatabaseById(1).getAmOwner(), equalTo(true));
assertThat(schema.getDatabaseById(2).getAmOwner(), equalTo(true));
assertThat(schema.getDatabaseById(1).getOwnerName(), equalTo("Alex"));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testMonthlyCalculatedIndicatorsWithPartnerAndYear.
@Test
@OnDataSet("/dbunit/monthly-calc-indicators.db.xml")
public void testMonthlyCalculatedIndicatorsWithPartnerAndYear() {
filteringOnDatabases(1);
withIndicatorAsDimension();
withPartnerAsDimension();
dimensions.add(yearDim);
dimensions.add(monthDim);
execute();
assertThat().thereAre(6).buckets();
assertThat().forMonth(2009, 1).forIndicator(7003).thereIsOneBucketWithValue(537);
assertThat().forMonth(2009, 2).forIndicator(7003).thereIsOneBucketWithValue(634);
PivotTableReportElement report = new PivotTableReportElement();
report.setColumnDimensions(Arrays.asList(indicatorDim, partnerDim));
report.setRowDimensions(Arrays.<Dimension>asList(yearDim, monthDim));
PivotTableDataBuilder tableDataBuilder = new PivotTableDataBuilder();
PivotTableData table = tableDataBuilder.build(report.getRowDimensions(), report.getColumnDimensions(), buckets);
}
Aggregations