Search in sources :

Example 41 with SiteDTO

use of org.activityinfo.legacy.shared.model.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.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Example 42 with SiteDTO

use of org.activityinfo.legacy.shared.model.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testGetPublicSites.

@Test
@OnDataSet("/dbunit/sites-public.db.xml")
public void testGetPublicSites() throws CommandException {
    int anonnoymsUserID = 0;
    setUser(anonnoymsUserID);
    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.assertThat("indicator", (Double) s.getIndicatorValue(1), equalTo(10000.0));
    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.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 43 with SiteDTO

use of org.activityinfo.legacy.shared.model.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testActivityQueryPaged.

@Ignore
@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.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 44 with SiteDTO

use of org.activityinfo.legacy.shared.model.SiteDTO in project activityinfo by bedatadriven.

the class GetSitesTest method testDatabase.

@Test
public void testDatabase() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites legacyCmd = new GetSites();
    GetSites newCmd = new GetSites();
    legacyCmd.filter().addRestriction(DimensionType.Database, 2);
    legacyCmd.setLegacyFetch(true);
    newCmd.filter().addRestriction(DimensionType.Database, 2);
    newCmd.setLegacyFetch(false);
    PagingLoadResult<SiteDTO> legacyResult = execute(legacyCmd);
    PagingLoadResult<SiteDTO> newResult = execute(newCmd);
    Assert.assertEquals("rows", 3, legacyResult.getData().size());
    Assert.assertNotNull("activityId", legacyResult.getData().get(0).getActivityId());
    Assert.assertEquals("rows", 3, newResult.getData().size());
    Assert.assertNotNull("activityId", newResult.getData().get(0).getActivityId());
    GetSites newMonthlyCmd = new GetSites();
    newMonthlyCmd.filter().addRestriction(DimensionType.Database, 2);
    newMonthlyCmd.setLegacyFetch(false);
    newMonthlyCmd.setFetchAllReportingPeriods(true);
    PagingLoadResult<SiteDTO> newMonthlyResult = execute(newMonthlyCmd);
    Assert.assertEquals("rows", 5, newMonthlyResult.getData().size());
}
Also used : GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Example 45 with SiteDTO

use of org.activityinfo.legacy.shared.model.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.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Aggregations

SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)48 Test (org.junit.Test)31 GetSites (org.activityinfo.legacy.shared.command.GetSites)16 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)12 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)9 OnDataSet (org.activityinfo.server.database.OnDataSet)8 Date (java.util.Date)6 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)6 PointValue (org.activityinfo.legacy.shared.reports.model.PointValue)5 ArrayList (java.util.ArrayList)4 UpdateSite (org.activityinfo.legacy.shared.command.UpdateSite)4 TableColumn (org.activityinfo.legacy.shared.reports.model.TableColumn)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)3 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)3 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)3 TableData (org.activityinfo.legacy.shared.reports.content.TableData)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 Delete (org.activityinfo.legacy.shared.command.Delete)2 Filter (org.activityinfo.legacy.shared.command.Filter)2 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)2