SwarmDockerClientFacade extends BaseDockerClientFacade { @Override public boolean terminateAgentContainer(@Nonnull String containerId, Duration timeout, boolean removeContainer) { client.removeService(containerId); return false; } SwarmDockerClientFacade(DockerClient client); @Nonnull @Override NewAgentHolderInfo createAgent(@Nonnull CreateAgentParameters createAgentParameters); @Override String startAgent(@Nonnull String serviceId); @Override String restartAgent(@Nonnull String serviceId); @Nonnull @Override List<AgentHolderInfo> listAgentHolders(@Nonnull String labelFilter, @Nonnull String valueFilter); @Override boolean terminateAgentContainer(@Nonnull String containerId, Duration timeout, boolean removeContainer); @Override CharSequence getLogs(@Nonnull String serviceId); @Nonnull @Override StreamHandler streamLogs(@Nonnull String serviceId); @Override boolean supportQueryingLogs();  }
@Test public void terminateAgentService() { SwarmDockerClientFacade facade = new SwarmDockerClientFacade(dockerClient); TestDockerClient.Service service = new TestDockerClient.Service(); dockerClient.service(service); boolean agentHolderStillExists = facade. terminateAgentContainer(service.getId(), DockerClient.DEFAULT_TIMEOUT, false); assertThat(dockerClient.getServices()).isEmpty(); assertThat(agentHolderStillExists).isFalse(); }