use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testCreateSubscriber_validateSetProperties.
@Test
void testCreateSubscriber_validateSetProperties() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration);
factory.setCredentialsProvider(this.credentialsProvider);
FlowControlSettings flowControlSettings = FlowControlSettings.newBuilder().setLimitExceededBehavior(FlowController.LimitExceededBehavior.Ignore).build();
factory.setGlobalFlowControlSettings(flowControlSettings);
when(mockPubSubConfiguration.computeMaxAckExtensionPeriod("defaultSubscription", projectIdProvider.getProjectId())).thenReturn(2L);
when(mockPubSubConfiguration.computeParallelPullCount("defaultSubscription", projectIdProvider.getProjectId())).thenReturn(2);
Subscriber expectedSubscriber = factory.createSubscriber("defaultSubscription", (message, consumer) -> {
});
assertThat(expectedSubscriber.getFlowControlSettings().getLimitExceededBehavior()).isEqualTo(FlowController.LimitExceededBehavior.Ignore);
assertThat(expectedSubscriber).hasFieldOrPropertyWithValue("maxAckExtensionPeriod", Duration.ofSeconds(2L)).hasFieldOrPropertyWithValue("numPullers", 2);
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testGetPullEndpoint_userSetValue.
@Test
void testGetPullEndpoint_userSetValue() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration);
factory.setPullEndpoint("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 DefaultSubscriberFactoryTests method testGetMaxAckExtensionPeriod_configurationIsPresent.
@Test
void testGetMaxAckExtensionPeriod_configurationIsPresent() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration);
when(mockPubSubConfiguration.computeMaxAckExtensionPeriod("subscription-name", projectIdProvider.getProjectId())).thenReturn(1L);
assertThat(factory.getMaxAckExtensionPeriod("subscription-name")).isEqualTo(Duration.ofSeconds(1));
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testGetMaxAckExtensionPeriod_userSetValue.
@Test
void testGetMaxAckExtensionPeriod_userSetValue() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration);
factory.setMaxAckExtensionPeriod(Duration.ofSeconds(1));
assertThat(factory.getMaxAckExtensionPeriod("subscription-name")).isEqualTo(Duration.ofSeconds(1));
}
use of com.google.cloud.spring.core.GcpProjectIdProvider in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultSubscriberFactoryTests method testGetParallelPullCount_userSetValue.
@Test
void testGetParallelPullCount_userSetValue() {
GcpProjectIdProvider projectIdProvider = () -> "project";
DefaultSubscriberFactory factory = new DefaultSubscriberFactory(projectIdProvider, mockPubSubConfiguration);
factory.setParallelPullCount(1);
assertThat(factory.getPullCount("subscription-name")).isEqualTo(1);
}
Aggregations