Search in sources :

Example 6 with SiteResult

use of org.activityinfo.shared.command.result.SiteResult in project activityinfo by bedatadriven.

the class GetSitesTest method duplicated.

@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void duplicated() {
    // A given site can be appear multiple times in the list if it is the
    // source
    // of one or more indicators
    setUser(1);
    GetSites cmd = new GetSites();
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(3));
}
Also used : SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 7 with SiteResult

use of org.activityinfo.shared.command.result.SiteResult in project activityinfo by bedatadriven.

the class GetSitesTest method filterOnPartner.

@Test
public void filterOnPartner() {
    setUser(1);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Project, 2);
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(1));
}
Also used : SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) Test(org.junit.Test)

Example 8 with SiteResult

use of org.activityinfo.shared.command.result.SiteResult in project activityinfo by bedatadriven.

the class GetSitesTest method filterByIndicator.

@Test
public void filterByIndicator() throws CommandException {
    setUser(1);
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Indicator, 5);
    SiteResult result = execute(new GetSites(filter));
    assertThat(result.getData().size(), equalTo(1));
    assertThat(result.getData().get(0).getId(), equalTo(9));
}
Also used : Filter(org.activityinfo.shared.command.Filter) SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) Test(org.junit.Test)

Example 9 with SiteResult

use of org.activityinfo.shared.command.result.SiteResult in project activityinfo by bedatadriven.

the class LocalSiteCreateTest method siteRemovePartnerConflict.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void siteRemovePartnerConflict() {
    // FIRST U1 adds a new partner
    int databaseId = 1;
    PartnerDTO iom = new PartnerDTO();
    iom.setName("IOM");
    CreateResult result = executeRemotely(new AddPartner(databaseId, iom));
    iom.setId(result.getNewId());
    // Now U2 synchronizes, and adds a new site with this partner
    synchronizeFirstTime();
    SiteDTO site = new SiteDTO();
    site.setId(3343234);
    site.setActivityId(1);
    site.setPartner(iom);
    site.setDate1(new Date());
    site.setDate2(new Date());
    site.setLocationId(1);
    executeLocally(new CreateSite(site));
    // At T+3, U2 thinks better, removes IOM
    executeRemotely(new RemovePartner(databaseId, iom.getId()));
    // At T+4, U1 synchronizes, and IOM is removed, but site remains
    synchronize();
    // Verify that there is still a label for this partner
    SiteResult sites = executeLocally(GetSites.byId(site.getId()));
    assertThat(sites.getTotalLength(), equalTo(1));
    assertThat(sites.getData().get(0).getName(), equalTo(site.getName()));
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) SiteResult(org.activityinfo.shared.command.result.SiteResult) RemovePartner(org.activityinfo.shared.command.RemovePartner) AddPartner(org.activityinfo.shared.command.AddPartner) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Date(java.util.Date) CreateSite(org.activityinfo.shared.command.CreateSite) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 10 with SiteResult

use of org.activityinfo.shared.command.result.SiteResult in project activityinfo by bedatadriven.

the class SiteExporterTest method sheetNameTest.

@Test
public void sheetNameTest() {
    LocaleProxy.initialize();
    CountryDTO somalia = new CountryDTO(1, "Somalia");
    somalia.getLocationTypes().add(new LocationTypeDTO(1, "Village"));
    UserDatabaseDTO syli = new UserDatabaseDTO();
    syli.setName("SYLI");
    syli.setCountry(somalia);
    ActivityDTO activity = new ActivityDTO();
    activity.setId(1);
    activity.setDatabase(syli);
    activity.setName("Construction/Rehabilitation of Sec. Schools");
    activity.setLocationTypeId(1);
    ActivityDTO activity2 = new ActivityDTO();
    activity2.setId(2);
    activity2.setDatabase(syli);
    activity2.setName("Construction/Rehabilitation of Primary Schools");
    activity2.setLocationTypeId(1);
    ActivityDTO activity3 = new ActivityDTO();
    activity3.setId(3);
    activity3.setDatabase(syli);
    activity3.setName("Construction Rehabil (2)");
    activity3.setLocationTypeId(1);
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(GetSites.class))).andReturn(new SiteResult(new ArrayList<SiteDTO>())).anyTimes();
    replay(dispatcher);
    Filter filter = new Filter();
    SiteExporter exporter = new SiteExporter(dispatcher);
    exporter.export(activity, filter);
    exporter.export(activity2, filter);
    exporter.export(activity3, filter);
    HSSFWorkbook book = exporter.getBook();
    assertThat(book.getSheetAt(0).getSheetName(), equalTo("SYLI - Construction Rehabilitat"));
    assertThat(book.getSheetAt(1).getSheetName(), equalTo("SYLI - Construction Rehabil (2)"));
    assertThat(book.getSheetAt(2).getSheetName(), equalTo("SYLI - Construction Rehabil 2"));
}
Also used : CountryDTO(org.activityinfo.shared.dto.CountryDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) SiteResult(org.activityinfo.shared.command.result.SiteResult) Filter(org.activityinfo.shared.command.Filter) LocationTypeDTO(org.activityinfo.shared.dto.LocationTypeDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) DispatcherSync(org.activityinfo.server.command.DispatcherSync) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Aggregations

SiteResult (org.activityinfo.shared.command.result.SiteResult)19 Test (org.junit.Test)12 SiteDTO (org.activityinfo.shared.dto.SiteDTO)11 GetSites (org.activityinfo.shared.command.GetSites)10 OnDataSet (org.activityinfo.server.database.OnDataSet)6 Date (java.util.Date)4 Filter (org.activityinfo.shared.command.Filter)4 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)3 DispatcherSync (org.activityinfo.server.command.DispatcherSync)3 User (org.activityinfo.server.database.hibernate.entity.User)2 CreateSite (org.activityinfo.shared.command.CreateSite)2 GetSchema (org.activityinfo.shared.command.GetSchema)2 UpdateSite (org.activityinfo.shared.command.UpdateSite)2 CreateResult (org.activityinfo.shared.command.result.CreateResult)2 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)2 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)2 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)2 TableColumn (org.activityinfo.shared.report.model.TableColumn)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1