Search in sources :

Example 16 with Connection

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

the class ServerResourceViewModelWithServiceTest method shouldReturnNewServiceItemsIfLoadResourcesWithConnection.

@Test
public void shouldReturnNewServiceItemsIfLoadResourcesWithConnection() {
    // given
    List<ObservableTreeItem> serviceItems = new ArrayList<>(model.getResourceItems());
    Connection connection = ResourceMocks.createConnection("http://localhost:8080", "dev@42.org");
    IProject project = ResourceMocks.createResource(IProject.class, ResourceKind.PROJECT);
    when(connection.getResources(ResourceKind.PROJECT)).thenReturn(Collections.singletonList(project));
    IService service = ResourceMocks.createResource(IService.class, ResourceKind.SERVICE);
    when(project.getResources(ResourceKind.SERVICE)).thenReturn(Collections.singletonList(service));
    // when
    model.loadResources(connection);
    // then
    List<ObservableTreeItem> newServiceItems = model.getResourceItems();
    assertThat(newServiceItems).isNotEqualTo(serviceItems);
}
Also used : ArrayList(java.util.ArrayList) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IProject(com.openshift.restclient.model.IProject) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 17 with Connection

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

the class ServerResourceViewModelWithReplicationControllerTest method shouldReturnNewSelectedDeploymentConfigIfLoadResourcesWithConnection.

@Test
public void shouldReturnNewSelectedDeploymentConfigIfLoadResourcesWithConnection() {
    // given
    IResource selectedDeploymentConfig = model.getResource();
    Connection connection = ResourceMocks.createConnection("https://localhost:8181", "ops@42.org");
    ConnectionsRegistrySingleton.getInstance().add(connection);
    try {
        IProject project = ResourceMocks.createResource(IProject.class, ResourceKind.PROJECT);
        when(connection.getResources(ResourceKind.PROJECT)).thenReturn(Collections.singletonList(project));
        IReplicationController replicationController = ResourceMocks.createResource(IReplicationController.class, ResourceKind.REPLICATION_CONTROLLER);
        when(project.getResources(ResourceKind.REPLICATION_CONTROLLER)).thenReturn(Collections.singletonList(replicationController));
        // when
        model.loadResources(connection);
        // then
        IResource newSelectedDeploymentConfig = model.getResource();
        assertThat(selectedDeploymentConfig).isNotEqualTo(newSelectedDeploymentConfig);
    } finally {
        ConnectionsRegistrySingleton.getInstance().remove(connection);
    }
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IResource(com.openshift.restclient.model.IResource) IProject(com.openshift.restclient.model.IProject) IReplicationController(com.openshift.restclient.model.IReplicationController) Test(org.junit.Test)

Example 18 with Connection

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

the class ServerResourceViewModelWithServiceTest method shouldLoadResourcesWhenToldTo.

@Test
public void shouldLoadResourcesWhenToldTo() {
    // given
    Connection connection = ResourceMocks.createConnection("http://10.1.2.2:8443", "dev@paas.redhat.com");
    ServerResourceViewModel model = new ServerResourceViewModel(connection);
    model.loadResources();
    // when
    // then
    verify(connection, atLeastOnce()).getResources(any());
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 19 with Connection

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

the class ServerResourceViewModelWithDeploymentConfigTest method shouldNotLoadResourcesBeforeBeingToldTo.

@Test
public void shouldNotLoadResourcesBeforeBeingToldTo() {
    // given
    Connection connection = ResourceMocks.createConnection("http://10.1.2.2:8443", "dev@paas.redhat.com");
    new ServerResourceViewModel(connection);
    // when
    // then
    verify(connection, never()).getResources(any());
    verify(connection, never()).getResources(any(), any());
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 20 with Connection

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

the class ServerResourceViewModelWithReplicationControllerTest method shouldNotLoadResourcesBeforeBeingToldTo.

@Test
public void shouldNotLoadResourcesBeforeBeingToldTo() {
    // given
    Connection connection = ResourceMocks.createConnection("http://10.1.2.2:8443", "dev@paas.redhat.com");
    new ServerResourceViewModel(connection);
    // when
    // then
    verify(connection, never()).getResources(any());
    verify(connection, never()).getResources(any(), any());
}
Also used : ServerResourceViewModel(org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) 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