@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, json); expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(null); replay(client, chefApi); fn.apply("foo"); verify(client, chefApi); }
@Override public BootstrapConfig apply(String from) { DatabagItem bootstrapConfig = api.getDatabagItem(databag, from); checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from); return json.fromJson(bootstrapConfig.toString(), BootstrapConfig.class); }
BootstrapConfigForGroup implements Function<String, BootstrapConfig> { @Override public BootstrapConfig apply(String from) { DatabagItem bootstrapConfig = api.getDatabagItem(databag, from); checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from); return json.fromJson(bootstrapConfig.toString(), BootstrapConfig.class); } }
BootstrapConfigForGroup implements Function<String, BootstrapConfig> { @Override public BootstrapConfig apply(String from) { DatabagItem bootstrapConfig = api.getDatabagItem(databag, from); checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from); return json.fromJson(bootstrapConfig.toString(), BootstrapConfig.class); } @Inject  BootstrapConfigForGroup(@Named(CHEF_BOOTSTRAP_DATABAG) String databag, ChefApi api, Json json); }
BootstrapConfigForGroup implements Function<String, BootstrapConfig> { @Override public BootstrapConfig apply(String from) { DatabagItem bootstrapConfig = api.getDatabagItem(databag, from); checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from); return json.fromJson(bootstrapConfig.toString(), BootstrapConfig.class); } @Inject  BootstrapConfigForGroup(@Named(CHEF_BOOTSTRAP_DATABAG) String databag, ChefApi api, Json json); @Override BootstrapConfig apply(String from); }
BootstrapConfigForGroup implements Function<String, BootstrapConfig> { @Override public BootstrapConfig apply(String from) { DatabagItem bootstrapConfig = api.getDatabagItem(databag, from); checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from); return json.fromJson(bootstrapConfig.toString(), BootstrapConfig.class); } @Inject  BootstrapConfigForGroup(@Named(CHEF_BOOTSTRAP_DATABAG) String databag, ChefApi api, Json json); @Override BootstrapConfig apply(String from);  }