use of org.eclipse.che.plugin.docker.client.json.ExecCreated in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToCreateExec.
@Test
public void shouldBeAbleToCreateExec() throws IOException, JsonParseException {
CreateExecParams createExecParams = CreateExecParams.create(CONTAINER, CMD_WITH_ARGS);
Exec exec = new Exec(CMD_WITH_ARGS, EXEC_ID);
ExecCreated execCreated = mock(ExecCreated.class);
doReturn(execCreated).when(dockerConnector).parseResponseStreamAndClose(inputStream, ExecCreated.class);
when(execCreated.getId()).thenReturn(EXEC_ID);
Exec returnedExec = dockerConnector.createExec(createExecParams);
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_POST);
verify(dockerConnection).path("/containers/" + createExecParams.getContainer() + "/exec");
verify(dockerConnection).header("Content-Type", MediaType.APPLICATION_JSON);
verify(dockerConnection).header(eq("Content-Length"), anyInt());
verify(dockerConnection).entity(any(byte[].class));
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
verify(dockerResponse).getInputStream();
assertEquals(returnedExec, exec);
}
Aggregations