Search in sources :

Example 1 with InspectContainerParams

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

the class DockerConnectorTest method shouldCallInspectContainerWithParametersObject.

@Test
public void shouldCallInspectContainerWithParametersObject() throws IOException {
    InspectContainerParams inspectContainerParams = InspectContainerParams.create(CONTAINER);
    ContainerInfo containerInfo = mock(ContainerInfo.class);
    doReturn(containerInfo).when(dockerConnector).inspectContainer(inspectContainerParams);
    ContainerInfo returnedContainerInfo = dockerConnector.inspectContainer(CONTAINER);
    verify(dockerConnector).inspectContainer((InspectContainerParams) captor.capture());
    assertEquals(captor.getValue(), inspectContainerParams);
    assertEquals(returnedContainerInfo, containerInfo);
}
Also used : InspectContainerParams(org.eclipse.che.plugin.docker.client.params.InspectContainerParams) ContainerInfo(org.eclipse.che.plugin.docker.client.json.ContainerInfo) Test(org.testng.annotations.Test)

Example 2 with InspectContainerParams

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

the class DockerConnectorTest method shouldBeAbleToInspectContainer.

@Test
public void shouldBeAbleToInspectContainer() throws IOException, JsonParseException {
    InspectContainerParams inspectContainerParams = InspectContainerParams.create(CONTAINER);
    ContainerInfo containerInfo = mock(ContainerInfo.class);
    doReturn(containerInfo).when(dockerConnector).parseResponseStreamAndClose(inputStream, ContainerInfo.class);
    ContainerInfo returnedContainerInfo = dockerConnector.inspectContainer(inspectContainerParams);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_GET);
    verify(dockerConnection).path("/containers/" + inspectContainerParams.getContainer() + "/json");
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
    verify(dockerResponse).getInputStream();
    assertEquals(returnedContainerInfo, containerInfo);
}
Also used : InspectContainerParams(org.eclipse.che.plugin.docker.client.params.InspectContainerParams) ContainerInfo(org.eclipse.che.plugin.docker.client.json.ContainerInfo) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 3 with InspectContainerParams

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

the class DockerConnectorTest method shouldThrowDockerExceptionWhileInspectingContainerIfResponseCodeIsNotSuccess.

@Test(expectedExceptions = DockerException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldThrowDockerExceptionWhileInspectingContainerIfResponseCodeIsNotSuccess() throws IOException {
    InspectContainerParams inspectContainerParams = InspectContainerParams.create(CONTAINER);
    when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
    dockerConnector.inspectContainer(inspectContainerParams);
    verify(dockerResponse).getStatus();
}
Also used : InspectContainerParams(org.eclipse.che.plugin.docker.client.params.InspectContainerParams) Test(org.testng.annotations.Test)

Aggregations

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