Search in sources :

Example 1 with OAuthDetailView

use of org.jboss.tools.openshift.internal.ui.wizard.connection.OAuthDetailView in project jbosstools-openshift by jbosstools.

the class ConnectionValidatorsTest method testOAuthAuthenticationValidatorInUI.

@Test
public void testOAuthAuthenticationValidatorInUI() {
    Connection connection1 = mockConnection(HOST1, null, TOKEN1);
    mockConnection(HOST2, null, TOKEN2);
    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 {
        OAuthDetailView view = new OAuthDetailView(null, pageModel, l, null, null);
        DataBindingContext dbc = new DataBindingContext();
        view.createControls(shell, null, dbc);
        view.onVisible(null, dbc);
        view.getTokenTextControl().setText(TOKEN2);
        MultiValidator v = findValidator(dbc);
        Assert.assertEquals(IStatus.ERROR, getStatusSeverity(v));
        view.getTokenTextControl().setText(TOKEN3);
        Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
    } finally {
        composite.dispose();
    }
}
Also used : IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) OAuthDetailView(org.jboss.tools.openshift.internal.ui.wizard.connection.OAuthDetailView) 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 OAuthDetailView (org.jboss.tools.openshift.internal.ui.wizard.connection.OAuthDetailView)1 Test (org.junit.Test)1