### Question:
ReceiveActivity extends CommoditySelectableActivity implements Serializable { public Receive generateReceive() { if ((allocation == null && spinnerSource.getSelectedItem().toString().contains(getString(R.string.lga_for_receive))) || (allocation != null && allocation.isDummy())) { generateDummyAllocation(textViewAllocationId.getText().toString().trim()); } Receive receive = new Receive(getString(FIXED_SOURCES.get(spinnerSource.getSelectedItemPosition())), allocation); for (int i = 0; i < arrayAdapter.getCount(); i++) { ReceiveCommodityViewModel viewModel = (ReceiveCommodityViewModel) arrayAdapter.getItem(i); ReceiveItem receiveItem = viewModel.getReceiveItem(); receive.addReceiveItem(receiveItem); } return receive; }  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 shouldGenerateAReceiveFromSelectedReceiveCommodities() throws Exception { ReceiveActivity receiveActivity = getReceiveActivity(); ReceiveCommodityViewModel viewModel = new ReceiveCommodityViewModel(new Commodity(PANADOL), 3, 6); EventBus.getDefault().post(new CommodityToggledEvent(viewModel)); Receive receive = receiveActivity.generateReceive(); assertThat(receive.getReceiveItems().size(), is(1)); assertThat(receive.getReceiveItems().get(0).getCommodity().getName(), is(PANADOL)); assertThat(receive.getSource(), is(application.getString(R.string.others))); }
@Test public void shouldGenerateReceiveWithSource() throws Exception { ReceiveActivity receiveActivity = getReceiveActivity(); ReceiveCommodityViewModel viewModel = new ReceiveCommodityViewModel(new Commodity(PANADOL), 3, 6); EventBus.getDefault().post(new CommodityToggledEvent(viewModel)); String applicationString = application.getString(R.string.zonal_store_for_receive); setSource(receiveActivity, applicationString); Receive receive = receiveActivity.generateReceive(); assertThat(receive.getSource(), is(application.getString(R.string.zonal_store))); }