Search in sources :

Example 6 with GetSites

use of org.activityinfo.shared.command.GetSites 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 7 with GetSites

use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method filterOnPartner.

@Test
public void filterOnPartner() {
    setUser(1);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Project, 2);
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(1));
}
Also used : SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) Test(org.junit.Test)

Example 8 with GetSites

use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method filterByIndicator.

@Test
public void filterByIndicator() throws CommandException {
    setUser(1);
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Indicator, 5);
    SiteResult result = execute(new GetSites(filter));
    assertThat(result.getData().size(), equalTo(1));
    assertThat(result.getData().get(0).getId(), equalTo(9));
}
Also used : Filter(org.activityinfo.shared.command.Filter) SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) Test(org.junit.Test)

Example 9 with GetSites

use of org.activityinfo.shared.command.GetSites 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 10 with GetSites

use of org.activityinfo.shared.command.GetSites 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)

Aggregations

GetSites (org.activityinfo.shared.command.GetSites)28 Test (org.junit.Test)18 SiteDTO (org.activityinfo.shared.dto.SiteDTO)16 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)10 SiteResult (org.activityinfo.shared.command.result.SiteResult)10 Filter (org.activityinfo.shared.command.Filter)8 OnDataSet (org.activityinfo.server.database.OnDataSet)5 StringWriter (java.io.StringWriter)2 GET (javax.ws.rs.GET)2 JsonGenerator (org.codehaus.jackson.JsonGenerator)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 CreateLocation (org.activityinfo.shared.command.CreateLocation)1 CreateSite (org.activityinfo.shared.command.CreateSite)1 Delete (org.activityinfo.shared.command.Delete)1 GenerateElement (org.activityinfo.shared.command.GenerateElement)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 PivotSites (org.activityinfo.shared.command.PivotSites)1