use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class CouchDbUtilTest method mockQueryResultWithNullDocValue.
/**
* Assert that if doc's value in JSON object
* is null, the result from jsonToObject
* will be null and no exception occurs.
*/
@Test
public void mockQueryResultWithNullDocValue() {
String queryResult = "{\"doc\":null}";
Gson gson = new Gson();
JsonObject jsonFromSearchQuery = new JsonParser().parse(queryResult).getAsJsonObject();
JsonObject mockResult = jsonToObject(gson, jsonFromSearchQuery, "doc", JsonObject.class);
assertEquals(null, mockResult);
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class DBServerTest method dbInfo.
@Test
public void dbInfo() {
DbInfo dbInfo = db.info();
assertNotNull(dbInfo);
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class DatabaseTest method permissionsParsing.
@Test
public void permissionsParsing() throws Exception {
CloudantClient client = CloudantClientHelper.newMockWebServerClientBuilder(mockWebServer).build();
Database db = client.database("notarealdb", false);
// Mock up a request of all permissions
// for GET _security
mockWebServer.enqueue(MockWebServerResources.PERMISSIONS);
// for PUT _security
mockWebServer.enqueue(MockWebServerResources.JSON_OK);
db.setPermissions("testUsername", EnumSet.allOf(Permissions.class));
// Mock up a failing request
String testError = "test error";
String testReason = "test reason";
// for GET _security
mockWebServer.enqueue(MockWebServerResources.PERMISSIONS);
mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody("{\"reason\":\"" + testReason + "\", \"error\":\"" + testError + "\"}"));
try {
db.setPermissions("testUsername", EnumSet.allOf(Permissions.class));
} catch (CouchDbException e) {
assertEquals(testError, e.getError());
assertEquals(testReason, e.getReason());
}
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class DatabaseTest method shards.
@Test
@RequiresCloudant
public void shards() {
List<Shard> shards = db.getShards();
assert (shards.size() > 0);
for (Shard s : shards) {
assertNotNull(s.getRange());
assertNotNull(s.getNodes());
assertNotNull(s.getNodes().hasNext());
}
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class DatabaseTest method shard.
@Test
@RequiresCloudant
public void shard() {
Shard s = db.getShard("snipe");
assertNotNull(s);
assertNotNull(s.getRange());
assertNotNull(s.getNodes());
assert (s.getNodes().hasNext());
}
Aggregations