use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithDeploymentConfigTest 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 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));
IDeploymentConfig deploymentConfig = ResourceMocks.createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
when(project.getResources(ResourceKind.DEPLOYMENT_CONFIG)).thenReturn(Collections.singletonList(deploymentConfig));
// 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 shouldReturnNewSelectedServiceIfLoadResourcesWithConnection.
@Test
public void shouldReturnNewSelectedServiceIfLoadResourcesWithConnection() {
// given
IResource selectedService = 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));
IService service = ResourceMocks.createResource(IService.class, ResourceKind.SERVICE);
when(project.getResources(ResourceKind.SERVICE)).thenReturn(Collections.singletonList(service));
// when
model.loadResources(connection);
// then
IResource newSelectedService = model.getResource();
assertThat(selectedService).isNotEqualTo(newSelectedService);
} finally {
ConnectionsRegistrySingleton.getInstance().remove(connection);
}
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithDeploymentConfigTest method shouldReturnNewServiceItemsIfLoadResourcesWithConnection.
@Test
public void shouldReturnNewServiceItemsIfLoadResourcesWithConnection() {
// given
List<ObservableTreeItem> resourceItems = 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));
IDeploymentConfig deploymentConfig = ResourceMocks.createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
when(project.getResources(ResourceKind.DEPLOYMENT_CONFIG)).thenReturn(Collections.singletonList(deploymentConfig));
// when
model.loadResources(connection);
// then
List<ObservableTreeItem> newResourceItems = model.getResourceItems();
assertThat(newResourceItems).isNotEqualTo(resourceItems);
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithReplicationControllerTest method shouldReturnNewServiceItemsIfLoadResourcesWithConnection.
@Test
public void shouldReturnNewServiceItemsIfLoadResourcesWithConnection() {
// given
List<ObservableTreeItem> resourceItems = 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));
IReplicationController replicationController = ResourceMocks.createResource(IReplicationController.class, ResourceKind.REPLICATION_CONTROLLER);
when(project.getResources(ResourceKind.REPLICATION_CONTROLLER)).thenReturn(Collections.singletonList(replicationController));
// when
model.loadResources(connection);
// then
List<ObservableTreeItem> newResourceItems = model.getResourceItems();
assertThat(newResourceItems).isNotEqualTo(resourceItems);
}
Aggregations