Search in sources :

Example 26 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO 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 SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO 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 SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO 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 SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO 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 SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO 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

SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)66 GetSchema (org.activityinfo.shared.command.GetSchema)56 Test (org.junit.Test)41 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)20 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 CreateResult (org.activityinfo.shared.command.result.CreateResult)9 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)8 MockEventBus (org.activityinfo.client.MockEventBus)6 HashMap (java.util.HashMap)5 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)5 UIConstants (org.activityinfo.client.i18n.UIConstants)5 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)5 OnDataSet (org.activityinfo.server.database.OnDataSet)5 Delete (org.activityinfo.shared.command.Delete)5 Filter (org.activityinfo.shared.command.Filter)5 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)5 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)5 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 CreateEntity (org.activityinfo.shared.command.CreateEntity)4 VoidResult (org.activityinfo.shared.command.result.VoidResult)4