-
Notifications
You must be signed in to change notification settings - Fork 52
[Fix #1280] Support both casting to JsonNode and Collection #1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>io.serverlessworkflow</groupId> | ||
| <artifactId>serverlessworkflow-experimental</artifactId> | ||
| <version>8.0.0-SNAPSHOT</version> | ||
| </parent> | ||
| <artifactId>serverlessworkflow-experimental-test</artifactId> | ||
| <name>Serverless Workflow :: Experimental :: Test</name> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
fjtirado marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <dependency> | ||
| <groupId>io.serverlessworkflow</groupId> | ||
| <artifactId>serverlessworkflow-experimental-fluent-func</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.serverlessworkflow</groupId> | ||
| <artifactId>serverlessworkflow-experimental-lambda</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.serverlessworkflow</groupId> | ||
| <artifactId>serverlessworkflow-impl-model</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
74 changes: 74 additions & 0 deletions
74
experimental/test/src/test/java/io/serverlessworkflow/fluent/test/FuncEventFilterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Copyright 2020-Present The Serverless Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.serverlessworkflow.fluent.test; | ||
|
|
||
| import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.emitJson; | ||
| import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.listen; | ||
| import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.toOne; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import com.fasterxml.jackson.databind.node.ArrayNode; | ||
| import io.serverlessworkflow.api.types.Workflow; | ||
| import io.serverlessworkflow.fluent.func.FuncWorkflowBuilder; | ||
| import io.serverlessworkflow.impl.WorkflowApplication; | ||
| import io.serverlessworkflow.impl.WorkflowModel; | ||
| import java.util.Collection; | ||
| import java.util.Map; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Tests for the Event Filter DSL specification. Verifies that the fluent builder correctly wires | ||
| * the payload parsing and contextual lambdas into the final Workflow definitions. | ||
| */ | ||
| class FuncEventFilterTest { | ||
|
|
||
| @Test | ||
| void testListenToOneCollection() { | ||
| runIt( | ||
| FuncWorkflowBuilder.workflow("listenToOneReviewCol") | ||
| .tasks( | ||
| listen("waitReview", toOne("org.acme.test.review")) | ||
| .outputAs((Collection<?> node) -> node.iterator().next())) | ||
| .build()); | ||
| } | ||
|
|
||
| @Test | ||
| void testListenToOneNode() { | ||
| runIt( | ||
| FuncWorkflowBuilder.workflow("listenToOneReviewNode") | ||
| .tasks( | ||
| listen("waitReview", toOne("org.acme.test.review")) | ||
| .outputAs((ArrayNode node) -> node.get(0))) | ||
| .build()); | ||
| } | ||
|
|
||
| private Workflow reviewEmitter() { | ||
| return FuncWorkflowBuilder.workflow("emitReview") | ||
| .tasks(emitJson("draftReady", "org.acme.test.review", Review.class)) | ||
| .build(); | ||
| } | ||
|
|
||
| private void runIt(Workflow listen) { | ||
| Review review = new Review("Torrente", "espectacular", 5); | ||
| try (WorkflowApplication app = WorkflowApplication.builder().build()) { | ||
| CompletableFuture<WorkflowModel> waiting = | ||
| app.workflowDefinition(listen).instance(Map.of()).start(); | ||
| app.workflowDefinition(reviewEmitter()).instance(review).start().join(); | ||
| assertThat(waiting.join().as(Review.class).orElseThrow()).isEqualTo(review); | ||
| } | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
experimental/test/src/test/java/io/serverlessworkflow/fluent/test/Review.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright 2020-Present The Serverless Workflow Specification Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.serverlessworkflow.fluent.test; | ||
|
|
||
| record Review(String title, String description, int rating) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mockito-coreis declared as a test dependency here but isn't used by any tests in this module, which adds unnecessary dependency weight and can slow down builds. Please remove it (or add a test that actually needs it).