use of org.activityinfo.shared.command.CreateEntity in project activityinfo by bedatadriven.
the class CreateDatabaseTest method createWithSpecificCountry.
@Test
@OnDataSet("/dbunit/multicountry.db.xml")
public void createWithSpecificCountry() throws CommandException {
UserDatabaseDTO db = new UserDatabaseDTO();
db.setName("Warchild Haiti");
db.setFullName("Warchild Haiti");
setUser(1);
CreateEntity cmd = new CreateEntity(db);
cmd.getProperties().put("countryId", 2);
CreateResult cr = execute(cmd);
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO newdb = schema.getDatabaseById(cr.getNewId());
assertNotNull(newdb);
assertThat(newdb.getCountry(), is(notNullValue()));
assertThat(newdb.getCountry().getName(), is(equalTo("Haiti")));
}
use of org.activityinfo.shared.command.CreateEntity 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());
}
Aggregations