use of com.cloudant.client.api.model.Params in project java-cloudant by cloudant.
the class UpdateHandlerTest method updateHandler_queryParams.
@Test
public void updateHandler_queryParams() {
final String oldValue = "foo";
final String newValue = "foo bar+plus=equals&ersand";
Response response = db.save(new Foo(null, oldValue));
Params params = new Params().addParam("field", "title").addParam("value", newValue);
String output = db.invokeUpdateHandler("example/example_update", response.getId(), params);
// retrieve from db to verify
Foo foo = db.find(Foo.class, response.getId());
assertNotNull(output);
assertEquals(foo.getTitle(), newValue);
}
use of com.cloudant.client.api.model.Params in project java-cloudant by cloudant.
the class UpdateHandlerTest method updateHandler_queryString.
@Test
public void updateHandler_queryString() {
final String oldValue = "foo";
final String newValue = "foo bar+plus=equals&ersand";
Response response = db.save(new Foo(null, oldValue));
Params params = new Params().addParam("field", "title").addParam("value", newValue);
String output = db.invokeUpdateHandler("example/example_update", response.getId(), params);
// retrieve from db to verify
Foo foo = db.find(Foo.class, response.getId());
assertNotNull(output);
assertEquals(foo.getTitle(), newValue);
}
use of com.cloudant.client.api.model.Params in project java-cloudant by cloudant.
the class UpdateHandlerTest method updateHandler_postUuid.
@Test
public void updateHandler_postUuid() {
String output = db.invokeUpdateHandler("example/get-uuid", null, new Params());
assertNotNull(output);
assertTrue(output.length() > 0);
}
use of com.cloudant.client.api.model.Params in project java-cloudant by cloudant.
the class AttachmentsTest method removeAttachment.
@Test
public void removeAttachment() {
String attachmentName = "txt_1.txt";
Attachment attachment1 = new Attachment("VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=", "text/plain");
// Bar extends Document
Bar bar = new Bar();
bar.addAttachment(attachmentName, attachment1);
Response response = db.save(bar);
Bar bar2 = db.find(Bar.class, response.getId(), new Params().attachments());
String base64Data = bar2.getAttachments().get("txt_1.txt").getData();
assertNotNull(base64Data);
response = db.removeAttachment(bar2, attachmentName);
Bar bar3 = db.find(Bar.class, response.getId(), new Params().attachments());
assertNull(bar3.getAttachments());
}
use of com.cloudant.client.api.model.Params in project java-cloudant by cloudant.
the class AttachmentsTest method attachmentInline_getWithDocument.
@Test
public void attachmentInline_getWithDocument() {
Attachment attachment = new Attachment("VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=", "text/plain");
Bar bar = new Bar();
bar.addAttachment("txt_1.txt", attachment);
Response response = db.save(bar);
Bar bar2 = db.find(Bar.class, response.getId(), new Params().attachments());
String base64Data = bar2.getAttachments().get("txt_1.txt").getData();
assertNotNull(base64Data);
}
Aggregations