### Question:
ReceiveActivity extends CommoditySelectableActivity implements Serializable { public void validateAllocationId(String text) { if (!allocationIdIsValid(text)) { textViewAllocationId.setError(String.format( getString(R.string.error_allocation_id_wrong_format), getAllocationIdFormat())); } else { if (completedAllocationIds.contains(text)) { textViewAllocationId.setError(getString(R.string.error_allocation_received)); } else { textViewAllocationId.setError(null); } } }  List<String> getReceiveSources(); Receive generateReceive(); void setAllocation(String allocationId); void validateAllocationId(String text); void validateAllocationId(); void onEvent(AllocationCreateEvent event); void clearInput(); static final String ALLOCATION_ID; @InjectView(R.id.spinnerSource)
    public Spinner spinnerSource; }### Answer:
@Test public void shouldShowAnErrorMessageForAllocationIdThatHasAlreadyBeenReceived() throws Exception { String item1 = "TW0001"; String item2 = "TW0002"; when(mockAllocationService.getReceivedAllocationIds()).thenReturn(new ArrayList<String>(Arrays.asList(item1, item2))); ReceiveActivity receiveActivity = getReceiveActivity(); setSource(receiveActivity, application.getString(R.string.zonal_store_for_receive)); assertThat(receiveActivity.textViewAllocationId.getError(), is(nullValue())); receiveActivity.textViewAllocationId.setText(item1); receiveActivity.validateAllocationId(); assertThat(receiveActivity.textViewAllocationId.getError().toString(), is(application.getString(R.string.error_allocation_received))); receiveActivity.validateAllocationId(); receiveActivity.textViewAllocationId.setText("TW12032"); assertThat(receiveActivity.textViewAllocationId.getError(), is(nullValue())); }