use of org.eclipse.che.plugin.docker.client.params.ListContainersParams in project che by eclipse.
the class DockerConnectorTest method shouldThrowDockerExceptionWhileGettingListContainersByParamsObjectIfResponseCodeIsNotSuccess.
@Test(expectedExceptions = DockerException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldThrowDockerExceptionWhileGettingListContainersByParamsObjectIfResponseCodeIsNotSuccess() throws IOException, JsonParseException {
ListContainersParams listContainersParams = ListContainersParams.create();
when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
dockerConnector.listContainers(listContainersParams);
verify(dockerResponse).getStatus();
}
use of org.eclipse.che.plugin.docker.client.params.ListContainersParams in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToGetListContainersByFiltersInTheListContainersParams.
@Test
public void shouldBeAbleToGetListContainersByFiltersInTheListContainersParams() throws IOException, JsonParseException {
Filters filters = new Filters().withFilter("testKey", "testValue");
ListContainersParams listContainersParams = ListContainersParams.create().withFilters(filters);
ContainerListEntry containerListEntry = mock(ContainerListEntry.class);
List<ContainerListEntry> expectedListContainers = singletonList(containerListEntry);
doReturn(expectedListContainers).when(dockerConnector).parseResponseStreamAndClose(eq(inputStream), Matchers.<TypeToken<List<ContainerListEntry>>>any());
List<ContainerListEntry> containers = dockerConnector.listContainers(listContainersParams);
verify(dockerConnection).query(eq("filters"), anyObject());
assertEquals(containers, expectedListContainers);
}
use of org.eclipse.che.plugin.docker.client.params.ListContainersParams in project che by eclipse.
the class DockerConnectorTest method shouldCallListContainersWithParametersObject.
@Test
public void shouldCallListContainersWithParametersObject() throws IOException {
ListContainersParams listContainersParams = ListContainersParams.create().withAll(true);
ContainerListEntry containerListEntry = mock(ContainerListEntry.class);
List<ContainerListEntry> expectedListContainers = singletonList(containerListEntry);
doReturn(expectedListContainers).when(dockerConnector).listContainers(listContainersParams);
List<ContainerListEntry> result = dockerConnector.listContainers();
ArgumentCaptor<ListContainersParams> listContainersParamsArgumentCaptor = ArgumentCaptor.forClass(ListContainersParams.class);
verify(dockerConnector).listContainers(listContainersParamsArgumentCaptor.capture());
assertEquals(result, expectedListContainers);
assertEquals(listContainersParamsArgumentCaptor.getValue(), listContainersParams);
}
use of org.eclipse.che.plugin.docker.client.params.ListContainersParams in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToGetListContainersWithListContainersParams.
@Test
public void shouldBeAbleToGetListContainersWithListContainersParams() throws IOException, JsonParseException {
ListContainersParams listContainersParams = ListContainersParams.create().withAll(true).withSize(true);
ContainerListEntry containerListEntry = mock(ContainerListEntry.class);
List<ContainerListEntry> expectedListContainers = singletonList(containerListEntry);
doReturn(expectedListContainers).when(dockerConnector).parseResponseStreamAndClose(eq(inputStream), Matchers.<TypeToken<List<ContainerListEntry>>>any());
List<ContainerListEntry> containers = dockerConnector.listContainers(listContainersParams);
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_GET);
verify(dockerConnection).path("/containers/json");
verify(dockerConnection).query("all", 1);
verify(dockerConnection).query("size", 1);
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
verify(dockerResponse).getInputStream();
verify(dockerConnector).parseResponseStreamAndClose(eq(inputStream), Matchers.<TypeToken<List<ContainerListEntry>>>any());
assertEquals(containers, expectedListContainers);
}
Aggregations