### Question:
OrderActivity extends CommoditySelectableActivity { @Override protected Button getSubmitButton() { return buttonSubmitOrder; }  OrderType getOrderType(); @Override void onBackPressed(); static OrderCommodityViewModel setupOrderCommodityViewModel(Commodity commodity);  }### Answer:
@Test public void shouldShowErrorMessageWhenUnexpectedOrderQuantityIsGiven() throws Exception { orderActivity = getOrderActivity(); OrderCommodityViewModel viewModel = new OrderCommodityViewModel(new Commodity("id", "Panado"), 20); viewModel.setOrderPeriodEndDate(new Date()); viewModel.setOrderPeriodStartDate(new Date()); OrderCommodityViewModel spyViewModel = spy(viewModel); when(spyViewModel.getExpectedOrderQuantity()).thenReturn(10); EventBus.getDefault().post(new CommodityToggledEvent(spyViewModel)); orderActivity.spinnerOrderType.setSelection(0); orderActivity.getSubmitButton().performClick(); assertThat(ShadowToast.getTextOfLatestToast(), is(String.format(application.getString(R.string.unexpected_order_quantity_error), spyViewModel.getName(), spyViewModel.getExpectedOrderQuantity())) ); assertThat(ShadowDialog.getLatestDialog(), is(nullValue())); }
@Test public void shouldShowErrorMessageWhenEmergencyReasonIsNull() throws Exception { orderActivity = getOrderActivity(); OrderCommodityViewModel viewModel = new OrderCommodityViewModel(new Commodity("id", "Panado"), 20); viewModel.setOrderPeriodEndDate(new Date()); viewModel.setOrderPeriodStartDate(new Date()); OrderCommodityViewModel spyViewModel = spy(viewModel); when(spyViewModel.getExpectedOrderQuantity()).thenReturn(10); EventBus.getDefault().post(new CommodityToggledEvent(spyViewModel)); orderActivity.spinnerOrderType.setSelection(1); orderActivity.getSubmitButton().performClick(); assertThat(ShadowToast.getTextOfLatestToast(), is(String.format(application.getString(R.string.unexpected_order_quantity_error), spyViewModel.getName(), spyViewModel.getExpectedOrderQuantity())) ); assertThat(ShadowDialog.getLatestDialog(), is(nullValue())); }