Search in sources :

Example 6 with CreateEntity

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

Example 7 with CreateEntity

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());
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) HashMap(java.util.HashMap) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

CreateEntity (org.activityinfo.shared.command.CreateEntity)7 GetSchema (org.activityinfo.shared.command.GetSchema)5 CreateResult (org.activityinfo.shared.command.result.CreateResult)5 Test (org.junit.Test)5 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)4 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)3 HashMap (java.util.HashMap)2 OnDataSet (org.activityinfo.server.database.OnDataSet)2 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Created (org.activityinfo.client.dispatch.callback.Created)1 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)1 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)1 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)1 CountryDTO (org.activityinfo.shared.dto.CountryDTO)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1 Capture (org.easymock.Capture)1