Search in sources :

Example 26 with SiteDTO

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()));
}
Also used : SiteDTO(org.activityinfo.shared.dto.SiteDTO) UpdateSite(org.activityinfo.shared.command.UpdateSite) Test(org.junit.Test)

Example 27 with SiteDTO

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));
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) Test(org.junit.Test)

Example 28 with SiteDTO

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());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) Test(org.junit.Test)

Example 29 with SiteDTO

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());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Test(org.junit.Test)

Example 30 with SiteDTO

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());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SiteDTO (org.activityinfo.shared.dto.SiteDTO)71 Test (org.junit.Test)32 GetSites (org.activityinfo.shared.command.GetSites)16 SiteResult (org.activityinfo.shared.command.result.SiteResult)11 CreateSite (org.activityinfo.shared.command.CreateSite)9 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)8 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)7 ArrayList (java.util.ArrayList)7 CreateResult (org.activityinfo.shared.command.result.CreateResult)7 Date (java.util.Date)6 OnDataSet (org.activityinfo.server.database.OnDataSet)6 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)6 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)6 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)5 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)5 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)5 UpdateSite (org.activityinfo.shared.command.UpdateSite)5 LocationDTO (org.activityinfo.shared.dto.LocationDTO)5 PointValue (org.activityinfo.shared.report.model.PointValue)5 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)4