use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method updateAdminEntity.
@Test
public void updateAdminEntity() throws JsonMappingException {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId(entity(21).asString());
changeObject.setFormId(adminLevelFormClass(2).asString());
changeObject.setFieldValue("name", "Nouveau Irumu");
Updater updater = updater();
updater.setEnforcePermissions(false);
updater.executeChange(changeObject);
query(adminLevelFormClass(2), "_id", "name");
assertThat(column("_id"), hasValues("z0000000010", "z0000000011", "z0000000012", "z0000000013", "z0000000021"));
assertThat(column("name"), hasValues("Bukavu", "Walungu", "Shabunda", "Kalehe", "Nouveau Irumu"));
}
use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method createSite.
@Test
public void createSite() throws JsonMappingException {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId("s0000000013");
changeObject.setFormId(activityFormClass(1).asString());
changeObject.setFieldValue("partner", partnerRecordId(1).asString());
changeObject.setFieldValue("date1", "2015-01-01");
changeObject.setFieldValue("date2", "2015-01-01");
changeObject.setFieldValue("BENE", 45000);
changeObject.setFieldValue("location", locationInstanceId(3).asString());
Updater updater = updater();
updater.executeChange(changeObject);
query(activityFormClass(1), "_id", "partner.label", "BENE");
assertThat(column("_id"), hasValues("s0000000001", "s0000000002", "s0000000003", "s0000000013"));
assertThat(column("partner.label"), hasValues("NRC", "NRC", "Solidarites", "NRC"));
assertThat(column("BENE"), hasValues(1500, 3600, 10000, 45000));
}
use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method creatingActivitiesWithNullaryLocations.
@Test
public void creatingActivitiesWithNullaryLocations() {
int newId = new KeyGenerator().generateInt();
RecordUpdate change = new RecordUpdate();
change.setRecordId(cuid(SITE_DOMAIN, newId).asString());
change.setFormId(activityFormClass(ADVOCACY).asString());
change.setFieldValue("partner", partnerRecordId(1).asString());
change.setFieldValue("date1", "2015-01-01");
change.setFieldValue("date2", "2015-01-31");
Updater updater = updater();
updater.executeChange(change);
query(activityFormClass(ADVOCACY), "_id", "partner");
}
use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method deleteAdminEntity.
@Test
public void deleteAdminEntity() {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId(entity(21).asString());
changeObject.setFormId(adminLevelFormClass(2).asString());
changeObject.setDeleted(true);
Updater updater = updater();
updater.setEnforcePermissions(false);
updater.executeChange(changeObject);
query(adminLevelFormClass(2), "_id", "name");
assertThat(column("name"), hasValues("Bukavu", "Walungu", "Shabunda", "Kalehe"));
}
use of org.activityinfo.model.resource.RecordUpdate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method updateSite.
@Test
public void updateSite() throws JsonMappingException {
RecordUpdate changeObject = new RecordUpdate();
changeObject.setRecordId("s0000000001");
changeObject.setFormId(activityFormClass(1).asString());
changeObject.setFieldValue("partner", partnerRecordId(2).asString());
Updater updater = updater();
updater.executeChange(changeObject);
query(activityFormClass(1), "_id", "partner.label", "BENE");
assertThat(column("_id"), hasValues("s0000000001", "s0000000002", "s0000000003"));
assertThat(column("partner.label"), hasValues("Solidarites", "NRC", "Solidarites"));
assertThat(column("BENE"), hasValues(1500, 3600, 10000));
}
Aggregations