我正在尝试对流式Kafka代码进行单元测试,运行单元测试时出现以下错误 由以下原因引起:org.springframework.beans.factory.BeanNotOfRequiredTypeException:名为“ input-stream-name”的Bean的类型应为“ org.springframework.messaging.SubscribableChannel
public interface TestStream {
@Input(TestStreamInputOutput.INPUT)
SubscribableChannel inboundTestMessageRequest();
@Output(TestStreamInputOutput.OUTPUT)
MessageChannel outboundTestStatusResponse();
}
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("stream")
public class TestStreamServiceImplTest {
@Autowired
private TesttreamServiceImpl testStreamServiceImpl;
@MockBean
private TestStream testStream;
@Mock
private MessageChannel messageChannel;
@Test
public void pushAwsEmailStatus_When_Dto_Not_Null_Success()
{
Optional<TestStatusDetailDto> testStatusDetailsDto = Optional.ofNullable(
TestStatusDetailDto.newBuilder()
.setMessageId("1234").setMessageStatus(TestStatusDetailDto.Sent).build());
Mockito.when(testStream.outboundTestStatusResponse()).thenReturn(messageChannel);
Mockito.when(messageChannel.send(Mockito.any(Message.class))).thenReturn(true);
testStreamServiceImpl.pushTestStatus(testStatusDetailsDto);
Mockito.verify(messageChannel,Mockito.times(1)).send(Mockito.any(Message.class));
}
}
spring.cloud.stream.bindings.input-stream-name.contentType = application / * + avro spring.cloud.stream.bindings.input-stream-name.destination = icom-in-message-status-events
spring.cloud.stream.bindings.input-stream-name-out.contentType = application / * + avro spring.cloud.stream.bindings.input-stream-name-out.destination = icom-hk-message-status-events
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-schema</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>