BeanNotOfRequiredTypeException: ожидается, что bean-компонент с именем 'input-stream-name' будет иметь тип 'org.springframework.messaging.SubscribeableChannel - PullRequest
0 голосов
/ 26 июня 2019

Я пытаюсь выполнить модульное тестирование кода Кафки в Spring-Stream. При выполнении модульного теста я получаю сообщение об ошибке, вызванное: org.springframework.beans.factory.BeanNotOfRequiredTypeException: ожидается, что компонент с именем «input-stream-name» будеттипа 'org.springframework.messaging.SubscribeableChannel

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));
    }
}

input kafka

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>
...