MMIARequisitionFragment extends BaseReportFragment implements MMIARequisitionPresenter.MMIARequisitionView { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_FOR_CUSTOM_REGIME) { regimeWrap.addCustomRegimenItem((Regimen) data.getSerializableExtra(Constants.PARAM_CUSTOM_REGIMEN)); } }  @Override void onCreate(Bundle savedInstanceState); @Override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState); @Override void onViewCreated(View view, Bundle savedInstanceState); @Override void refreshRequisitionForm(RnRForm form); @NonNull Subscriber<Void> getOnSavedSubscriber(); @Override void showValidationAlert(); @Override void setProcessButtonName(String buttonName); @Override void completeSuccess(); @NonNull String getSignatureDialogTitle(); @Override void onActivityResult(int requestCode, int resultCode, Intent data); static final int REQUEST_FOR_CUSTOM_REGIME; }
@Test public void shouldAddCustomRegimenItem() { MMIARequisitionFragment mmiaRequisitionFragmentSpy = spy(mmiaRequisitionFragment); Regimen regimen = new Regimen(); Observable<Void> value = Observable.create(Observer::onCompleted); when(mmiaFormPresenter.addCustomRegimenItem(regimen)).thenReturn(value); RnRForm rnRForm = new RnRForm(); when(mmiaFormPresenter.getRnRForm()).thenReturn(rnRForm); Intent data = new Intent(); data.putExtra(Constants.PARAM_CUSTOM_REGIMEN, regimen); mmiaRequisitionFragmentSpy.onActivityResult(MMIARequisitionFragment.REQUEST_FOR_CUSTOM_REGIME, Activity.RESULT_OK, data); verify(mmiaRequisitionFragmentSpy.regimeWrap).addCustomRegimenItem(regimen); }