@Test public void testAddBlueprintForDefaults() throws HttpResponseException { String result = blueprintCommands.addBlueprint(); verify(ambariClient).addDefaultBlueprints(); assertEquals("Default blueprints added", result); }
@CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") public String addBlueprint( @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url, @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file) { String message; try { String json = file == null ? readContent(url) : readContent(file); if (json != null) { client.addBlueprint(json); context.setHint(Hints.BUILD_CLUSTER); context.setBlueprintsAvailable(true); message = String.format("Blueprint: '%s' has been added", getBlueprintName(json)); } else { message = "No blueprint specified"; } } catch (Exception e) { message = "Cannot add blueprint: " + e.getMessage(); } return message; }
BlueprintCommands implements CommandMarker { @CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") public String addBlueprint( @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url, @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file) { String message; try { String json = file == null ? readContent(url) : readContent(file); if (json != null) { client.addBlueprint(json); context.setHint(Hints.BUILD_CLUSTER); context.setBlueprintsAvailable(true); message = String.format("Blueprint: '%s' has been added", getBlueprintName(json)); } else { message = "No blueprint specified"; } } catch (Exception e) { message = "Cannot add blueprint: " + e.getMessage(); } return message; } }
BlueprintCommands implements CommandMarker { @CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") public String addBlueprint( @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url, @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file) { String message; try { String json = file == null ? readContent(url) : readContent(file); if (json != null) { client.addBlueprint(json); context.setHint(Hints.BUILD_CLUSTER); context.setBlueprintsAvailable(true); message = String.format("Blueprint: '%s' has been added", getBlueprintName(json)); } else { message = "No blueprint specified"; } } catch (Exception e) { message = "Cannot add blueprint: " + e.getMessage(); } return message; } @Autowired  BlueprintCommands(AmbariClient client, AmbariContext context, ObjectMapper jsonMapper); }
BlueprintCommands implements CommandMarker { @CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") public String addBlueprint( @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url, @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file) { String message; try { String json = file == null ? readContent(url) : readContent(file); if (json != null) { client.addBlueprint(json); context.setHint(Hints.BUILD_CLUSTER); context.setBlueprintsAvailable(true); message = String.format("Blueprint: '%s' has been added", getBlueprintName(json)); } else { message = "No blueprint specified"; } } catch (Exception e) { message = "Cannot add blueprint: " + e.getMessage(); } return message; } @Autowired  BlueprintCommands(AmbariClient client, AmbariContext context, ObjectMapper jsonMapper); @CliAvailabilityIndicator("blueprint list") boolean isBlueprintListCommandAvailable(); @CliCommand(value = "blueprint list", help = "Lists all known blueprints") String listBlueprints(); @CliAvailabilityIndicator(value = "blueprint show") boolean isBlueprintShowCommandAvailable(); @CliCommand(value = "blueprint show", help = "Shows the blueprint by its id") String showBlueprint(
    @CliOption(key = "id", mandatory = true, help = "Id of the blueprint") Blueprint id); @CliAvailabilityIndicator(value = "blueprint add") boolean isBlueprintAddCommandAvailable(); @CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") String addBlueprint(
    @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url,
    @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file); @CliAvailabilityIndicator(value = "blueprint defaults") boolean isBlueprintDefaultsAddCommandAvailable(); @CliCommand(value = "blueprint defaults", help = "Adds the default blueprints to Ambari") String addBlueprint(); }
BlueprintCommands implements CommandMarker { @CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") public String addBlueprint( @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url, @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file) { String message; try { String json = file == null ? readContent(url) : readContent(file); if (json != null) { client.addBlueprint(json); context.setHint(Hints.BUILD_CLUSTER); context.setBlueprintsAvailable(true); message = String.format("Blueprint: '%s' has been added", getBlueprintName(json)); } else { message = "No blueprint specified"; } } catch (Exception e) { message = "Cannot add blueprint: " + e.getMessage(); } return message; } @Autowired  BlueprintCommands(AmbariClient client, AmbariContext context, ObjectMapper jsonMapper); @CliAvailabilityIndicator("blueprint list") boolean isBlueprintListCommandAvailable(); @CliCommand(value = "blueprint list", help = "Lists all known blueprints") String listBlueprints(); @CliAvailabilityIndicator(value = "blueprint show") boolean isBlueprintShowCommandAvailable(); @CliCommand(value = "blueprint show", help = "Shows the blueprint by its id") String showBlueprint(
    @CliOption(key = "id", mandatory = true, help = "Id of the blueprint") Blueprint id); @CliAvailabilityIndicator(value = "blueprint add") boolean isBlueprintAddCommandAvailable(); @CliCommand(value = "blueprint add", help = "Add a new blueprint with either --url or --file") String addBlueprint(
    @CliOption(key = "url", mandatory = false, help = "URL of the blueprint to download from") String url,
    @CliOption(key = "file", mandatory = false, help = "File which contains the blueprint") File file); @CliAvailabilityIndicator(value = "blueprint defaults") boolean isBlueprintDefaultsAddCommandAvailable(); @CliCommand(value = "blueprint defaults", help = "Adds the default blueprints to Ambari") String addBlueprint();  }