dk2k commented on PR #16127: URL: https://github.com/apache/camel/pull/16127#issuecomment-2449624622
Hi Claus @davsclaus , your PR gives a good hint on the capabilities, which I missed. I like this functional Stream-like API, but in some cases you need something less rigid. I don't insist, that my proposed changes in API cover something previously completely uncovered. My point is: 1. For each type of processing like regex("value[2,3]") you need to add a method into MockValueBuilder. What happens if I want to use an expression with xpath()? I need to add a method. Another type of processing? Another method. Sounds like poor extendability/maintainability. If you ask me how somebody may want to process a header with xpath, I have this link https://stackoverflow.com/questions/49381455/extract-xml-using-xpath-in-camel So, people send XMLs in HTTP headers :) I check options for xpath and I can see that currently it can be applied only to request's body, not to headers. 2. MockEndpoint already provides means to test a header value against a constant: resultEndpoint.expectedHeaderReceived("header", "value"); I believe the same expectation can be checked with: mock.message(4).header("header").regex("value"); or mock.message(4).header("header").asExpression("value"); (More cumbersome, but still it's a duplication of capabilities of method expectedHeaderReceived() - I can understand that it may be preserved for the sake of backward compatibility) That's why I decided to extend the API. New method expectedExpressionMatches() is designed very similar to expectedHeaderReceived() expectedExpressionMatches() provides extendability. My plan was to create XpathExpression(Expression expr, String xpath) - maybe in a separate PR. The more testing capabilities, the better. Like ThereIsMoreThanOneWayToDoIt principle in Perl -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org