Search in sources :

Example 1 with BioDataForm

use of org.activityinfo.store.testing.BioDataForm in project activityinfo by bedatadriven.

the class RecordTreeLoaderTest method references.

@Test
public void references() {
    BioDataForm bioDataForm = setup.getBioDataForm();
    Observable<Maybe<RecordTree>> recordTree = setup.getFormStore().getRecordTree(bioDataForm.getRecordRef(0));
    Connection<Maybe<RecordTree>> recordTreeView = setup.connect(recordTree);
    RecordTree tree = recordTreeView.assertLoaded().get();
    LookupKeySet lookupKeySet = new LookupKeySet(tree.getFormTree(), tree.getFormTree().getRootField(BioDataForm.PROTECTION_CODE_FIELD_ID).getField());
    assertThat(lookupKeySet.getLookupKeys(), hasSize(1));
    ReferenceValue referenceValue = (ReferenceValue) tree.getRoot().get(BioDataForm.PROTECTION_CODE_FIELD_ID);
    RecordRef ref = referenceValue.getOnlyReference();
    assertThat(lookupKeySet.label(tree, ref), equalTo(Maybe.of("00667")));
}
Also used : RecordTree(org.activityinfo.model.formTree.RecordTree) Maybe(org.activityinfo.promise.Maybe) LookupKeySet(org.activityinfo.model.formTree.LookupKeySet) ReferenceValue(org.activityinfo.model.type.ReferenceValue) RecordRef(org.activityinfo.model.type.RecordRef) BioDataForm(org.activityinfo.store.testing.BioDataForm) Test(org.junit.Test)

Aggregations

LookupKeySet (org.activityinfo.model.formTree.LookupKeySet)1 RecordTree (org.activityinfo.model.formTree.RecordTree)1 RecordRef (org.activityinfo.model.type.RecordRef)1 ReferenceValue (org.activityinfo.model.type.ReferenceValue)1 Maybe (org.activityinfo.promise.Maybe)1 BioDataForm (org.activityinfo.store.testing.BioDataForm)1 Test (org.junit.Test)1