DefaultDockerClientFacade extends BaseDockerClientFacade { @Override public String startAgent(@Nonnull String containerId) { client.startContainer(containerId); return containerId; } DefaultDockerClientFacade(@Nonnull DockerClient client); @Nonnull @Override NewAgentHolderInfo createAgent(@Nonnull CreateAgentParameters createAgentParameters); @Override String startAgent(@Nonnull String containerId); @Override String restartAgent(@Nonnull String containerId); @Nonnull @Override List<AgentHolderInfo> listAgentHolders(@Nonnull String labelFilter, @Nonnull String valueFilter); @Override boolean terminateAgentContainer(@Nonnull String containerId, @Nonnull Duration timeout, boolean removeContainer); @Nonnull @Override CharSequence getLogs(@Nonnull String containerId); @Nonnull @Override StreamHandler streamLogs(@Nonnull String containerId); @Override boolean supportQueryingLogs(); static final String CONTAINER_RUNNING_STATE; }
@Test public void startAgentContainer() { Interceptor<DockerClient> interceptor = Interceptor.wrap(dockerClient, DockerClient.class); DefaultDockerClientFacade facade = new DefaultDockerClientFacade(interceptor.buildProxy()); Container container = new Container(); dockerClient.container(container); String taskId = facade.startAgent(container.getId()); assertThat(taskId).isEqualTo(container.getId()); assertThat(container.isRunning()).isTrue(); assertThat(interceptor.getInvocations()).hasSize(1).first() .matches(invocation -> invocation.matches("startContainer", container.getId())); }