Package org.jclouds.scriptbuilder.domain.chef

Examples of org.jclouds.scriptbuilder.domain.chef.Role


   }

   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));
   }
View Full Code Here


      assertEquals(statementList.get(1).render(OsFamily.UNIX), expected.render(OsFamily.UNIX));
   }

   public void testCreateRolesIfNecessaryWithMultipleRoleAndCustomPath() {
      ImmutableList.Builder<Statement> statements = ImmutableList.builder();
      Role roleFoo = Role.builder().name("foo").runlist(RunList.builder().recipe("foo").build()).build();
      Role roleBar = Role.builder().name("bar").runlist(RunList.builder().recipe("bar").build()).build();
      ChefSolo solo = ChefSolo.builder().rolePath("/tmp/roles").defineRole(roleFoo).defineRole(roleBar).build();

      solo.createRolesIfNecessary(statements);
      ImmutableList<Statement> statementList = statements.build();

      Statement expectedFoo = createOrOverwriteFile("/tmp/roles/" + roleFoo.getName() + ".json",
            ImmutableSet.of(roleFoo.toJsonString()));
      Statement expectedBar = createOrOverwriteFile("/tmp/roles/" + roleBar.getName() + ".json",
            ImmutableSet.of(roleBar.toJsonString()));

      assertEquals(statementList.size(), 3);
      assertEquals(statementList.get(0), exec("{md} /tmp/roles"));
      assertEquals(statementList.get(1).render(OsFamily.UNIX), expectedFoo.render(OsFamily.UNIX));
      assertEquals(statementList.get(2).render(OsFamily.UNIX), expectedBar.render(OsFamily.UNIX));
View Full Code Here

TOP

Related Classes of org.jclouds.scriptbuilder.domain.chef.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.