apupier commented on code in PR #2892:
URL: https://github.com/apache/camel-kamelets/pull/2892#discussion_r3490845726
##########
library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java:
##########
@@ -126,6 +126,18 @@ void testGetKameletsByNamespace() throws Exception {
assertTrue(c.isEmpty());
}
+ @Test
+ void testLookupMethodsNeverReturnNull() throws Exception {
+ // Hardened contract: the label/annotation lookups return a non-null
+ // (possibly empty) list and never NPE on a Kamelet that lacks the
+ // queried label/annotation.
+ assertNotNull(catalog.getKameletsByName("does-not-exist"));
+ assertTrue(catalog.getKameletsByType("does-not-exist").isEmpty());
+ assertTrue(catalog.getKameletsByNamespace("does-not-exist").isEmpty());
+ assertTrue(catalog.getKameletsByGroups("does-not-exist").isEmpty());
+ assertTrue(catalog.getKameletByProvider("does-not-exist").isEmpty());
Review Comment:
using AssertJ assertThat(catalog.getXXX()"does-not-exists").isEmpty() will
provide a more readbale errro message and the code is also a bi tore readable
##########
library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java:
##########
@@ -126,6 +126,18 @@ void testGetKameletsByNamespace() throws Exception {
assertTrue(c.isEmpty());
}
+ @Test
+ void testLookupMethodsNeverReturnNull() throws Exception {
+ // Hardened contract: the label/annotation lookups return a non-null
+ // (possibly empty) list and never NPE on a Kamelet that lacks the
+ // queried label/annotation.
+ assertNotNull(catalog.getKameletsByName("does-not-exist"));
Review Comment:
Shouldn't we checked for non empty list too?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]