use of org.eclipse.core.databinding.observable.value.WritableValue in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorsTest method testOAuthAuthenticationValidator.
@Test
public void testOAuthAuthenticationValidator() {
Connection connection1 = mockConnection(HOST1, null, TOKEN1);
mockConnection(HOST2, null, TOKEN2);
ConnectionWizardPageModel pageModel = mockConnectionWizardPageModel(connection1);
WritableValue<String> tokenObservable = new WritableValue<String>();
WritableValue<String> urlObservable = new WritableValue<String>();
MultiValidator v = ConnectionValidatorFactory.createOAuthAuthenticationValidator(pageModel, tokenObservable, urlObservable);
v.observeValidatedValue(urlObservable);
// New connection
urlObservable.setValue(HOST3);
tokenObservable.setValue(TOKEN3);
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
urlObservable.setValue(HOST2);
// Host exists, but token is different
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
tokenObservable.setValue(TOKEN2);
// Existing not selected connection
Assert.assertEquals(IStatus.ERROR, getStatusSeverity(v));
// Selected connection
urlObservable.setValue(HOST1);
tokenObservable.setValue(TOKEN1);
Assert.assertEquals(IStatus.OK, getStatusSeverity(v));
}
Aggregations