Search in sources :

Example 41 with Connection

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

the class ConnectionTest method should_not_equals_if_different_user.

@Test
public void should_not_equals_if_different_user() throws Exception {
    // given
    Connection two = new Connection(new ClientBuilder("https://localhost:8443").build(), null);
    two.setUsername("bar");
    // when
    // then
    assertThat(connection).isNotEqualTo(two);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) ClientBuilder(com.openshift.restclient.ClientBuilder) Test(org.junit.Test)

Example 42 with Connection

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

the class ConnectionPersistencyTest method shouldLoadUsernamesAsDefaultHostConnection.

@Ignore("no default server for OpenShift 3 yet")
@Test
public void shouldLoadUsernamesAsDefaultHostConnection() {
    // pre-condition
    ConnectionPersistency persistency = new ConnectionPersistency() {

        @Override
        protected String[] loadPersisted() {
            return new String[] { "bingobongo@redhat.com" };
        }
    };
    // operations
    Collection<Connection> connections = persistency.load();
    // verification
    assertEquals(1, connections.size());
    Connection connection = connections.iterator().next();
    assertTrue(connection.isDefaultHost());
    assertEquals("bingobongo@redhat.com", connection.getUsername());
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) ConnectionPersistency(org.jboss.tools.openshift.core.connection.ConnectionPersistency) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 43 with Connection

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

the class ConnectionWizardPageModelTest method should_disable_promptCredentials_on_edited_connection_when_disposing_model_and_was_disabled_before_editing_it.

@Test
public void should_disable_promptCredentials_on_edited_connection_when_disposing_model_and_was_disabled_before_editing_it() {
    // given prompt is disabled once connection is being edited
    Connection connection = mockOS3Connection("foo", "https://localhost");
    doReturn(false).when(connection).isEnablePromptCredentials();
    allConnections.add(connection);
    ConnectionWizardPageModel model = new TestableConnectionWizardPageModel(connection, allConnections, connection.getClass(), true, wizardModel);
    verify(connection).enablePromptCredentials(false);
    // when
    model.dispose();
    // then disable 2x, once when editing, 2nd time when disposing
    verify(connection, times(2)).enablePromptCredentials(false);
}
Also used : ConnectionWizardPageModel(org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 44 with Connection

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

the class ConnectionTest method should_credentialsEqual_for_cloned_connection.

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

Example 45 with Connection

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

the class ConnectionTest method setup.

@Before
public void setup() throws Exception {
    this.client = createClient("foo", "42", "https://localhost:8443");
    this.connection = new Connection(client, prompter);
    this.testableConnection = createTestableConnection("42", client, prompter);
    doReturn(createClient("foo", "42", "https://localhost:8443")).when(client).clone();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) Before(org.junit.Before)

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