@Test(expected = UnsatisfiedRequirementException.class) public void testDockerMachineRequirementCheckNoMatchingNameNotMatched() throws Exception { when(commandLineExecutor.execCommandAsArray(anyVararg())).thenReturn(Arrays.asList(new String[] {"my-docker-machine"})); DockerMachineRequirement dockerMachineRequirement = new DockerMachineRequirement(commandLineExecutor); dockerMachineRequirement.check(createContext("testing")); }
@Override public void check(RequiresDockerMachine context) throws UnsatisfiedRequirementException { String name = context.name(); try { if (name != null && !name.isEmpty()) { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--filter", "name=" + name, "--format", "{{.Name}}"); if (!machines.contains(name)) { throw new UnsatisfiedRequirementException("Docker machine with name: [" + name + "] not found!"); } } else { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--format", "{{.Name}}"); if (machines.size() > 0) { throw new UnsatisfiedRequirementException("No docker machine found!"); } } } catch (ExecutionException e) { throw new UnsatisfiedRequirementException("Cannot execute docker-machine command."); } }
DockerMachineRequirement implements Constraint<RequiresDockerMachine> { @Override public void check(RequiresDockerMachine context) throws UnsatisfiedRequirementException { String name = context.name(); try { if (name != null && !name.isEmpty()) { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--filter", "name=" + name, "--format", "{{.Name}}"); if (!machines.contains(name)) { throw new UnsatisfiedRequirementException("Docker machine with name: [" + name + "] not found!"); } } else { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--format", "{{.Name}}"); if (machines.size() > 0) { throw new UnsatisfiedRequirementException("No docker machine found!"); } } } catch (ExecutionException e) { throw new UnsatisfiedRequirementException("Cannot execute docker-machine command."); } } }
DockerMachineRequirement implements Constraint<RequiresDockerMachine> { @Override public void check(RequiresDockerMachine context) throws UnsatisfiedRequirementException { String name = context.name(); try { if (name != null && !name.isEmpty()) { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--filter", "name=" + name, "--format", "{{.Name}}"); if (!machines.contains(name)) { throw new UnsatisfiedRequirementException("Docker machine with name: [" + name + "] not found!"); } } else { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--format", "{{.Name}}"); if (machines.size() > 0) { throw new UnsatisfiedRequirementException("No docker machine found!"); } } } catch (ExecutionException e) { throw new UnsatisfiedRequirementException("Cannot execute docker-machine command."); } } DockerMachineRequirement();  DockerMachineRequirement(CommandLineExecutor commandLineExecutor); }
DockerMachineRequirement implements Constraint<RequiresDockerMachine> { @Override public void check(RequiresDockerMachine context) throws UnsatisfiedRequirementException { String name = context.name(); try { if (name != null && !name.isEmpty()) { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--filter", "name=" + name, "--format", "{{.Name}}"); if (!machines.contains(name)) { throw new UnsatisfiedRequirementException("Docker machine with name: [" + name + "] not found!"); } } else { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--format", "{{.Name}}"); if (machines.size() > 0) { throw new UnsatisfiedRequirementException("No docker machine found!"); } } } catch (ExecutionException e) { throw new UnsatisfiedRequirementException("Cannot execute docker-machine command."); } } DockerMachineRequirement();  DockerMachineRequirement(CommandLineExecutor commandLineExecutor); @Override void check(RequiresDockerMachine context); }
DockerMachineRequirement implements Constraint<RequiresDockerMachine> { @Override public void check(RequiresDockerMachine context) throws UnsatisfiedRequirementException { String name = context.name(); try { if (name != null && !name.isEmpty()) { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--filter", "name=" + name, "--format", "{{.Name}}"); if (!machines.contains(name)) { throw new UnsatisfiedRequirementException("Docker machine with name: [" + name + "] not found!"); } } else { List<String> machines = commandLineExecutor.execCommandAsArray("docker-machine", "ls", "--format", "{{.Name}}"); if (machines.size() > 0) { throw new UnsatisfiedRequirementException("No docker machine found!"); } } } catch (ExecutionException e) { throw new UnsatisfiedRequirementException("Cannot execute docker-machine command."); } } DockerMachineRequirement();  DockerMachineRequirement(CommandLineExecutor commandLineExecutor); @Override void check(RequiresDockerMachine context);  }