protected Role(String name, Optional<String> description, Optional<String> jsonDefaultAttributes, Optional<String> jsonOverrideAttributes, Optional<RunList> runlist) { this.name = checkNotNull(name, "name must be set"); this.description = checkNotNull(description, "description must be set"); this.jsonDefaultAttributes = checkNotNull(jsonDefaultAttributes, "jsonDefaultAttributes must be set"); this.jsonOverrideAttributes = checkNotNull(jsonOverrideAttributes, "jsonOverrideAttributes must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); }
protected Role(String name, Optional<String> description, Optional<String> jsonDefaultAttributes, Optional<String> jsonOverrideAttributes, Optional<RunList> runlist) { this.name = checkNotNull(name, "name must be set"); this.description = checkNotNull(description, "description must be set"); this.jsonDefaultAttributes = checkNotNull(jsonDefaultAttributes, "jsonDefaultAttributes must be set"); this.jsonOverrideAttributes = checkNotNull(jsonOverrideAttributes, "jsonOverrideAttributes must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); }
protected Role(String name, Optional<String> description, Optional<String> jsonDefaultAttributes, Optional<String> jsonOverrideAttributes, Optional<RunList> runlist) { this.name = checkNotNull(name, "name must be set"); this.description = checkNotNull(description, "description must be set"); this.jsonDefaultAttributes = checkNotNull(jsonDefaultAttributes, "jsonDefaultAttributes must be set"); this.jsonOverrideAttributes = checkNotNull(jsonOverrideAttributes, "jsonOverrideAttributes must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); }
protected Role(String name, Optional<String> description, Optional<String> jsonDefaultAttributes, Optional<String> jsonOverrideAttributes, Optional<RunList> runlist) { this.name = checkNotNull(name, "name must be set"); this.description = checkNotNull(description, "description must be set"); this.jsonDefaultAttributes = checkNotNull(jsonDefaultAttributes, "jsonDefaultAttributes must be set"); this.jsonOverrideAttributes = checkNotNull(jsonOverrideAttributes, "jsonOverrideAttributes must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); }
protected Role(String name, Optional<String> description, Optional<String> jsonDefaultAttributes, Optional<String> jsonOverrideAttributes, Optional<RunList> runlist) { this.name = checkNotNull(name, "name must be set"); this.description = checkNotNull(description, "description must be set"); this.jsonDefaultAttributes = checkNotNull(jsonDefaultAttributes, "jsonDefaultAttributes must be set"); this.jsonOverrideAttributes = checkNotNull(jsonOverrideAttributes, "jsonOverrideAttributes must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); }
public void testToStringWithRecipeAndRole() { assertEquals(RunList.builder().recipe("apache2").role("webserver").build().toString(), "[\"recipe[apache2]\",\"role[webserver]\"]"); }
public void testCreateNodeConfigurationWithRunList() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); RunList runlist = RunList.builder().recipe("foo").role("bar").build(); ChefSolo solo = ChefSolo.builder().runlist(runlist).build(); solo.createNodeConfiguration(statements); ImmutableList<Statement> statementList = statements.build(); Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json", ImmutableSet.of("{\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}")); assertEquals(statementList.size(), 1); assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX)); }
public void testCreateNodeConfigurationWithJsonAttributesAndRunList() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); RunList runlist = RunList.builder().recipe("foo").role("bar").build(); ChefSolo solo = ChefSolo.builder().jsonAttributes("{\"foo\":\"bar\"}").runlist(runlist).build(); solo.createNodeConfiguration(statements); ImmutableList<Statement> statementList = statements.build(); Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json", ImmutableSet.of("{\"foo\":\"bar\",\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}")); assertEquals(statementList.size(), 1); assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX)); }
public void testCreateNodeConfigurationWithRunList() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); RunList runlist = RunList.builder().recipe("foo").role("bar").build(); ChefSolo solo = ChefSolo.builder().runlist(runlist).build(); solo.createNodeConfiguration(statements); ImmutableList<Statement> statementList = statements.build(); Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json", ImmutableSet.of("{\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}")); assertEquals(statementList.size(), 1); assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX)); }
public void testCreateNodeConfigurationWithJsonAttributesAndRunList() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); RunList runlist = RunList.builder().recipe("foo").role("bar").build(); ChefSolo solo = ChefSolo.builder().jsonAttributes("{\"foo\":\"bar\"}").runlist(runlist).build(); solo.createNodeConfiguration(statements); ImmutableList<Statement> statementList = statements.build(); Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/node.json", ImmutableSet.of("{\"foo\":\"bar\",\"run_list\":[\"recipe[foo]\",\"role[bar]\"]}")); assertEquals(statementList.size(), 1); assertEquals(statementList.get(0).render(OsFamily.UNIX), expected.render(OsFamily.UNIX)); }
public void testCreateRolesIfNecessaryWithOneRole() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); RunList runlist = RunList.builder().recipe("bar").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); ChefSolo solo = ChefSolo.builder().defineRole(role).build(); solo.createRolesIfNecessary(statements); ImmutableList<Statement> statementList = statements.build(); Statement expected = createOrOverwriteFile(ChefSolo.DEFAULT_SOLO_PATH + "/roles/" + role.getName() + ".json", ImmutableSet.of(role.toJsonString())); assertEquals(statementList.size(), 2); assertEquals(statementList.get(0), exec("{md} " + ChefSolo.DEFAULT_SOLO_PATH + "/roles")); assertEquals(statementList.get(1).render(OsFamily.UNIX), expected.render(OsFamily.UNIX)); }
public void testCreateRolesIfNecessaryWithOneRoleAndCustomPath() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); RunList runlist = RunList.builder().recipe("bar").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); ChefSolo solo = ChefSolo.builder().rolePath("/tmp/roles").defineRole(role).build(); solo.createRolesIfNecessary(statements); ImmutableList<Statement> statementList = statements.build(); Statement expected = createOrOverwriteFile("/tmp/roles/" + role.getName() + ".json", ImmutableSet.of(role.toJsonString())); assertEquals(statementList.size(), 2); assertEquals(statementList.get(0), exec("{md} /tmp/roles")); assertEquals(statementList.get(1).render(OsFamily.UNIX), expected.render(OsFamily.UNIX)); }
public void testToJsonStringWithSingleRecipe() { RunList runlist = RunList.builder().recipe("apache2").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\",\"run_list\":[\"recipe[apache2]\"]}"); }
public void testToJsonStringWithSingleRole() { RunList runlist = RunList.builder().role("webserver").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\",\"run_list\":[\"role[webserver]\"]}"); }
public void testToJsonStringWithSingleRole() { RunList runlist = RunList.builder().role("webserver").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\",\"run_list\":[\"role[webserver]\"]}"); }
public void testToJsonStringWithMultipleRoles() { RunList runlist = RunList.builder().role("webserver").role("firewall").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"," + "\"run_list\":[\"role[webserver]\",\"role[firewall]\"]}"); }
public void testToJsonStringWithRolesAndRecipes() { RunList runlist = RunList.builder().role("webserver").recipe("git").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"," + "\"run_list\":[\"role[webserver]\",\"recipe[git]\"]}"); } }
public void testToJsonStringWithMultipleRecipes() { RunList runlist = RunList.builder().recipe("apache2").recipe("git").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"," + "\"run_list\":[\"recipe[apache2]\",\"recipe[git]\"]}"); }
public void testToJsonStringWithMultipleRoles() { RunList runlist = RunList.builder().role("webserver").role("firewall").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"," + "\"run_list\":[\"role[webserver]\",\"role[firewall]\"]}"); }
public void testToJsonStringWithRolesAndRecipes() { RunList runlist = RunList.builder().role("webserver").recipe("git").build(); Role role = Role.builder().name("foo").runlist(runlist).build(); assertEquals(role.toJsonString(), "{\"name\": \"foo\",\"description\":\"\",\"default_attributes\":{},\"override_attributes\":{}," + "\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"," + "\"run_list\":[\"role[webserver]\",\"recipe[git]\"]}"); } }