use of org.javarosa.core.model.data.SelectMultiData in project javarosa by opendatakit.
the class SelectMultiDataTests method testVectorImmutability.
public void testVectorImmutability() {
SelectMultiData data = new SelectMultiData(firstTwo);
Selection[] copy = new Selection[firstTwo.size()];
firstTwo.toArray(copy);
firstTwo.set(0, two);
firstTwo.remove(1);
List<Selection> internal = (List<Selection>) data.getValue();
assertVectorIdentity("External Reference: ", internal, copy);
data.setValue(lastTwo);
List<Selection> start = (List<Selection>) data.getValue();
Selection[] external = new Selection[start.size()];
start.toArray(external);
start.remove(1);
start.set(0, one);
assertVectorIdentity("Internal Reference: ", (List<Selection>) data.getValue(), external);
}
use of org.javarosa.core.model.data.SelectMultiData in project javarosa by opendatakit.
the class SelectMultiDataTests method testSetData.
public void testSetData() {
SelectMultiData data = new SelectMultiData(firstTwo);
data.setValue(lastTwo);
assertTrue("SelectMultiData did not set value properly. Maintained old value.", !(data.getValue().equals(firstTwo)));
assertEquals("SelectMultiData did not properly set value ", data.getValue(), lastTwo);
data.setValue(firstTwo);
assertTrue("SelectMultiData did not set value properly. Maintained old value.", !(data.getValue().equals(lastTwo)));
assertEquals("SelectMultiData did not properly reset value ", data.getValue(), firstTwo);
}
use of org.javarosa.core.model.data.SelectMultiData in project javarosa by opendatakit.
the class SelectMultiDataTests method testBadDataTypes.
public void testBadDataTypes() {
boolean failure = false;
SelectMultiData data = new SelectMultiData(firstTwo);
try {
data.setValue(invalid);
data = new SelectMultiData(invalid);
} catch (Exception e) {
failure = true;
}
assertTrue("SelectMultiData did not throw a proper exception while being set to invalid data.", failure);
Selection[] values = new Selection[firstTwo.size()];
firstTwo.toArray(values);
assertVectorIdentity("Ensure not overwritten: ", (List<Selection>) data.getValue(), values);
}
Aggregations