use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testGetParallelPullCount_newConfiguration.
@Test
void testGetParallelPullCount_newConfiguration() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, this.pubSubConfig);
assertThat(factory.getPullCount("subscription-name")).isNull();
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testGetParallelPullCount_configurationIsPresent.
@Test
void testGetParallelPullCount_configurationIsPresent() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration);
when(mockPubSubConfiguration.computeParallelPullCount("subscription-name", projectIdProvider.getProjectId())).thenReturn(1);
assertThat(factory.getPullCount("subscription-name")).isEqualTo(1);
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testNewSubscriber_constructorWithPubSubConfiguration.
@Test
void testNewSubscriber_constructorWithPubSubConfiguration() {
GcpProjectIdProvider projectIdProvider = () -> "angeldust";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, this.pubSubConfig);
factory.setCredentialsProvider(this.credentialsProvider);
Subscriber subscriber = factory.createSubscriber("midnight cowboy", (message, consumer) -> {
});
assertThat(subscriber.getSubscriptionNameString()).isEqualTo("projects/angeldust/subscriptions/midnight cowboy");
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testGetPullEndpoint_configurationIsPresent.
@Test
void testGetPullEndpoint_configurationIsPresent() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(() -> "project", mockPubSubConfiguration);
when(mockPubSubConfiguration.computePullEndpoint("subscription-name", projectIdProvider.getProjectId())).thenReturn("my-endpoint");
assertThat(factory.getPullEndpoint("subscription-name")).isEqualTo("my-endpoint");
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class GcpPubSubAutoConfigurationTests method pullConfig_selectiveConfigurationSet.
@Test
void pullConfig_selectiveConfigurationSet() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(GcpPubSubAutoConfiguration.class)).withPropertyValues("spring.cloud.gcp.pubsub.subscription.subscription-name.max-ack-extension-period=7", "spring.cloud.gcp.pubsub.subscription.subscription-name.parallel-pull-count=12", "spring.cloud.gcp.pubsub.subscription.subscription-name.pull-endpoint=my-endpoint").withUserConfiguration(TestConfig.class);
contextRunner.run(ctx -> {
GcpPubSubProperties gcpPubSubProperties = ctx.getBean(GcpPubSubProperties.class);
GcpProjectIdProvider projectIdProvider = ctx.getBean(GcpProjectIdProvider.class);
assertThat(gcpPubSubProperties.computeMaxAckExtensionPeriod("subscription-name", projectIdProvider.getProjectId())).isEqualTo(7L);
assertThat(gcpPubSubProperties.computeParallelPullCount("subscription-name", projectIdProvider.getProjectId())).isEqualTo(12);
assertThat(gcpPubSubProperties.computePullEndpoint("subscription-name", projectIdProvider.getProjectId())).isEqualTo("my-endpoint");
assertThat(gcpPubSubProperties.getFullyQualifiedSubscriberProperties()).containsKey(ProjectSubscriptionName.parse("projects/fake project/subscriptions/subscription-name"));
});
}
Aggregations