//[TestMethod]
        public void Batches_Success()
        {
            var    getBatchesResult = service.ListBatches();
            string batchId          = "";

            using (FileStream fsInput = File.OpenRead(objectStorageCredentialsInputFilepath))
            {
                using (FileStream fsOutput = File.OpenRead(objectStorageCredentialsOutputFilepath))
                {
                    var createBatchResult = service.CreateBatch(
                        "html_conversion",
                        fsInput,
                        "us-south",
                        "compare-comply-integration-test-bucket-input",
                        fsOutput,
                        "us-south",
                        "compare-comply-integration-test-bucket-output"
                        );
                    batchId = createBatchResult.BatchId;
                    Assert.IsNotNull(createBatchResult);
                    Assert.IsTrue(!string.IsNullOrEmpty(createBatchResult.BatchId));
                }
            }

            var getBatchResult    = service.GetBatch(batchId);
            var updateBatchResult = service.UpdateBatch(batchId, "rescan");

            Assert.IsNotNull(updateBatchResult);
            Assert.IsNotNull(getBatchResult);
            Assert.IsTrue(getBatchResult.BatchId == batchId);
            Assert.IsTrue(getBatchesResult._Batches != null);
            Assert.IsNotNull(getBatchesResult);
        }
        public void CreateBatch_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 function              = "function";
            var inputCredentialsFile  = new MemoryStream();
            var inputBucketLocation   = "inputBucketLocation";
            var inputBucketName       = "inputBucketName";
            var outputCredentialsFile = new MemoryStream();
            var outputBucketLocation  = "outputBucketLocation";
            var outputBucketName      = "outputBucketName";
            var model = "model";

            var result = service.CreateBatch(function: function, inputCredentialsFile: inputCredentialsFile, inputBucketLocation: inputBucketLocation, inputBucketName: inputBucketName, outputCredentialsFile: outputCredentialsFile, outputBucketLocation: outputBucketLocation, outputBucketName: outputBucketName, model: model);

            request.Received().WithArgument("version", versionDate);
        }
Ejemplo n.º 3
0
        public void Batches_Success()
        {
            service.WithHeader("X-Watson-Test", "1");
            var    getBatchesResult = service.ListBatches();
            string batchId          = "";

            using (FileStream fsInput = File.OpenRead(objectStorageCredentialsInputFilepath))
            {
                using (FileStream fsOutput = File.OpenRead(objectStorageCredentialsOutputFilepath))
                {
                    using (MemoryStream msInput = new MemoryStream())
                    {
                        using (MemoryStream msOutput = new MemoryStream())
                        {
                            fsInput.CopyTo(msInput);
                            fsOutput.CopyTo(msOutput);
                            service.WithHeader("X-Watson-Test", "1");
                            var createBatchResult = service.CreateBatch(
                                function: "html_conversion",
                                inputCredentialsFile: msInput,
                                inputBucketLocation: "us-south",
                                inputBucketName: "compare-comply-integration-test-bucket-input",
                                outputCredentialsFile: msOutput,
                                outputBucketLocation: "us-south",
                                outputBucketName: "compare-comply-integration-test-bucket-output"
                                );

                            batchId = createBatchResult.Result.BatchId;
                            Assert.IsNotNull(createBatchResult.Result);
                            Assert.IsTrue(!string.IsNullOrEmpty(createBatchResult.Result.BatchId));
                        }
                    }
                }
            }

            service.WithHeader("X-Watson-Test", "1");
            var getBatchResult = service.GetBatch(
                batchId: batchId
                );

            service.WithHeader("X-Watson-Test", "1");
            var updateBatchResult = service.UpdateBatch(
                batchId: batchId,
                action: "rescan",
                model: compareComplyModel
                );

            Assert.IsNotNull(updateBatchResult);
            Assert.IsNotNull(getBatchResult);
            Assert.IsTrue(getBatchResult.Result.BatchId == batchId);
            Assert.IsTrue(getBatchesResult.Result._Batches != null);
            Assert.IsNotNull(getBatchesResult);
        }
Ejemplo n.º 4
0
        public IEnumerator TestCreateBatch()
        {
            Log.Debug("CompareComplyServiceV1IntegrationTests", "Attempting to CreateBatch...");
            BatchStatus createBatchResponse = null;

            using (FileStream fsInput = File.OpenRead(objectStorageCredentialsInputFilepath))
            {
                using (FileStream fsOutput = File.OpenRead(objectStorageCredentialsOutputFilepath))
                {
                    using (MemoryStream msInput = new MemoryStream())
                    {
                        using (MemoryStream msOutput = new MemoryStream())
                        {
                            fsInput.CopyTo(msInput);
                            fsOutput.CopyTo(msOutput);
                            service.CreateBatch(
                                callback: (DetailedResponse <BatchStatus> response, IBMError error) =>
                            {
                                Log.Debug("CompareComplyServiceV1IntegrationTests", "CreateBatch result: {0}", response.Response);
                                createBatchResponse = response.Result;
                                createdBatchId      = createBatchResponse.BatchId;
                                Assert.IsNotNull(createBatchResponse);
                                Assert.IsNotNull(createdBatchId);
                                Assert.IsNull(error);
                            },
                                function: "html_conversion",
                                inputCredentialsFile: msInput,
                                inputBucketLocation: "us-south",
                                inputBucketName: "compare-comply-integration-test-bucket-input",
                                outputCredentialsFile: msOutput,
                                outputBucketLocation: "us-south",
                                outputBucketName: "compare-comply-integration-test-bucket-output",
                                model: "contracts"
                                );
                        }
                    }
                }
            }
            while (createBatchResponse == null)
            {
                yield return(null);
            }
        }
Ejemplo n.º 5
0
        public void CreateBatch()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            CompareComplyService service = new CompareComplyService(versionDate, config);

            service.SetEndpoint(url);

            using (FileStream fsInput = File.OpenRead(objectStorageCredentialsInputFilepath))
            {
                using (FileStream fsOutput = File.OpenRead(objectStorageCredentialsOutputFilepath))
                {
                    using (MemoryStream msInput = new MemoryStream())
                    {
                        using (MemoryStream msOutput = new MemoryStream())
                        {
                            fsInput.CopyTo(msInput);
                            fsOutput.CopyTo(msOutput);
                            var result = service.CreateBatch(
                                function: "html_conversion",
                                inputCredentialsFile: msInput,
                                inputBucketLocation: "us-south",
                                inputBucketName: "compare-comply-integration-test-bucket-input",
                                outputCredentialsFile: msOutput,
                                outputBucketLocation: "us-south",
                                outputBucketName: "compare-comply-integration-test-bucket-output"
                                );

                            batchId = result.Result.BatchId;
                            Console.WriteLine(result.Response);
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void CreateBatch()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            CompareComplyService service = new CompareComplyService(tokenOptions, versionDate);

            using (FileStream fsInput = File.OpenRead(objectStorageCredentialsInputFilepath))
            {
                using (FileStream fsOutput = File.OpenRead(objectStorageCredentialsOutputFilepath))
                {
                    using (MemoryStream msInput = new MemoryStream())
                    {
                        using (MemoryStream msOutput = new MemoryStream())
                        {
                            fsInput.CopyTo(msInput);
                            fsOutput.CopyTo(msOutput);
                            var result = service.CreateBatch(
                                function: "html_conversion",
                                inputCredentialsFile: msInput,
                                inputBucketLocation: "us-south",
                                inputBucketName: "compare-comply-integration-test-bucket-input",
                                outputCredentialsFile: msOutput,
                                outputBucketLocation: "us-south",
                                outputBucketName: "compare-comply-integration-test-bucket-output"
                                );

                            batchId = result.Result.BatchId;
                            Console.WriteLine(result.Response);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void CreateBatch()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

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

            service.SetServiceUrl("{serviceUrl}");

            using (FileStream fsInput = File.OpenRead("{object-storage-input-credentials-filepath}"))
            {
                using (FileStream fsOutput = File.OpenRead("{object-storage-output-credentials-filepath}"))
                {
                    using (MemoryStream msInput = new MemoryStream())
                    {
                        using (MemoryStream msOutput = new MemoryStream())
                        {
                            fsInput.CopyTo(msInput);
                            fsOutput.CopyTo(msOutput);
                            var result = service.CreateBatch(
                                function: "html_conversion",
                                inputCredentialsFile: msInput,
                                inputBucketLocation: "us-south",
                                inputBucketName: "bucket-input",
                                outputCredentialsFile: msOutput,
                                outputBucketLocation: "us-south",
                                outputBucketName: "bucket-output"
                                );

                            batchId = result.Result.BatchId;
                            Console.WriteLine(result.Response);
                        }
                    }
                }
            }
        }