Search in sources :

Example 1 with InspectImageParams

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

the class DockerConnectorTest method shouldBeAbleToInspectImage.

@Test
public void shouldBeAbleToInspectImage() throws IOException, JsonParseException {
    InspectImageParams inspectImageParams = InspectImageParams.create(IMAGE);
    ImageInfo imageInfo = mock(ImageInfo.class);
    doReturn(imageInfo).when(dockerConnector).parseResponseStreamAndClose(inputStream, ImageInfo.class);
    ImageInfo returnedImageInfo = dockerConnector.inspectImage(inspectImageParams);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_GET);
    verify(dockerConnection).path("/images/" + inspectImageParams.getImage() + "/json");
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
    verify(dockerResponse).getInputStream();
    assertEquals(returnedImageInfo, imageInfo);
}
Also used : InspectImageParams(org.eclipse.che.plugin.docker.client.params.InspectImageParams) ImageInfo(org.eclipse.che.plugin.docker.client.json.ImageInfo) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 2 with InspectImageParams

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

the class DockerConnectorTest method shouldThrowDockerExceptionWhileGettingImageInfoIfResponseCodeIsNotSuccess.

@Test(expectedExceptions = DockerException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldThrowDockerExceptionWhileGettingImageInfoIfResponseCodeIsNotSuccess() throws IOException {
    InspectImageParams inspectImageParams = InspectImageParams.create(IMAGE);
    when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
    dockerConnector.inspectImage(inspectImageParams);
    verify(dockerResponse).getStatus();
}
Also used : InspectImageParams(org.eclipse.che.plugin.docker.client.params.InspectImageParams) Test(org.testng.annotations.Test)

Example 3 with InspectImageParams

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

the class DockerConnectorTest method shouldCallInspectImageWithParametersObject.

@Test
public void shouldCallInspectImageWithParametersObject() throws IOException {
    InspectImageParams inspectImageParams = InspectImageParams.create(IMAGE);
    ImageInfo imageInfo = mock(ImageInfo.class);
    doReturn(imageInfo).when(dockerConnector).inspectImage(any(InspectImageParams.class));
    ImageInfo returnedImageInfo = dockerConnector.inspectImage(IMAGE);
    verify(dockerConnector).inspectImage((InspectImageParams) captor.capture());
    assertEquals(captor.getValue(), inspectImageParams);
    assertEquals(returnedImageInfo, imageInfo);
}
Also used : InspectImageParams(org.eclipse.che.plugin.docker.client.params.InspectImageParams) ImageInfo(org.eclipse.che.plugin.docker.client.json.ImageInfo) Test(org.testng.annotations.Test)

Aggregations

InspectImageParams (org.eclipse.che.plugin.docker.client.params.InspectImageParams)3 Test (org.testng.annotations.Test)3 ImageInfo (org.eclipse.che.plugin.docker.client.json.ImageInfo)2 URI (java.net.URI)1