### Question:
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);  }### Answer:
@Test public void testSetValueNull() { presenter.setValue(null); verifySetValueCommonActions(null); verify(simpleConditionEditor).setValue(null); verifyShowSimpleConditionEditor(); }
@Test public void testSetValueWithScriptNonInJava() { ScriptTypeValue value = new ScriptTypeValue("javascript", SCRIPT_VALUE); presenter.setValue(value); verifySetValueCommonActions(value); verifyShowScriptEditor(); }
@Test public void testSetValueWithScriptInJavaEmpty() { ScriptTypeValue value = new ScriptTypeValue("java", ""); presenter.setValue(value); verifySetValueCommonActions(value); verifyShowSimpleConditionEditor(); }
@Test public void testSetValueWithScriptInJavaParseable() { 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).setValue(condition); verifyShowSimpleConditionEditor(); }
@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(); }
@Test public void testSetValueWithScriptInJavaNotParseable() { ScriptTypeValue value = new ScriptTypeValue("java", SCRIPT_VALUE); ParseConditionResult result = mock(ParseConditionResult.class); when(result.hasError()).thenReturn(true); doReturn(PromiseMock.success(result)) .when(conditionEditorParsingService) .call(eq(SCRIPT_VALUE)); presenter.setValue(value); verifySetValueCommonActions(value); verify(simpleConditionEditor, never()).setValue(any()); verifyShowScriptEditor(); }