@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final VersionResponse response = client.version().get(); if (json) { out.println(Json.asPrettyStringUnchecked(response)); } else { out.println(String.format("Client Version: %s%nMaster Version: %s", response.getClientVersion(), response.getMasterVersion())); } return 0; }
@Test public void testJsonVersion() throws Exception { startDefaultMaster(); final VersionResponse version = getVersion("version", "--json", "-z", masterEndpoint()); assertEquals("wrong client version", POM_VERSION, version.getClientVersion()); assertEquals("wrong master version", POM_VERSION, version.getMasterVersion()); }
@Test public void testVersionWithServerError() throws Exception { startDefaultMaster(); // If master returns with an error, we should still get the correct client version, and a // nice error message instead of master version. Specify bogus path to make this happen. final VersionResponse version = getVersion("version", "--json", "-z", masterEndpoint() + "/badPath"); assertEquals("wrong client version", POM_VERSION, version.getClientVersion()); assertEquals("wrong master version", "Master replied with error code 404", version.getMasterVersion()); }
@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final VersionResponse response = client.version().get(); if (json) { out.println(Json.asPrettyStringUnchecked(response)); } else { out.println(String.format("Client Version: %s%nMaster Version: %s", response.getClientVersion(), response.getMasterVersion())); } return 0; }