use of org.eclipse.che.plugin.docker.client.json.NetworkCreated in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToCreateNetwork.
@Test
public void shouldBeAbleToCreateNetwork() throws Exception {
// given
CreateNetworkParams createNetworkParams = CreateNetworkParams.create(createNewNetwork());
NetworkCreated originNetworkCreated = new NetworkCreated().withId("some_id").withWarning("some_warning");
ByteArrayInputStream inputStream = new ByteArrayInputStream(GSON.toJson(originNetworkCreated).getBytes());
doReturn(inputStream).when(dockerResponse).getInputStream();
// when
NetworkCreated networkCreated = dockerConnector.createNetwork(createNetworkParams);
// then
assertEquals(networkCreated, originNetworkCreated);
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_POST);
verify(dockerConnection).path("/networks/create");
verify(dockerConnection).header("Content-Type", MediaType.APPLICATION_JSON);
verify(dockerConnection).header(eq("Content-Length"), anyInt());
ArgumentCaptor<byte[]> argumentCaptor = ArgumentCaptor.forClass(byte[].class);
verify(dockerConnection).entity(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue(), GSON.toJson(createNetworkParams.getNetwork()).getBytes());
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
verify(dockerResponse).getInputStream();
}
Aggregations