Search in sources :

Example 1 with BasicAuthenticationDetailView

use of org.jboss.tools.openshift.internal.ui.wizard.connection.BasicAuthenticationDetailView 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();
    }
}
Also used : IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) BasicAuthenticationDetailView(org.jboss.tools.openshift.internal.ui.wizard.connection.BasicAuthenticationDetailView) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) ConnectionWizardPageModel(org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel) Connection(org.jboss.tools.openshift.core.connection.Connection) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) Test(org.junit.Test)

Aggregations

DataBindingContext (org.eclipse.core.databinding.DataBindingContext)1 IValueChangeListener (org.eclipse.core.databinding.observable.value.IValueChangeListener)1 ValueChangeEvent (org.eclipse.core.databinding.observable.value.ValueChangeEvent)1 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1 Connection (org.jboss.tools.openshift.core.connection.Connection)1 ConnectionWizardPageModel (org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel)1 BasicAuthenticationDetailView (org.jboss.tools.openshift.internal.ui.wizard.connection.BasicAuthenticationDetailView)1 Test (org.junit.Test)1