Search in sources :

Example 1 with OriginalLabelsIn

use of com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn in project java-sdk by watson-developer-cloud.

the class CompareComplyTest method testAddFeedbackWOptions.

@Test
public void testAddFeedbackWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"feedback_id\": \"feedbackId\", \"user_id\": \"userId\", \"comment\": \"comment\", \"created\": \"2019-01-01T12:00:00.000Z\", \"feedback_data\": {\"feedback_type\": \"feedbackType\", \"document\": {\"title\": \"title\", \"hash\": \"hash\"}, \"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"original_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"updated_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"pagination\": {\"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\", \"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5}}}";
    String addFeedbackPath = "/v1/feedback";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the ShortDoc model
    ShortDoc shortDocModel = new ShortDoc.Builder().title("testString").hash("testString").build();
    // Construct an instance of the Location model
    Location locationModel = new Location.Builder().begin(Long.valueOf("26")).end(Long.valueOf("26")).build();
    // Construct an instance of the Label model
    Label labelModel = new Label.Builder().nature("testString").party("testString").build();
    // Construct an instance of the TypeLabel model
    TypeLabel typeLabelModel = new TypeLabel.Builder().label(labelModel).provenanceIds(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).modification("added").build();
    // Construct an instance of the Category model
    Category categoryModel = new Category.Builder().label("Amendments").provenanceIds(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).modification("added").build();
    // Construct an instance of the OriginalLabelsIn model
    OriginalLabelsIn originalLabelsInModel = new OriginalLabelsIn.Builder().types(new java.util.ArrayList<TypeLabel>(java.util.Arrays.asList(typeLabelModel))).categories(new java.util.ArrayList<Category>(java.util.Arrays.asList(categoryModel))).build();
    // Construct an instance of the UpdatedLabelsIn model
    UpdatedLabelsIn updatedLabelsInModel = new UpdatedLabelsIn.Builder().types(new java.util.ArrayList<TypeLabel>(java.util.Arrays.asList(typeLabelModel))).categories(new java.util.ArrayList<Category>(java.util.Arrays.asList(categoryModel))).build();
    // Construct an instance of the FeedbackDataInput model
    FeedbackDataInput feedbackDataInputModel = new FeedbackDataInput.Builder().feedbackType("testString").document(shortDocModel).modelId("testString").modelVersion("testString").location(locationModel).text("testString").originalLabels(originalLabelsInModel).updatedLabels(updatedLabelsInModel).build();
    // Construct an instance of the AddFeedbackOptions model
    AddFeedbackOptions addFeedbackOptionsModel = new AddFeedbackOptions.Builder().feedbackData(feedbackDataInputModel).userId("testString").comment("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<FeedbackReturn> response = compareComplyService.addFeedback(addFeedbackOptionsModel).execute();
    assertNotNull(response);
    FeedbackReturn 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, addFeedbackPath);
}
Also used : Category(com.ibm.watson.compare_comply.v1.model.Category) FeedbackDataInput(com.ibm.watson.compare_comply.v1.model.FeedbackDataInput) Label(com.ibm.watson.compare_comply.v1.model.Label) TypeLabel(com.ibm.watson.compare_comply.v1.model.TypeLabel) ShortDoc(com.ibm.watson.compare_comply.v1.model.ShortDoc) OriginalLabelsIn(com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) FeedbackReturn(com.ibm.watson.compare_comply.v1.model.FeedbackReturn) TypeLabel(com.ibm.watson.compare_comply.v1.model.TypeLabel) AddFeedbackOptions(com.ibm.watson.compare_comply.v1.model.AddFeedbackOptions) UpdatedLabelsIn(com.ibm.watson.compare_comply.v1.model.UpdatedLabelsIn) Location(com.ibm.watson.compare_comply.v1.model.Location) Test(org.testng.annotations.Test)

Aggregations

AddFeedbackOptions (com.ibm.watson.compare_comply.v1.model.AddFeedbackOptions)1 Category (com.ibm.watson.compare_comply.v1.model.Category)1 FeedbackDataInput (com.ibm.watson.compare_comply.v1.model.FeedbackDataInput)1 FeedbackReturn (com.ibm.watson.compare_comply.v1.model.FeedbackReturn)1 Label (com.ibm.watson.compare_comply.v1.model.Label)1 Location (com.ibm.watson.compare_comply.v1.model.Location)1 OriginalLabelsIn (com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn)1 ShortDoc (com.ibm.watson.compare_comply.v1.model.ShortDoc)1 TypeLabel (com.ibm.watson.compare_comply.v1.model.TypeLabel)1 UpdatedLabelsIn (com.ibm.watson.compare_comply.v1.model.UpdatedLabelsIn)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.testng.annotations.Test)1