use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class DesignTest method testDelete.
@Test
public void testDelete() {
// Dummy Data
SchemaDTO schema = DTOs.pear();
// Collaborator
DispatcherStub service = new DispatcherStub();
service.setResult(GetSchema.class, schema);
service.setResult(Delete.class, new VoidResult());
// Collaborator
DesignPresenter.View view = createNiceMock(DesignPresenter.View.class);
expect(view.getSelection()).andReturn(schema.getActivityById(91));
view.confirmDeleteSelected(isA(ConfirmCallback.class));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
((ConfirmCallback) getCurrentArguments()[0]).confirmed();
return null;
}
});
replay(view);
// Collaborator
UIConstants constants = createNiceMock(UIConstants.class);
replay(constants);
DesignPresenter designer = new DesignPresenter(new MockEventBus(), service, new StateManagerStub(), view, constants);
designer.go(schema.getDatabaseById(1));
// Verify that the proper delete command executes
designer.onUIAction(UIActions.DELETE);
Delete cmd = service.getLastExecuted(Delete.class);
Assert.assertEquals("Activity", cmd.getEntityName());
Assert.assertEquals(91, cmd.getId());
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class DesignTest method testNewActivityComesWithFolders.
@Test
public void testNewActivityComesWithFolders() {
// Test data
SchemaDTO schema = DTOs.pear();
// Collaborator : EventBus
MockEventBus eventBus = new MockEventBus();
// Collaborator : Command Service
DispatcherStub service = new DispatcherStub();
service.setResult(GetSchema.class, schema);
service.setResult(CreateEntity.class, new CreateResult(991));
// Collaborator : View
MockDesignTree view = new MockDesignTree();
// Constants
UIConstants constants = createNiceMock(UIConstants.class);
replay(constants);
// Class under test
DesignPresenter designer = new DesignPresenter(eventBus, service, new StateManagerStub(), view, constants);
// VERIFY that when an activity is added, it appears at the end of the
// list with two
// sub folders
designer.go(schema.getDatabaseById(1));
view.newEntityProperties.put("name", "Psychosocial support");
designer.onNew("Activity");
List<ModelData> rootItems = designer.getTreeStore().getRootItems();
ActivityDTO addedActivity = (ActivityDTO) rootItems.get(rootItems.size() - 1);
Assert.assertEquals("Psychosocial support", addedActivity.getName());
Assert.assertEquals("child nodes", 2, designer.getTreeStore().getChildCount(addedActivity));
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class DimensionPrunerTest method setupData.
@Before
public void setupData() {
ActivityDTO dist = new ActivityDTO(1, "Distribution");
IndicatorDTO nbMenages = new IndicatorDTO();
nbMenages.setId(NB_MENAGES_INDICATOR_ID);
nbMenages.setName("Nb Menages");
dist.getIndicators().add(nbMenages);
AttributeGroupDTO distFunding = new AttributeGroupDTO(NFI_FUNDING_GROUP_ID);
distFunding.setName("Funding Source");
dist.getAttributeGroups().add(distFunding);
ActivityDTO fairs = new ActivityDTO(2, "Faire");
AttributeGroupDTO fairFunding = new AttributeGroupDTO(FAIR_FUNDING_GROUP_ID);
fairFunding.setName("Funding Source");
fairs.getAttributeGroups().add(fairFunding);
IndicatorDTO voucherValue = new IndicatorDTO();
voucherValue.setId(VOUCHER_INDICATOR_ID);
voucherValue.setName("Voucher Value");
fairs.getIndicators().add(voucherValue);
UserDatabaseDTO nfi = new UserDatabaseDTO(1, "NFI");
nfi.getActivities().add(dist);
nfi.getActivities().add(fairs);
this.schema = new SchemaDTO();
schema.getDatabases().add(nfi);
dispatcher.setResult(GetSchema.class, schema);
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class ActivityTest method updatePublished.
@Test
public void updatePublished() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("published", Published.ALL_ARE_PUBLISHED.getIndex());
execute(new UpdateEntity("Activity", 1, changes));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(Published.ALL_ARE_PUBLISHED.getIndex(), schema.getActivityById(1).getPublished());
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class ActivityTest method updateSortOrderTest.
@Test
public void updateSortOrderTest() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes1 = new HashMap<String, Object>();
changes1.put("sortOrder", 2);
Map<String, Object> changes2 = new HashMap<String, Object>();
changes2.put("sortOrder", 1);
execute(new BatchCommand(new UpdateEntity("Activity", 1, changes1), new UpdateEntity("Activity", 2, changes2)));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(2, schema.getDatabaseById(1).getActivities().get(0).getId());
Assert.assertEquals(1, schema.getDatabaseById(1).getActivities().get(1).getId());
}
Aggregations