Package org.jclouds.chef.domain

Examples of org.jclouds.chef.domain.DatabagItem


      } catch (IllegalStateException e) {

      }

      String jsonConfig = buildBootstrapConfiguration(bootstrapConfig);
      DatabagItem runlist = new DatabagItem(group, jsonConfig);

      if (api.getDatabagItem(databag, group) == null) {
         api.createDatabagItem(databag, runlist);
      } else {
         api.updateDatabagItem(databag, runlist);
View Full Code Here


      this.api = checkNotNull(api, "api");
   }

   @Override
   public DatabagItem apply(String from) {
      DatabagItem bootstrapConfig = api.getDatabagItem(databag, from);
      checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from);
      return bootstrapConfig;
   }
View Full Code Here

      protected DatabagItem createJsonLiteralFromRawJson(String text) {
         IdHolder idHolder = gson.fromJson(text, IdHolder.class);
         checkState(idHolder.id != null,
               "databag item must be a json hash ex. {\"id\":\"item1\",\"my_key\":\"my_data\"}; was %s", text);
         text = text.replaceFirst(String.format("\\{\"id\"[ ]?:\"%s\",", idHolder.id), "{");
         return new DatabagItem(idHolder.id, text);
      }
View Full Code Here

   }

   @Test(dependsOnMethods = "testCreateDatabagItem")
   public void testUpdateDatabagItem() throws Exception {
      for (String databagItemId : api.listDatabagItems(PREFIX)) {
         DatabagItem databagItem = api.getDatabagItem(PREFIX, databagItemId);
         api.updateDatabagItem(PREFIX, databagItem);
      }
   }
View Full Code Here

   }

   @Test(dependsOnMethods = "testSearchDatabagWithOptions")
   public void testDeleteDatabagItem() throws Exception {
      for (String databagItemId : api.listDatabagItems(PREFIX)) {
         DatabagItem databagItem = api.deleteDatabagItem(PREFIX, databagItemId);
         assertNotNull(databagItem, "Deleted data bag item should not be null");
         assertEquals(databagItem.getId(), databagItemId, "Deleted data bag item id must match the original id");
         assertNull(api.getDatabagItem(PREFIX, databagItemId), "Data bag item should not exist");
      }
   }
View Full Code Here

   }

   public void test1() {
      String itemJson = "{\"my_key\":\"my_data\"}";
      String searchJson = "{\"rows\":[{\"raw_data\": {\"id\":\"item1\",\"my_key\":\"my_data\"}}]}";
      DatabagItem item = new DatabagItem("item1", itemJson);
      SearchResult<DatabagItem> result = handler.apply(HttpResponse.builder().statusCode(200).message("ok")
            .payload(searchJson).build());
      assertEquals(result.size(), 1);
      assertEquals(result.iterator().next(), item);
   }
View Full Code Here

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

      mapper = injector.getInstance(Json.class);
   }

   public void test1() {
      String json = "{\"my_key\":\"my_data\",\"id\":\"item1\"}";
      DatabagItem item = new DatabagItem("item1", json);
      assertEquals(handler.apply(HttpResponse.builder().statusCode(200).message("ok").payload(json).build()), item);
      assertEquals(mapper.toJson(item), json);
   }
View Full Code Here

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

   @Test(dependsOnMethods = "testCreateDatabag")
   public void testCreateDatabagItem() throws Exception {
      Properties config = new Properties();
      config.setProperty("foo", "bar");
      api.deleteDatabagItem(PREFIX, PREFIX);
      DatabagItem databagItem = api.createDatabagItem(PREFIX, new DatabagItem("config", json.toJson(config)));
      databagitemId = databagItem.getId();
      assertNotNull(databagItem, "Created data bag item should not be null");
      assertEquals(databagItem.getId(), "config");

      // The databagItem json contains extra keys: (the name and the type if the
      // item)
      Properties props = json.fromJson(databagItem.toString(), Properties.class);
      for (Object key : config.keySet()) {
         assertTrue(props.containsKey(key));
         assertEquals(config.get(key), props.get(key));
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.chef.domain.DatabagItem

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.