use of org.activityinfo.store.spi.TypedRecordUpdate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method testSingleSiteResource.
@Test
public void testSingleSiteResource() throws IOException {
int databaseId = 1;
ResourceId formId = CuidAdapter.activityFormClass(1);
TypedRecordUpdate update = new TypedRecordUpdate();
update.setUserId(userId);
update.setFormId(formId);
update.setRecordId(cuid(SITE_DOMAIN, 1));
update.set(field(formId, PARTNER_FIELD), CuidAdapter.partnerRef(databaseId, 2));
update.set(indicatorField(1), new Quantity(900));
update.set(attributeGroupField(1), new EnumValue(attributeId(CATASTROPHE_NATURELLE_ID)));
Updater updater = updater();
updater.execute(update);
query(CuidAdapter.activityFormClass(1), "_id", "partner", "BENE", "cause");
assertThat(column("_id"), hasValues(cuid(SITE_DOMAIN, 1), cuid(SITE_DOMAIN, 2), cuid(SITE_DOMAIN, 3)));
assertThat(column("partner"), hasValues(partnerRecordId(2), partnerRecordId(1), partnerRecordId(2)));
assertThat(column("BENE"), hasValues(900, 3600, 10000));
assertThat(column("cause"), hasValues("Catastrophe Naturelle", "Deplacement", "Catastrophe Naturelle"));
}
Aggregations