gnodet-bot commented on code in PR #30345:
URL: https://github.com/apache/camel/pull/30345#discussion_r4616052577
##########
catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java:
##########
@@ -2269,6 +2269,66 @@ public void chaosModel() {
Assertions.assertFalse(chaos.getCollection("recipes").isEmpty());
}
+ @Test
+ public void patternRecipesResource() throws Exception {
+ String json;
+ try (InputStream is = catalog.loadResource("patterns",
"recipes.json")) {
+ assertNotNull(is);
+ json = loadText(is);
+ }
+
+ JsonObject patternRecipes = JsonMapper.deserialize(json);
+ assertNotNull(patternRecipes);
+ assertEquals("1", String.valueOf(patternRecipes.get("schemaVersion")));
+ assertNotNull(patternRecipes.getString("description"));
+
+ java.util.Collection<?> recipes =
patternRecipes.getCollection("recipes");
Review Comment:
**Missing imports — use short type names instead of FQCNs.**
Three types in this method are referenced by their fully-qualified names
(`java.util.Collection`, `java.util.Set`, `java.util.HashSet`) instead of
adding imports at the top of the file. Compare with the new
`PatternRecipesYamlValidationTest.java` added in the same PR, which correctly
imports these types.
Please add:
```
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
```
…and use the short names (`Collection<?>`, `Set<String>`, `new HashSet<>()`,
`Set.of(...)`) throughout the method (also applies to lines 2289 and 2318).
##########
catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java:
##########
@@ -2269,6 +2269,66 @@ public void chaosModel() {
Assertions.assertFalse(chaos.getCollection("recipes").isEmpty());
}
+ @Test
+ public void patternRecipesResource() throws Exception {
+ String json;
+ try (InputStream is = catalog.loadResource("patterns",
"recipes.json")) {
+ assertNotNull(is);
+ json = loadText(is);
+ }
+
+ JsonObject patternRecipes = JsonMapper.deserialize(json);
+ assertNotNull(patternRecipes);
+ assertEquals("1", String.valueOf(patternRecipes.get("schemaVersion")));
+ assertNotNull(patternRecipes.getString("description"));
+
+ java.util.Collection<?> recipes =
patternRecipes.getCollection("recipes");
+ assertNotNull(recipes);
+ assertEquals(10, recipes.size());
+
+ java.util.Set<String> ids = new java.util.HashSet<>();
+
+ for (Object value : recipes) {
+ assertTrue(value instanceof JsonObject, "Each recipe must be a
JSON object");
+
+ JsonObject recipe = (JsonObject) value;
+ String id = recipe.getString("id");
+
+ assertNotNull(id, "Each recipe must have an id");
+ assertTrue(ids.add(id), "Duplicate recipe id: " + id);
+ assertNotNull(recipe.getString("name"), id + " needs a name");
+ assertNotNull(recipe.getString("problem"), id + " needs a problem
statement");
+
+ assertNotNull(recipe.getCollection("components"), id + " needs
components");
+ assertNotNull(recipe.getCollection("eips"), id + " needs EIPs");
+ assertNotNull(recipe.getCollection("recommendedOptions"), id + "
needs recommendedOptions");
+ assertNotNull(recipe.getCollection("pitfalls"), id + " needs
pitfalls");
+ assertNotNull(recipe.getCollection("examples"), id + " needs
examples");
+
+ JsonObject route = recipe.getJsonObject("exampleRoute");
+ assertNotNull(route, id + " needs exampleRoute");
+ assertEquals("yaml", route.getString("dsl"), id + " must use YAML
DSL");
+
+ String source = route.getString("source");
+ assertNotNull(source, id + " needs YAML source");
+ assertTrue(!source.isBlank(), id + " YAML source must not be
empty");
Review Comment:
**Use `assertFalse` instead of `assertTrue(!expr)`.**
Negating the condition inside `assertTrue` obscures the intent and produces
a less informative failure message. Prefer the dedicated assertion:
```suggestion
assertFalse(source.isBlank(), id + " YAML source must not be
empty");
```
--
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]