@Test public void testSetValueWithScriptInJavaParseableInClient() { when(conditionEditorGeneratorService.isAvailable()).thenReturn(true); ScriptTypeValue value = new ScriptTypeValue("java", SCRIPT_VALUE); ParseConditionResult result = mock(ParseConditionResult.class); Condition condition = mock(Condition.class); when(result.hasError()).thenReturn(false); when(result.getCondition()).thenReturn(condition); doReturn(PromiseMock.success(result)) .when(conditionEditorParsingService) .call(eq(SCRIPT_VALUE)); presenter.setValue(value); verifySetValueCommonActions(value); verify(simpleConditionEditor, never()).setValue(any()); verifyShowScriptEditor(); }
@Override public void setValue(ScriptTypeValue value) { super.setValue(value); scriptEditor.setValue(value); simpleConditionEditor.clear(); clearError(); if (value != null) { if (isInDefaultLanguage(value) && !isServiceAvailable()) { if (!isEmpty(value.getScript())) { conditionEditorParsingService .call(value.getScript()) .then(result -> { onSetValue(result); return null; }) .catch_(throwable -> { onSetValueError((Throwable) throwable); return null; }); } else { showSimpleConditionEditor(); } } else { showScriptEditor(); } } else { simpleConditionEditor.setValue(null); showSimpleConditionEditor(); } }
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { @Override public void setValue(ScriptTypeValue value) { super.setValue(value); scriptEditor.setValue(value); simpleConditionEditor.clear(); clearError(); if (value != null) { if (isInDefaultLanguage(value) && !isServiceAvailable()) { if (!isEmpty(value.getScript())) { conditionEditorParsingService .call(value.getScript()) .then(result -> { onSetValue(result); return null; }) .catch_(throwable -> { onSetValueError((Throwable) throwable); return null; }); } else { showSimpleConditionEditor(); } } else { showScriptEditor(); } } else { simpleConditionEditor.setValue(null); showSimpleConditionEditor(); } } }
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { @Override public void setValue(ScriptTypeValue value) { super.setValue(value); scriptEditor.setValue(value); simpleConditionEditor.clear(); clearError(); if (value != null) { if (isInDefaultLanguage(value) && !isServiceAvailable()) { if (!isEmpty(value.getScript())) { conditionEditorParsingService .call(value.getScript()) .then(result -> { onSetValue(result); return null; }) .catch_(throwable -> { onSetValueError((Throwable) throwable); return null; }); } else { showSimpleConditionEditor(); } } else { showScriptEditor(); } } else { simpleConditionEditor.setValue(null); showSimpleConditionEditor(); } } @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> { @Override public void setValue(ScriptTypeValue value) { super.setValue(value); scriptEditor.setValue(value); simpleConditionEditor.clear(); clearError(); if (value != null) { if (isInDefaultLanguage(value) && !isServiceAvailable()) { if (!isEmpty(value.getScript())) { conditionEditorParsingService .call(value.getScript()) .then(result -> { onSetValue(result); return null; }) .catch_(throwable -> { onSetValueError((Throwable) throwable); return null; }); } else { showSimpleConditionEditor(); } } else { showScriptEditor(); } } else { simpleConditionEditor.setValue(null); showSimpleConditionEditor(); } } @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> { @Override public void setValue(ScriptTypeValue value) { super.setValue(value); scriptEditor.setValue(value); simpleConditionEditor.clear(); clearError(); if (value != null) { if (isInDefaultLanguage(value) && !isServiceAvailable()) { if (!isEmpty(value.getScript())) { conditionEditorParsingService .call(value.getScript()) .then(result -> { onSetValue(result); return null; }) .catch_(throwable -> { onSetValueError((Throwable) throwable); return null; }); } else { showSimpleConditionEditor(); } } else { showScriptEditor(); } } else { simpleConditionEditor.setValue(null); showSimpleConditionEditor(); } } @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);  }