Search in sources :

Example 26 with GetSchema

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

the class LocalSchemaChangeTest method createActivity.

@Test
public void createActivity() {
    synchronizeFirstTime();
    SchemaDTO schema = executeLocally(new GetSchema());
    ActivityDTO activity = new ActivityDTO();
    activity.setName("New Activity");
    activity.setReportingFrequency(0);
    activity.setLocationTypeId(1);
    CreateResult createResult = executeRemotely(CreateEntity.Activity(schema.getDatabaseById(1), activity));
    synchronize();
    schema = executeLocally(new GetSchema());
    ActivityDTO createdActivity = schema.getActivityById(createResult.getNewId());
    assertThat(createdActivity, is(not(nullValue())));
    assertThat(createdActivity.getName(), equalTo(activity.getName()));
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 27 with GetSchema

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

the class LocalSchemaChangeTest method createIndicator.

@Test
public void createIndicator() {
    synchronizeFirstTime();
    SchemaDTO schema = executeLocally(new GetSchema());
    Map<String, Object> indicator = Maps.newHashMap();
    indicator.put("name", "New Indicator");
    indicator.put("units", "bricks");
    indicator.put("activityId", 2);
    CreateResult createResult = executeRemotely(new CreateEntity("Indicator", indicator));
    synchronize();
    schema = executeLocally(new GetSchema());
    IndicatorDTO createdIndicator = schema.getIndicatorById(createResult.getNewId());
    assertThat(createdIndicator, is(not(nullValue())));
    assertThat(createdIndicator.getName(), equalTo("New Indicator"));
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 28 with GetSchema

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

the class GetSchemaTest method testDatabaseVisibilityNone.

@Test
public void testDatabaseVisibilityNone() throws CommandException {
    // Stefan
    setUser(3);
    SchemaDTO schema = execute(new GetSchema());
    assertTrue("STEFAN does not have access to RRM", schema.getDatabaseById(2) == null);
}
Also used : SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 29 with GetSchema

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

the class GetSchemaTest method testIndicators.

@Test
public void testIndicators() throws CommandException {
    // Alex
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    assertTrue("no indicators case", schema.getActivityById(2).getIndicators().size() == 0);
    ActivityDTO nfi = schema.getActivityById(1);
    assertThat("indicators are present", nfi.getIndicators().size(), equalTo(4));
    IndicatorDTO test = nfi.getIndicatorById(2);
    assertThat("property:name", test.getName(), equalTo("baches"));
    assertThat("property:units", test.getUnits(), equalTo("menages"));
    assertThat("property:aggregation", test.getAggregation(), equalTo(IndicatorDTO.AGGREGATE_SUM));
    assertThat("property:category", test.getCategory(), equalTo("outputs"));
    assertThat("property:listHeader", test.getListHeader(), equalTo("header"));
    assertThat("property:description", test.getDescription(), equalTo("desc"));
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 30 with GetSchema

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

the class GetSchemaTest method testDatabasePublished.

@Test
@OnDataSet("/dbunit/sites-public.db.xml")
public void testDatabasePublished() throws CommandException {
    // Anonymouse user should fetch schema database with pulished
    // activities.
    setUser(0);
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getDatabases().size(), equalTo(1));
}
Also used : SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

GetSchema (org.activityinfo.shared.command.GetSchema)65 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)56 Test (org.junit.Test)42 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)9 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 CreateEntity (org.activityinfo.shared.command.CreateEntity)5 Filter (org.activityinfo.shared.command.Filter)5 HashMap (java.util.HashMap)4 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 Delete (org.activityinfo.shared.command.Delete)4 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 BatchCommand (org.activityinfo.shared.command.BatchCommand)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2