Search in sources :

Example 46 with OnDataSet

use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.

the class LocalSiteCreateTest method createNew.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createNew() {
    synchronize();
    // create a new detached, client model
    SiteDTO newSite = SiteDTOs.newSite();
    LocationDTO location = LocationDTOs.newLocation();
    executeLocally(new CreateLocation(location));
    newSite.setLocation(location);
    // create command
    CreateSite cmd = new CreateSite(newSite);
    // execute the command
    CreateResult result = executeLocally(cmd);
    // let the client know the command has succeeded
    newSite.setId(result.getNewId());
    // try to retrieve what we've created FROM OUR CLIENT SIDE DATABASE
    SiteResult loadResult = executeLocally(GetSites.byId(newSite.getId()));
    Assert.assertEquals(1, loadResult.getData().size());
    SiteDTO secondRead = loadResult.getData().get(0);
    // confirm that the changes are there
    SiteDTOs.validateNewSite(secondRead);
    newRequest();
    // now Sync with the server
    synchronize();
    // Confirm that paging works client side
    GetSites pagingRequest = new GetSites();
    pagingRequest.setLimit(1);
    executeLocally(pagingRequest);
}
Also used : CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 47 with OnDataSet

use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.

the class XFormResourceTest method parseWithBlankComments.

@Test
@OnDataSet("/dbunit/chad-form.db.xml")
public void parseWithBlankComments() throws IOException {
    byte[] bytes = asByteSource(getResource(XFormResourceTest.class, "form-no-comments.mime")).read();
    Response response = formSubmissionResource.submit(bytes);
    assertEquals(CREATED, fromStatusCode(response.getStatus()));
// Map<String, Object> map = store.getLastUpdated().getProperties();
// assertEquals(7, map.size());
// assertEquals(CLASS_ID.asString(), map.get("classId"));
// assertEquals(new ReferenceValue(partnerInstanceId(507, 562)).asRecord(), map.get(fieldName(PARTNER_FIELD)));
// assertEquals(new LocalDate(2005, 8, 31).asRecord(), map.get(fieldName(END_DATE_FIELD)));
// assertEquals("09/06/06", map.get(CODE_FIELD));
// assertEquals(new ReferenceValue(entity(141796)).asRecord(), map.get("a1081f11"));
// assertNull(map.get("i5346"));
// assertEquals(new NarrativeValue("Awesome.").asRecord(), map.get("a1081f14"));
// assertNotNull(map.get("backupBlobId"));
}
Also used : Response(javax.ws.rs.core.Response) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 48 with OnDataSet

use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.

the class XFormResourceTest method itemSet.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void itemSet() throws IOException {
    ItemSetBuilder builder = new ItemSetBuilder(resourceLocator, injector.getProvider(EntityManager.class));
    StreamingOutput output = builder.build(CuidAdapter.activityFormClass(1));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    output.write(baos);
    System.out.println(new String(baos.toByteArray()));
}
Also used : EntityManager(javax.persistence.EntityManager) StreamingOutput(javax.ws.rs.core.StreamingOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

OnDataSet (org.activityinfo.server.database.OnDataSet)48 Test (org.junit.Test)46 PartnerResult (org.activityinfo.legacy.shared.command.result.PartnerResult)9 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)8 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)6 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)6 EntityManager (javax.persistence.EntityManager)5 GetSites (org.activityinfo.legacy.shared.command.GetSites)5 FormInstance (org.activityinfo.model.form.FormInstance)5 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)4 Date (java.util.Date)4 Response (javax.ws.rs.core.Response)4 GetSyncRegionUpdates (org.activityinfo.legacy.shared.command.GetSyncRegionUpdates)4 SyncRegionUpdate (org.activityinfo.legacy.shared.command.result.SyncRegionUpdate)4 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)4 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)4 ResourceId (org.activityinfo.model.resource.ResourceId)4 LocalDate (org.activityinfo.model.type.time.LocalDate)4 GetUsers (org.activityinfo.legacy.shared.command.GetUsers)3 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)3