コード例 #1
0
ファイル: BatchService.cs プロジェクト: BakanaCI/Bakana
        public async Task <GetBatchResponse> Get(GetBatchRequest request)
        {
            var batch = await batchRepository.Get(request.BatchId);

            if (batch == null)
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            return(batch.ConvertTo <GetBatchResponse>());
        }
コード例 #2
0
 /// <summary>Snippet for GetBatch</summary>
 public void GetBatchRequestObject()
 {
     // Snippet: GetBatch(GetBatchRequest, CallSettings)
     // Create client
     BatchControllerClient batchControllerClient = BatchControllerClient.Create();
     // Initialize request argument(s)
     GetBatchRequest request = new GetBatchRequest
     {
         BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
     };
     // Make the request
     Batch response = batchControllerClient.GetBatch(request);
     // End snippet
 }
コード例 #3
0
        public async stt::Task GetBatchRequestObjectAsync()
        {
            moq::Mock <BatchController.BatchControllerClient> mockGrpcClient = new moq::Mock <BatchController.BatchControllerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetBatchRequest request = new GetBatchRequest
            {
                BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
            };
            Batch expectedResponse = new Batch
            {
                BatchName     = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
                Uuid          = "uuid6f877cef",
                CreateTime    = new wkt::Timestamp(),
                PysparkBatch  = new PySparkBatch(),
                SparkBatch    = new SparkBatch(),
                SparkRBatch   = new SparkRBatch(),
                SparkSqlBatch = new SparkSqlBatch(),
                RuntimeInfo   = new RuntimeInfo(),
                State         = Batch.Types.State.Failed,
                StateMessage  = "state_message46cf28c0",
                StateTime     = new wkt::Timestamp(),
                Creator       = "creator253324ee",
                Labels        =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                RuntimeConfig     = new RuntimeConfig(),
                EnvironmentConfig = new EnvironmentConfig(),
                Operation         = "operation615a23f7",
                StateHistory      =
                {
                    new Batch.Types.StateHistory(),
                },
            };

            mockGrpcClient.Setup(x => x.GetBatchAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Batch>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            BatchControllerClient client = new BatchControllerClientImpl(mockGrpcClient.Object, null);
            Batch responseCallSettings   = await client.GetBatchAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Batch responseCancellationToken = await client.GetBatchAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #4
0
ファイル: BatchServiceTests.cs プロジェクト: BakanaCI/Bakana
        public void Get_Batch_Should_Throw_With_Invalid_Batch_Id()
        {
            // Arrange
            batchRepository.Get(Arg.Any <string>()).ReturnsNull();

            var request = new GetBatchRequest
            {
                BatchId = TestBatchId
            };

            // Act / Assert
            var exception = Assert.ThrowsAsync <HttpError>(() => Sut.Get(request));

            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound.ToString());
            exception.Message.Should().Be("Batch TestBatch not found");
        }
コード例 #5
0
        /// <summary>Snippet for GetBatchAsync</summary>
        public async Task GetBatchRequestObjectAsync()
        {
            // Snippet: GetBatchAsync(GetBatchRequest, CallSettings)
            // Additional: GetBatchAsync(GetBatchRequest, CancellationToken)
            // Create client
            BatchControllerClient batchControllerClient = await BatchControllerClient.CreateAsync();

            // Initialize request argument(s)
            GetBatchRequest request = new GetBatchRequest
            {
                BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
            };
            // Make the request
            Batch response = await batchControllerClient.GetBatchAsync(request);

            // End snippet
        }
コード例 #6
0
ファイル: BatchServiceTests.cs プロジェクト: BakanaCI/Bakana
        public async Task It_Should_Get_Batch()
        {
            // Arrange
            var batch = TestData.Entities.Batches.FullyPopulated;

            batch.Id = TestBatchId;
            batchRepository.Get(Arg.Any <string>()).Returns(batch);

            var request = new GetBatchRequest
            {
                BatchId = TestBatchId
            };

            // Act
            var response = await Sut.Get(request);

            // Assert
            response.Should().BeEquivalentTo(TestData.DomainModels.Batches.FullyPopulated);
        }