我在爲使用Spring Integration DSL的IntegrationFlow編寫測試用例時遇到了麻煩。下面是我的代碼片段,我想測試'變換'部分。請提供一些幫助,用嘲諷的手柄部分或者有一些其他的方式來測試這一點 - 我們沒有mocking framework尚未IntegrationTests for Spring IntegrationFlow
public class DmwConfig {
@Value("${dmw.url.hostname}")
public String hostName;
@Bean
public MessageChannel dmwGetProductDetailsByEanChannel() {
return MessageChannels.direct().get();
}
@Bean
public IntegrationFlow dmwGetProductDetailsByEan() {
return IntegrationFlows
.from("input")
.channel("dmwGetProductDetailsByEanChannel")
.handle(httpMessageHandlerSpec())
.<JsonNode, ProductModel>transform(
node -> new ProductModel(
node.findValue("name").asText(null),
node.findValue("inventory").findValue("orderable").asBoolean(false),
node.findValue("stock_level").asInt(0),
node.findValue("price").asDouble(0),
"", // this url field will be enriched in the controller because the url doesn't contain any data from the response
node.findValue("image_groups").findValue("link").asText(null)
)
)
.get();
}
@Bean
public HttpRequestExecutingMessageHandler httpMessageHandlerSpec() {
return Http
.outboundGateway((Message<DmwPayload> p) -> "foobar url")
.charset("UTF-8")
.httpMethod(HttpMethod.GET)
.expectedResponseType(JsonNode.class).get();
}
}