use of org.eclipse.che.ide.api.dialogs.InputValidator in project che by eclipse.
the class SshKeyManagerPresenterTest method shouldReturnNullOnHostNameWithSeveralDotsAndDashesValidation.
@Test
public void shouldReturnNullOnHostNameWithSeveralDotsAndDashesValidation() throws OperationException {
String validHostname = "ho-st.na-me.com";
Violation violation = ((InputValidator) presenter.hostNameValidator).validate(validHostname);
assertNull(violation);
}
use of org.eclipse.che.ide.api.dialogs.InputValidator in project che by eclipse.
the class InputDialogPresenterTest method shouldShowErrorHintWhenValueIsIncorrect.
@Test
public void shouldShowErrorHintWhenValueIsIncorrect() throws Exception {
reset(view);
when(view.getValue()).thenReturn(INCORRECT_INPUT_VALUE);
InputValidator inputValidator = mock(InputValidator.class);
InputValidator.Violation violation = mock(InputValidator.Violation.class);
when(inputValidator.validate(INCORRECT_INPUT_VALUE)).thenReturn(violation);
when(violation.getMessage()).thenReturn(ERROR_MESSAGE);
presenter.withValidator(inputValidator);
presenter.inputValueChanged();
verify(view).showErrorHint(anyString());
verify(view, never()).hideErrorHint();
verify(view, never()).setValue(anyString());
}
use of org.eclipse.che.ide.api.dialogs.InputValidator in project che by eclipse.
the class InputDialogPresenterTest method onEnterClickedWhenInputValueIsCorrect.
@Test
public void onEnterClickedWhenInputValueIsCorrect() throws Exception {
reset(view);
when(view.getValue()).thenReturn(CORRECT_INPUT_VALUE);
InputValidator inputValidator = mock(InputValidator.class);
when(inputValidator.validate(CORRECT_INPUT_VALUE)).thenReturn(null);
presenter.withValidator(inputValidator);
presenter.onEnterClicked();
verify(view, never()).showErrorHint(anyString());
verify(view).hideErrorHint();
verify(view).closeDialog();
verify(inputCallback).accepted(eq(CORRECT_INPUT_VALUE));
}
use of org.eclipse.che.ide.api.dialogs.InputValidator in project che by eclipse.
the class InputDialogPresenterTest method onEnterClickedWhenInputValueIsIncorrect.
@Test
public void onEnterClickedWhenInputValueIsIncorrect() throws Exception {
reset(view);
when(view.getValue()).thenReturn(INCORRECT_INPUT_VALUE);
InputValidator inputValidator = mock(InputValidator.class);
InputValidator.Violation violation = mock(InputValidator.Violation.class);
when(inputValidator.validate(INCORRECT_INPUT_VALUE)).thenReturn(violation);
when(violation.getMessage()).thenReturn(ERROR_MESSAGE);
presenter.withValidator(inputValidator);
presenter.onEnterClicked();
verify(view).showErrorHint(anyString());
verify(view, never()).hideErrorHint();
verify(view, never()).setValue(anyString());
verify(inputCallback, never()).accepted(anyString());
}
use of org.eclipse.che.ide.api.dialogs.InputValidator in project che by eclipse.
the class InputDialogPresenterTest method shouldNotShowErrorHintWhenViolationHasCorrectValue.
@Test
public void shouldNotShowErrorHintWhenViolationHasCorrectValue() throws Exception {
reset(view);
when(view.getValue()).thenReturn(INCORRECT_INPUT_VALUE);
InputValidator inputValidator = mock(InputValidator.class);
InputValidator.Violation violation = mock(InputValidator.Violation.class);
when(inputValidator.validate(INCORRECT_INPUT_VALUE)).thenReturn(violation);
when(violation.getMessage()).thenReturn(null);
when(violation.getCorrectedValue()).thenReturn(CORRECT_INPUT_VALUE);
presenter.withValidator(inputValidator);
presenter.inputValueChanged();
verify(view, never()).showErrorHint(anyString());
verify(view).hideErrorHint();
verify(view).setValue(eq(CORRECT_INPUT_VALUE));
}
Aggregations