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));
}
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));
}
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));
}
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()));
}
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"));
}
Aggregations