Search in sources :

Example 31 with OnDataSet

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"));
}
Also used : PartnerResult(org.activityinfo.legacy.shared.command.result.PartnerResult) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 32 with OnDataSet

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"));
}
Also used : PartnerResult(org.activityinfo.legacy.shared.command.result.PartnerResult) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 33 with OnDataSet

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));
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FormClass(org.activityinfo.model.form.FormClass) ReferenceValue(org.activityinfo.model.type.ReferenceValue) RecordRef(org.activityinfo.model.type.RecordRef) FormInstance(org.activityinfo.model.form.FormInstance) FormField(org.activityinfo.model.form.FormField) LocalDate(org.activityinfo.model.type.time.LocalDate) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 34 with OnDataSet

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"));
}
Also used : SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 35 with OnDataSet

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);
}
Also used : PivotTableDataBuilder(org.activityinfo.legacy.shared.impl.pivot.PivotTableDataBuilder) OnDataSet(org.activityinfo.server.database.OnDataSet)

Aggregations

OnDataSet (org.activityinfo.server.database.OnDataSet)48 Test (org.junit.Test)46 PartnerResult (org.activityinfo.legacy.shared.command.result.PartnerResult)9 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)8 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)6 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)6 EntityManager (javax.persistence.EntityManager)5 GetSites (org.activityinfo.legacy.shared.command.GetSites)5 FormInstance (org.activityinfo.model.form.FormInstance)5 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)4 Date (java.util.Date)4 Response (javax.ws.rs.core.Response)4 GetSyncRegionUpdates (org.activityinfo.legacy.shared.command.GetSyncRegionUpdates)4 SyncRegionUpdate (org.activityinfo.legacy.shared.command.result.SyncRegionUpdate)4 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)4 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)4 ResourceId (org.activityinfo.model.resource.ResourceId)4 LocalDate (org.activityinfo.model.type.time.LocalDate)4 GetUsers (org.activityinfo.legacy.shared.command.GetUsers)3 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)3