Source:
<code>public void testNetworksConnectContainer() throws Exception { assumeTrue("Docker API should be at least v1.21 to support Container Creation with " + "HostConfig, got " + sut.version().apiVersion(), compareVersion(sut.version().apiVersion(), "1.21") >= 0); assumeFalse(CIRCLECI); final String networkName = randomName(); final String containerName = randomName(); final NetworkCreation networkCreation = sut.createNetwork(NetworkConfig.builder().name(networkName).build()); assertThat(networkCreation.id(), is(notNullValue())); final ContainerConfig containerConfig = ContainerConfig.builder().image(BUSYBOX_LATEST).cmd("sh", "-c", "while :; do sleep 1; done") .build(); final ContainerCreation containerCreation = sut.createContainer(containerConfig, containerName); assertThat(containerCreation.id(), is(notNullValue())); sut.startContainer(containerCreation.id()); sut.connectToNetwork(containerCreation.id(), networkCreation.id()); Network network = sut.inspectNetwork(networkCreation.id()); assertThat(network.containers().size(), equalTo(1)); assertThat(network.containers().get(containerCreation.id()), notNullValue()); final ContainerInfo containerInfo = sut.inspectContainer(containerCreation.id()); assertThat(containerInfo.networkSettings().networks().size(), is(2)); final AttachedNetwork attachedNetwork = containerInfo.networkSettings().networks().get(networkName); assertThat(attachedNetwork, is(notNullValue())); assertThat(attachedNetwork.endpointId(), is(notNullValue())); assertThat(attachedNetwork.gateway(), is(notNullValue())); assertThat(attachedNetwork.ipAddress(), is(notNullValue())); assertThat(attachedNetwork.ipPrefixLen(), is(notNullValue())); <START> assertThat(attachedNetwork.macAddress(), is(notNullValue())); <END> sut.disconnectFromNetwork(containerCreation.id(), networkCreation.id()); network = sut.inspectNetwork(networkCreation.id()); assertThat(network.containers().size(), equalTo(0)); sut.stopContainer(containerCreation.id(), 1); sut.removeContainer(containerCreation.id()); sut.removeNetwork(networkCreation.id()); }</code><technical_language>Yea good</technical_language>

Target:
public void testNetworksConnectContainer() throws Exception { assumeTrue("Docker API should be at least v1.21 to support Container Creation with " + "HostConfig, got " + sut.version().apiVersion(), compareVersion(sut.version().apiVersion(), "1.21") >= 0); assumeFalse(CIRCLECI); final String networkName = randomName(); final String containerName = randomName(); final NetworkCreation networkCreation = sut.createNetwork(NetworkConfig.builder().name(networkName).build()); assertThat(networkCreation.id(), is(notNullValue())); final ContainerConfig containerConfig = ContainerConfig.builder().image(BUSYBOX_LATEST).cmd("sh", "-c", "while :; do sleep 1; done") .build(); final ContainerCreation containerCreation = sut.createContainer(containerConfig, containerName); assertThat(containerCreation.id(), is(notNullValue())); sut.startContainer(containerCreation.id()); sut.connectToNetwork(containerCreation.id(), networkCreation.id()); Network network = sut.inspectNetwork(networkCreation.id()); assertThat(network.containers().size(), equalTo(1)); assertThat(network.containers().get(containerCreation.id()), notNullValue()); final ContainerInfo containerInfo = sut.inspectContainer(containerCreation.id()); assertThat(containerInfo.networkSettings().networks().size(), is(2)); final AttachedNetwork attachedNetwork = containerInfo.networkSettings().networks().get(networkName); assertThat(attachedNetwork, is(notNullValue())); assertThat(attachedNetwork.endpointId(), is(notNullValue())); assertThat(attachedNetwork.gateway(), is(notNullValue())); assertThat(attachedNetwork.ipAddress(), is(notNullValue())); assertThat(attachedNetwork.ipPrefixLen(), is(notNullValue())); assertThat(attachedNetwork.macAddress(), is(notNullValue())); assertThat(attachedNetwork.ipv6Gateway(), is(notNullValue())); assertThat(attachedNetwork.globalIPv6Address(), is(notNullValue())); assertThat(attachedNetwork.globalIPv6PrefixLen(), greaterThanOrEqualTo(0)); sut.disconnectFromNetwork(containerCreation.id(), networkCreation.id()); network = sut.inspectNetwork(networkCreation.id()); assertThat(network.containers().size(), equalTo(0)); sut.stopContainer(containerCreation.id(), 1); sut.removeContainer(containerCreation.id()); sut.removeNetwork(networkCreation.id()); }