Package org.jclouds.chef

Examples of org.jclouds.chef.ChefApi


      verify(client);
      verify(chefApi);
   }

   public void testWhenClientsInListReplacesMissing() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Client client = createMock(Client.class);
      PrivateKey privateKey = createMock(PrivateKey.class);

      ClientForGroup fn = new ClientForGroup(chefApi);

      expect(chefApi.listClients()).andReturn(ImmutableSet.<String> of("foo-client-00", "foo-client-02"));
      expect(chefApi.createClient("foo-client-01")).andReturn(client);
      expect(client.getPrivateKey()).andReturn(privateKey);

      replay(client);
      replay(chefApi);
View Full Code Here


   private Json json = injector.getInstance(Json.class);

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWhenNoDatabagItem() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Client client = createMock(Client.class);

      RunListForGroup fn = new RunListForGroup(new BootstrapConfigForGroup("jclouds", chefApi), json);

      expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(null);

      replay(client);
      replay(chefApi);

      fn.apply("foo");
View Full Code Here

      verify(chefApi);
   }

   @Test
   public void testReadRunList() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Api api = createMock(Api.class);

      RunListForGroup fn = new RunListForGroup(new BootstrapConfigForGroup("jclouds", chefApi), json);
      DatabagItem config = new DatabagItem("foo",
            "{\"tomcat6\":{\"ssl_port\":8433},\"run_list\":[\"recipe[apache2]\",\"role[webserver]\"]}");

      expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(config);

      replay(api);
      replay(chefApi);

      assertEquals(fn.apply("foo"), ImmutableList.of("recipe[apache2]", "role[webserver]"));
View Full Code Here

@Test(groups = "unit", testName = "BootstrapConfigForGroupTest")
public class BootstrapConfigForGroupTest {

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWhenNoDatabagItem() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Client client = createMock(Client.class);

      BootstrapConfigForGroup fn = new BootstrapConfigForGroup("jclouds", chefApi);

      expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(null);

      replay(client);
      replay(chefApi);

      fn.apply("foo");
View Full Code Here

      verify(chefApi);
   }

   @Test
   public void testReturnsItem() throws IOException {
      ChefApi chefApi = createMock(ChefApi.class);
      Api api = createMock(Api.class);

      BootstrapConfigForGroup fn = new BootstrapConfigForGroup("jclouds", chefApi);
      DatabagItem config = new DatabagItem("foo",
            "{\"tomcat6\":{\"ssl_port\":8433},\"run_list\":[\"recipe[apache2]\",\"role[webserver]\"]}");

      expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(config);

      replay(api);
      replay(chefApi);

      assertEquals(fn.apply("foo"), config);
View Full Code Here

@Test(groups = { "unit" })
public class UpdateAutomaticAttributesOnNodeImplTest {

   @Test
   public void test() {
      ChefApi chef = createMock(ChefApi.class);

      Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();
      Supplier<Map<String, JsonBall>> automaticSupplier = Suppliers.<Map<String, JsonBall>> ofInstance(automatic);

      Node node = Node.builder().name("name").environment("_default").build();
      Node nodeWithAutomatic = Node.builder().name("name").environment("_default").automaticAttributes(automatic)
            .build();

      expect(chef.getNode("name")).andReturn(node);
      expect(chef.updateNode(nodeWithAutomatic)).andReturn(null);

      replay(chef);

      UpdateAutomaticAttributesOnNodeImpl updater = new UpdateAutomaticAttributesOnNodeImpl(chef, automaticSupplier);
View Full Code Here

@Test(groups = "unit", testName = "CreateNodeAndPopulateAutomaticAttributesImplTest")
public class CreateNodeAndPopulateAutomaticAttributesImplTest {

   @Test
   public void testWithNoRunlist() {
      ChefApi chef = createMock(ChefApi.class);

      Supplier<Map<String, JsonBall>> automaticSupplier = Suppliers.<Map<String, JsonBall>> ofInstance(ImmutableMap.<String, JsonBall> of());

      Node nodeWithAutomatic = Node.builder().name("name").environment("_default")
            .automaticAttributes(automaticSupplier.get()).build();

      chef.createNode(nodeWithAutomatic);

      replay(chef);

      CreateNodeAndPopulateAutomaticAttributesImpl updater = new CreateNodeAndPopulateAutomaticAttributesImpl(chef,
            automaticSupplier);
View Full Code Here

TOP

Related Classes of org.jclouds.chef.ChefApi

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.