From 2cd6c20908ab660a8c4f250bb4b36a9ec855aad4 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Mon, 28 Oct 2024 16:04:20 +0000 Subject: [PATCH 1/5] feat: add property to customize universe domain in Pub/Sub --- .../pubsub/GcpPubSubAutoConfiguration.java | 1 + .../GcpPubSubAutoConfigurationTests.java | 34 ++++++++++++++++ .../pubsub/core/PubSubConfiguration.java | 40 +++++++++++++++++++ .../support/DefaultPublisherFactory.java | 10 +++++ .../support/DefaultSubscriberFactory.java | 19 +++++++++ .../DefaultSubscriberFactoryTests.java | 12 ++++-- 6 files changed, 112 insertions(+), 4 deletions(-) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java index 0dab08655c..d8c3d30162 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java @@ -373,6 +373,7 @@ public PublisherFactory defaultPublisherFactory( batchingSettings.ifAvailable(factory::setBatchingSettings); factory.setEnableMessageOrdering(gcpPubSubProperties.getPublisher().getEnableMessageOrdering()); factory.setEndpoint(gcpPubSubProperties.getPublisher().getEndpoint()); + factory.setUniverseDomain(gcpPubSubProperties.getPublisher().getUniverseDomain()); List customizers = customizersProvider.orderedStream() .collect(Collectors.toList()); diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java index 86a16d8621..25ebb9cc88 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java @@ -1412,6 +1412,40 @@ void flowControlSettings_multipleKeysForSameSubscription_firstOneUsed(CapturedOu }); } + @Test + void universeDomain_selectiveConfigurationSet() { + contextRunner + .withPropertyValues( + "spring.cloud.gcp.pubsub.subscription.subscription-name.universe-domain=example.com") + .run( + ctx -> { + GcpPubSubProperties gcpPubSubProperties = ctx.getBean(GcpPubSubProperties.class); + GcpProjectIdProvider projectIdProvider = ctx.getBean(GcpProjectIdProvider.class); + + assertThat( + gcpPubSubProperties.computeSubscriberUniverseDomain( + "subscription-name", projectIdProvider.getProjectId())) + .isEqualTo("example.com"); + }); + } + + @Test + void universeDomain_globalAndSelectiveConfigurationSet_selectiveTakesPrecedence() { + contextRunner + .withPropertyValues( + "spring.cloud.gcp.pubsub.subscriber.universe-domain=example1.com", + "spring.cloud.gcp.pubsub.subscription.subscription-name.universe-domain=example2.com") + .run( + ctx -> { + GcpPubSubProperties gcpPubSubProperties = ctx.getBean(GcpPubSubProperties.class); + GcpProjectIdProvider projectIdProvider = ctx.getBean(GcpProjectIdProvider.class); + + assertThat( + gcpPubSubProperties.computeSubscriberUniverseDomain( + "subscription-name", projectIdProvider.getProjectId())) + .isEqualTo("example2.com"); + }); + } @Configuration static class CustomizerConfig { diff --git a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/core/PubSubConfiguration.java b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/core/PubSubConfiguration.java index 6934eced90..4faec0f4c7 100644 --- a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/core/PubSubConfiguration.java +++ b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/core/PubSubConfiguration.java @@ -291,6 +291,22 @@ public String computePullEndpoint(String subscriptionName, String projectId) { return pullEndpoint != null ? pullEndpoint : this.globalSubscriber.getPullEndpoint(); } + /** + * Returns the universe domain. The subscription-specific property takes precedence if both global + * and subscription-specific properties are set. If subscription-specific configuration is not set + * then the global configuration is picked. + * + * @param subscriptionName subscription name + * @param projectId project id + * @return pull endpoint + */ + public String computeSubscriberUniverseDomain(String subscriptionName, String projectId) { + String universeDomain = + getSubscriptionProperties(PubSubSubscriptionUtils.toProjectSubscriptionName(subscriptionName, projectId)) + .getUniverseDomain(); + return universeDomain != null ? universeDomain : this.globalSubscriber.getUniverseDomain(); + } + /** * Computes the retry settings. The subscription-specific property takes precedence if both global * and subscription-specific properties are set. If subscription-specific settings are not set @@ -384,6 +400,8 @@ public static class Publisher { /** Set publisher endpoint. Example: "us-east1-pubsub.googleapis.com:443". */ private String endpoint; + private String universeDomain; + public Batching getBatching() { return this.batching; } @@ -441,6 +459,14 @@ public String getEndpoint() { public void setEndpoint(String endpoint) { this.endpoint = endpoint; } + + public String getUniverseDomain() { + return universeDomain; + } + + public void setUniverseDomain(String universeDomain) { + this.universeDomain = universeDomain; + } } /** Subscriber settings. */ @@ -487,6 +513,12 @@ public static class Subscriber { /** RPC status codes that should be retried when pulling messages. */ private Code[] retryableCodes = null; + /** + * Universe domain of the client which is part of the endpoint that is formatted as + * `${service}.${universeDomain}:${port}`. + */ + private String universeDomain; + public String getFullyQualifiedName() { return fullyQualifiedName; } @@ -571,6 +603,14 @@ public int getMaxAcknowledgementThreads() { public void setMaxAcknowledgementThreads(int maxAcknowledgementThreads) { this.maxAcknowledgementThreads = maxAcknowledgementThreads; } + + public String getUniverseDomain() { + return universeDomain; + } + + public void setUniverseDomain(String universeDomain) { + this.universeDomain = universeDomain; + } } /** Health Check settings. */ diff --git a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactory.java b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactory.java index 5b5c1d62fb..7192335b58 100644 --- a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactory.java +++ b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactory.java @@ -56,6 +56,8 @@ public class DefaultPublisherFactory implements PublisherFactory { private String endpoint; + private String universeDomain; + private List customizers; /** @@ -151,6 +153,10 @@ public void setEndpoint(String endpoint) { this.endpoint = endpoint; } + public void setUniverseDomain(String universeDomain) { + this.universeDomain = universeDomain; + } + /** * Accepts a list of {@link Publisher.Builder} customizers. * The customizers are applied in the order provided, so the later customizers can override @@ -222,6 +228,10 @@ void applyPublisherSettings(Publisher.Builder publisherBuilder) { if (this.endpoint != null) { publisherBuilder.setEndpoint(this.endpoint); } + + if (this.universeDomain != null) { + publisherBuilder.setUniverseDomain(this.universeDomain); + } } void applyCustomizers(Publisher.Builder publisherBuilder, String topic) { diff --git a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java index f0f08ab6f0..74456c23a0 100644 --- a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java +++ b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java @@ -70,6 +70,8 @@ public class DefaultSubscriberFactory implements SubscriberFactory { private String pullEndpoint; + private String universeDomain; + private ApiClock apiClock; private RetrySettings subscriberStubRetrySettings; @@ -300,6 +302,12 @@ public Subscriber createSubscriber(String subscriptionName, MessageReceiver rece subscriberBuilder.setParallelPullCount(pullCount); } + String universeDomain = getUniverseDomain(subscriptionName); + if (universeDomain != null) { + subscriberBuilder.setUniverseDomain(universeDomain); + } + + Subscriber subscriber = subscriberBuilder.build(); if (shouldAddToHealthCheck) { @@ -557,6 +565,13 @@ public Code[] getRetryableCodes(String subscriptionName) { return this.pubSubConfiguration.computeRetryableCodes(subscriptionName, projectId); } + String getUniverseDomain(String subscriptionName) { + if (this.universeDomain != null) { + return this.universeDomain; + } + return this.pubSubConfiguration.computeSubscriberUniverseDomain(subscriptionName, projectId); + } + public void setExecutorProviderMap(Map executorProviderMap) { this.executorProviderMap = executorProviderMap; } @@ -582,6 +597,10 @@ public void setRetrySettingsMap(Map retr this.retrySettingsMap = retrySettingsMap; } + public void setUniverseDomain(String universeDomain){ + this.universeDomain = universeDomain; + } + public void setGlobalRetrySettings(RetrySettings retrySettings) { this.globalRetrySettings = retrySettings; } diff --git a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java index 786c25791d..cd6afaea4d 100644 --- a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java +++ b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java @@ -363,17 +363,20 @@ void testCreateSubscriber_validateSetProperties() { "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(2L); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(3L); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(4L); when(mockPubSubConfiguration.computeParallelPullCount( "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(2); when(mockPubSubConfiguration.computePullEndpoint( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn("test.endpoint"); + when(mockPubSubConfiguration.computeSubscriberUniverseDomain( + "defaultSubscription", projectIdProvider.getProjectId())) + .thenReturn("example.com"); Subscriber expectedSubscriber = factory.createSubscriber("defaultSubscription", (message, consumer) -> {}); @@ -385,7 +388,8 @@ void testCreateSubscriber_validateSetProperties() { .hasFieldOrPropertyWithValue("minDurationPerAckExtension", Duration.ofSeconds(3L)) .hasFieldOrPropertyWithValue("maxDurationPerAckExtension", Duration.ofSeconds(4L)) .hasFieldOrPropertyWithValue("numPullers", 2) - .hasFieldOrPropertyWithValue("subStubSettings.endpoint", "test.endpoint"); + .hasFieldOrPropertyWithValue("subStubSettings.endpoint", "test.endpoint") + .hasFieldOrPropertyWithValue("universeDomain", "example.com"); } @Test From 6d6b6508452564a6e4f82f028193d4be361f42b3 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Mon, 28 Oct 2024 16:13:40 +0000 Subject: [PATCH 2/5] fix checkstyle --- .../cloud/spring/pubsub/support/DefaultSubscriberFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java index 74456c23a0..1ba9347b97 100644 --- a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java +++ b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactory.java @@ -597,7 +597,7 @@ public void setRetrySettingsMap(Map retr this.retrySettingsMap = retrySettingsMap; } - public void setUniverseDomain(String universeDomain){ + public void setUniverseDomain(String universeDomain) { this.universeDomain = universeDomain; } From 7b3421e3ec00184aec6118dadfe09916bca171d7 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Mon, 28 Oct 2024 21:19:00 +0000 Subject: [PATCH 3/5] add unit testing --- .../GcpPubSubAutoConfigurationTests.java | 18 ++- .../support/DefaultPublisherFactoryTests.java | 1 - .../DefaultSubscriberFactoryTests.java | 103 +++++++++--------- 3 files changed, 68 insertions(+), 54 deletions(-) diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java index 25ebb9cc88..b79c80b2f1 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java @@ -1413,7 +1413,7 @@ void flowControlSettings_multipleKeysForSameSubscription_firstOneUsed(CapturedOu } @Test - void universeDomain_selectiveConfigurationSet() { + void subscriberUniverseDomain_selectiveConfigurationSet() { contextRunner .withPropertyValues( "spring.cloud.gcp.pubsub.subscription.subscription-name.universe-domain=example.com") @@ -1430,7 +1430,7 @@ void universeDomain_selectiveConfigurationSet() { } @Test - void universeDomain_globalAndSelectiveConfigurationSet_selectiveTakesPrecedence() { + void subscriberUniverseDomain_globalAndSelectiveConfigurationSet_selectiveTakesPrecedence() { contextRunner .withPropertyValues( "spring.cloud.gcp.pubsub.subscriber.universe-domain=example1.com", @@ -1447,6 +1447,20 @@ void universeDomain_globalAndSelectiveConfigurationSet_selectiveTakesPrecedence( }); } + @Test + void publisherUniverseDomain() { + contextRunner + .withPropertyValues("spring.cloud.gcp.pubsub.publisher.universe-domain=example.com") + .run( + ctx -> { + GcpPubSubProperties gcpPubSubProperties = ctx.getBean(GcpPubSubProperties.class); + CachingPublisherFactory publisherFactory = + ctx.getBean("defaultPublisherFactory", CachingPublisherFactory.class); + assertThat(gcpPubSubProperties.getPublisher().getUniverseDomain()) + .isEqualTo("example.com"); + }); + } + @Configuration static class CustomizerConfig { diff --git a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java index 1fc4e7df42..6c8200b246 100644 --- a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java +++ b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java @@ -56,7 +56,6 @@ public void setUp() throws IOException { @Test void testGetPublisher() { - Publisher publisher = factory.createPublisher("testTopic"); assertThat(((ProjectTopicName) publisher.getTopicName()).getTopic()).isEqualTo("testTopic"); diff --git a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java index cd6afaea4d..77c7e55415 100644 --- a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java +++ b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java @@ -84,7 +84,8 @@ void setUp() { @Test void testNewSubscriber() { - DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); + DefaultSubscriberFactory factory = + new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); factory.setCredentialsProvider(this.credentialsProvider); Subscriber subscriber = factory.createSubscriber("midnight cowboy", (message, consumer) -> {}); @@ -110,25 +111,24 @@ void testNewSubscriber_constructorWithPubSubConfiguration() { void testNewSubscriber_constructorWithPubSubConfiguration_nullPubSubConfiguration() { assertThatThrownBy(() -> new DefaultSubscriberFactory(() -> "angeldust", null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The pub/sub configuration can't be null."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The pub/sub configuration can't be null."); } @Test void testNewDefaultSubscriberFactory_nullProjectProvider() { assertThatThrownBy(() -> new DefaultSubscriberFactory(null, pubSubConfig)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The project ID provider can't be null."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The project ID provider can't be null."); } @Test void testNewDefaultSubscriberFactory_nullProject() { assertThatThrownBy(() -> new DefaultSubscriberFactory(() -> null, pubSubConfig)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The project ID can't be null or empty."); - + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The project ID can't be null or empty."); } @Test @@ -137,8 +137,8 @@ void testCreatePullRequest_greaterThanZeroMaxMessages() { factory.setCredentialsProvider(this.credentialsProvider); assertThatThrownBy(() -> factory.createPullRequest("test", -1, true)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The maxMessages must be greater than 0."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The maxMessages must be greater than 0."); } @Test @@ -163,9 +163,11 @@ void testGetExecutorProvider_presentInMap() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); - ConcurrentHashMap executorProviderMap = new ConcurrentHashMap<>(); + ConcurrentHashMap executorProviderMap = + new ConcurrentHashMap<>(); executorProviderMap.put( - ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), mockExecutorProvider); + ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), + mockExecutorProvider); factory.setExecutorProviderMap(executorProviderMap); assertThat(factory.getExecutorProvider("subscription-name")).isSameAs(mockExecutorProvider); @@ -176,9 +178,11 @@ void testGetExecutorProvider_fullyQualifiedNameNotInMap_pickGlobal() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); - ConcurrentHashMap executorProviderMap = new ConcurrentHashMap<>(); + ConcurrentHashMap executorProviderMap = + new ConcurrentHashMap<>(); executorProviderMap.put( - ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), mockExecutorProvider); + ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), + mockExecutorProvider); factory.setExecutorProviderMap(executorProviderMap); factory.setExecutorProvider(mockGlobalExecutorProvider); @@ -240,8 +244,11 @@ void testGetRetrySettings_presentInMap_pickSelective() { .setRpcTimeoutMultiplier(10) .setMaxRpcTimeout(Duration.ofSeconds(10)) .build(); - ConcurrentHashMap settingsMap = new ConcurrentHashMap<>(); - settingsMap.put(ProjectSubscriptionName.parse("projects/project/subscriptions/mySubscription"), expectedRetrySettings); + ConcurrentHashMap settingsMap = + new ConcurrentHashMap<>(); + settingsMap.put( + ProjectSubscriptionName.parse("projects/project/subscriptions/mySubscription"), + expectedRetrySettings); factory.setRetrySettingsMap(settingsMap); RetrySettings actualRetrySettings = factory.getRetrySettings("mySubscription"); @@ -317,8 +324,7 @@ void testBuildGlobalSubscriberStubSettings_retry_pickUserBean() throws IOExcepti } @Test - void testBuildGlobalSubscriberStubSettings_retry_pickGlobalConfiguration() - throws IOException { + void testBuildGlobalSubscriberStubSettings_retry_pickGlobalConfiguration() throws IOException { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); when(mockPubSubConfiguration.getSubscriber()).thenReturn(mockSubscriber); @@ -389,7 +395,7 @@ void testCreateSubscriber_validateSetProperties() { .hasFieldOrPropertyWithValue("maxDurationPerAckExtension", Duration.ofSeconds(4L)) .hasFieldOrPropertyWithValue("numPullers", 2) .hasFieldOrPropertyWithValue("subStubSettings.endpoint", "test.endpoint") - .hasFieldOrPropertyWithValue("universeDomain", "example.com"); + .hasFieldOrPropertyWithValue("subStubSettings.universeDomain", "example.com"); } @Test @@ -399,14 +405,11 @@ void testCreateSubscriber_invalidMinDurationPerAckExtension_throwsException() { new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); factory.setCredentialsProvider(this.credentialsProvider); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(-4L); assertThatThrownBy( - () -> factory.createSubscriber( - "defaultSubscription", - (message, consumer) -> { } - )) + () -> factory.createSubscriber("defaultSubscription", (message, consumer) -> {})) .isExactlyInstanceOf(IllegalArgumentException.class); } @@ -417,14 +420,11 @@ void testCreateSubscriber_invalidMaxDurationPerAckExtension_throwsException() { new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); factory.setCredentialsProvider(this.credentialsProvider); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(-2L); assertThatThrownBy( - () -> factory.createSubscriber( - "defaultSubscription", - (message, consumer) -> { } - )) + () -> factory.createSubscriber("defaultSubscription", (message, consumer) -> {})) .isExactlyInstanceOf(IllegalArgumentException.class); } @@ -435,17 +435,14 @@ void testCreateSubscriber_invalidDurationPerAckExtensions_throwsException() { new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); factory.setCredentialsProvider(this.credentialsProvider); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(4L); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(3L); assertThatThrownBy( - () -> factory.createSubscriber( - "defaultSubscription", - (message, consumer) -> { } - )) + () -> factory.createSubscriber("defaultSubscription", (message, consumer) -> {})) .isExactlyInstanceOf(IllegalArgumentException.class); } @@ -474,10 +471,13 @@ void testGetFlowControlSettings_presentInMap_pickSubscriptionSpecific() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); - ConcurrentHashMap settingsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap settingsMap = + new ConcurrentHashMap<>(); FlowControlSettings expectedFlowSettings = FlowControlSettings.newBuilder().setMaxOutstandingRequestBytes(10L).build(); - settingsMap.put(ProjectSubscriptionName.parse("projects/project/subscriptions/defaultSubscription1"), expectedFlowSettings); + settingsMap.put( + ProjectSubscriptionName.parse("projects/project/subscriptions/defaultSubscription1"), + expectedFlowSettings); factory.setFlowControlSettingsMap(settingsMap); FlowControlSettings actualFlowSettings = factory.getFlowControlSettings("defaultSubscription1"); @@ -543,7 +543,7 @@ void testGetMinDurationPerAckExtension_userSetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "subscription-name", projectIdProvider.getProjectId())) + "subscription-name", projectIdProvider.getProjectId())) .thenReturn(1L); assertThat(factory.getMinDurationPerAckExtension("subscription-name")) @@ -556,8 +556,9 @@ void testGetMinDurationPerAckExtension_factorySetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); - when(mockPubSubConfiguration.computeMinDurationPerAckExtension("subscription-name", - projectIdProvider.getProjectId())).thenReturn(3L); + when(mockPubSubConfiguration.computeMinDurationPerAckExtension( + "subscription-name", projectIdProvider.getProjectId())) + .thenReturn(3L); // subscription level setting is used when factory-level one is not provided assertThat(factory.getMinDurationPerAckExtension("subscription-name")) @@ -577,8 +578,9 @@ void testGetMaxDurationPerAckExtension_factorySetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); - when(mockPubSubConfiguration.computeMaxDurationPerAckExtension("subscription-name", - projectIdProvider.getProjectId())).thenReturn(3L); + when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( + "subscription-name", projectIdProvider.getProjectId())) + .thenReturn(3L); // subscription level setting is used when factory-level one is not provided assertThat(factory.getMaxDurationPerAckExtension("subscription-name")) @@ -598,8 +600,7 @@ void testGetMinDurationPerAckExtension_newConfiguration() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, this.pubSubConfig); - assertThat(factory.getMinDurationPerAckExtension("subscription-name")) - .isNull(); + assertThat(factory.getMinDurationPerAckExtension("subscription-name")).isNull(); } @Test @@ -608,7 +609,7 @@ void testGetMaxDurationPerAckExtension_userSetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "subscription-name", projectIdProvider.getProjectId())) + "subscription-name", projectIdProvider.getProjectId())) .thenReturn(2L); assertThat(factory.getMaxDurationPerAckExtension("subscription-name")) @@ -621,8 +622,7 @@ void testGetMaxDurationPerAckExtension_newConfiguration() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, this.pubSubConfig); - assertThat(factory.getMaxDurationPerAckExtension("subscription-name")) - .isNull(); + assertThat(factory.getMaxDurationPerAckExtension("subscription-name")).isNull(); } @Test @@ -755,8 +755,7 @@ void testBuildGlobalSubscriberStubSettings_retryableCodes_userProvidedValue() } @Test - void testBuildGlobalSubscriberStubSettings_retryableCodes_pickConfiguration() - throws IOException { + void testBuildGlobalSubscriberStubSettings_retryableCodes_pickConfiguration() throws IOException { GcpProjectIdProvider projectIdProvider = () -> "project"; DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); @@ -809,7 +808,8 @@ void testNewSubscriber_shouldNotAddToHealthCheck() { when(healthTrackerRegistry.isTracked(subscriptionName)).thenReturn(true); - DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); + DefaultSubscriberFactory factory = + new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); factory.setCredentialsProvider(this.credentialsProvider); factory.setHealthTrackerRegistry(healthTrackerRegistry); @@ -828,7 +828,8 @@ void testNewSubscriber_shouldAddToHealthCheck() { when(healthTrackerRegistry.isTracked(subscriptionName)).thenReturn(false); - DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); + DefaultSubscriberFactory factory = + new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); factory.setCredentialsProvider(this.credentialsProvider); factory.setHealthTrackerRegistry(healthTrackerRegistry); From d7a4e2f9222e5c68b9c80886191bc1eb69aba17d Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Tue, 29 Oct 2024 18:54:51 +0000 Subject: [PATCH 4/5] undo formatting --- .../support/DefaultPublisherFactoryTests.java | 1 + .../DefaultSubscriberFactoryTests.java | 107 +++++++++--------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java index 6c8200b246..1fc4e7df42 100644 --- a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java +++ b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultPublisherFactoryTests.java @@ -56,6 +56,7 @@ public void setUp() throws IOException { @Test void testGetPublisher() { + Publisher publisher = factory.createPublisher("testTopic"); assertThat(((ProjectTopicName) publisher.getTopicName()).getTopic()).isEqualTo("testTopic"); diff --git a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java index 77c7e55415..67f3279c94 100644 --- a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java +++ b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/support/DefaultSubscriberFactoryTests.java @@ -84,8 +84,7 @@ void setUp() { @Test void testNewSubscriber() { - DefaultSubscriberFactory factory = - new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); + DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); factory.setCredentialsProvider(this.credentialsProvider); Subscriber subscriber = factory.createSubscriber("midnight cowboy", (message, consumer) -> {}); @@ -111,24 +110,25 @@ void testNewSubscriber_constructorWithPubSubConfiguration() { void testNewSubscriber_constructorWithPubSubConfiguration_nullPubSubConfiguration() { assertThatThrownBy(() -> new DefaultSubscriberFactory(() -> "angeldust", null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The pub/sub configuration can't be null."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The pub/sub configuration can't be null."); } @Test void testNewDefaultSubscriberFactory_nullProjectProvider() { assertThatThrownBy(() -> new DefaultSubscriberFactory(null, pubSubConfig)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The project ID provider can't be null."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The project ID provider can't be null."); } @Test void testNewDefaultSubscriberFactory_nullProject() { assertThatThrownBy(() -> new DefaultSubscriberFactory(() -> null, pubSubConfig)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The project ID can't be null or empty."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The project ID can't be null or empty."); + } @Test @@ -137,8 +137,8 @@ void testCreatePullRequest_greaterThanZeroMaxMessages() { factory.setCredentialsProvider(this.credentialsProvider); assertThatThrownBy(() -> factory.createPullRequest("test", -1, true)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("The maxMessages must be greater than 0."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("The maxMessages must be greater than 0."); } @Test @@ -163,11 +163,9 @@ void testGetExecutorProvider_presentInMap() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); - ConcurrentHashMap executorProviderMap = - new ConcurrentHashMap<>(); + ConcurrentHashMap executorProviderMap = new ConcurrentHashMap<>(); executorProviderMap.put( - ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), - mockExecutorProvider); + ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), mockExecutorProvider); factory.setExecutorProviderMap(executorProviderMap); assertThat(factory.getExecutorProvider("subscription-name")).isSameAs(mockExecutorProvider); @@ -178,11 +176,9 @@ void testGetExecutorProvider_fullyQualifiedNameNotInMap_pickGlobal() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); - ConcurrentHashMap executorProviderMap = - new ConcurrentHashMap<>(); + ConcurrentHashMap executorProviderMap = new ConcurrentHashMap<>(); executorProviderMap.put( - ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), - mockExecutorProvider); + ProjectSubscriptionName.parse("projects/project/subscriptions/subscription-name"), mockExecutorProvider); factory.setExecutorProviderMap(executorProviderMap); factory.setExecutorProvider(mockGlobalExecutorProvider); @@ -244,11 +240,8 @@ void testGetRetrySettings_presentInMap_pickSelective() { .setRpcTimeoutMultiplier(10) .setMaxRpcTimeout(Duration.ofSeconds(10)) .build(); - ConcurrentHashMap settingsMap = - new ConcurrentHashMap<>(); - settingsMap.put( - ProjectSubscriptionName.parse("projects/project/subscriptions/mySubscription"), - expectedRetrySettings); + ConcurrentHashMap settingsMap = new ConcurrentHashMap<>(); + settingsMap.put(ProjectSubscriptionName.parse("projects/project/subscriptions/mySubscription"), expectedRetrySettings); factory.setRetrySettingsMap(settingsMap); RetrySettings actualRetrySettings = factory.getRetrySettings("mySubscription"); @@ -324,7 +317,8 @@ void testBuildGlobalSubscriberStubSettings_retry_pickUserBean() throws IOExcepti } @Test - void testBuildGlobalSubscriberStubSettings_retry_pickGlobalConfiguration() throws IOException { + void testBuildGlobalSubscriberStubSettings_retry_pickGlobalConfiguration() + throws IOException { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); when(mockPubSubConfiguration.getSubscriber()).thenReturn(mockSubscriber); @@ -369,16 +363,16 @@ void testCreateSubscriber_validateSetProperties() { "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(2L); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(3L); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(4L); when(mockPubSubConfiguration.computeParallelPullCount( "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(2); when(mockPubSubConfiguration.computePullEndpoint( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn("test.endpoint"); when(mockPubSubConfiguration.computeSubscriberUniverseDomain( "defaultSubscription", projectIdProvider.getProjectId())) @@ -405,11 +399,14 @@ void testCreateSubscriber_invalidMinDurationPerAckExtension_throwsException() { new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); factory.setCredentialsProvider(this.credentialsProvider); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(-4L); assertThatThrownBy( - () -> factory.createSubscriber("defaultSubscription", (message, consumer) -> {})) + () -> factory.createSubscriber( + "defaultSubscription", + (message, consumer) -> { } + )) .isExactlyInstanceOf(IllegalArgumentException.class); } @@ -420,11 +417,14 @@ void testCreateSubscriber_invalidMaxDurationPerAckExtension_throwsException() { new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); factory.setCredentialsProvider(this.credentialsProvider); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(-2L); assertThatThrownBy( - () -> factory.createSubscriber("defaultSubscription", (message, consumer) -> {})) + () -> factory.createSubscriber( + "defaultSubscription", + (message, consumer) -> { } + )) .isExactlyInstanceOf(IllegalArgumentException.class); } @@ -435,14 +435,17 @@ void testCreateSubscriber_invalidDurationPerAckExtensions_throwsException() { new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); factory.setCredentialsProvider(this.credentialsProvider); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(4L); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "defaultSubscription", projectIdProvider.getProjectId())) + "defaultSubscription", projectIdProvider.getProjectId())) .thenReturn(3L); assertThatThrownBy( - () -> factory.createSubscriber("defaultSubscription", (message, consumer) -> {})) + () -> factory.createSubscriber( + "defaultSubscription", + (message, consumer) -> { } + )) .isExactlyInstanceOf(IllegalArgumentException.class); } @@ -471,13 +474,10 @@ void testGetFlowControlSettings_presentInMap_pickSubscriptionSpecific() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration); - ConcurrentHashMap settingsMap = - new ConcurrentHashMap<>(); + ConcurrentHashMap settingsMap = new ConcurrentHashMap<>(); FlowControlSettings expectedFlowSettings = FlowControlSettings.newBuilder().setMaxOutstandingRequestBytes(10L).build(); - settingsMap.put( - ProjectSubscriptionName.parse("projects/project/subscriptions/defaultSubscription1"), - expectedFlowSettings); + settingsMap.put(ProjectSubscriptionName.parse("projects/project/subscriptions/defaultSubscription1"), expectedFlowSettings); factory.setFlowControlSettingsMap(settingsMap); FlowControlSettings actualFlowSettings = factory.getFlowControlSettings("defaultSubscription1"); @@ -543,7 +543,7 @@ void testGetMinDurationPerAckExtension_userSetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "subscription-name", projectIdProvider.getProjectId())) + "subscription-name", projectIdProvider.getProjectId())) .thenReturn(1L); assertThat(factory.getMinDurationPerAckExtension("subscription-name")) @@ -556,9 +556,8 @@ void testGetMinDurationPerAckExtension_factorySetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); - when(mockPubSubConfiguration.computeMinDurationPerAckExtension( - "subscription-name", projectIdProvider.getProjectId())) - .thenReturn(3L); + when(mockPubSubConfiguration.computeMinDurationPerAckExtension("subscription-name", + projectIdProvider.getProjectId())).thenReturn(3L); // subscription level setting is used when factory-level one is not provided assertThat(factory.getMinDurationPerAckExtension("subscription-name")) @@ -578,9 +577,8 @@ void testGetMaxDurationPerAckExtension_factorySetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); - when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "subscription-name", projectIdProvider.getProjectId())) - .thenReturn(3L); + when(mockPubSubConfiguration.computeMaxDurationPerAckExtension("subscription-name", + projectIdProvider.getProjectId())).thenReturn(3L); // subscription level setting is used when factory-level one is not provided assertThat(factory.getMaxDurationPerAckExtension("subscription-name")) @@ -600,7 +598,8 @@ void testGetMinDurationPerAckExtension_newConfiguration() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, this.pubSubConfig); - assertThat(factory.getMinDurationPerAckExtension("subscription-name")).isNull(); + assertThat(factory.getMinDurationPerAckExtension("subscription-name")) + .isNull(); } @Test @@ -609,7 +608,7 @@ void testGetMaxDurationPerAckExtension_userSetValue() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); when(mockPubSubConfiguration.computeMaxDurationPerAckExtension( - "subscription-name", projectIdProvider.getProjectId())) + "subscription-name", projectIdProvider.getProjectId())) .thenReturn(2L); assertThat(factory.getMaxDurationPerAckExtension("subscription-name")) @@ -622,7 +621,8 @@ void testGetMaxDurationPerAckExtension_newConfiguration() { DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, this.pubSubConfig); - assertThat(factory.getMaxDurationPerAckExtension("subscription-name")).isNull(); + assertThat(factory.getMaxDurationPerAckExtension("subscription-name")) + .isNull(); } @Test @@ -755,7 +755,8 @@ void testBuildGlobalSubscriberStubSettings_retryableCodes_userProvidedValue() } @Test - void testBuildGlobalSubscriberStubSettings_retryableCodes_pickConfiguration() throws IOException { + void testBuildGlobalSubscriberStubSettings_retryableCodes_pickConfiguration() + throws IOException { GcpProjectIdProvider projectIdProvider = () -> "project"; DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration); @@ -808,8 +809,7 @@ void testNewSubscriber_shouldNotAddToHealthCheck() { when(healthTrackerRegistry.isTracked(subscriptionName)).thenReturn(true); - DefaultSubscriberFactory factory = - new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); + DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); factory.setCredentialsProvider(this.credentialsProvider); factory.setHealthTrackerRegistry(healthTrackerRegistry); @@ -828,8 +828,7 @@ void testNewSubscriber_shouldAddToHealthCheck() { when(healthTrackerRegistry.isTracked(subscriptionName)).thenReturn(false); - DefaultSubscriberFactory factory = - new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); + DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "angeldust", pubSubConfig); factory.setCredentialsProvider(this.credentialsProvider); factory.setHealthTrackerRegistry(healthTrackerRegistry); From 547fa60292c8c879299fcc9be497a658cf6f2ed3 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Tue, 29 Oct 2024 19:50:05 +0000 Subject: [PATCH 5/5] add unit testing for publisherFactory --- .../autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java index b79c80b2f1..f38a6d625f 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java @@ -1458,6 +1458,8 @@ void publisherUniverseDomain() { ctx.getBean("defaultPublisherFactory", CachingPublisherFactory.class); assertThat(gcpPubSubProperties.getPublisher().getUniverseDomain()) .isEqualTo("example.com"); + assertThat(publisherFactory) + .hasFieldOrPropertyWithValue("delegate.universeDomain", "example.com"); }); }