Spring cloud stream output destination to object

Viewed 326

I am testing a spring cloud stream channel like this:

@RunWith(SpringRunner.class)
@IntegrationTest
@SpringBootTest
@AutoConfigureStubRunner(
        stubsMode = StubRunnerProperties.StubsMode.LOCAL,
        ids = "br.com.marco.cadeacerva:users:+:stubs:8090")
public class UsersConsumerTest {

    @Autowired
    StubTrigger trigger;

    @MockBean
    UserInterestsAggregator consumer;

    @Autowired
    OutputDestination output;

    @Test
    public void shouldConsumeUsersEvents() {
        trigger.trigger("sendUserMessage");
        Message<byte[]> message = output.receive();
        verify(consumer).aggregate(any(UserDTO.class));
    }
}

I am triggering the message via spring cloud contract machinery, and would like to know if there is a way to receive the message payload of a specific type T instead of a byte[]? If not, what is the best way to convert the bytes to the original type?

0 Answers
Related