我想知道消息是否通过特定通道进行测试,或者我想从特定通道获取消息
所以我的流程是:controller -> gateway -> ServiceActivator
private final Gateway gateway;
public ResponseEntity<Map<String,String>> submit(String applicationId, ApplicationDto applicationDto) {
applicationDto.setApplicationId(applicationId);
gateway.submitApplication(applicationDto);
return ResponseEntity.ok(Map.of(MESSAGE, "Accepted submit"));
}
字符串
网关
@Gateway(requestChannel = "submitApplicationChannel", replyChannel = "replySubmitApplicationChannel")
WorkflowPayload submitApplication(ApplicationDto applicationDto);
型
管道
@Bean
MessageChannel submitApplicationChannel() {
return new DirectChannel();
}
型
所以我的测试是发送一个启动流的请求
@Test
@DisplayName("Application Submission")
void submissionTest() throws Exception {
mockMvc.perform(MockMvcRequestBuilders
.post("/api/v1/applications/contract-validation/" + APPLICATION_ID)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(payload)))
.andExpect(status().isAccepted())
.andReturn();
//Check HERE if the message passed through the channel
}
型
你能给予我搭把手吗?
1条答案
按热度按时间j5fpnvbx1#
在测试中,在调用网关之前,将
ChannelInterceptor
添加到submitApplicationChannel
。字符串