Search in sources :

Example 76 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class ConnectionTest method should_not_credentialsEqual_if_different_token.

@Test
public void should_not_credentialsEqual_if_different_token() throws Exception {
    // given
    connection = new Connection(new ClientBuilder("https://someplace").withUserName("foo").withPassword("bar").usingToken("mytoken").build(), null);
    Connection two = (Connection) connection.clone();
    assertThat(two).isEqualTo(connection);
    assertThat(two.credentialsEqual(connection)).isTrue();
    // when
    two.setToken("tokenTwo");
    // then
    assertThat(two).isEqualTo(connection);
    assertThat(two.credentialsEqual(connection)).isFalse();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) ClientBuilder(com.openshift.restclient.ClientBuilder) Test(org.junit.Test)

Example 77 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class ConnectionTest method should_not_credentialsEqual_if_different_password.

@Test
public void should_not_credentialsEqual_if_different_password() throws Exception {
    // given
    Connection two = (Connection) connection.clone();
    // when
    two.setPassword("aPassword123");
    // then
    assertThat(two).isEqualTo(connection);
    assertThat(two.credentialsEqual(connection)).isFalse();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 78 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerContentProviderTest method modelShouldHaveConnectionThatIsAddedInRegistry.

@Test
public void modelShouldHaveConnectionThatIsAddedInRegistry() throws MalformedURLException {
    // given
    int numOfConnections = model.getConnections().size();
    Connection connection2 = ConnectionTestUtils.createConnection("aUser", "123456", "https://127.0.0.1:8080");
    // when
    registry.add(connection2);
    // then
    assertThat(model.getConnections()).hasSize(numOfConnections + 1);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Test(org.junit.Test)

Example 79 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerLabelProviderTest method getStyledTextForAConnection.

@Test
public void getStyledTextForAConnection() throws Exception {
    Connection connection = ConnectionTestUtils.createConnection("username", "token", client.getBaseURL().toString());
    connection.setUsername("foo@bar.com");
    String exp = String.format("foo@bar.com %s", client.getBaseURL().toString());
    assertEquals("Exp. a connection to display its base URL", exp, provider.getStyledText(connection).getString());
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) StyledString(org.eclipse.jface.viewers.StyledString) Test(org.junit.Test)

Example 80 with Connection

use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.

the class OpenShiftExplorerLabelProviderTest method getStyledTextForAConnectionWithoutUserName.

@Test
public void getStyledTextForAConnectionWithoutUserName() throws Exception {
    Connection connection = ConnectionTestUtils.createConnection(null, "token", client.getBaseURL().toString());
    String exp = String.format("<unknown user> %s", client.getBaseURL().toString());
    assertEquals("Exp. a connection to display its base URL", exp, provider.getStyledText(connection).getString());
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) StyledString(org.eclipse.jface.viewers.StyledString) Test(org.junit.Test)

Aggregations

Connection (org.jboss.tools.openshift.core.connection.Connection)110 Test (org.junit.Test)48 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)30 IResource (com.openshift.restclient.model.IResource)27 IProject (com.openshift.restclient.model.IProject)18 IService (com.openshift.restclient.model.IService)11 IStatus (org.eclipse.core.runtime.IStatus)11 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)9 Collection (java.util.Collection)8 List (java.util.List)8 ISelection (org.eclipse.jface.viewers.ISelection)8 IPod (com.openshift.restclient.model.IPod)7 ArrayList (java.util.ArrayList)7 CoreException (org.eclipse.core.runtime.CoreException)7 OpenShiftException (com.openshift.restclient.OpenShiftException)6 ResourceKind (com.openshift.restclient.ResourceKind)6 IRoute (com.openshift.restclient.model.route.IRoute)6 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Status (org.eclipse.core.runtime.Status)6