0

I have a route

from("sql:classpath:sql/selectAccounts.sql?outputClass=Account&delay={{EXEC_INTVAL_MS:60000}}&useIterator=false")
    .routeId(ROUTE_MIGRATE_ACCOUNTS)
    .to("log:accounts?showAll=true&level=DEBUG")
    .setHeader(HEADER_MIGRATION_TYPE, constant(HEADER_MIGRATION_TYPE_ACCOUNTS))
    .setHeader(HEADER_API_TYPE, constant(HEADER_API_TYPE_ADRE))
    .setHeader(SQL_STORED_TEMPLATE, constant("${header.apiType}.MIGRATION_STARTET(INTEGER ${header.id})"))
    .to("direct:markStarted")

from("direct:markStarted").routeId(ROUTE_MARK_STARTED_IN)
    .split(body())
    .setHeader("id", convertToExpression(simple("${body.id}"),Integer.class))
    .to("sql-stored:template").id(ID_MARK_STARTED_TO_SQL_STORE)
    .log("${header.id} marked as migration started");

with Headers

    static final String HEADER_API_TYPE = "apiType";
    static final String HEADER_API_TYPE_ADRE = "ADRE_API";

I would love to test if the sql-stored is called with expected header where the placeholder a filled like this

ADRE_API.MIGRATION_STARTET(INTEGER 12)

I found

mockSQLStored.expectedHeaderValuesReceivedInAnyOrder(SQL_STORED_TEMPLATE,
"${header.apiType}.MIGRATION_STARTET(INTEGER ${header.id})",
"${header.apiType}.MIGRATION_STARTET(INTEGER ${header.id})");

whats working perfect like this.

How can I check the header filled with the params?

1 Answers1

0

Actually you don't, because this would test the underlying sql-component of the Camel framework, which is already tested. Instead of this, you could test if the filled "id"-header contains the expected number (extracted from the body) which would be 12 in this case:

mockSQLStored.expectedHeaderValuesReceivedInAnyOrder("id", 12);
d4kine
  • 1
  • 1