IncidentRegisterPresenter extends RecordRegisterPresenter { @Override public void saveRecord(ItemValuesMap itemValuesMap, List<String> photoPaths, RecordRegisterView.SaveRecordCallback callback) { ItemValuesMap fieldValueVerifyResult = getView().getFieldValueVerifyResult(); if (fieldValueVerifyResult != null && fieldValueVerifyResult.getValues().size() > 0) { callback.onFieldValueInvalid(); return; } IncidentTemplateForm incidentForm = incidentFormService.getGBVTemplate(); boolean validateRequiredFields = incidentService.validateRequiredFields(incidentForm, itemValuesMap); if (!validateRequiredFields) { callback.onRequiredFieldNotFilled(); return; } clearProfileItems(itemValuesMap); try { Incident record = incidentService.saveOrUpdate(itemValuesMap); addProfileItems(itemValuesMap, record.getRegistrationDate(), record.getUniqueId(), null, record.getId()); callback.onSaveSuccessful(record.getId()); } catch (IOException e) { callback.onSavedFail(); } } @Inject  IncidentRegisterPresenter(IncidentService incidentService, IncidentFormService
            incidentFormService); @Override void saveRecord(ItemValuesMap itemValuesMap, List<String> photoPaths,
                           RecordRegisterView.SaveRecordCallback callback); @Override List<Field> getFields(int position); @Override RecordForm getTemplateForm();  }
@Test public void required_Field_is_false_when_save_record() { ItemValuesMap itemValuesMap = new ItemValuesMap(); itemValuesMap.addBooleanItem("is_case", true); itemValuesMap.addNumberItem("age", 12); RecordRegisterView.SaveRecordCallback callback = mock(RecordRegisterView .SaveRecordCallback.class); IncidentTemplateForm incidentTemplateForm = mock(IncidentTemplateForm.class); when(incidentFormService.getGBVTemplate()).thenReturn(incidentTemplateForm); when(incidentService.validateRequiredFields(incidentTemplateForm, itemValuesMap)) .thenReturn(false); RecordRegisterView view = mock(RecordRegisterView.class); when(view.getFieldValueVerifyResult()).thenReturn(new ItemValuesMap()); incidentRegisterPresenter.attachView(view); incidentRegisterPresenter.saveRecord(itemValuesMap, new ArrayList<String>(), callback); verify(callback, times(1)).onRequiredFieldNotFilled(); }