Search in sources :

Example 1 with IAnswerData

use of org.javarosa.core.model.data.IAnswerData in project collect by opendatakit.

the class ExDecimalWidget method getDoubleAnswerValue.

private Double getDoubleAnswerValue() {
    IAnswerData dataHolder = getFormEntryPrompt().getAnswerValue();
    Double d = null;
    if (dataHolder != null) {
        Object dataValue = dataHolder.getValue();
        if (dataValue != null) {
            if (dataValue instanceof Integer) {
                d = (double) (Integer) dataValue;
            } else {
                d = (Double) dataValue;
            }
        }
    }
    return d;
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData)

Example 2 with IAnswerData

use of org.javarosa.core.model.data.IAnswerData in project collect by opendatakit.

the class ExIntegerWidget method getIntegerAnswerValue.

private Integer getIntegerAnswerValue() {
    IAnswerData dataHolder = getFormEntryPrompt().getAnswerValue();
    Integer d = null;
    if (dataHolder != null) {
        Object dataValue = dataHolder.getValue();
        if (dataValue != null) {
            if (dataValue instanceof Double) {
                d = ((Double) dataValue).intValue();
            } else {
                d = (Integer) dataValue;
            }
        }
    }
    return d;
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData)

Example 3 with IAnswerData

use of org.javarosa.core.model.data.IAnswerData in project collect by opendatakit.

the class IntegerWidget method getIntegerAnswerValue.

private Integer getIntegerAnswerValue() {
    IAnswerData dataHolder = getFormEntryPrompt().getAnswerValue();
    Integer d = null;
    if (dataHolder != null) {
        Object dataValue = dataHolder.getValue();
        if (dataValue != null) {
            if (dataValue instanceof Double) {
                d = ((Double) dataValue).intValue();
            } else {
                d = (Integer) dataValue;
            }
        }
    }
    return d;
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData)

Example 4 with IAnswerData

use of org.javarosa.core.model.data.IAnswerData in project collect by opendatakit.

the class TriggerWidgetTest method checkingTheTriggerBoxShouldSetTheAnswer.

@Test
public void checkingTheTriggerBoxShouldSetTheAnswer() {
    TriggerWidget widget = getWidget();
    assertNull(widget.getAnswer());
    CheckBox triggerButton = widget.getTriggerButton();
    assertFalse(triggerButton.isChecked());
    triggerButton.setChecked(true);
    triggerButton.callOnClick();
    IAnswerData answer = widget.getAnswer();
    assertEquals(answer.getDisplayText(), TriggerWidget.OK_TEXT);
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData) CheckBox(android.widget.CheckBox) Test(org.junit.Test) QuestionWidgetTest(org.odk.collect.android.widgets.base.QuestionWidgetTest)

Example 5 with IAnswerData

use of org.javarosa.core.model.data.IAnswerData in project collect by opendatakit.

the class BinaryWidgetTest method settingANewAnswerShouldRemoveTheOldAnswer.

@Test
public void settingANewAnswerShouldRemoveTheOldAnswer() {
    A answer = getInitialAnswer();
    when(formEntryPrompt.getAnswerText()).thenReturn(answer.getDisplayText());
    W widget = getWidget();
    A newAnswer = getNextAnswer();
    Object binaryData = createBinaryData(newAnswer);
    widget.setBinaryData(binaryData);
    IAnswerData answerData = widget.getAnswer();
    assertNotNull(answerData);
    assertEquals(answerData.getDisplayText(), newAnswer.getDisplayText());
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData) Test(org.junit.Test)

Aggregations

IAnswerData (org.javarosa.core.model.data.IAnswerData)31 Test (org.junit.Test)8 Constraint (org.javarosa.core.model.condition.Constraint)6 TreeReference (org.javarosa.core.model.instance.TreeReference)6 SelectMultiData (org.javarosa.core.model.data.SelectMultiData)5 ArrayList (java.util.ArrayList)4 SelectOneData (org.javarosa.core.model.data.SelectOneData)4 Selection (org.javarosa.core.model.data.helper.Selection)4 TreeElement (org.javarosa.core.model.instance.TreeElement)4 List (java.util.List)3 FormDef (org.javarosa.core.model.FormDef)3 StringData (org.javarosa.core.model.data.StringData)3 BigDecimal (java.math.BigDecimal)2 FormIndex (org.javarosa.core.model.FormIndex)2 SelectChoice (org.javarosa.core.model.SelectChoice)2 EvaluationContext (org.javarosa.core.model.condition.EvaluationContext)2 ConstraintHint (org.javarosa.core.model.condition.pivot.ConstraintHint)2 DateData (org.javarosa.core.model.data.DateData)2 DateTimeData (org.javarosa.core.model.data.DateTimeData)2 DecimalData (org.javarosa.core.model.data.DecimalData)2