use of com.openshift.restclient.model.IService in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method shouldReturnNullGivenNoDCNameSelectorNorRCisFoundForService.
@Test
public void shouldReturnNullGivenNoDCNameSelectorNorRCisFoundForService() throws CoreException {
// given
Connection connection = ResourceMocks.create3ProjectsConnection();
IService service = ResourceMocks.PROJECT2_SERVICES[0];
// when
IDeploymentConfig dc = ResourceUtils.getDeploymentConfigFor(service, connection);
// then
assertThat(dc).isNull();
}
use of com.openshift.restclient.model.IService in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method serviceAndRouteWithDifferentNameShouldNotBeRelated.
public void serviceAndRouteWithDifferentNameShouldNotBeRelated() {
// given
IRoute route = mock(IRoute.class);
when(route.getServiceName()).thenReturn("42");
IService service = mock(IService.class);
when(service.getName()).thenReturn("24");
// when
// then
assertThat(areRelated(route, service)).isFalse();
}
use of com.openshift.restclient.model.IService in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method testGetServicesForPod.
@Test
public void testGetServicesForPod() {
IService match = mock(IService.class);
when(match.getSelector()).thenReturn(serviceSelector);
IService nomatch = mock(IService.class);
when(nomatch.getSelector()).thenReturn(new HashMap<>());
Collection<IService> services = Arrays.asList(nomatch, match);
IService[] exp = new IService[] { match };
assertArrayEquals(exp, getServicesFor(pod, services).toArray());
}
use of com.openshift.restclient.model.IService in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method testAreRelatedForBuildConfigAndService.
@Test
public void testAreRelatedForBuildConfigAndService() {
// given
// when
// then
assertThat(areRelated((IBuildConfig) null, (IService) null)).isFalse();
// given
// when
// then
assertThat(areRelated(mock(IBuildConfig.class), (IService) null)).isFalse();
// given
// when
// then
assertThat(areRelated((IBuildConfig) null, mock(IService.class))).isFalse();
// given
IBuildConfig buildConfig = mock(IBuildConfig.class);
when(buildConfig.getName()).thenReturn("42");
IService service = mock(IService.class);
when(service.getName()).thenReturn("24");
// when
// then
assertThat(areRelated(buildConfig, service)).isFalse();
// given
buildConfig = mock(IBuildConfig.class);
when(buildConfig.getName()).thenReturn("42");
service = mock(IService.class);
when(service.getName()).thenReturn("42");
// when
// then
assertThat(areRelated(buildConfig, service)).isTrue();
}
use of com.openshift.restclient.model.IService in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method shouldReturnDeploymentConfigForServiceByNameGivenServiceHasDCNameSelector.
@Test
public void shouldReturnDeploymentConfigForServiceByNameGivenServiceHasDCNameSelector() throws CoreException {
// given
Connection connection = ResourceMocks.create3ProjectsConnection();
IService service = ResourceMocks.PROJECT2_SERVICES[1];
// when
IDeploymentConfig dc = ResourceUtils.getDeploymentConfigFor(service, connection);
// then
assertThat(dc).isEqualTo(ResourceMocks.PROJECT2_DEPLOYMENTCONFIGS[2]);
}
Aggregations