use of org.activityinfo.shared.dto.SiteDTO 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.dto.SiteDTO in project activityinfo by bedatadriven.
the class SiteDTOs method newSite.
public static SiteDTO newSite() {
SiteDTO newSite = new SiteDTO();
newSite.setId(new KeyGenerator().generateInt());
newSite.setActivityId(1);
newSite.setLocationId(1);
newSite.setPartner(new PartnerDTO(1, "Foobar"));
newSite.setReportingPeriodId(new KeyGenerator().generateInt());
newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
newSite.setIndicatorValue(1, 996.0);
newSite.setIndicatorValue(2, null);
newSite.setAttributeValue(1, true);
newSite.setAttributeValue(2, false);
newSite.setComments("huba huba");
newSite.setProject(new ProjectDTO(1, "WoeiProject"));
return newSite;
}
use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class SiteDTOs method validateNewSite.
public static void validateNewSite(SiteDTO secondRead) {
SiteDTO newSite = newSite();
Assert.assertEquals("site.location.name", LocationDTOs.newLocation().getName(), secondRead.getLocationName());
Assert.assertEquals("site.location.axe", LocationDTOs.newLocation().getAxe(), secondRead.getLocationAxe());
Assert.assertEquals("site.attribute[1]", true, secondRead.getAttributeValue(1));
Assert.assertEquals("site.reportingPeriod[0].indicatorValue[0]", 996.0, secondRead.getIndicatorValue(1), 0.1);
Assert.assertEquals("site.comments", newSite.getComments(), secondRead.getComments());
Assert.assertEquals("site.partner", newSite.getPartner().getId(), secondRead.getPartner().getId());
}
use of org.activityinfo.shared.dto.SiteDTO 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"));
}
use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class TableGeneratorTest method dummySite.
public SiteDTO dummySite() {
SiteDTO site = new SiteDTO();
site.setId(1);
site.setLocationName("tampa bay");
site.setIndicatorValue(INDICATOR_ID, 1500d);
site.setX(28.4);
site.setY(1.2);
return site;
}
Aggregations