SwarmDockerClientFacade extends BaseDockerClientFacade { @Override public String restartAgent(@Nonnull String serviceId) { try { scale(serviceId, Scaling.DOWN); scale(serviceId, Scaling.UP); return queryTaskId(serviceId); } catch (NodeProcessingException e) { throw new DockerClientFacadeException("Failed to process response from daemon.", e); } } 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 restartAgentContainer() { SwarmDockerClientFacade facade = new SwarmDockerClientFacade(dockerClient); TestDockerClient.Service service = new TestDockerClient.Service(); service.pushTask(); dockerClient.service(service); String taskId = facade.restartAgent(service.getId()); Deque<TestDockerClient.Task> replicas = service.getReplicas(); assertThat(replicas).hasSize(1).first().matches(replica -> replica.getId().equals(taskId)); }