Search in sources :

Example 1 with GetTargets

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

the class TargetTest method deleteTargetTest.

@Test
public void deleteTargetTest() {
    TargetDTO target = createTarget();
    CreateResult cresult = execute(new AddTarget(db.getId(), target));
    int newId = cresult.getNewId();
    /*
         * Load Targets to verify the changes have stuck
         */
    List<TargetDTO> targets = execute(new GetTargets(db.getId())).getData();
    TargetDTO dto = getTargetById(targets, newId);
    Assert.assertEquals("name", "Target0071", dto.getName());
    /*
         * Delete new target now
         */
    execute(new Delete(dto));
    /*
         * Verify if target is deleted.
         */
    targets = execute(new GetTargets()).getData();
    TargetDTO deleted = getTargetById(targets, newId);
    Assert.assertNull(deleted);
}
Also used : Delete(org.activityinfo.shared.command.Delete) GetTargets(org.activityinfo.shared.command.GetTargets) CreateResult(org.activityinfo.shared.command.result.CreateResult) AddTarget(org.activityinfo.shared.command.AddTarget) TargetDTO(org.activityinfo.shared.dto.TargetDTO) Test(org.junit.Test)

Example 2 with GetTargets

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

the class TargetTest method testTarget.

@Test
public void testTarget() throws CommandException {
    /*
         * Create a new Target
         */
    TargetDTO target = createTarget();
    CreateResult cresult = execute(new AddTarget(db.getId(), target));
    int newId = cresult.getNewId();
    /*
         * Load Targets to verify the changes have stuck
         */
    List<TargetDTO> targets = execute(new GetTargets(db.getId())).getData();
    TargetDTO dto = getTargetById(targets, newId);
    Assert.assertNotNull(dto);
    Assert.assertEquals("name", "Target0071", dto.getName());
}
Also used : GetTargets(org.activityinfo.shared.command.GetTargets) CreateResult(org.activityinfo.shared.command.result.CreateResult) AddTarget(org.activityinfo.shared.command.AddTarget) TargetDTO(org.activityinfo.shared.dto.TargetDTO) Test(org.junit.Test)

Example 3 with GetTargets

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

the class TargetTest method updateTargetNameTest.

@Test
public void updateTargetNameTest() throws Throwable {
    Map<String, Object> changes1 = new HashMap<String, Object>();
    changes1.put("name", "newNameOfTarget");
    execute(new BatchCommand(new UpdateEntity("Target", 1, changes1)));
    List<TargetDTO> targets = execute(new GetTargets(db.getId())).getData();
    TargetDTO dto = getTargetById(targets, 1);
    Assert.assertEquals("newNameOfTarget", dto.getName());
}
Also used : GetTargets(org.activityinfo.shared.command.GetTargets) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) HashMap(java.util.HashMap) BatchCommand(org.activityinfo.shared.command.BatchCommand) TargetDTO(org.activityinfo.shared.dto.TargetDTO) Test(org.junit.Test)

Aggregations

GetTargets (org.activityinfo.shared.command.GetTargets)3 TargetDTO (org.activityinfo.shared.dto.TargetDTO)3 Test (org.junit.Test)3 AddTarget (org.activityinfo.shared.command.AddTarget)2 CreateResult (org.activityinfo.shared.command.result.CreateResult)2 HashMap (java.util.HashMap)1 BatchCommand (org.activityinfo.shared.command.BatchCommand)1 Delete (org.activityinfo.shared.command.Delete)1 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)1