use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class UpdateSiteTest method charsets.
@Test
public void charsets() throws CommandException {
// retrieve from the server
ListResult<SiteDTO> result = execute(GetSites.byId(1));
SiteDTO original = result.getData().get(0);
SiteDTO modified = original.copy();
assertThat(modified.getId(), equalTo(original.getId()));
// modify and generate command
// note that the character sequence below is two characters:
// the first a simple unicode character and the second a code point
// requiring 4-bytes.
// http://www.charbase.com/20731-unicode-cjk-unified-ideograph
// NOTE: for the moment, i'm rolling back utf8mb4 support becuase it
// requires
// Mysql-5.5 which is **PITA*** to get running on earlier versions of
// ubuntu.
// To be reapplied when suppport
// modified.setComments("≥\ud841\udf31");
modified.setComments("≥");
System.out.println(modified.getComments());
assertThat(modified.getComments().codePointCount(0, modified.getComments().length()), equalTo(1));
UpdateSite cmd = new UpdateSite(original, modified);
assertThat((String) cmd.getChanges().get("comments"), equalTo(modified.getComments()));
execute(cmd);
// retrieve the old one
result = execute(GetSites.byId(1));
SiteDTO secondRead = result.getData().get(0);
// confirm that the changes are there
assertThat(secondRead.getComments(), equalTo(modified.getComments()));
}
use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class GetSitesTest method testActivityQueryBasic.
@Test
public void testActivityQueryBasic() throws CommandException {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo("date2", SortDir.DESC));
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("totalLength", 3, result.getData().size());
Assert.assertEquals("totalLength", 3, result.getTotalLength());
Assert.assertEquals("offset", 0, result.getOffset());
// Assert.assertNull("row(0).activity",
// result.getData().get(0).getActivity());
// assure sorted
Assert.assertEquals("sorted", 2, result.getData().get(0).getId());
Assert.assertEquals("sorted", 1, result.getData().get(1).getId());
Assert.assertEquals("sorted", 3, result.getData().get(2).getId());
// assure indicators are present (site id=3)
SiteDTO s = result.getData().get(2);
Assert.assertEquals("entityName", "Ituri", s.getAdminEntity(1).getName());
Assert.assertNotNull("admin bounds", s.getAdminEntity(1).getBounds());
Assert.assertEquals("indicator", 10000.0, s.getIndicatorValue(1));
Assert.assertNull("site x", s.getX());
// assure project is present
SiteDTO s1 = result.getData().get(1);
assertThat(s1.getId(), equalTo(1));
assertThat(s1.getProject().getId(), equalTo(1));
}
use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class GetSitesTest method testIndicatorSort.
@Test
public void testIndicatorSort() throws CommandException {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
PagingLoadResult<SiteDTO> result = execute(cmd);
// assure sorted
Assert.assertEquals("sorted", 10000.0, result.getData().get(0).getIndicatorValue(1));
Assert.assertEquals("sorted", 3600.0, result.getData().get(1).getIndicatorValue(1));
Assert.assertEquals("sorted", 1500.0, result.getData().get(2).getIndicatorValue(1));
Assert.assertNotNull("activityId", result.getData().get(0).getActivityId());
}
use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class GetSitesTest method testDatabasePartner2PartnerVisibility.
@Test
public void testDatabasePartner2PartnerVisibility() throws CommandException {
// BAVON (can't see other partner's stuff)
setUser(2);
GetSites cmd = new GetSites();
cmd.getFilter().addRestriction(DimensionType.Database, 1);
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("rows", 3, result.getData().size());
}
use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.
the class GetSitesTest method testSeekSite.
@Test
@Ignore
public void testSeekSite() throws Exception {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
cmd.setLimit(2);
cmd.setSeekToSiteId(1);
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("second page returned", 2, result.getOffset());
Assert.assertEquals("rows on this page", 1, result.getData().size());
Assert.assertEquals("correct site returned", 1, result.getData().get(0).getId());
}
Aggregations