/// <summary>
        /// Discover a library in a project by name.
        /// </summary>
        /// <param name="projectId">The ID of the project in which to discover the library.</param>
        /// <param name="libraryName">The name of the library to discover.</param>
        /// <returns>The ID of the discovered library.</returns>
        private async Task <string> DiscoverProjectLibrary(string projectId, string libraryName)
        {
            IList <string> projectLibraryIDs = await GetAllProjectLibraries(projectId).ConfigureAwait(false);

            foreach (string libraryID in projectLibraryIDs)
            {
                var getLibraryRequest = new GetLibraryRequest
                {
                    LibraryId = libraryID,
                };

                Console.WriteLine($"Getting library with LibraryId={getLibraryRequest.LibraryId}...");

                Library library = await this.psetClient.GetLibraryAsync(getLibraryRequest).ConfigureAwait(false);

                Console.Write($"Got library: ");
                this.PrintLibrary(library);
                Console.WriteLine();

                if (library.Name == libraryName)
                {
                    Console.WriteLine("Library discovered!");

                    return(library.Id);
                }
                else
                {
                    Console.WriteLine("Not a match.");
                }
            }

            return(null);
        }
Пример #2
0
        public async Task SendLargeRequest_SuccessResponse()
        {
            // Arrage
            var httpClient = CreateGrpcWebClient();
            var channel    = GrpcChannel.ForAddress(httpClient.BaseAddress !, new GrpcChannelOptions
            {
                HttpClient    = httpClient,
                LoggerFactory = LoggerFactory
            });

            var client  = new IssueService.IssueServiceClient(channel);
            var request = new GetLibraryRequest();

            request.UserId     = "admin";
            request.SearchTerm = string.Empty;
            for (var i = 0; i < 4096; i++)
            {
                request.Carriers.Add(i.ToString());
            }

            try
            {
                // Act
                var response = await client.GetLibraryAsync(request).ResponseAsync.DefaultTimeout();

                // Assert
                Assert.AreEqual("admin", response.UserId);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Error for {GrpcTestMode}-{EndpointName}", ex);
            }
        }
Пример #3
0
        public async Task SendLargeRequest_SuccessResponse()
        {
            // Arrage
            var httpClient = CreateGrpcWebClient();
            var channel    = GrpcChannel.ForAddress(httpClient.BaseAddress, new GrpcChannelOptions
            {
                HttpClient    = httpClient,
                LoggerFactory = LoggerFactory
            });

            var client  = new IssueService.IssueServiceClient(channel);
            var request = new GetLibraryRequest();

            request.UserId     = "admin";
            request.SearchTerm = string.Empty;
            for (var i = 0; i < 4096; i++)
            {
                request.Carriers.Add(i.ToString());
            }

            // Act
            var response = await client.GetLibraryAsync(request);

            // Assert
            Assert.AreEqual("admin", response.UserId);
        }
Пример #4
0
        public override Task <GetLibraryResponse> GetLibrary(GetLibraryRequest request, ServerCallContext context)
        {
            GetLibraryResponse response = new GetLibraryResponse();

            response.UserId     = request.UserId;
            response.SearchTerm = request.SearchTerm;
            response.Carriers.AddRange(request.Carriers);

            return(Task.FromResult(response));
        }
Пример #5
0
        /// <summary>
        /// Discover a library in a project by name.
        /// </summary>
        /// <param name="projectId">The ID of the project in which to discover the library.</param>
        /// <param name="libraryName">The name of the library to discover.</param>
        /// <returns>The ID of the discovered library.</returns>
        private async Task <string> DiscoverLibrary(string projectId, string libraryName)
        {
            var getNodeLinksRequest = new GetNodeLinksRequest
            {
                ForestId = string.Format(ProjectDataForestIDPattern, projectId),
                TreeId   = DiscoveryTreeID,
                NodeId   = DiscoveryTreeRootNodeID,
            };

            Console.WriteLine($"Getting the links of the project discovery tree root node (ProjectId={projectId}, ForestId={getNodeLinksRequest.ForestId}, TreeId={getNodeLinksRequest.TreeId}, NodeId={getNodeLinksRequest.NodeId})...");

            var discoveryTreeRootNodeLinks = await this.orgClient.GetNodeLinksAsync(getNodeLinksRequest).ConfigureAwait(false);

            Console.WriteLine($"Got {discoveryTreeRootNodeLinks.Count} links:");
            discoveryTreeRootNodeLinks.ToList().ForEach(link => Console.WriteLine(link));

            foreach (string link in discoveryTreeRootNodeLinks)
            {
                if (!link.StartsWith(DiscoveryTreeRootNodeLinkPrefix))
                {
                    throw new InvalidDataException("Project discovery tree root node link is in unexpected format.");
                }

                var getLibraryRequest = new GetLibraryRequest
                {
                    LibraryId = link.Substring(DiscoveryTreeRootNodeLinkPrefix.Length, link.Length - DiscoveryTreeRootNodeLinkPrefix.Length),
                };

                Console.WriteLine($"Getting library with LibraryId={getLibraryRequest.LibraryId}...");

                Library library = await this.psetClient.GetLibraryAsync(getLibraryRequest).ConfigureAwait(false);

                Console.Write($"Got library: ");
                this.PrintLibrary(library);
                Console.WriteLine();

                if (library.Name == libraryName)
                {
                    Console.WriteLine("Library discovered!");

                    return(library.Id);
                }
                else
                {
                    Console.WriteLine("Not a match.");
                }
            }

            return(null);
        }
Пример #6
0
        /// <summary>
        /// Gets the specified library.
        /// </summary>
        /// <param name="libraryID">The ID of the library.</param>
        /// <returns>The library to get.</returns>
        private async Task <Library> GetLibrary(string libraryID)
        {
            var getLibraryRequest = new GetLibraryRequest
            {
                LibraryId = libraryID,
            };

            Console.WriteLine($"Getting library with LibraryId={getLibraryRequest.LibraryId}...");

            Library library = await this.psetClient.GetLibraryAsync(getLibraryRequest).ConfigureAwait(false);

            Console.Write($"Got library: ");
            this.PrintLibrary(library);
            Console.WriteLine();

            return(library);
        }