GetDiscoveryDocAction extends EndpointsToolAction { @Override public boolean execute() throws ClassNotFoundException, IOException, ApiConfigException { String warPath = getWarPath(warOption); List<String> serviceClassNames = getServiceClassNames(warPath); if (serviceClassNames.isEmpty()) { return false; } getDiscoveryDoc(computeClassPath(warPath, getClassPath(classPathOption)), getOutputPath(outputOption), serviceClassNames, getHostname(hostnameOption, warPath), getBasePath(basePathOption), true); return true; } GetDiscoveryDocAction(); @Override boolean execute(); Map<String, String> getDiscoveryDoc(URL[] classPath, String outputDirPath,
      List<String> serviceClassNames, String hostname, String basePath, boolean outputToDisk); @Override String getUsageString(); static final String NAME; }
@Test public void testMissingOption() throws Exception { tool.execute(new String[]{GetDiscoveryDocAction.NAME, option(EndpointsToolAction.OPTION_CLASS_PATH_SHORT), "classPath", option(EndpointsToolAction.OPTION_HOSTNAME_SHORT), "foo.com", "MyService"}); assertFalse(usagePrinted); assertThat(Lists.newArrayList(classPath)) .containsExactly(new File("classPath").toURI().toURL(), new File(new File(EndpointsToolAction.DEFAULT_WAR_PATH).getAbsoluteFile(), "/WEB-INF/classes") .toURI() .toURL()); assertEquals(EndpointsToolAction.DEFAULT_OUTPUT_PATH, outputDirPath); assertStringsEqual(Arrays.asList("MyService"), serviceClassNames); }
@Test public void testMissingArgument() throws Exception { tool.execute(new String[]{GetDiscoveryDocAction.NAME, option(EndpointsToolAction.OPTION_CLASS_PATH_SHORT), "classPath", option(EndpointsToolAction.OPTION_OUTPUT_DIR_SHORT), "outputDir", option(EndpointsToolAction.OPTION_HOSTNAME_SHORT), "foo.com"}); assertTrue(usagePrinted); }