Search in sources :

Example 21 with AdminEntityDTO

use of org.activityinfo.shared.dto.AdminEntityDTO in project activityinfo by bedatadriven.

the class CreateSiteTest method testAdminBoundCreate.

@Test
@Ignore("WIP")
public void testAdminBoundCreate() throws CommandException {
    // create a new detached, client model
    SiteDTO newSite = new SiteDTO();
    newSite.setActivityId(4);
    newSite.setPartner(new PartnerDTO(1, "Foobar"));
    newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
    newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
    newSite.setAdminEntity(1, new AdminEntityDTO(1, 2, "Sud Kivu"));
    newSite.setAdminEntity(2, new AdminEntityDTO(2, 11, "Walungu"));
    newSite.setAdminEntity(3, null);
    newSite.setX(27.432);
    newSite.setY(1.23);
    newSite.setComments("huba huba");
    newSite.setProject(new ProjectDTO(1, "SomeProject"));
    // create command
    CreateSite cmd = new CreateSite(newSite);
    // execute the command
    setUser(1);
    newSite.setProject(new ProjectDTO(1, "SomeProject"));
    CreateResult result = execute(cmd);
    newSite.setId(result.getNewId());
    // try to retrieve what we've created
    PagingLoadResult<SiteDTO> loadResult = execute(GetSites.byId(newSite.getId()));
    Assert.assertEquals(1, loadResult.getData().size());
    SiteDTO secondRead = loadResult.getData().get(0);
    // confirm that the changes are there
    Assert.assertEquals("site.location.name", "Walungu", secondRead.getLocationName());
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) GregorianCalendar(java.util.GregorianCalendar) SiteDTO(org.activityinfo.shared.dto.SiteDTO) CreateSite(org.activityinfo.shared.command.CreateSite) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)21 ArrayList (java.util.ArrayList)4 AdminEntityResult (org.activityinfo.shared.command.result.AdminEntityResult)4 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)3 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)3 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)3 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)3 GetAdminEntities (org.activityinfo.shared.command.GetAdminEntities)3 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)3 SiteDTO (org.activityinfo.shared.dto.SiteDTO)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 AdminEntity (org.activityinfo.server.database.hibernate.entity.AdminEntity)2 AdminLevel (org.activityinfo.server.database.hibernate.entity.AdminLevel)2 Filter (org.activityinfo.shared.command.Filter)2 LocationDTO (org.activityinfo.shared.dto.LocationDTO)2 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)1 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1