Search in sources :

Example 1 with DeleteFeedbackOptions

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

the class CompareComplyServiceIT method testFeedbackOperations.

@Test
public void testFeedbackOperations() {
    String userId = "lp_java";
    String comment = "could be better";
    String text = "1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist " + "Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing " + "infrastructure.";
    ShortDoc shortDoc = new ShortDoc.Builder().title("doc title").hash("").build();
    Location location = new Location.Builder().begin(241).end(237).build();
    OriginalLabelsIn.Builder originalLabelsInBuilder = new OriginalLabelsIn.Builder();
    Label label1 = new Label.Builder().nature("Obligation").party("IBM").build();
    List<String> ids1 = Arrays.asList("85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795");
    TypeLabel typeLabel1 = new TypeLabel.Builder().label(label1).provenanceIds(ids1).build();
    Label label2 = new Label.Builder().nature("End User").party("Exclusion").build();
    List<String> ids2 = Arrays.asList("85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795");
    TypeLabel typeLabel2 = new TypeLabel.Builder().label(label2).provenanceIds(ids2).build();
    List<TypeLabel> types = Arrays.asList(typeLabel1, typeLabel2);
    originalLabelsInBuilder.types(types);
    Category category1 = new Category.Builder().label(Category.Label.RESPONSIBILITIES).provenanceIds(new ArrayList<String>()).build();
    Category category2 = new Category.Builder().label(Category.Label.AMENDMENTS).provenanceIds(new ArrayList<String>()).build();
    originalLabelsInBuilder.categories(Arrays.asList(category1, category2));
    UpdatedLabelsIn.Builder updatedLabelsInBuilder = new UpdatedLabelsIn.Builder();
    Label label3 = new Label.Builder().nature("Disclaimer").party("buyer").build();
    TypeLabel typeLabel3 = new TypeLabel.Builder().label(label3).build();
    updatedLabelsInBuilder.types(Arrays.asList(typeLabel1, typeLabel3));
    updatedLabelsInBuilder.categories(Arrays.asList(category1, category2));
    FeedbackDataInput feedbackDataInput = new FeedbackDataInput.Builder().document(shortDoc).location(location).text(text).originalLabels(originalLabelsInBuilder.build()).updatedLabels(updatedLabelsInBuilder.build()).feedbackType("element_classification").modelId("contracts").modelVersion("11.00").build();
    AddFeedbackOptions addFeedbackOptions = new AddFeedbackOptions.Builder().userId(userId).comment(comment).feedbackData(feedbackDataInput).build();
    FeedbackReturn feedbackReturn = service.addFeedback(addFeedbackOptions).execute().getResult();
    String feedbackId = feedbackReturn.getFeedbackId();
    GetFeedbackOptions getFeedbackOptions = new GetFeedbackOptions.Builder().feedbackId(feedbackId).build();
    GetFeedback getFeedback = service.getFeedback(getFeedbackOptions).addHeader("x-watson-metadata", "customer_id=sdk-test-customer-id").execute().getResult();
    assertEquals(text, getFeedback.getFeedbackData().getText());
    DeleteFeedbackOptions deleteFeedbackOptions = new DeleteFeedbackOptions.Builder().feedbackId(feedbackId).build();
    service.deleteFeedback(deleteFeedbackOptions).execute();
    FeedbackList feedbackList = service.listFeedback().execute().getResult();
    List<GetFeedback> allFeedback = feedbackList.getFeedback();
    boolean successfullyDeleted = true;
    for (GetFeedback feedback : allFeedback) {
        if (feedback.getFeedbackId().equals(feedbackId)) {
            successfullyDeleted = false;
            break;
        }
    }
    assertTrue(successfullyDeleted);
}
Also used : GetFeedback(com.ibm.watson.compare_comply.v1.model.GetFeedback) 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) ArrayList(java.util.ArrayList) FeedbackList(com.ibm.watson.compare_comply.v1.model.FeedbackList) ShortDoc(com.ibm.watson.compare_comply.v1.model.ShortDoc) OriginalLabelsIn(com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn) GetFeedbackOptions(com.ibm.watson.compare_comply.v1.model.GetFeedbackOptions) 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) DeleteFeedbackOptions(com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions) Location(com.ibm.watson.compare_comply.v1.model.Location) Test(org.junit.Test)

Example 2 with DeleteFeedbackOptions

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

the class CompareComplyTest method testDeleteFeedbackWOptions.

@Test
public void testDeleteFeedbackWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "{\"status\": 6, \"message\": \"message\"}";
    String deleteFeedbackPath = "/v1/feedback/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the DeleteFeedbackOptions model
    DeleteFeedbackOptions deleteFeedbackOptionsModel = new DeleteFeedbackOptions.Builder().feedbackId("testString").model("contracts").build();
    // Invoke operation with valid options model (positive test)
    Response<FeedbackDeleted> response = compareComplyService.deleteFeedback(deleteFeedbackOptionsModel).execute();
    assertNotNull(response);
    FeedbackDeleted responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "DELETE");
    // Check query
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    // Get query params
    assertEquals(query.get("version"), "testString");
    assertEquals(query.get("model"), "contracts");
    // Check request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, deleteFeedbackPath);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteFeedbackOptions(com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions) FeedbackDeleted(com.ibm.watson.compare_comply.v1.model.FeedbackDeleted) Test(org.testng.annotations.Test)

Example 3 with DeleteFeedbackOptions

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

the class CompareComply method deleteFeedback.

/**
 * Delete a specified feedback entry.
 *
 * <p>Deletes a feedback entry with a specified `feedback_id`.
 *
 * @param deleteFeedbackOptions the {@link DeleteFeedbackOptions} containing the options for the
 *     call
 * @return a {@link ServiceCall} with a result of type {@link FeedbackDeleted}
 */
public ServiceCall<FeedbackDeleted> deleteFeedback(DeleteFeedbackOptions deleteFeedbackOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteFeedbackOptions, "deleteFeedbackOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("feedback_id", deleteFeedbackOptions.feedbackId());
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/feedback/{feedback_id}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "deleteFeedback");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.query("version", String.valueOf(this.version));
    if (deleteFeedbackOptions.model() != null) {
        builder.query("model", String.valueOf(deleteFeedbackOptions.model()));
    }
    ResponseConverter<FeedbackDeleted> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<FeedbackDeleted>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) FeedbackDeleted(com.ibm.watson.compare_comply.v1.model.FeedbackDeleted)

Aggregations

DeleteFeedbackOptions (com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions)2 FeedbackDeleted (com.ibm.watson.compare_comply.v1.model.FeedbackDeleted)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 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 FeedbackList (com.ibm.watson.compare_comply.v1.model.FeedbackList)1 FeedbackReturn (com.ibm.watson.compare_comply.v1.model.FeedbackReturn)1 GetFeedback (com.ibm.watson.compare_comply.v1.model.GetFeedback)1 GetFeedbackOptions (com.ibm.watson.compare_comply.v1.model.GetFeedbackOptions)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 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1