Example #1
0
  @Test(expected = DockerApiConnectionException.class)
  public void shouldWrapJaxRsException() {
    given(docker.containers(anyInt(), anyInt(), anyString(), anyString(), anyInt()))
        .willThrow(ProcessingException.class);

    Dockers.getUsedPorts(docker);
  }
Example #2
0
  @Test
  public void shouldRetrievePublicPort() {
    Port port = new Port();
    port.setPrivatePort(1);
    port.setPublicPort(2);
    Container container = new Container();
    container.setPorts(Arrays.asList(port));
    given(docker.containers(anyInt(), anyInt(), anyString(), anyString(), anyInt()))
        .willReturn(Arrays.asList(container));

    // When
    Set<Integer> ports = Dockers.getUsedPorts(docker);

    // Then
    assertEquals(1, ports.size());
    assertEquals(port.getPublicPort(), ports.iterator().next());
  }