Search in sources :

Example 1 with Delete

use of org.activityinfo.legacy.shared.command.Delete in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteIndicator.

@Test
public void testDeleteIndicator() throws CommandException {
    int activityId = 1;
    int indicatorId = 1;
    execute(new Delete("Indicator", indicatorId));
    ActivityFormDTO form = execute(new GetActivityForm(activityId));
    assertNull(form.getIndicatorById(indicatorId));
    PagingResult<SiteDTO> sites = execute(GetSites.byId(1));
    assertNull(sites.getData().get(0).getIndicatorValue(1));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 2 with Delete

use of org.activityinfo.legacy.shared.command.Delete in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteLocationType.

@Test
public void testDeleteLocationType() throws CommandException {
    int locationTypeId = 4;
    SchemaDTO schema = execute(new GetSchema());
    // assert location type exists
    assertNotNull(schema.getLocationTypeById(locationTypeId));
    execute(new Delete("LocationType", locationTypeId));
    schema = execute(new GetSchema());
    // assert "delete" flag is set
    assertTrue(schema.getLocationTypeById(locationTypeId).isDeleted());
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 3 with Delete

use of org.activityinfo.legacy.shared.command.Delete in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteActivity.

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

Example 4 with Delete

use of org.activityinfo.legacy.shared.command.Delete in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteSite.

@Test
public void testDeleteSite() throws CommandException {
    PagingResult<SiteDTO> sites = execute(GetSites.byId(3));
    execute(new Delete(sites.getData().get(0)));
    sites = execute(GetSites.byId(3));
    Assert.assertEquals(0, sites.getData().size());
    sites = execute(new GetSites());
    assertNull(getById(sites.getData(), 3));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Example 5 with Delete

use of org.activityinfo.legacy.shared.command.Delete in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteAttribute.

@Test
public void testDeleteAttribute() throws CommandException {
    ActivityFormDTO form = execute(new GetActivityForm(1));
    execute(new Delete(form.getAttributeById(1)));
    form = execute(new GetActivityForm(1));
    assertNull(form.getAttributeById(1));
}
Also used : Delete(org.activityinfo.legacy.shared.command.Delete) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Aggregations

Delete (org.activityinfo.legacy.shared.command.Delete)5 Test (org.junit.Test)5 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)3 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)2 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 GetSites (org.activityinfo.legacy.shared.command.GetSites)1