Search in sources :

Example 16 with Analyzer

use of com.ibm.cloud.cloudant.v1.model.Analyzer in project cloudant-java-sdk by IBM.

the class CloudantTest method testPostSearchAnalyzeWOptions.

@Test
public void testPostSearchAnalyzeWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"tokens\": [\"tokens\"]}";
    String postSearchAnalyzePath = "/_search_analyze";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the PostSearchAnalyzeOptions model
    PostSearchAnalyzeOptions postSearchAnalyzeOptionsModel = new PostSearchAnalyzeOptions.Builder().analyzer("arabic").text("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<SearchAnalyzeResult> response = cloudantService.postSearchAnalyze(postSearchAnalyzeOptionsModel).execute();
    assertNotNull(response);
    SearchAnalyzeResult 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, postSearchAnalyzePath);
}
Also used : PostSearchAnalyzeOptions(com.ibm.cloud.cloudant.v1.model.PostSearchAnalyzeOptions) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) SearchAnalyzeResult(com.ibm.cloud.cloudant.v1.model.SearchAnalyzeResult) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Test (org.testng.annotations.Test)15 ArrayList (java.util.ArrayList)11 Analyzer (com.ibm.cloud.cloudant.v1.model.Analyzer)10 HashMap (java.util.HashMap)9 MockResponse (okhttp3.mockwebserver.MockResponse)6 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 AnalyzerConfiguration (com.ibm.cloud.cloudant.v1.model.AnalyzerConfiguration)5 SearchIndexDefinition (com.ibm.cloud.cloudant.v1.model.SearchIndexDefinition)5 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)4 GeoIndexDefinition (com.ibm.cloud.cloudant.v1.model.GeoIndexDefinition)4 IndexTextOperatorDefaultField (com.ibm.cloud.cloudant.v1.model.IndexTextOperatorDefaultField)4 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)3 DesignDocumentOptions (com.ibm.cloud.cloudant.v1.model.DesignDocumentOptions)3 DesignDocumentViewsMapReduce (com.ibm.cloud.cloudant.v1.model.DesignDocumentViewsMapReduce)3 DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)3 IndexDefinition (com.ibm.cloud.cloudant.v1.model.IndexDefinition)3 IndexField (com.ibm.cloud.cloudant.v1.model.IndexField)3 Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)3 GetDesignDocumentOptions (com.ibm.cloud.cloudant.v1.model.GetDesignDocumentOptions)2