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