use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class DocumentsCRUDTest method updateWithIdContainSlash.
@Test
public void updateWithIdContainSlash() {
String idWithSlash = "a/" + generateUUID();
Response response = db.save(new Bar(idWithSlash));
Bar bar = db.find(Bar.class, response.getId());
Response responseUpdate = db.update(bar);
assertEquals(idWithSlash, responseUpdate.getId());
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class ReplicatorTest method replicatorDB.
@Test
public void replicatorDB() throws Exception {
// trigger a replication
Response response = account.replicator().replicatorDocId(repDocId).source(db1URI).target(db2URI).continuous(true).createTarget(true).save();
// we need the replication to start before continuing
Utils.waitForReplicatorToStart(account, response.getId());
// find all replicator docs
List<ReplicatorDocument> replicatorDocs = account.replicator().findAll();
assertThat(replicatorDocs.size(), is(not(0)));
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class ResponseTest method verifyDocumentSaved.
@Test
public void verifyDocumentSaved() {
Response response = db.save(foo);
assertEquals(2, response.getStatusCode() / 100);
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class ResponseTest method verifyDocumentConflict.
@Test
public void verifyDocumentConflict() {
try {
Response response = db.save(foo);
assertEquals(2, response.getStatusCode() / 100);
db.save(foo);
fail("A DocumentConflictException should be thrown");
} catch (DocumentConflictException e) {
exceptionAsserts(e, 409, "");
}
}
use of com.cloudant.client.api.model.Response in project java-cloudant by cloudant.
the class AttachmentsTest method attachmentStandaloneNullIdNullRev.
@Test
public void attachmentStandaloneNullIdNullRev() throws IOException, URISyntaxException {
byte[] bytesToDB = "binary data".getBytes();
ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesToDB);
// Save the attachment to a doc with the given ID
Response response = db.saveAttachment(bytesIn, "foo.txt", "text/plain", null, null);
Document doc = db.find(Document.class, response.getId());
assertTrue(doc.getAttachments().containsKey("foo.txt"));
InputStream in = db.getAttachment(response.getId(), "foo.txt");
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
IOUtils.copy(in, bytesOut);
byte[] bytesFromDB = bytesOut.toByteArray();
assertArrayEquals(bytesToDB, bytesFromDB);
} finally {
in.close();
}
}
Aggregations