Search in sources :

Example 56 with SchemaDTO

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

the class DeleteTest method testDeleteActivity.

@Test
public void testDeleteActivity() throws CommandException {
    SchemaDTO schema = execute(new GetSchema());
    execute(new Delete(schema.getActivityById(1)));
    execute(new Delete("Activity", 4));
    schema = execute(new GetSchema());
    Assert.assertNull("delete by entity reference", schema.getActivityById(1));
    Assert.assertNull("delete by id", schema.getActivityById(4));
}
Also used : Delete(org.activityinfo.shared.command.Delete) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 57 with SchemaDTO

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

the class AttributeGroupTest method testCreate.

@Test
public void testCreate() throws Exception {
    // execute the command
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("name", "Type de Conflit");
    properties.put("multipleAllowed", true);
    properties.put("activityId", 1);
    CreateEntity cmd = new CreateEntity("AttributeGroup", properties);
    CreateResult result = execute(cmd);
    // check if it has been added
    SchemaDTO schema = execute(new GetSchema());
    ActivityDTO activity = schema.getActivityById(1);
    AttributeGroupDTO group = activity.getAttributeGroupById(result.getNewId());
    Assert.assertNotNull("attribute group is created", group);
    Assert.assertEquals("name is correct", group.getName(), "Type de Conflit");
    Assert.assertTrue("multiple allowed is set to true", group.isMultipleAllowed());
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) HashMap(java.util.HashMap) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 58 with SchemaDTO

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

the class LocalSchemaChangeTest method deleteActivity.

@Test
public void deleteActivity() {
    synchronizeFirstTime();
    SchemaDTO schema = executeLocally(new GetSchema());
    assertThat(schema.getActivityById(2), is(not(nullValue())));
    executeRemotely(new Delete("Activity", 2));
    synchronize();
    schema = executeLocally(new GetSchema());
    assertThat(schema.getActivityById(2), is(nullValue()));
}
Also used : Delete(org.activityinfo.shared.command.Delete) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 59 with SchemaDTO

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

the class ProjectTest method updateProject.

@Test
public void updateProject() {
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    ProjectDTO project = schema.getProjectById(2);
    project.setName("RRMP II");
    project.setDescription("RRMP The Next Generation");
    execute(RequestChange.update(project, "name", "description"));
    schema = execute(new GetSchema());
    assertThat(schema.getProjectById(2).getName(), equalTo("RRMP II"));
    assertThat(schema.getProjectById(2).getDescription(), equalTo("RRMP The Next Generation"));
    project.setName("RRMP III");
    project.setDescription(null);
    execute(RequestChange.update(project, "name", "description"));
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 60 with SchemaDTO

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

the class ProjectTest method deleteProject.

@Test
public void deleteProject() {
    setUser(1);
    long originalDatabaseVersion = lookupDbVersion(1);
    int projectId = 2;
    execute(RequestChange.delete("Project", projectId));
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getProjectById(projectId), nullValue());
    // make sure it's gone from sites
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Site, 3);
    SiteResult sites = execute(new GetSites(filter));
    assertThat(sites.getData().get(0).getProject(), is(nullValue()));
    // and doesn't show up in pivoting...
    PivotSites pivot = new PivotSites();
    Dimension projectDimension = new Dimension(DimensionType.Project);
    pivot.setDimensions(projectDimension);
    pivot.setFilter(filter);
    PivotResult buckets = execute(pivot);
    assertThat(buckets.getBuckets().size(), equalTo(1));
    assertThat(buckets.getBuckets().get(0).getCategory(projectDimension), is(nullValue()));
    // make sure the version number of the database is updated
    assertThat(lookupDbVersion(1), not(equalTo(originalDatabaseVersion)));
}
Also used : PivotSites(org.activityinfo.shared.command.PivotSites) Filter(org.activityinfo.shared.command.Filter) SiteResult(org.activityinfo.shared.command.result.SiteResult) PivotResult(org.activityinfo.shared.command.PivotSites.PivotResult) GetSites(org.activityinfo.shared.command.GetSites) Dimension(org.activityinfo.shared.report.model.Dimension) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) 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