Package org.jclouds.chef.domain

Examples of org.jclouds.chef.domain.DatabagItem


   }

   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


      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

   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

   @Test(dependsOnMethods = { "testDatabagExists" })
   public void testCreateDatabagItem() {
      Properties config = new Properties();
      config.setProperty("foo", "bar");
      databagItem = api.createDatabagItem(PREFIX, new DatabagItem("config", json.toJson(config)));
      assertNotNull(databagItem);
      assertEquals(databagItem.getId(), "config");
      assertEquals(config, json.fromJson(databagItem.toString(), Properties.class));
   }
View Full Code Here

   }

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

      databags.deleteContainer(databagName);
   }

   @Override
   public DatabagItem deleteDatabagItem(String databagName, String databagItemId) {
      DatabagItem item = blobToDatabagItem.apply(databags.getBlob(databagName, databagItemId));
      databags.removeBlob(databagName, databagItemId);
      return item;
   }
View Full Code Here

   @Singleton
   private static class BlobToDatabagItem implements Function<Blob, DatabagItem> {
      @Override
      public DatabagItem apply(Blob from) {
         try {
            return from == null ? null : new DatabagItem(from.getMetadata().getName(), Strings2.toStringAndClose(from
                  .getPayload().getInput()));
         } catch (IOException e) {
            propagate(e);
            return null;
         }
View Full Code Here

      } catch (IllegalStateException e) {

      }

      String bootstrapConfig = buildBootstrapConfiguration(runList, Optional.fromNullable(jsonAttributes));
      DatabagItem runlist = new DatabagItem(group, bootstrapConfig);

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

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

   @Override
   public List<String> apply(String from) {
      DatabagItem bootstrapConfig = bootstrapConfigForGroup.apply(from);
      Map<String, JsonBall> config = json.fromJson(bootstrapConfig.toString(),
            BootstrapConfigForGroup.BOOTSTRAP_CONFIG_TYPE);
      JsonBall runlist = config.get("run_list");
      return json.fromJson(runlist.toString(), RUN_LIST_TYPE);
   }
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.