Search in sources :

Example 61 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testAll.

@Test
public void testAll() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites cmd = new GetSites();
    PagingLoadResult<SiteDTO> result = execute(cmd);
    Assert.assertEquals("rows", 8, result.getData().size());
    Assert.assertNotNull("activityId", result.getData().get(0).getActivityId());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Test(org.junit.Test)

Example 62 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testActivityQueryPaged.

@Test
public void testActivityQueryPaged() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites cmd = new GetSites();
    cmd.filter().onActivity(1);
    cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
    cmd.setLimit(2);
    cmd.setOffset(0);
    PagingLoadResult<SiteDTO> result = execute(cmd);
    assertThat("offset", result.getOffset(), equalTo(0));
    cmd.setOffset(1);
    cmd.setLimit(2);
    result = execute(cmd);
    assertThat(result.getOffset(), equalTo(1));
    assertThat(result.getData().size(), equalTo(2));
    assertThat("total length", result.getTotalLength(), equalTo(3));
    cmd.setOffset(0);
    cmd.setLimit(50);
    result = execute(cmd);
    assertThat(result.getOffset(), equalTo(0));
    assertThat(result.getData().size(), equalTo(3));
    assertThat("total length", result.getTotalLength(), equalTo(3));
}
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 63 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method linkedSitesFilteredByIndicator.

@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void linkedSitesFilteredByIndicator() {
    setUser(1);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Indicator, 1);
    cmd.setSortInfo(new SortInfo("locationName", SortDir.ASC));
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(2));
    SiteDTO site1 = result.getData().get(0);
    SiteDTO site2 = result.getData().get(1);
    System.out.println(site1.getProperties());
    System.out.println(site2.getProperties());
    assertThat(site1.getId(), equalTo(1));
    assertThat(site1.getLocationName(), equalTo("Penekusu Kivu"));
    assertThat(site1.getActivityId(), equalTo(1));
    assertThat(site1.getIndicatorValue(1), equalTo(1500d));
    assertThat(site2.getId(), equalTo(2));
    assertThat(site2.getLocationName(), equalTo("Penekusu Kivu 2"));
    assertThat(site2.getActivityId(), equalTo(1));
    assertThat(site2.getIndicatorValue(1), equalTo(400d));
}
Also used : SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 64 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testDatabase.

@Test
public void testDatabase() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Database, 2);
    PagingLoadResult<SiteDTO> result = execute(cmd);
    Assert.assertEquals("rows", 3, result.getData().size());
    Assert.assertNotNull("activityId", result.getData().get(0).getActivityId());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Test(org.junit.Test)

Example 65 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testAllWithRemovedUser.

@Test
public void testAllWithRemovedUser() throws CommandException {
    // Christian (Bad guy!)
    setUser(5);
    PagingLoadResult<SiteDTO> result = execute(new GetSites());
    Assert.assertEquals("rows", 0, result.getData().size());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) 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