Repository: serverlessworkflow/sdk-java (java)

Issue:
Change order of parameters on WorflowReader static methods
https://github.com/serverlessworkflow/sdk-java/issues/498 added an addition parameter to allow json schema validation of workflow definitions. 
This parameter should have been added at the end, not at the beginning. 

Pull request:
[Fix #506] Change order of parameters in WorkflowReader
Fix https://github.com/serverlessworkflow/sdk-java/issues/506

Patch:
diff --git a/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java b/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java
index f5eb3f2..6868a6d 100644
--- a/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java
+++ b/api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java
@@ -38,11 +38,11 @@ public class WorkflowReader {
   }
 
   public static Workflow readWorkflow(Path path) throws IOException {
-    return readWorkflow(defaultReader(), path, WorkflowFormat.fromPath(path));
+    return readWorkflow(path, WorkflowFormat.fromPath(path), defaultReader());
   }
 
   public static Workflow readWorkflow(Path path, WorkflowFormat format) throws IOException {
-    return readWorkflow(defaultReader(), path, format);
+    return readWorkflow(path, format, defaultReader());
   }
 
   public static Workflow readWorkflowFromString(String input, WorkflowFormat format)
@@ -51,35 +51,35 @@ public class WorkflowReader {
   }
 
   public static Workflow readWorkflowFromClasspath(String classpath) throws IOException {
-    return readWorkflowFromClasspath(defaultReader(), classpath);
+    return readWorkflowFromClasspath(classpath, defaultReader());
   }
 
   public static Workflow readWorkflowFromClasspath(
       String classpath, ClassLoader cl, WorkflowFormat format) throws IOException {
-    return readWorkflowFromClasspath(defaultReader(), classpath);
+    return readWorkflowFromClasspath(classpath, defaultReader());
   }
 
-  public static Workflow readWorkflow(WorkflowReaderOperations reader, Path path)
+  public static Workflow readWorkflow(Path path, WorkflowReaderOperations reader)
       throws IOException {
-    return readWorkflow(reader, path, WorkflowFormat.fromPath(path));
+    return readWorkflow(path, WorkflowFormat.fromPath(path), reader);
   }
 
   public static Workflow readWorkflow(
-      WorkflowReaderOperations reader, Path path, WorkflowFormat format) throws IOException {
+      Path path, WorkflowFormat format, WorkflowReaderOperations reader) throws IOException {
     return reader.read(Files.readAllBytes(path), format);
   }
 
   public static Workflow readWorkflowFromClasspath(
-      WorkflowReaderOperations reader, String classpath) throws IOException {
+      String classpath, WorkflowReaderOperations reader) throws IOException {
     return readWorkflowFromClasspath(
-        reader,
         classpath,
         Thread.currentThread().getContextClassLoader(),
-        WorkflowFormat.fromFileName(classpath));
+        WorkflowFormat.fromFileName(classpath),
+        reader);
   }
 
   public static Workflow readWorkflowFromClasspath(
-      WorkflowReaderOperations reader, String classpath, ClassLoader cl, WorkflowFormat format)
+      String classpath, ClassLoader cl, WorkflowFormat format, WorkflowReaderOperations reader)
       throws IOException {
     try (InputStream in = cl.getResourceAsStream(classpath)) {
       if (in == null) {


Test patch:
diff --git a/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java b/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java
index 5d58e8b..39d7045 100644
--- a/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java
+++ b/api/src/test/java/io/serverlessworkflow/api/FeaturesTest.java
@@ -60,7 +60,7 @@ public class FeaturesTest {
         "features/call-http-query-parameters.yaml"
       })
   public void testSpecFeaturesParsing(String workflowLocation) throws IOException {
-    Workflow workflow = readWorkflowFromClasspath(validation(), workflowLocation);
+    Workflow workflow = readWorkflowFromClasspath(workflowLocation, validation());
     assertWorkflow(workflow);
     assertWorkflowEquals(workflow, writeAndReadInMemory(workflow));
   }
diff --git a/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java b/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java
index c97f11e..6ac708b 100644
--- a/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java
+++ b/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java
@@ -53,7 +53,7 @@ public class WorkflowDefinitionTest {
   @MethodSource("provideParameters")
   void testWorkflowExecution(String fileName, Consumer<WorkflowDefinition> assertions)
       throws IOException {
-    assertions.accept(appl.workflowDefinition(readWorkflowFromClasspath(validation(), fileName)));
+    assertions.accept(appl.workflowDefinition(readWorkflowFromClasspath(fileName, validation())));
   }
 
   private static Stream<Arguments> provideParameters() {