Search in sources :

Example 1 with DefaultQueryParamsPassages

use of com.ibm.watson.discovery.v2.model.DefaultQueryParamsPassages in project java-sdk by watson-developer-cloud.

the class DiscoveryTest method testCreateProjectWOptions.

@Test
public void testCreateProjectWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"document_retrieval\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 11}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}";
    String createProjectPath = "/v2/projects";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the DefaultQueryParamsPassages model
    DefaultQueryParamsPassages defaultQueryParamsPassagesModel = new DefaultQueryParamsPassages.Builder().enabled(true).count(Long.valueOf("26")).fields(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).characters(Long.valueOf("26")).perDocument(true).maxPerDocument(Long.valueOf("26")).build();
    // Construct an instance of the DefaultQueryParamsTableResults model
    DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = new DefaultQueryParamsTableResults.Builder().enabled(true).count(Long.valueOf("26")).perDocument(Long.valueOf("26")).build();
    // Construct an instance of the DefaultQueryParamsSuggestedRefinements model
    DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = new DefaultQueryParamsSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("26")).build();
    // Construct an instance of the DefaultQueryParams model
    DefaultQueryParams defaultQueryParamsModel = new DefaultQueryParams.Builder().collectionIds(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).passages(defaultQueryParamsPassagesModel).tableResults(defaultQueryParamsTableResultsModel).aggregation("testString").suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel).spellingSuggestions(true).highlight(true).count(Long.valueOf("26")).sort("testString").xReturn(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
    // Construct an instance of the CreateProjectOptions model
    CreateProjectOptions createProjectOptionsModel = new CreateProjectOptions.Builder().name("testString").type("document_retrieval").defaultQueryParameters(defaultQueryParamsModel).build();
    // Invoke operation with valid options model (positive test)
    Response<ProjectDetails> response = discoveryService.createProject(createProjectOptionsModel).execute();
    assertNotNull(response);
    ProjectDetails 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);
    assertNotNull(query);
    // Get query params
    assertEquals(query.get("version"), "testString");
    // Check request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, createProjectPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) ProjectDetails(com.ibm.watson.discovery.v2.model.ProjectDetails) DefaultQueryParamsSuggestedRefinements(com.ibm.watson.discovery.v2.model.DefaultQueryParamsSuggestedRefinements) CreateProjectOptions(com.ibm.watson.discovery.v2.model.CreateProjectOptions) DefaultQueryParams(com.ibm.watson.discovery.v2.model.DefaultQueryParams) DefaultQueryParamsPassages(com.ibm.watson.discovery.v2.model.DefaultQueryParamsPassages) DefaultQueryParamsTableResults(com.ibm.watson.discovery.v2.model.DefaultQueryParamsTableResults) Test(org.testng.annotations.Test)

Aggregations

CreateProjectOptions (com.ibm.watson.discovery.v2.model.CreateProjectOptions)1 DefaultQueryParams (com.ibm.watson.discovery.v2.model.DefaultQueryParams)1 DefaultQueryParamsPassages (com.ibm.watson.discovery.v2.model.DefaultQueryParamsPassages)1 DefaultQueryParamsSuggestedRefinements (com.ibm.watson.discovery.v2.model.DefaultQueryParamsSuggestedRefinements)1 DefaultQueryParamsTableResults (com.ibm.watson.discovery.v2.model.DefaultQueryParamsTableResults)1 ProjectDetails (com.ibm.watson.discovery.v2.model.ProjectDetails)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.testng.annotations.Test)1