use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class DimensionPrunerTest method setupData.
@Before
public void setupData() {
ActivityDTO dist = new ActivityDTO(1, "Distribution");
IndicatorDTO nbMenages = new IndicatorDTO();
nbMenages.setId(NB_MENAGES_INDICATOR_ID);
nbMenages.setName("Nb Menages");
dist.getIndicators().add(nbMenages);
AttributeGroupDTO distFunding = new AttributeGroupDTO(NFI_FUNDING_GROUP_ID);
distFunding.setName("Funding Source");
dist.getAttributeGroups().add(distFunding);
ActivityDTO fairs = new ActivityDTO(2, "Faire");
AttributeGroupDTO fairFunding = new AttributeGroupDTO(FAIR_FUNDING_GROUP_ID);
fairFunding.setName("Funding Source");
fairs.getAttributeGroups().add(fairFunding);
IndicatorDTO voucherValue = new IndicatorDTO();
voucherValue.setId(VOUCHER_INDICATOR_ID);
voucherValue.setName("Voucher Value");
fairs.getIndicators().add(voucherValue);
UserDatabaseDTO nfi = new UserDatabaseDTO(1, "NFI");
nfi.getActivities().add(dist);
nfi.getActivities().add(fairs);
this.schema = new SchemaDTO();
schema.getDatabases().add(nfi);
dispatcher.setResult(GetSchema.class, schema);
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class ActivityTest method testActivity.
@Test
public void testActivity() throws CommandException {
/*
* Initial data load
*/
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO db = schema.getDatabaseById(1);
/*
* Create a new activity
*/
LocationTypeDTO locType = schema.getCountryById(1).getLocationTypes().get(0);
ActivityDTO act = new ActivityDTO();
act.setName("Warshing the dishes");
act.setLocationTypeId(locType.getId());
act.setReportingFrequency(ActivityDTO.REPORT_MONTHLY);
CreateResult cresult = execute(CreateEntity.Activity(db, act));
int newId = cresult.getNewId();
/*
* Reload schema to verify the changes have stuck
*/
schema = execute(new GetSchema());
act = schema.getActivityById(newId);
Assert.assertEquals("name", "Warshing the dishes", act.getName());
Assert.assertEquals("locationType", locType.getName(), act.getLocationType().getName());
Assert.assertEquals("reportingFrequency", ActivityDTO.REPORT_MONTHLY, act.getReportingFrequency());
Assert.assertEquals("public", Published.NOT_PUBLISHED.getIndex(), act.getPublished());
}
use of org.activityinfo.shared.dto.UserDatabaseDTO in project activityinfo by bedatadriven.
the class CreateDatabaseTest method testCreate.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testCreate() throws CommandException {
UserDatabaseDTO db = new UserDatabaseDTO();
db.setName("RIMS");
db.setFullName("Reintegration Management Information System");
CreateResult cr = execute(new CreateEntity(db));
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO newdb = schema.getDatabaseById(cr.getNewId());
assertNotNull(newdb);
assertEquals(db.getName(), newdb.getName());
assertEquals(db.getFullName(), newdb.getFullName());
assertNotNull(newdb.getCountry());
assertEquals("Alex", newdb.getOwnerName());
}
use of org.activityinfo.shared.dto.UserDatabaseDTO 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.UserDatabaseDTO in project activityinfo by bedatadriven.
the class ExportIntegrationTest method fullTest.
@Test
public void fullTest() throws Throwable {
User user = new User();
user.setId(1);
user.setName("Alex");
SchemaDTO schema = execute(new GetSchema());
SiteExporter export = new SiteExporter(getDispatcherSync());
for (UserDatabaseDTO db : schema.getDatabases()) {
for (ActivityDTO activity : db.getActivities()) {
export.export(activity, new Filter());
}
}
File outputDir = new File("target/report-test/");
outputDir.mkdirs();
FileOutputStream fos = new FileOutputStream("target/report-test/ExportTest.xls");
export.getBook().write(fos);
fos.close();
}
Aggregations