|
| 1 | +/* |
| 2 | + * Copyright 2026-present the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.cloud.stream.binder.kafka.streams; |
| 18 | + |
| 19 | +import java.util.stream.Stream; |
| 20 | + |
| 21 | +import org.junit.jupiter.api.Test; |
| 22 | + |
| 23 | +import org.springframework.beans.factory.ObjectProvider; |
| 24 | +import org.springframework.cloud.stream.binder.kafka.streams.properties.KafkaStreamsBinderConfigurationProperties; |
| 25 | +import org.springframework.cloud.stream.binder.kafka.streams.properties.KafkaStreamsExtendedBindingProperties; |
| 26 | +import org.springframework.cloud.stream.config.BindingServiceProperties; |
| 27 | +import org.springframework.cloud.stream.function.StreamFunctionProperties; |
| 28 | +import org.springframework.core.env.ConfigurableEnvironment; |
| 29 | +import org.springframework.kafka.config.StreamsBuilderFactoryBeanConfigurer; |
| 30 | +import org.springframework.kafka.core.CleanupConfig; |
| 31 | + |
| 32 | +import static org.assertj.core.api.Assertions.assertThat; |
| 33 | +import static org.mockito.Mockito.mock; |
| 34 | +import static org.mockito.Mockito.when; |
| 35 | + |
| 36 | +/** |
| 37 | + * Tests for {@link KafkaStreamsBinderSupportAutoConfiguration}. |
| 38 | + * |
| 39 | + * @author wadhwaroh-lang |
| 40 | + */ |
| 41 | +class KafkaStreamsBinderSupportAutoConfigurationTests { |
| 42 | + |
| 43 | + @Test |
| 44 | + @SuppressWarnings("unchecked") |
| 45 | + void kafkaStreamsFunctionProcessorUsesAllStreamsBuilderFactoryBeanConfigurers() { |
| 46 | + StreamsBuilderFactoryBeanConfigurer first = mock(StreamsBuilderFactoryBeanConfigurer.class); |
| 47 | + StreamsBuilderFactoryBeanConfigurer second = mock(StreamsBuilderFactoryBeanConfigurer.class); |
| 48 | + ObjectProvider<StreamsBuilderFactoryBeanConfigurer> customizerProvider = mock(ObjectProvider.class); |
| 49 | + ObjectProvider<CleanupConfig> cleanupConfigProvider = mock(ObjectProvider.class); |
| 50 | + when(customizerProvider.orderedStream()).thenReturn(Stream.of(first, second)); |
| 51 | + |
| 52 | + KafkaStreamsFunctionProcessor processor = new KafkaStreamsBinderSupportAutoConfiguration() |
| 53 | + .kafkaStreamsFunctionProcessor( |
| 54 | + mock(BindingServiceProperties.class), |
| 55 | + mock(KafkaStreamsExtendedBindingProperties.class), |
| 56 | + mock(KeyValueSerdeResolver.class), |
| 57 | + mock(KafkaStreamsBindingInformationCatalogue.class), |
| 58 | + mock(KafkaStreamsMessageConversionDelegate.class), |
| 59 | + cleanupConfigProvider, |
| 60 | + mock(StreamFunctionProperties.class), |
| 61 | + mock(KafkaStreamsBinderConfigurationProperties.class), |
| 62 | + customizerProvider, |
| 63 | + mock(ConfigurableEnvironment.class) |
| 64 | + ); |
| 65 | + |
| 66 | + assertThat(processor.customizers).containsExactly(first, second); |
| 67 | + } |
| 68 | +} |
0 commit comments