Search in sources :

Example 6 with CreateEntity

use of org.activityinfo.legacy.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
    ActivityFormDTO activity = execute(new GetActivityForm(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.legacy.shared.command.CreateEntity) AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) HashMap(java.util.HashMap) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 7 with CreateEntity

use of org.activityinfo.legacy.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")));
}
Also used : CreateEntity(org.activityinfo.legacy.shared.command.CreateEntity) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)7 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)4 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)4 Test (org.junit.Test)4 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)3 HashMap (java.util.HashMap)2 OnDataSet (org.activityinfo.server.database.OnDataSet)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlUtils.fromString (com.google.gwt.safehtml.shared.SafeHtmlUtils.fromString)1 XFormReader (org.activityinfo.io.xform.XFormReader)1 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)1 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)1 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)1 CountryDTO (org.activityinfo.legacy.shared.model.CountryDTO)1 FormClass (org.activityinfo.model.form.FormClass)1 MySqlStorageProvider (org.activityinfo.store.mysql.MySqlStorageProvider)1 Created (org.activityinfo.ui.client.dispatch.callback.Created)1 Capture (org.easymock.Capture)1