(test): add test coverage for camel-rest component#21162
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🤖 CI automation will test this PR automatically. 🐫 Apache Camel Committers, please review the following items:
|
squakez
left a comment
There was a problem hiding this comment.
From a quick look it seems that these tests are just checking the creation of the mock, asserting that some value is initialized or not null. I don't see any business logic really tested, am I wrong?
indeed, it does seem to be leaning a bit too much on that. I'll mark this one as a draft ... I am still adjusting the spec for coverage and this one need further checks |
50251b8 to
ccef330
Compare
|
camel-rest is tested via other components where you use it with platform-http / jetty / undertow that has rest-dsl tests. |
Yes. We may need to see how to account aggregate report for coverage to have a more meaningful value and don't get tricked by that 0% which is not accurate. I will work on this one. |
orpiske
left a comment
There was a problem hiding this comment.
I finally had some time to look at this one. There's some unnecessary tests, indeed ... but there are others that do test some of the code in this component.
Even though it might be tested somewhere, relying on test at a distance could be ... tricky for contributors to figure out what broke.
I'm going to remove the useless tests and we can keep the remaining bits.
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class RestApiComponentTest { |
There was a problem hiding this comment.
This test is unnecessary
| import static org.mockito.Mockito.when; | ||
|
|
||
| @ExtendWith(MockitoExtension.class) | ||
| class RestApiEndpointFactoryTest { |
There was a problem hiding this comment.
This test is unnecessary
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class RestConfigurerTest { |
There was a problem hiding this comment.
This test is unnecessary
|
FYI, with the aggregate coverage we already have 73.2% in this component. This is now available in the report. For sure, any useful test which cover the business logic here should be evaluated and kept. |
|
Another thing: this component must not depend on camel-test-junit5. It causes a cyclic dependency issue. |
e821199 to
ec5c738
Compare
Add unit tests for camel-rest component focusing on meaningful behavior tests: - RestComponent URI parsing and endpoint creation - RestEndpoint behavior and error handling - RestProducer query parameter resolution and exchange preparation - RestApiEndpoint creation and factory interactions - DefaultRestRegistry service management - RestProducerBindingProcessor and callback behavior Tests cover: - Error conditions and exception handling - URI template placeholder resolution - Query parameter substitution with optional placeholders - Host scheme handling and normalization - Component property propagation - Consumer/producer creation with factories
ec5c738 to
9e608dd
Compare
On a side note: this one is very picky with the dependencies required. Likely to be a byproduct of https://issues.apache.org/jira/browse/CAMEL-18701, which I hope we'll fix sometime when we work on the next major. |
Summary
Test Coverage
Tests cover the following classes:
RestComponentandRestEndpointRestApiComponentandRestApiEndpointRestProducerandRestApiProducerDefaultRestRegistryandDefaultRestRegistryFactoryRestProducerBindingProcessorand callbacksTest plan