gmunozfe commented on code in PR #4135:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4135#discussion_r2568169291
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/OpenAPIInterfaceGenIT.java:
##########
@@ -51,4 +59,63 @@ void verifyOperationIdIsGeneratedByDefault() {
.body("paths.'/helloworld'.get.operationId",
is("getAllProcessInstances_helloworld"));
}
+ @ParameterizedTest
+ @ValueSource(strings = { "helloworld", "expression", "greet", "long-call",
"squareService" })
+ void verifyProcessPrefixSchemasForMultipleWorkflows(String processId) {
+ String openapi =
+ RestAssured.given()
+ .accept(ContentType.JSON)
+ .when()
+ .get("/q/openapi?format=json")
+ .then()
+ .statusCode(200)
+ .extract()
+ .asString();
+
+ JsonPath jp = new JsonPath(openapi);
+
+ Map<String, Object> schemas = jp.getMap("components.schemas");
+ assertTrue(schemas.containsKey("Expression Input"));
+ assertTrue(schemas.containsKey("Expression Output"));
+
+ Map<String, Object> inputSchema =
jp.getMap("components.schemas['Expression Input']");
+ assertNotNull(inputSchema, "Input schema should exist for processId: "
+ processId);
+ assertTrue(inputSchema.containsKey("type"), "Input schema should
contain 'type' field for processId: " + processId);
+
+ List<String> postTags = jp.getList("paths.'/" + processId +
"'.post.tags");
+ assertTrue(postTags.contains("Process - " + processId));
+
+ Map<String, Object> getProps = jp.getMap("paths.'/" + processId +
"'.get.responses.'200'.content.'application/json'.schema.properties");
+ if (getProps != null) {
+ assertTrue(getProps.containsKey("workflowdata") ||
getProps.containsKey("id"));
+ }
+ }
+
+ @Test
+ void verifyOperationsWithoutProcessPrefixAreNotModified() {
+ String openapi =
+ RestAssured.given()
+ .accept(ContentType.JSON)
+ .when()
+ .get("/q/openapi?format=json")
+ .then()
+ .statusCode(200)
+ .extract()
+ .asString();
+
+ JsonPath jp = new JsonPath(openapi);
+
+ List<String> tags = jp.getList("paths.'/noprefix'.post.tags");
+ if (tags != null) {
+ boolean hasProcessPrefix = tags.stream().anyMatch(tag ->
tag.startsWith("Process - "));
+ assertTrue(!hasProcessPrefix);
+ }
+
+ Map<String, Object> inProps =
jp.getMap("paths.'/noprefix'.post.requestBody.content.'application/json'.schema.properties");
+ assertTrue(inProps == null || inProps.isEmpty());
+
+ Map<String, Object> outProps =
jp.getMap("paths.'/noprefix'.get.responses.'200'.content.'application/json'.schema.properties");
+ assertTrue(outProps == null || outProps.isEmpty());
Review Comment:
Same as before, I just will check that schema is not null
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/OpenAPIInterfaceGenIT.java:
##########
@@ -51,4 +59,63 @@ void verifyOperationIdIsGeneratedByDefault() {
.body("paths.'/helloworld'.get.operationId",
is("getAllProcessInstances_helloworld"));
}
+ @ParameterizedTest
+ @ValueSource(strings = { "helloworld", "expression", "greet", "long-call",
"squareService" })
+ void verifyProcessPrefixSchemasForMultipleWorkflows(String processId) {
+ String openapi =
+ RestAssured.given()
+ .accept(ContentType.JSON)
+ .when()
+ .get("/q/openapi?format=json")
+ .then()
+ .statusCode(200)
+ .extract()
+ .asString();
+
+ JsonPath jp = new JsonPath(openapi);
+
+ Map<String, Object> schemas = jp.getMap("components.schemas");
+ assertTrue(schemas.containsKey("Expression Input"));
+ assertTrue(schemas.containsKey("Expression Output"));
+
+ Map<String, Object> inputSchema =
jp.getMap("components.schemas['Expression Input']");
+ assertNotNull(inputSchema, "Input schema should exist for processId: "
+ processId);
+ assertTrue(inputSchema.containsKey("type"), "Input schema should
contain 'type' field for processId: " + processId);
+
+ List<String> postTags = jp.getList("paths.'/" + processId +
"'.post.tags");
+ assertTrue(postTags.contains("Process - " + processId));
+
+ Map<String, Object> getProps = jp.getMap("paths.'/" + processId +
"'.get.responses.'200'.content.'application/json'.schema.properties");
+ if (getProps != null) {
+ assertTrue(getProps.containsKey("workflowdata") ||
getProps.containsKey("id"));
+ }
+ }
+
+ @Test
+ void verifyOperationsWithoutProcessPrefixAreNotModified() {
+ String openapi =
+ RestAssured.given()
+ .accept(ContentType.JSON)
+ .when()
+ .get("/q/openapi?format=json")
+ .then()
+ .statusCode(200)
+ .extract()
+ .asString();
+
+ JsonPath jp = new JsonPath(openapi);
+
+ List<String> tags = jp.getList("paths.'/noprefix'.post.tags");
+ if (tags != null) {
+ boolean hasProcessPrefix = tags.stream().anyMatch(tag ->
tag.startsWith("Process - "));
+ assertTrue(!hasProcessPrefix);
+ }
+
+ Map<String, Object> inProps =
jp.getMap("paths.'/noprefix'.post.requestBody.content.'application/json'.schema.properties");
+ assertTrue(inProps == null || inProps.isEmpty());
+
+ Map<String, Object> outProps =
jp.getMap("paths.'/noprefix'.get.responses.'200'.content.'application/json'.schema.properties");
+ assertTrue(outProps == null || outProps.isEmpty());
Review Comment:
Same as before, I just will check that schema is not null
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]