< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: AsyncResponse.Transports.GooglePubSub.GooglePubSubCorrelationIdExtractor
Assembly: AsyncResponse.Transports.GooglePubSub
File(s): /_/src/Transports/AsyncResponse.Transports.GooglePubSub/GooglePubSubCorrelationIdExtractor.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 27
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Extract(...)100%66100%

File(s)

/_/src/Transports/AsyncResponse.Transports.GooglePubSub/GooglePubSubCorrelationIdExtractor.cs

#LineLine coverage
 1using Google.Cloud.PubSub.V1;
 2
 3namespace AsyncResponse.Transports.GooglePubSub;
 4
 5/// <summary>
 6/// Extracts the AsyncResponse correlation id from an inbound response message: first from the
 7/// configured message attribute, then from the JSON body via the configured paths (walked by the
 8/// shared <see cref="CorrelationIdJsonPaths"/>).
 9/// </summary>
 10internal static class GooglePubSubCorrelationIdExtractor
 11{
 12    /// <summary>Extracts the correlation id from the supplied message.</summary>
 13    public static string? Extract(
 14        PubsubMessage message,
 15        string messageJson,
 16        GooglePubSubAsyncResponseOptions options)
 17    {
 3018        if (!string.IsNullOrWhiteSpace(options.CorrelationIdAttribute)
 3019            && message.Attributes.TryGetValue(options.CorrelationIdAttribute, out var attributeValue)
 3020            && !string.IsNullOrWhiteSpace(attributeValue))
 21        {
 422            return attributeValue;
 23        }
 24
 2625        return CorrelationIdJsonPaths.Extract(messageJson, options.CorrelationIdJsonPaths);
 26    }
 27}