Search in sources :

Example 11 with IService

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();
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 12 with IService

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();
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) IService(com.openshift.restclient.model.IService)

Example 13 with IService

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());
}
Also used : IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 14 with IService

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();
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 15 with IService

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]);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Aggregations

IService (com.openshift.restclient.model.IService)32 Test (org.junit.Test)15 Connection (org.jboss.tools.openshift.core.connection.Connection)10 IResource (com.openshift.restclient.model.IResource)9 IRoute (com.openshift.restclient.model.route.IRoute)8 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)6 IProject (com.openshift.restclient.model.IProject)5 ResourceKind (com.openshift.restclient.ResourceKind)4 IBuildConfig (com.openshift.restclient.model.IBuildConfig)4 IPod (com.openshift.restclient.model.IPod)4 IReplicationController (com.openshift.restclient.model.IReplicationController)4 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)3 CoreException (org.eclipse.core.runtime.CoreException)3 ResourceUtils (org.jboss.tools.openshift.internal.core.util.ResourceUtils)3 IClient (com.openshift.restclient.IClient)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2