JCLOUDS-335: Properly deserialize the deleteDatabagItem response

This commit is contained in:
Ignasi Barrera 2013-10-04 10:14:28 +02:00
parent 92b3f5942c
commit 2b3bcaf034
3 changed files with 15 additions and 2 deletions

View File

@ -79,6 +79,7 @@ import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.SinceApiVersion;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.WrapWith;
@ -424,6 +425,7 @@ public interface ChefApi extends Closeable {
@DELETE
@Path("/data/{databagName}/{databagItemId}")
@Fallback(NullOnNotFoundOr404.class)
@SelectJson("raw_data")
DatabagItem deleteDatabagItem(@PathParam("databagName") String databagName,
@PathParam("databagItemId") String databagItemId);

View File

@ -45,12 +45,12 @@ import org.jclouds.chef.functions.ParseKeySetFromJson;
import org.jclouds.chef.functions.ParseSearchClientsFromJson;
import org.jclouds.chef.functions.ParseSearchDatabagFromJson;
import org.jclouds.chef.functions.ParseSearchNodesFromJson;
import org.jclouds.chef.functions.ParseSearchRolesFromJson;
import org.jclouds.chef.options.CreateClientOptions;
import org.jclouds.chef.options.SearchOptions;
import org.jclouds.date.TimeStamp;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ParseJson;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnInputStream;
@ -490,7 +490,7 @@ public class ChefApiTest extends BaseAsyncApiTest<ChefApi> {
+ "-test\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, NullOnNotFoundOr404.class);

View File

@ -26,6 +26,7 @@ import static org.jclouds.util.Predicates2.retry;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@ -297,6 +298,16 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
}
}
@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");
}
}
@Test
public void testListSearchIndexes() throws Exception {
Set<String> indexes = api.listSearchIndexes();