I am having trouble in writing test cases for my IntegrationFlow which is using Spring Integration DSL. Below is my code snippet and I would like to test the 'transform' part. Please provide some help in mocking the handle part or if there is some other way to test this -
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();
}
}