use of com.ibm.cloud.cloudant.v1.model.Analyzer in project cloudant-java-sdk by IBM.
the class PostSearchAnalyzeOptionsTest method testPostSearchAnalyzeOptions.
@Test
public void testPostSearchAnalyzeOptions() throws Throwable {
PostSearchAnalyzeOptions postSearchAnalyzeOptionsModel = new PostSearchAnalyzeOptions.Builder().analyzer("arabic").text("testString").build();
assertEquals(postSearchAnalyzeOptionsModel.analyzer(), "arabic");
assertEquals(postSearchAnalyzeOptionsModel.text(), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.Analyzer in project cloudant-java-sdk by IBM.
the class IndexTextOperatorDefaultFieldTest method testIndexTextOperatorDefaultField.
@Test
public void testIndexTextOperatorDefaultField() throws Throwable {
Analyzer analyzerModel = new Analyzer.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
assertEquals(analyzerModel.name(), "classic");
assertEquals(analyzerModel.stopwords(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
IndexTextOperatorDefaultField indexTextOperatorDefaultFieldModel = new IndexTextOperatorDefaultField.Builder().analyzer(analyzerModel).enabled(true).build();
assertEquals(indexTextOperatorDefaultFieldModel.analyzer(), analyzerModel);
assertEquals(indexTextOperatorDefaultFieldModel.enabled(), Boolean.valueOf(true));
String json = TestUtilities.serialize(indexTextOperatorDefaultFieldModel);
IndexTextOperatorDefaultField indexTextOperatorDefaultFieldModelNew = TestUtilities.deserialize(json, IndexTextOperatorDefaultField.class);
assertTrue(indexTextOperatorDefaultFieldModelNew instanceof IndexTextOperatorDefaultField);
assertEquals(indexTextOperatorDefaultFieldModelNew.analyzer().toString(), analyzerModel.toString());
assertEquals(indexTextOperatorDefaultFieldModelNew.enabled(), Boolean.valueOf(true));
}
use of com.ibm.cloud.cloudant.v1.model.Analyzer in project cloudant-java-sdk by IBM.
the class IndexDefinitionTest method testIndexDefinition.
@Test
public void testIndexDefinition() throws Throwable {
Analyzer analyzerModel = new Analyzer.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
assertEquals(analyzerModel.name(), "classic");
assertEquals(analyzerModel.stopwords(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
IndexTextOperatorDefaultField indexTextOperatorDefaultFieldModel = new IndexTextOperatorDefaultField.Builder().analyzer(analyzerModel).enabled(true).build();
assertEquals(indexTextOperatorDefaultFieldModel.analyzer(), analyzerModel);
assertEquals(indexTextOperatorDefaultFieldModel.enabled(), Boolean.valueOf(true));
IndexField indexFieldModel = new IndexField.Builder().name("testString").type("boolean").add("foo", "asc").build();
assertEquals(indexFieldModel.getName(), "testString");
assertEquals(indexFieldModel.getType(), "boolean");
assertEquals(indexFieldModel.get("foo"), "asc");
IndexDefinition indexDefinitionModel = new IndexDefinition.Builder().defaultAnalyzer(analyzerModel).defaultField(indexTextOperatorDefaultFieldModel).fields(new java.util.ArrayList<IndexField>(java.util.Arrays.asList(indexFieldModel))).indexArrayLengths(true).partialFilterSelector(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).build();
assertEquals(indexDefinitionModel.defaultAnalyzer(), analyzerModel);
assertEquals(indexDefinitionModel.defaultField(), indexTextOperatorDefaultFieldModel);
assertEquals(indexDefinitionModel.fields(), new java.util.ArrayList<IndexField>(java.util.Arrays.asList(indexFieldModel)));
assertEquals(indexDefinitionModel.indexArrayLengths(), Boolean.valueOf(true));
assertEquals(indexDefinitionModel.partialFilterSelector(), new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
String json = TestUtilities.serialize(indexDefinitionModel);
IndexDefinition indexDefinitionModelNew = TestUtilities.deserialize(json, IndexDefinition.class);
assertTrue(indexDefinitionModelNew instanceof IndexDefinition);
assertEquals(indexDefinitionModelNew.defaultAnalyzer().toString(), analyzerModel.toString());
assertEquals(indexDefinitionModelNew.defaultField().toString(), indexTextOperatorDefaultFieldModel.toString());
assertEquals(indexDefinitionModelNew.indexArrayLengths(), Boolean.valueOf(true));
}
use of com.ibm.cloud.cloudant.v1.model.Analyzer in project cloudant-java-sdk by IBM.
the class SearchIndexDefinitionTest method testSearchIndexDefinition.
@Test
public void testSearchIndexDefinition() throws Throwable {
Analyzer analyzerModel = new Analyzer.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
assertEquals(analyzerModel.name(), "classic");
assertEquals(analyzerModel.stopwords(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder().name("classic").stopwords(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).fields(new java.util.HashMap<String, Analyzer>() {
{
put("foo", analyzerModel);
}
}).build();
assertEquals(analyzerConfigurationModel.name(), "classic");
assertEquals(analyzerConfigurationModel.stopwords(), new java.util.ArrayList<String>(java.util.Arrays.asList("testString")));
assertEquals(analyzerConfigurationModel.fields(), new java.util.HashMap<String, Analyzer>() {
{
put("foo", analyzerModel);
}
});
SearchIndexDefinition searchIndexDefinitionModel = new SearchIndexDefinition.Builder().analyzer(analyzerConfigurationModel).index("testString").build();
assertEquals(searchIndexDefinitionModel.analyzer(), analyzerConfigurationModel);
assertEquals(searchIndexDefinitionModel.index(), "testString");
String json = TestUtilities.serialize(searchIndexDefinitionModel);
SearchIndexDefinition searchIndexDefinitionModelNew = TestUtilities.deserialize(json, SearchIndexDefinition.class);
assertTrue(searchIndexDefinitionModelNew instanceof SearchIndexDefinition);
assertEquals(searchIndexDefinitionModelNew.analyzer().toString(), analyzerConfigurationModel.toString());
assertEquals(searchIndexDefinitionModelNew.index(), "testString");
}
use of com.ibm.cloud.cloudant.v1.model.Analyzer in project cloudant-java-sdk by IBM.
the class CloudantTest method testPostExplainWOptions.
@Test
public void testPostExplainWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"dbname\": \"dbname\", \"fields\": [\"fields\"], \"index\": {\"ddoc\": \"ddoc\", \"def\": {\"default_analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"default_field\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"enabled\": true}, \"fields\": [{\"name\": \"name\", \"type\": \"boolean\"}], \"index_array_lengths\": true, \"partial_filter_selector\": {\"mapKey\": \"anyValue\"}}, \"name\": \"name\", \"type\": \"json\"}, \"limit\": 0, \"opts\": {\"mapKey\": \"anyValue\"}, \"range\": {\"end_key\": [\"anyValue\"], \"start_key\": [\"anyValue\"]}, \"selector\": {\"mapKey\": \"anyValue\"}, \"skip\": 0}";
String postExplainPath = "/testString/_explain";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the PostExplainOptions model
PostExplainOptions postExplainOptionsModel = new PostExplainOptions.Builder().db("testString").selector(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).bookmark("testString").conflicts(true).executionStats(true).fields(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).limit(Long.valueOf("0")).skip(Long.valueOf("0")).sort(new java.util.ArrayList<java.util.Map<String, String>>(java.util.Arrays.asList(new java.util.HashMap<String, String>() {
{
put("foo", "asc");
}
}))).stable(true).update("true").useIndex(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).r(Long.valueOf("1")).build();
// Invoke operation with valid options model (positive test)
Response<ExplainResult> response = cloudantService.postExplain(postExplainOptionsModel).execute();
assertNotNull(response);
ExplainResult responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, postExplainPath);
}
Aggregations