public void ListFeedback_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

            client.GetAsync(Arg.Any <string>())
            .Returns(request);

            CompareComplyService service = new CompareComplyService(client);
            var versionDate = "versionDate";

            service.VersionDate = versionDate;

            var      feedbackType       = "feedbackType";
            DateTime?before             = DateTime.MaxValue;
            DateTime?after              = DateTime.MaxValue;
            var      documentTitle      = "documentTitle";
            var      modelId            = "modelId";
            var      modelVersion       = "modelVersion";
            var      categoryRemoved    = "categoryRemoved";
            var      categoryAdded      = "categoryAdded";
            var      categoryNotChanged = "categoryNotChanged";
            var      typeRemoved        = "typeRemoved";
            var      typeAdded          = "typeAdded";
            var      typeNotChanged     = "typeNotChanged";
            long?    pageLimit          = 1;
            var      cursor             = "cursor";
            var      sort         = "sort";
            var      includeTotal = false;

            var result = service.ListFeedback(feedbackType: feedbackType, before: before, after: after, documentTitle: documentTitle, modelId: modelId, modelVersion: modelVersion, categoryRemoved: categoryRemoved, categoryAdded: categoryAdded, categoryNotChanged: categoryNotChanged, typeRemoved: typeRemoved, typeAdded: typeAdded, typeNotChanged: typeNotChanged, pageLimit: pageLimit, cursor: cursor, sort: sort, includeTotal: includeTotal);

            request.Received().WithArgument("version", versionDate);
        }
Ejemplo n.º 2
0
        public void ListFeedback()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            CompareComplyService service = new CompareComplyService("2018-10-15", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var result = service.ListFeedback();

            Console.WriteLine(result.Response);
        }
Ejemplo n.º 3
0
        public void ListFeedback()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            CompareComplyService service = new CompareComplyService(versionDate, config);

            service.SetEndpoint(url);

            var result = service.ListFeedback();

            Console.WriteLine(result.Response);
        }
Ejemplo n.º 4
0
        public void ListFeedback()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            CompareComplyService service = new CompareComplyService(tokenOptions, versionDate);

            var result = service.ListFeedback();

            Console.WriteLine(result.Response);
        }
Ejemplo n.º 5
0
        public IEnumerator TestListFeedback()
        {
            Log.Debug("CompareComplyServiceV1IntegrationTests", "Attempting to ListFeedback...");
            FeedbackList listFeedbackResponse = null;

            service.ListFeedback(
                callback: (DetailedResponse <FeedbackList> response, IBMError error) =>
            {
                Log.Debug("CompareComplyServiceV1IntegrationTests", "ListFeedback result: {0}", response.Response);
                listFeedbackResponse = response.Result;
                Assert.IsNotNull(listFeedbackResponse);
                Assert.IsNotNull(listFeedbackResponse.Feedback);
                Assert.IsTrue(listFeedbackResponse.Feedback.Count > 0);
                Assert.IsNull(error);
            },
                feedbackType: "element_classification",
                includeTotal: true
                );

            while (listFeedbackResponse == null)
            {
                yield return(null);
            }
        }
Ejemplo n.º 6
0
        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 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);
        }