@Test public void testOnSimpleConditionChangeWithServiceError() { when(translationService.getValue(UNEXPECTED_SCRIPT_GENERATION_ERROR, ERROR)).thenReturn(TRANSLATED_MESSAGE); doReturn(PromiseMock.error(new Throwable(ERROR))) .when(conditionEditorGeneratorService) .call(any()); when(simpleConditionEditor.isValid()).thenReturn(true); presenter.onSimpleConditionChange(mock(Condition.class), mock(Condition.class)); verify(errorPopup).showMessage(TRANSLATED_MESSAGE); verify(changeHandler, never()).onValueChange(any(), any()); }
void onSimpleConditionChange(Condition oldValue, Condition newValue) { if (simpleConditionEditor.isValid()) { conditionEditorGeneratorService .call(newValue) .then(result -> { onSimpleConditionChange(result); return null; }) .catch_(throwable -> { onSimpleConditionChangeError((Throwable) throwable); return null; }); } else { clearError(); } }
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { void onSimpleConditionChange(Condition oldValue, Condition newValue) { if (simpleConditionEditor.isValid()) { conditionEditorGeneratorService .call(newValue) .then(result -> { onSimpleConditionChange(result); return null; }) .catch_(throwable -> { onSimpleConditionChangeError((Throwable) throwable); return null; }); } else { clearError(); } } }
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { void onSimpleConditionChange(Condition oldValue, Condition newValue) { if (simpleConditionEditor.isValid()) { conditionEditorGeneratorService .call(newValue) .then(result -> { onSimpleConditionChange(result); return null; }) .catch_(throwable -> { onSimpleConditionChangeError((Throwable) throwable); return null; }); } else { clearError(); } } @Inject  ConditionEditorFieldEditorPresenter(final View view,
                                               final SimpleConditionEditorPresenter simpleConditionEditor,
                                               final ScriptTypeFieldEditorPresenter scriptEditor,
                                               final ErrorPopupPresenter errorPopup,
                                               final ConditionEditorParsingService conditionEditorParsingService,
                                               final ConditionEditorGeneratorService conditionEditorGeneratorService,
                                               final ClientTranslationService translationService); }
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { void onSimpleConditionChange(Condition oldValue, Condition newValue) { if (simpleConditionEditor.isValid()) { conditionEditorGeneratorService .call(newValue) .then(result -> { onSimpleConditionChange(result); return null; }) .catch_(throwable -> { onSimpleConditionChangeError((Throwable) throwable); return null; }); } else { clearError(); } } @Inject  ConditionEditorFieldEditorPresenter(final View view,
                                               final SimpleConditionEditorPresenter simpleConditionEditor,
                                               final ScriptTypeFieldEditorPresenter scriptEditor,
                                               final ErrorPopupPresenter errorPopup,
                                               final ConditionEditorParsingService conditionEditorParsingService,
                                               final ConditionEditorGeneratorService conditionEditorGeneratorService,
                                               final ClientTranslationService translationService); boolean isServiceAvailable(); @PostConstruct void init(); void init(ClientSession session); @Override void setReadOnly(boolean readOnly); @Override void setValue(ScriptTypeValue value); }
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { void onSimpleConditionChange(Condition oldValue, Condition newValue) { if (simpleConditionEditor.isValid()) { conditionEditorGeneratorService .call(newValue) .then(result -> { onSimpleConditionChange(result); return null; }) .catch_(throwable -> { onSimpleConditionChangeError((Throwable) throwable); return null; }); } else { clearError(); } } @Inject  ConditionEditorFieldEditorPresenter(final View view,
                                               final SimpleConditionEditorPresenter simpleConditionEditor,
                                               final ScriptTypeFieldEditorPresenter scriptEditor,
                                               final ErrorPopupPresenter errorPopup,
                                               final ConditionEditorParsingService conditionEditorParsingService,
                                               final ConditionEditorGeneratorService conditionEditorGeneratorService,
                                               final ClientTranslationService translationService); boolean isServiceAvailable(); @PostConstruct void init(); void init(ClientSession session); @Override void setReadOnly(boolean readOnly); @Override void setValue(ScriptTypeValue value);  }