use of org.activityinfo.server.database.hibernate.entity.User in project activityinfo by bedatadriven.
the class LocationBuilderTest method cutting.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void cutting() throws Exception {
EntityManager em = emf.createEntityManager();
int chunkSize = 2;
LocationUpdateBuilder builder = new LocationUpdateBuilder(em, chunkSize);
GetSyncRegionUpdates request = new GetSyncRegionUpdates("location/" + 1, null);
SyncRegionUpdate update = builder.build(new User(), request);
assertThat(update.isComplete(), equalTo(false));
// first chunk
assertThat(update.getVersion(), equalTo("2"));
assertThat(update.getSql(), containsString("Ngshwe"));
request.setLocalVersion(update.getVersion());
update = builder.build(new User(), request);
assertThat(update.isComplete(), equalTo(true));
// second chunk
assertThat(update.getVersion(), equalTo("3"));
assertThat(update.getSql(), containsString("Boga"));
}
use of org.activityinfo.server.database.hibernate.entity.User in project activityinfo by bedatadriven.
the class ReportMailerTest method testEmail.
private void testEmail(String locale) {
User user = new User();
user.setEmail("akbertram@gmail.com");
user.setName("alex");
user.setLocale(locale);
ReportSubscription sub = new ReportSubscription();
sub.setTemplate(new ReportDefinition());
sub.getTemplate().setId(5040);
sub.setUser(user);
sub.setEmailDelivery(EmailDelivery.WEEKLY);
sub.setEmailDay(1);
Report report = new Report();
report.setTitle("Rapport RRM Mensuelle");
String text = ReportMailerHelper.composeTextEmail(sub, report);
System.out.println(text);
Assert.assertTrue("user name is present", text.contains(user.getName()));
Assert.assertTrue("link is correct without comma", text.contains("#report/5040"));
}
use of org.activityinfo.server.database.hibernate.entity.User 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.server.database.hibernate.entity.User in project activityinfo by bedatadriven.
the class GeoDigestModelBuilderTest method testFindDatabasesOwnerAndNotification.
@Test
public void testFindDatabasesOwnerAndNotification() throws Exception {
// owner & notification
User user = em.find(User.class, 1);
List<Database> dbs = geoDigestModelBuilder.findDatabases(user);
assertThat(dbs.size(), is(equalTo(2)));
assertTrue(dbs.contains(em.find(Database.class, 1)));
assertTrue(dbs.contains(em.find(Database.class, 2)));
}
use of org.activityinfo.server.database.hibernate.entity.User in project activityinfo by bedatadriven.
the class GeoDigestModelBuilderTest method testFindDatabasesOwnerAndViewAndNotification.
@Test
public void testFindDatabasesOwnerAndViewAndNotification() throws Exception {
// owner & view & notification
User user = em.find(User.class, 100);
List<Database> dbs = geoDigestModelBuilder.findDatabases(user);
assertThat(dbs.size(), is(equalTo(2)));
assertTrue(dbs.contains(em.find(Database.class, 3)));
assertTrue(dbs.contains(em.find(Database.class, 100)));
}
Aggregations