use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class ConnectionTest method ownsResource_should_return_false_when_clients_are_different.
@Test
public void ownsResource_should_return_false_when_clients_are_different() {
IClient diffClient = mock(IClient.class);
Map<String, Object> mocks = givenAResourceThatAcceptsAVisitorForIClientCapability(diffClient);
assertFalse(connection.ownsResource((IResource) mocks.get("resource")));
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenInWebConsoleHandlerTest method test.
@Theory
public void test(DataPair dataPair) {
IResource resourceMock = dataPair.getResource();
if (resourceMock != null) {
when(resourceMock.getNamespaceName()).thenReturn("namespace");
when(resourceMock.getName()).thenReturn("qwerty");
when(resourceMock.getLabels()).thenReturn(new HashMap<String, String>() {
{
put("buildconfig", "label");
}
});
}
assertEquals(dataPair.getExpected(), handlerMock.getWebConsoleUrl(connectionMock, resourceMock));
}
use of com.openshift.restclient.model.IResource 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 com.openshift.restclient.model.IResource 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 com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithServiceTest method shouldReturn1stServiceInListIfInitializedServiceIsNotInListOfAllServices.
@Test
public void shouldReturn1stServiceInListIfInitializedServiceIsNotInListOfAllServices() {
// given
IService otherService = ResourceMocks.createResource(IService.class, ResourceKind.SERVICE);
ServerResourceViewModel model = new ServerResourceViewModel(otherService, connection);
model.loadResources();
// when
IResource service = model.getResource();
// then
assertThat(service).isEqualTo(ResourceMocks.PROJECT2_SERVICES[0]);
}
Aggregations