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();
}
}
Aggregations