use of org.activityinfo.legacy.shared.model.SchemaDTO in project activityinfo by bedatadriven.
the class SchemaCacheTest method testSchemaCache.
@Test
public void testSchemaCache() {
CacheManager proxyMgr = new CacheManager(new MockEventBus());
new SchemaCache(proxyMgr);
SchemaDTO schema = DTOs.pear();
proxyMgr.notifyListenersOfSuccess(new GetSchema(), schema);
CacheResult<SchemaDTO> proxyResult = proxyMgr.execute(new GetSchema());
Assert.assertTrue("could execute locally", proxyResult.isCouldExecute());
Assert.assertEquals("PEAR", proxyResult.getResult().getDatabaseById(1).getName());
}
use of org.activityinfo.legacy.shared.model.SchemaDTO in project activityinfo by bedatadriven.
the class TargetTest method setUser.
@Before
public void setUser() {
setUser(DATABASE_OWNER);
SchemaDTO schema = execute(new GetSchema());
db = schema.getDatabaseById(1);
}
use of org.activityinfo.legacy.shared.model.SchemaDTO 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());
TaskContext context = new TaskContext(getDispatcherSync(), new NullStorageProvider(), "XYZ");
SiteExporter export = new SiteExporter(context);
for (UserDatabaseDTO db : schema.getDatabases()) {
for (ActivityDTO activity : db.getActivities()) {
export.export(execute(new GetActivityForm(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();
}
use of org.activityinfo.legacy.shared.model.SchemaDTO in project activityinfo by bedatadriven.
the class LinkIndicatorTest method setUser.
@Before
public void setUser() {
setUser(DATABASE_OWNER);
/*
* Initial data load
*/
SchemaDTO schema = execute(new GetSchema());
db = schema.getDatabaseById(1);
}
use of org.activityinfo.legacy.shared.model.SchemaDTO in project activityinfo by bedatadriven.
the class LockedPeriodTest method createForFolder.
@Test
public void createForFolder() {
setUser(1);
LockedPeriodDTO dto = new LockedPeriodDTO();
dto.setName("NFI ");
dto.setFromDate(new LocalDate(2011, 1, 1));
dto.setToDate(new LocalDate(2011, 1, 31));
dto.setEnabled(true);
CreateLockedPeriod create = new CreateLockedPeriod(dto);
create.setFolderId(1);
execute(create);
// Now verify that they appear
SchemaDTO schema = execute(new GetSchema());
assertThat(schema.getDatabaseById(1).getFolderById(1).getLockedPeriods(), Matchers.hasSize(1));
LockedPeriodSet locks = new LockedPeriodSet(schema);
assertTrue(locks.isActivityLocked(1, new LocalDate(2011, 1, 1)));
// Verify that the new code works too...
DatabaseProviderImpl provider = new DatabaseProviderImpl(Providers.of(em));
UserDatabaseMeta metadata = provider.getDatabaseMetadata(CuidAdapter.databaseId(1), 1);
ArrayList<RecordLock> folderLocks = Lists.newArrayList(metadata.getEffectiveLocks(CuidAdapter.folderId(1)));
ArrayList<RecordLock> formLocks = Lists.newArrayList(metadata.getEffectiveLocks(CuidAdapter.activityFormClass(1)));
assertThat(folderLocks, Matchers.hasSize(2));
assertThat(formLocks, Matchers.hasSize(3));
}
Aggregations