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);
}
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"));
}
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()));
}
Aggregations