Search in sources :

Example 16 with SelectMultiData

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);
}
Also used : SelectMultiData(org.javarosa.core.model.data.SelectMultiData) Selection(org.javarosa.core.model.data.helper.Selection) List(java.util.List) ArrayList(java.util.ArrayList)

Example 17 with SelectMultiData

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);
}
Also used : SelectMultiData(org.javarosa.core.model.data.SelectMultiData)

Example 18 with SelectMultiData

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);
}
Also used : SelectMultiData(org.javarosa.core.model.data.SelectMultiData) Selection(org.javarosa.core.model.data.helper.Selection)

Aggregations

SelectMultiData (org.javarosa.core.model.data.SelectMultiData)18 Selection (org.javarosa.core.model.data.helper.Selection)14 ArrayList (java.util.ArrayList)10 SelectOneData (org.javarosa.core.model.data.SelectOneData)8 List (java.util.List)7 SelectChoice (org.javarosa.core.model.SelectChoice)7 Constraint (org.javarosa.core.model.condition.Constraint)5 IAnswerData (org.javarosa.core.model.data.IAnswerData)5 DateData (org.javarosa.core.model.data.DateData)3 DateTimeData (org.javarosa.core.model.data.DateTimeData)3 SuppressLint (android.annotation.SuppressLint)2 Date (java.util.Date)2 QuestionDef (org.javarosa.core.model.QuestionDef)2 EvaluationContext (org.javarosa.core.model.condition.EvaluationContext)2 ConstraintHint (org.javarosa.core.model.condition.pivot.ConstraintHint)2 BooleanData (org.javarosa.core.model.data.BooleanData)2 DecimalData (org.javarosa.core.model.data.DecimalData)2 GeoPointData (org.javarosa.core.model.data.GeoPointData)2 GeoShapeData (org.javarosa.core.model.data.GeoShapeData)2 GeoTraceData (org.javarosa.core.model.data.GeoTraceData)2