Search in sources :

Example 1 with ContainerCommitted

use of org.eclipse.che.plugin.docker.client.json.ContainerCommitted in project che by eclipse.

the class DockerConnectorTest method shouldBeAbleToCommitImage.

@Test
public void shouldBeAbleToCommitImage() throws IOException, JsonParseException {
    CommitParams commitParams = CommitParams.create(CONTAINER).withRepository(REPOSITORY);
    ContainerCommitted containerCommitted = mock(ContainerCommitted.class);
    when(dockerResponse.getStatus()).thenReturn(RESPONSE_CREATED_CODE);
    when(containerCommitted.getId()).thenReturn(IMAGE);
    doReturn(containerCommitted).when(dockerConnector).parseResponseStreamAndClose(inputStream, ContainerCommitted.class);
    String returnedImage = dockerConnector.commit(commitParams);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_POST);
    verify(dockerConnection).path("/commit");
    verify(dockerConnection).query("container", commitParams.getContainer());
    verify(dockerConnection).query("repo", commitParams.getRepository());
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
    verify(dockerResponse).getInputStream();
    assertEquals(returnedImage, IMAGE);
}
Also used : ContainerCommitted(org.eclipse.che.plugin.docker.client.json.ContainerCommitted) CommitParams(org.eclipse.che.plugin.docker.client.params.CommitParams) Matchers.anyString(org.mockito.Matchers.anyString) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

URI (java.net.URI)1 ContainerCommitted (org.eclipse.che.plugin.docker.client.json.ContainerCommitted)1 CommitParams (org.eclipse.che.plugin.docker.client.params.CommitParams)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Test (org.testng.annotations.Test)1