use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class DesignDocumentsTest method designDocRemoveNoPrefixWithRevision.
/**
* Validate that a design document can be retrieved without using the "_design" prefix when a
* revision is supplied
*
* @throws Exception
*/
@Test
public void designDocRemoveNoPrefixWithRevision() throws Exception {
// Write a doc with a _design prefix
Response r = designManager.put(designDocExample);
// Retrieve it without a prefix
Utils.assertOKResponse(designManager.remove("example", r.getRev()));
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class DesignDocumentsTest method designDocGetNoPrefixWithRevision.
/**
* Validate that a design document can be retrieved without using the "_design" prefix when a
* revision is supplied
*
* @throws Exception
*/
@Test
public void designDocGetNoPrefixWithRevision() throws Exception {
// Write a doc with a _design prefix
Response r = designManager.put(designDocExample);
// Retrieve it without a prefix
assertNotNull(designManager.get("example", r.getRev()), "The design doc should be " + "retrieved without a _design prefix");
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class Utils method removeReplicatorTestDoc.
public static void removeReplicatorTestDoc(CloudantClient account, String replicatorDocId) throws Exception {
// Grab replicator doc revision using HTTP HEAD command
String replicatorDb = "_replicator";
URI uri = new URIBase(account.getBaseUri()).path(replicatorDb).path(replicatorDocId).build();
HttpConnection head = Http.HEAD(uri);
// add a response interceptor to allow us to retrieve the ETag revision header
final AtomicReference<String> revisionRef = new AtomicReference<String>();
head.responseInterceptors.add(new HttpConnectionResponseInterceptor() {
@Override
public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context) {
revisionRef.set(context.connection.getConnection().getHeaderField("ETag"));
return context;
}
});
account.executeRequest(head);
String revision = revisionRef.get();
assertNotNull("The revision should not be null", revision);
Database replicator = account.database(replicatorDb, false);
Response removeResponse = replicator.remove(replicatorDocId, revision.replaceAll("\"", ""));
assertThat(removeResponse.getError(), is(nullValue()));
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class DocumentsCRUDTest method findByIdAndRev.
@Test
public void findByIdAndRev() {
Response response = db.save(new Foo());
Foo foo = db.find(Foo.class, response.getId(), response.getRev());
assertNotNull(foo);
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class DocumentsCRUDTest method deleteByIdAndRevValues.
@Test
public void deleteByIdAndRevValues() {
Response response = db.save(new Foo());
db.remove(response.getId(), response.getRev());
}
Aggregations