use of org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel in project jbosstools-openshift by jbosstools.
the class ConnectionWizardPageModelTest method should_disable_promptCredentials_on_edited_connection_when_disposing_model_and_was_disabled_before_editing_it.
@Test
public void should_disable_promptCredentials_on_edited_connection_when_disposing_model_and_was_disabled_before_editing_it() {
// given prompt is disabled once connection is being edited
Connection connection = mockOS3Connection("foo", "https://localhost");
doReturn(false).when(connection).isEnablePromptCredentials();
allConnections.add(connection);
ConnectionWizardPageModel model = new TestableConnectionWizardPageModel(connection, allConnections, connection.getClass(), true, wizardModel);
verify(connection).enablePromptCredentials(false);
// when
model.dispose();
// then disable 2x, once when editing, 2nd time when disposing
verify(connection, times(2)).enablePromptCredentials(false);
}
use of org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel in project jbosstools-openshift by jbosstools.
the class ConnectionWizardPageModelTest method should_default_connection_be_OS3.
@Test
public void should_default_connection_be_OS3() {
ConnectionWizardPageModel model = new TestableConnectionWizardPageModel(null, allConnections, null, true, wizardModel);
assertThat(model.getConnectionFactory().getId()).isEqualTo(IConnectionsFactory.CONNECTIONFACTORY_OPENSHIFT_ID);
}
use of org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel in project jbosstools-openshift by jbosstools.
the class ConnectionWizardPageModelTest method getAllConnections_should_return_all_connections_and_NewConnectionMarker_if_connection_type_is_null_and_connection_change_is_allowed.
@SuppressWarnings("unchecked")
@Test
public void getAllConnections_should_return_all_connections_and_NewConnectionMarker_if_connection_type_is_null_and_connection_change_is_allowed() {
// pre-condition
ConnectionWizardPageModel model = new TestableConnectionWizardPageModel(editedConnection, allConnections, null, true, wizardModel);
// operation
// verification
assertThat(model.getAllConnections()).containsExactlyElementsOf(union(Collections.singletonList(NewConnectionMarker.getInstance()), allConnections));
}
use of org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel in project jbosstools-openshift by jbosstools.
the class ConnectionWizardPageModelTest method getAllHosts_should_only_contain_unique_hosts.
@Test
public void getAllHosts_should_only_contain_unique_hosts() {
// pre-condition
assertThat(allConnections).isNotEmpty();
// add duplicate host
allConnections.add(allConnections.get(0));
ConnectionWizardPageModel model = new TestableConnectionWizardPageModel(editedConnection, allConnections, null, false, wizardModel);
// operation
Collection<String> allHosts = model.getAllHosts();
// verification
assertThat(allHosts).containsOnly(this.allHosts);
}
use of org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorsTest method testBasicAuthenticationValidatorInUI.
@Test
public void testBasicAuthenticationValidatorInUI() {
Connection connection1 = mockConnection(HOST1, USER1, null);
mockConnection(HOST2, USER2, null);
ConnectionWizardPageModel pageModel = mockConnectionWizardPageModel(connection1);
Mockito.when(pageModel.getHost()).thenReturn(HOST2);
IValueChangeListener<Object> l = new IValueChangeListener<Object>() {
@Override
public void handleValueChange(ValueChangeEvent<? extends Object> event) {
}
};
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
Composite composite = new Composite(shell, SWT.NONE);
try {
BasicAuthenticationDetailView view = new BasicAuthenticationDetailView(pageModel, l, null);
DataBindingContext dbc = new DataBindingContext();
view.createControls(shell, null, dbc);
view.onVisible(null, dbc);
view.getPasswordTextControl().setText("pass");
view.getUsernameTextControl().setText(USER2);
MultiValidator v = findValidator(dbc);
Assert.assertEquals(IStatus.ERROR, getStatusSeverity(v));
view.getUsernameTextControl().setText(USER3);
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
} finally {
composite.dispose();
}
}
Aggregations