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);
}
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());
}
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());
}
}
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());
}
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());
}
Aggregations