Search in sources :

Example 1 with RemoveNetworkParams

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

the class DockerConnectorTest method shouldThrowExceptionOnRemoveNetworkIfResponseCodeIsNot20x.

@Test(expectedExceptions = NetworkNotFoundException.class, expectedExceptionsMessageRegExp = "exc_message")
public void shouldThrowExceptionOnRemoveNetworkIfResponseCodeIsNot20x() throws Exception {
    // given
    doReturn(404).when(dockerResponse).getStatus();
    ByteArrayInputStream inputStream = new ByteArrayInputStream("exc_message".getBytes());
    doReturn(inputStream).when(dockerResponse).getInputStream();
    RemoveNetworkParams removeNetworkParams = RemoveNetworkParams.create("net_id");
    // when
    dockerConnector.removeNetwork(removeNetworkParams);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RemoveNetworkParams(org.eclipse.che.plugin.docker.client.params.RemoveNetworkParams) Test(org.testng.annotations.Test)

Example 2 with RemoveNetworkParams

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

the class DockerConnectorTest method shouldBeAbleToRemoveNetworkWithParams.

@Test
public void shouldBeAbleToRemoveNetworkWithParams() throws Exception {
    // given
    String netId = "net_id";
    RemoveNetworkParams removeNetworkParams = RemoveNetworkParams.create(netId);
    // when
    dockerConnector.removeNetwork(removeNetworkParams);
    // then
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_DELETE);
    verify(dockerConnection).path("/networks/" + netId);
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) RemoveNetworkParams(org.eclipse.che.plugin.docker.client.params.RemoveNetworkParams) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

RemoveNetworkParams (org.eclipse.che.plugin.docker.client.params.RemoveNetworkParams)2 Test (org.testng.annotations.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 URI (java.net.URI)1 Matchers.anyString (org.mockito.Matchers.anyString)1