public void AddFeedback_Success() { IClient client = Substitute.For <IClient>(); IRequest request = Substitute.For <IRequest>(); client.PostAsync(Arg.Any <string>()) .Returns(request); CompareComplyService service = new CompareComplyService(client); var versionDate = "versionDate"; service.VersionDate = versionDate; var feedbackData = new FeedbackDataInput(); var userId = "userId"; var comment = "comment"; var result = service.AddFeedback(feedbackData: feedbackData, userId: userId, comment: comment); JObject bodyObject = new JObject(); if (feedbackData != null) { bodyObject["feedback_data"] = JToken.FromObject(feedbackData); } if (!string.IsNullOrEmpty(userId)) { bodyObject["user_id"] = JToken.FromObject(userId); } if (!string.IsNullOrEmpty(comment)) { bodyObject["comment"] = JToken.FromObject(comment); } var json = JsonConvert.SerializeObject(bodyObject); request.Received().WithArgument("version", versionDate); request.Received().WithBodyContent(Arg.Is <StringContent>(x => x.ReadAsStringAsync().Result.Equals(json))); }
public void Feedback_Success() { DateTime before = DateTime.Now; DateTime after = new DateTime(2018, 11, 13); service.WithHeader("X-Watson-Test", "1"); var ListFeedbackResult = service.ListFeedback( feedbackType: "element_classification", before: before, after: after, documentTitle: "doc title", modelId: "contracts", modelVersion: "11.00", categoryRemoved: "categoryRemoved", categoryAdded: "categoryAdded", categoryNotChanged: "categoryUnchanged", typeRemoved: "nature:party", typeAdded: "nature:party", typeNotChanged: "nature:party", pageLimit: 3, sort: "created" ); string userId = "user_id_123x"; string comment = "Test feedback comment"; #region feedbackData FeedbackDataInput feedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, 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.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnumValue.RESPONSIBILITIES, ProvenanceIds = new List <string>() { } }, new Category() { Label = Category.LabelEnumValue.AMENDMENTS, ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnumValue.RESPONSIBILITIES, }, new Category() { Label = Category.LabelEnumValue.AUDITS } } } }; #endregion service.WithHeader("X-Watson-Test", "1"); var addFeedbackResult = service.AddFeedback( feedbackData: feedbackData, userId: userId, comment: comment ); string feedbackId = addFeedbackResult.Result.FeedbackId; service.WithHeader("X-Watson-Test", "1"); var getFeedbackResult = service.GetFeedback( feedbackId: feedbackId, model: compareComplyModel ); service.WithHeader("X-Watson-Test", "1"); var deleteFeedbackResult = service.DeleteFeedback( feedbackId: feedbackId ); Assert.IsNotNull(deleteFeedbackResult.Result.Status); Assert.IsNotNull(getFeedbackResult.Result.FeedbackId); Assert.IsNotNull(addFeedbackResult.Result.FeedbackId); Assert.IsNotNull(ListFeedbackResult.Result.Feedback); }
public IEnumerator TestAddFeedback() { Log.Debug("CompareComplyServiceV1IntegrationTests", "Attempting to AddFeedback..."); FeedbackReturn addFeedbackResponse = null; #region feedbackData var feedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, 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.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelValue.RESPONSIBILITIES, ProvenanceIds = new List <string>() { } }, new Category() { Label = Category.LabelValue.AMENDMENTS, ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelValue.RESPONSIBILITIES, }, new Category() { Label = Category.LabelValue.AUDITS } } } }; #endregion service.AddFeedback( callback: (DetailedResponse <FeedbackReturn> response, IBMError error) => { Log.Debug("CompareComplyServiceV1IntegrationTests", "AddFeedback result: {0}", response.Response); addFeedbackResponse = response.Result; createdFeedbackId = addFeedbackResponse.FeedbackId; Assert.IsNotNull(addFeedbackResponse); Assert.IsNotNull(createdFeedbackId); Assert.IsNull(error); }, feedbackData: feedbackData, userId: "user_id_123x", comment: "Test feedback comment" ); while (addFeedbackResponse == null) { yield return(null); } }
public void AddFeedback() { IamConfig config = new IamConfig( apikey: apikey ); CompareComplyService service = new CompareComplyService(versionDate, config); service.SetEndpoint(url); #region feedbackData FeedbackDataInput feedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, 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.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnumValue.RESPONSIBILITIES, ProvenanceIds = new List <string>() { } }, new Category() { Label = Category.LabelEnumValue.AMENDMENTS, ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnumValue.RESPONSIBILITIES, }, new Category() { Label = Category.LabelEnumValue.AUDITS } } } }; #endregion var result = service.AddFeedback( feedbackData: feedbackData, userId: "user_id_123x", comment: "Test feedback comment" ); feedbackId = result.Result.FeedbackId; Console.WriteLine(result.Response); }
public void Feedback_Success() { DateTime before = DateTime.Now; DateTime after = new DateTime(2018, 11, 13); var ListFeedbackResult = service.ListFeedback( feedbackType: "element_classification", before: before, after: after, documentTitle: "doc title", modelId: "contracts", modelVersion: "11.00", categoryRemoved: "categoryRemoved", categoryAdded: "categoryAdded", categoryNotChanged: "categoryUnchanged", typeRemoved: "nature:party", typeAdded: "nature:party", typeNotChanged: "nature:party", pageLimit: 3, sort: "sort" ); FeedbackInput feedbackData = new FeedbackInput() { UserId = "user_id_123x", Comment = "Test feedback comment", FeedbackData = new FeedbackDataInput() { FeedbackType = "element_classification", Document = new ShortDoc() { Hash = "", Title = "doc title" }, ModelId = "contracts", ModelVersion = "11.00", Location = new Location() { Begin = 241, End = 237 }, 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.", OriginalLabels = new OriginalLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } }, new TypeLabel() { Label = new Label() { Nature = "End User", Party = "Exclusion" }, ProvenanceIds = new List <string>() { "85f5981a-ba91-44f5-9efa-0bd22e64b7bc", "ce0480a1-5ef1-4c3e-9861-3743b5610795" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnum.RESPONSIBILITIES, ProvenanceIds = new List <string>() { } }, new Category() { Label = Category.LabelEnum.AMENDMENTS, ProvenanceIds = new List <string>() { } } } }, UpdatedLabels = new UpdatedLabelsIn() { Types = new List <TypeLabel>() { new TypeLabel() { Label = new Label() { Nature = "Obligation", Party = "IBM" } }, new TypeLabel() { Label = new Label() { Nature = "Disclaimer", Party = "buyer" } } }, Categories = new List <Category>() { new Category() { Label = Category.LabelEnum.RESPONSIBILITIES, }, new Category() { Label = Category.LabelEnum.AUDITS } } } } }; var addFeedbackResult = service.AddFeedback(feedbackData); string feedbackId = addFeedbackResult.FeedbackId; // temporary fix for a bug requiring `x-watson-metadata` header Dictionary <string, object> customData = new Dictionary <string, object>(); Dictionary <string, string> customHeaders = new Dictionary <string, string>(); customHeaders.Add("x-watson-metadata", "customer_id=sdk-test-customer-id"); customData.Add(Constants.CUSTOM_REQUEST_HEADERS, customHeaders); var getFeedbackResult = service.GetFeedback(feedbackId, customData: customData); var deleteFeedbackResult = service.DeleteFeedback(feedbackId); Assert.IsNotNull(deleteFeedbackResult); Assert.IsNotNull(getFeedbackResult); Assert.IsNotNull(addFeedbackResult); Assert.IsNotNull(ListFeedbackResult); }