BarcodeWidget extends QuestionWidget implements BinaryDataReceiver { @Override public IAnswerData getAnswer() { String answer = binding.barcodeAnswerText.getText().toString(); return answer.isEmpty() ? null : new StringData(answer); } BarcodeWidget(Context context, QuestionDetails questionDetails, WaitingForDataRegistry waitingForDataRegistry,
                         CameraUtils cameraUtils); @Override void clearAnswer(); @Override IAnswerData getAnswer(); @Override void setBinaryData(Object answer); @Override void setOnLongClickListener(OnLongClickListener l); @Override void cancelLongPress();  }
@Test public void getAnswer_whenPromptDoesNotHaveAnswer_returnsNull() { BarcodeWidget widget = createWidget(promptWithAnswer(null)); assertThat(widget.getAnswer(), nullValue()); }
@Test public void getAnswer_whenPromptHasAnswer_returnsCorrectAnswer() { BarcodeWidget widget = createWidget(promptWithAnswer(new StringData("blah"))); assertThat(widget.getAnswer().getDisplayText(), is("blah")); }