Search in sources :

Example 26 with IPod

use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.

the class PortForwardingUtilsTest method shouldGetForwardablePortsOnStartedState.

@Test
@SuppressWarnings("unchecked")
public void shouldGetForwardablePortsOnStartedState() {
    // given
    final IPod pod = Mockito.mock(IPod.class);
    final PortPair port = Mockito.mock(PortPair.class);
    final IPortForwardable portForwardable = Mockito.mock(IPortForwardable.class);
    Mockito.when(portForwardable.getPortPairs()).thenReturn(Arrays.asList(port));
    Mockito.when(pod.accept(Mockito.any(CapabilityVisitor.class), Mockito.any(IPortForwardable.class))).thenReturn(portForwardable);
    PortForwardingUtils.startPortForwarding(pod, port);
    // when
    final Set<PortPair> forwardablePorts = PortForwardingUtils.getForwardablePorts(pod);
    // then
    assertThat(forwardablePorts).isNotNull().containsExactly(port);
}
Also used : IPortForwardable(com.openshift.restclient.capability.resources.IPortForwardable) PortPair(com.openshift.restclient.capability.resources.IPortForwardable.PortPair) CapabilityVisitor(com.openshift.restclient.capability.CapabilityVisitor) IPod(com.openshift.restclient.model.IPod) Test(org.junit.Test)

Example 27 with IPod

use of com.openshift.restclient.model.IPod in project jbosstools-openshift by jbosstools.

the class ResourceUtilsTest method podListWithDeploymentConfigKeyShouldReturnDeploymentConfigName.

@Test
public void podListWithDeploymentConfigKeyShouldReturnDeploymentConfigName() {
    // given
    final HashMap<String, String> podLabels = new HashMap<>();
    podLabels.put("foo", "booh");
    podLabels.put("bar", "car");
    podLabels.put(ResourceUtils.DEPLOYMENT_CONFIG, "hooolahoo");
    IPod pod = ResourceMocks.createResource(IPod.class, ResourceKind.POD, p -> when(p.getLabels()).thenReturn(podLabels));
    List<IPod> pods = Arrays.asList(ResourceMocks.createResource(IPod.class, ResourceKind.POD), pod, ResourceMocks.createResource(IPod.class, ResourceKind.POD));
    // when
    String name = getDeploymentConfigNameFor(pods);
    // then
    assertThat(name).isEqualTo("hooolahoo");
}
Also used : HashMap(java.util.HashMap) IPod(com.openshift.restclient.model.IPod) Test(org.junit.Test)

Aggregations

IPod (com.openshift.restclient.model.IPod)27 Connection (org.jboss.tools.openshift.core.connection.Connection)11 Test (org.junit.Test)9 IResource (com.openshift.restclient.model.IResource)8 ResourceKind (com.openshift.restclient.ResourceKind)6 IPortForwardable (com.openshift.restclient.capability.resources.IPortForwardable)6 PortPair (com.openshift.restclient.capability.resources.IPortForwardable.PortPair)6 IReplicationController (com.openshift.restclient.model.IReplicationController)6 HashMap (java.util.HashMap)6 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)6 CapabilityVisitor (com.openshift.restclient.capability.CapabilityVisitor)5 Collection (java.util.Collection)5 List (java.util.List)5 Map (java.util.Map)5 ResourceUtils (org.jboss.tools.openshift.internal.core.util.ResourceUtils)5 IBuild (com.openshift.restclient.model.IBuild)4 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)4 IService (com.openshift.restclient.model.IService)4 CoreException (org.eclipse.core.runtime.CoreException)4 ISelection (org.eclipse.jface.viewers.ISelection)4