Search in sources :

Example 1 with GetNetworksParams

use of org.eclipse.che.plugin.docker.client.params.network.GetNetworksParams in project che by eclipse.

the class DockerConnectorTest method shouldBeAbleToGetNetworksWithParams.

@Test
public void shouldBeAbleToGetNetworksWithParams() throws Exception {
    // given
    Network network = createNetwork();
    List<Network> originNetworks = singletonList(network);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(GSON.toJson(originNetworks).getBytes());
    doReturn(inputStream).when(dockerResponse).getInputStream();
    GetNetworksParams getNetworksParams = GetNetworksParams.create().withFilters(new Filters().withFilter("key", "value1", "value2"));
    // when
    List<Network> actual = dockerConnector.getNetworks(getNetworksParams);
    // then
    assertEquals(actual, originNetworks);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_GET);
    verify(dockerConnection).path("/networks");
    verify(dockerConnection).query(eq("filters"), anyObject());
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
    verify(dockerResponse).getInputStream();
}
Also used : Filters(org.eclipse.che.plugin.docker.client.json.Filters) ByteArrayInputStream(java.io.ByteArrayInputStream) GetNetworksParams(org.eclipse.che.plugin.docker.client.params.network.GetNetworksParams) Network(org.eclipse.che.plugin.docker.client.json.network.Network) ContainerInNetwork(org.eclipse.che.plugin.docker.client.json.network.ContainerInNetwork) NewNetwork(org.eclipse.che.plugin.docker.client.json.network.NewNetwork) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 URI (java.net.URI)1 Filters (org.eclipse.che.plugin.docker.client.json.Filters)1 ContainerInNetwork (org.eclipse.che.plugin.docker.client.json.network.ContainerInNetwork)1 Network (org.eclipse.che.plugin.docker.client.json.network.Network)1 NewNetwork (org.eclipse.che.plugin.docker.client.json.network.NewNetwork)1 GetNetworksParams (org.eclipse.che.plugin.docker.client.params.network.GetNetworksParams)1 Test (org.testng.annotations.Test)1