use of com.openshift.restclient.capability.resources.IPortForwardable.PortPair in project jbosstools-openshift by jbosstools.
the class PortForwardingUtilsTest method shouldStopPortForwarding.
@Test
@SuppressWarnings("unchecked")
public void shouldStopPortForwarding() throws IOException {
// given
final IPod pod = Mockito.mock(IPod.class);
final PortPair port = Mockito.mock(PortPair.class);
final IPortForwardable portForwardable = Mockito.mock(IPortForwardable.class);
Mockito.when(pod.accept(Mockito.any(CapabilityVisitor.class), Mockito.any(IPortForwardable.class))).thenReturn(portForwardable);
Mockito.when(portForwardable.isForwarding()).thenReturn(true);
Mockito.when(portForwardable.getPortPairs()).thenReturn(Arrays.asList(port));
PortForwardingUtils.startPortForwarding(pod, port);
// when
final IPortForwardable stopPortForwarding = PortForwardingUtils.stopPortForwarding(pod, null);
// then
assertThat(stopPortForwarding).isNotNull().isEqualTo(portForwardable);
assertThat(PortForwardingUtils.isPortForwardingStarted(pod)).isFalse();
Mockito.verify(portForwardable, Mockito.times(1)).stop();
}
use of com.openshift.restclient.capability.resources.IPortForwardable.PortPair 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);
}
Aggregations