use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class SearchTests method multipleDrillDownTest.
@Test
public /**
* Request a search with two drilldown queries against the views101
* design document. The design document only contains one animal
* that satisfies the drilldown requirements.
* Assert that the result is one animal in the class bird, and
* that the only existing min_length value of this animal is small.
*/
void multipleDrillDownTest() {
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.includeDocs(true).counts(new String[] { "class", "diet" }).ranges("{ \"min_length\": {\"small\": \"[0 TO 1.0]\"," + "\"medium\": \"[1.1 TO 3.0]\", \"large\": \"[3.1 TO 9999999]\"} }").drillDown("class", "bird").drillDown("diet", "omnivore").querySearchResult("class:bird", Animal.class);
assertNotNull(rslt);
assertNotNull(rslt.getRanges());
assertEquals(1, rslt.getRanges().entrySet().size());
assertEquals(3, rslt.getRanges().get("min_length").entrySet().size());
assertEquals(new Long(1), rslt.getRanges().get("min_length").get("small"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("medium"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("large"));
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class SearchTests method drillDownTest.
@Test
public void drillDownTest() {
// do a faceted search for drilldown
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.includeDocs(true).counts(new String[] { "class", "diet" }).ranges("{ \"min_length\": {\"small\": \"[0 TO 1.0]\"," + "\"medium\": \"[1.1 TO 3.0]\", \"large\": \"[3.1 TO 9999999]\"} }").drillDown("class", "mammals").querySearchResult("class:mammal", Animal.class);
assertNotNull(rslt);
assertNotNull(rslt.getRanges());
assertEquals(1, rslt.getRanges().entrySet().size());
assertEquals(3, rslt.getRanges().get("min_length").entrySet().size());
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("small"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("medium"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("large"));
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class SearchTests method multiValueDrillDownTest.
@Test
public void multiValueDrillDownTest() {
// do a faceted search for multi-value drilldown
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.includeDocs(true).drillDown("diet", "carnivore", "omnivore").querySearchResult("class:mammal", Animal.class);
assertNotNull(rslt);
assertEquals(4, rslt.getTotalRows());
List<String> ids = new ArrayList<String>();
for (SearchResultRow row : rslt.getRows()) {
ids.add(row.getId());
}
List<String> expectedIds = Arrays.asList("panda", "aardvark", "badger", "lemur");
assertTrue(ids.containsAll(expectedIds));
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class SearchTests method groupSortTest.
@Test
public void groupSortTest() {
Search srch = db.search("views101/animals");
Map<String, List<Animal>> groups = srch.includeDocs(true).groupField("diet", false).groupSort("[\"-diet<string>\"]").queryGroups("l*", Animal.class);
assertNotNull(groups);
assertEquals(2, groups.size());
Iterator<String> it = groups.keySet().iterator();
// diet in reverse order
assertEquals("omnivore", it.next());
assertEquals("herbivore", it.next());
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class URIBaseTest method buildAccountUri_noTrailingPathSeparator.
@Test
public void buildAccountUri_noTrailingPathSeparator() throws Exception {
CloudantClient client = ClientBuilder.url(clientResource.get().getBaseUri().toURL()).build();
Assertions.assertFalse(client.getBaseUri().toString().endsWith("/"));
URI clientUri = new URIBase(client.getBaseUri()).build();
Assertions.assertFalse(clientUri.toString().endsWith("/"));
// Check that path is not missing / separators
clientUri = new URIBase(client.getBaseUri()).path("").path("api").path("couch").build();
URI expectedAccountUri = new URI(clientResource.get().getBaseUri().toString() + "/api/couch");
Assertions.assertEquals(expectedAccountUri, clientUri);
}
Aggregations