Search in sources :

Example 21 with IAnswerData

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

the class TimeWidgetTest method updatingTheDateAndTimeWidgetsShouldUpdateTheAnswer.

@Test
public void updatingTheDateAndTimeWidgetsShouldUpdateTheAnswer() {
    TimeWidget widget = getWidget();
    DateTime dateTime = getNextDateTime();
    widget.updateTime(dateTime);
    IAnswerData answer = widget.getAnswer();
    DateTime answerDateTime = new DateTime(answer.getValue());
    assertEquals(dateTime, answerDateTime);
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData) DateTime(org.joda.time.DateTime) Test(org.junit.Test) GeneralDateTimeWidgetTest(org.odk.collect.android.widgets.base.GeneralDateTimeWidgetTest)

Example 22 with IAnswerData

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

the class BinaryWidgetTest method getAnswerShouldReturnCorrectAnswerAfterBeingSet.

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

Example 23 with IAnswerData

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

the class GeneralSelectOneWidgetTest method getAnswerShouldReflectTheCurrentlySelectedChoice.

@Test
public void getAnswerShouldReflectTheCurrentlySelectedChoice() {
    W widget = getWidget();
    assertNull(widget.getAnswer());
    List<SelectChoice> selectChoices = getSelectChoices();
    for (int i = 0; i < widget.getChoiceCount(); i++) {
        widget.setChoiceSelected(i, true);
        SelectChoice selectChoice = selectChoices.get(i);
        IAnswerData answer = widget.getAnswer();
        assertEquals(selectChoice.getValue(), answer.getDisplayText());
    }
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData) SelectChoice(org.javarosa.core.model.SelectChoice) Test(org.junit.Test)

Example 24 with IAnswerData

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

the class GeneralStringWidgetTest method getAnswerShouldReturnExistingAnswerIfPromptHasExistingAnswer.

@Override
@SuppressWarnings("unchecked")
public void getAnswerShouldReturnExistingAnswerIfPromptHasExistingAnswer() {
    super.getAnswerShouldReturnExistingAnswerIfPromptHasExistingAnswer();
    W widget = getWidget();
    IAnswerData answer = widget.getAnswer();
    assertEquals(widget.getAnswerText(), answer.getDisplayText());
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData)

Example 25 with IAnswerData

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

the class QuestionWidgetTest method getAnswerShouldReturnExistingAnswerIfPromptHasExistingAnswer.

@Test
public void getAnswerShouldReturnExistingAnswerIfPromptHasExistingAnswer() {
    A answer = getInitialAnswer();
    if (answer instanceof StringData && !(this instanceof ItemsetWidgetTest)) {
        when(formEntryPrompt.getAnswerText()).thenReturn((String) answer.getValue());
    } else {
        when(formEntryPrompt.getAnswerValue()).thenReturn(answer);
    }
    W widget = getWidget();
    IAnswerData newAnswer = widget.getAnswer();
    assertNotNull(newAnswer);
    assertEquals(newAnswer.getDisplayText(), answer.getDisplayText());
}
Also used : IAnswerData(org.javarosa.core.model.data.IAnswerData) ItemsetWidgetTest(org.odk.collect.android.widgets.ItemsetWidgetTest) StringData(org.javarosa.core.model.data.StringData) Test(org.junit.Test) ItemsetWidgetTest(org.odk.collect.android.widgets.ItemsetWidgetTest)

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