From a011a8d6074717f7c7681355c9b39d4e18985355 Mon Sep 17 00:00:00 2001 From: Snarr Date: Mon, 2 Dec 2024 17:57:59 -0500 Subject: [PATCH] Rename "assign_to" method to "assign" in Java and Python --- .../littlehorse/sdk/wfsdk/WfRunVariable.java | 2 +- .../sdk/wfsdk/internal/WfRunVariableImpl.java | 2 +- .../wfsdk/internal/WorkflowThreadImplTest.java | 10 +++++----- sdk-python/littlehorse/workflow.py | 2 +- sdk-python/tests/test_workflow.py | 10 +++++----- server/src/test/java/e2e/BasicTest.java | 2 +- server/src/test/java/e2e/ExpressionTest.java | 18 +++++++++--------- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/WfRunVariable.java b/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/WfRunVariable.java index a5a1002a5..7f17f0ef3 100644 --- a/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/WfRunVariable.java +++ b/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/WfRunVariable.java @@ -214,5 +214,5 @@ public interface WfRunVariable extends LHExpression { * provided by the Json Path is mutated. * @param rhs is the value to set this WfRunVariable to. */ - void assignTo(Serializable rhs); + void assign(Serializable rhs); } diff --git a/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/WfRunVariableImpl.java b/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/WfRunVariableImpl.java index 25a198b68..4f408af79 100644 --- a/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/WfRunVariableImpl.java +++ b/sdk-java/src/main/java/io/littlehorse/sdk/wfsdk/internal/WfRunVariableImpl.java @@ -181,7 +181,7 @@ public WorkflowConditionImpl isNotIn(Serializable rhs) { } @Override - public void assignTo(Serializable rhs) { + public void assign(Serializable rhs) { parent.mutate(this, VariableMutationType.ASSIGN, rhs); } diff --git a/sdk-java/src/test/java/io/littlehorse/sdk/wfsdk/internal/WorkflowThreadImplTest.java b/sdk-java/src/test/java/io/littlehorse/sdk/wfsdk/internal/WorkflowThreadImplTest.java index 681c6a666..2a8aa238e 100644 --- a/sdk-java/src/test/java/io/littlehorse/sdk/wfsdk/internal/WorkflowThreadImplTest.java +++ b/sdk-java/src/test/java/io/littlehorse/sdk/wfsdk/internal/WorkflowThreadImplTest.java @@ -550,7 +550,7 @@ void mutationsShouldUseVariableAssignment() { // Deprecated the literal_value and node_output approach Workflow workflow = new WorkflowImpl("obiwan", wf -> { WfRunVariable myVar = wf.addVariable("my-var", VariableType.STR); - myVar.assignTo("some-value"); + myVar.assign("some-value"); }); PutWfSpecRequest wfSpec = workflow.compileWorkflow(); @@ -570,7 +570,7 @@ void nodeOutputMutationsShouldAlsoUseVariableAssignments() { // Deprecated the literal_value and node_output approach Workflow workflow = new WorkflowImpl("obiwan", wf -> { WfRunVariable myVar = wf.addVariable("my-var", VariableType.STR); - myVar.assignTo(wf.execute("use-the-force")); + myVar.assign(wf.execute("use-the-force")); }); PutWfSpecRequest wfSpec = workflow.compileWorkflow(); @@ -590,7 +590,7 @@ void nodeOutputMutationsShouldCarryJsonPath() { // Deprecated the literal_value and node_output approach Workflow workflow = new WorkflowImpl("obiwan", wf -> { WfRunVariable myVar = wf.addVariable("my-var", VariableType.STR); - myVar.assignTo(wf.execute("use-the-force").jsonPath("$.hello.there")); + myVar.assign(wf.execute("use-the-force").jsonPath("$.hello.there")); }); PutWfSpecRequest wfSpec = workflow.compileWorkflow(); @@ -614,7 +614,7 @@ void assigningVariablesToOtherVariablesShouldUseVariableAssignment() { Workflow workflow = new WorkflowImpl("obiwan", wf -> { WfRunVariable myVar = wf.addVariable("my-var", VariableType.STR); WfRunVariable otherVar = wf.addVariable("other-var", VariableType.STR); - myVar.assignTo(otherVar); + myVar.assign(otherVar); }); PutWfSpecRequest wfSpec = workflow.compileWorkflow(); @@ -632,7 +632,7 @@ void assigningVariablesToOtherVariablesShouldCarryJsonPath() { Workflow workflow = new WorkflowImpl("obiwan", wf -> { WfRunVariable myVar = wf.addVariable("my-var", VariableType.STR); WfRunVariable otherVar = wf.addVariable("other-var", VariableType.JSON_OBJ); - myVar.assignTo(otherVar.jsonPath("$.hello.there")); + myVar.assign(otherVar.jsonPath("$.hello.there")); }); PutWfSpecRequest wfSpec = workflow.compileWorkflow(); diff --git a/sdk-python/littlehorse/workflow.py b/sdk-python/littlehorse/workflow.py index 10d2297c5..74d6e72d9 100644 --- a/sdk-python/littlehorse/workflow.py +++ b/sdk-python/littlehorse/workflow.py @@ -586,7 +586,7 @@ def is_in(self, rhs: Any) -> WorkflowCondition: def is_not_in(self, rhs: Any) -> WorkflowCondition: return self.parent.condition(self, Comparator.NOT_IN, rhs) - def assign_to(self, rhs: Any) -> None: + def assign(self, rhs: Any) -> None: self.parent.mutate(self, VariableMutationType.ASSIGN, rhs) def add(self, other: Any) -> LHExpression: diff --git a/sdk-python/tests/test_workflow.py b/sdk-python/tests/test_workflow.py index 9b5ea55af..1604efd22 100644 --- a/sdk-python/tests/test_workflow.py +++ b/sdk-python/tests/test_workflow.py @@ -1082,7 +1082,7 @@ def my_entrypoint(thread: WorkflowThread) -> None: def test_mutations_should_use_variable_assignments(self): def my_entrypoint(thread: WorkflowThread) -> None: my_var = thread.add_variable("my-var", VariableType.STR) - my_var.assign_to("some-value") + my_var.assign("some-value") wf_spec = Workflow("obiwan", my_entrypoint).compile() entrypoint = wf_spec.thread_specs[wf_spec.entrypoint_thread_name] @@ -1095,7 +1095,7 @@ def my_entrypoint(thread: WorkflowThread) -> None: def test_node_output_mutations_should_also_use_variable_assignments(self): def my_entrypoint(thread: WorkflowThread) -> None: my_var = thread.add_variable("my-var", VariableType.STR) - my_var.assign_to(thread.execute("use-the-force")) + my_var.assign(thread.execute("use-the-force")) wf_spec = Workflow("obiwan", my_entrypoint).compile() entrypoint = wf_spec.thread_specs[wf_spec.entrypoint_thread_name] @@ -1108,7 +1108,7 @@ def my_entrypoint(thread: WorkflowThread) -> None: def test_node_output_mutations_should_carry_json_path(self): def my_entrypoint(thread: WorkflowThread) -> None: my_var = thread.add_variable("my-var", VariableType.STR) - my_var.assign_to(thread.execute("use-the-force").with_json_path("$.hello.there")) + my_var.assign(thread.execute("use-the-force").with_json_path("$.hello.there")) wfSpec = Workflow("obiwan", my_entrypoint).compile() entrypoint = wfSpec.thread_specs[wfSpec.entrypoint_thread_name] @@ -1124,7 +1124,7 @@ def test_assigning_variables_to_other_variables_should_use_variable_assignment(s def my_entrypoint(thread: WorkflowThread) -> None: my_var = thread.add_variable("my-var", VariableType.STR) other_var = thread.add_variable("other-var", VariableType.STR) - my_var.assign_to(other_var) + my_var.assign(other_var) wfSpec = Workflow("obiwan", my_entrypoint).compile() entrypoint = wfSpec.thread_specs[wfSpec.entrypoint_thread_name] @@ -1137,7 +1137,7 @@ def test_assigning_variables_to_other_variables_should_carry_json_path(self): def my_entrypoint(thread: WorkflowThread) -> None: my_var = thread.add_variable("my-var", VariableType.STR) other_var = thread.add_variable("other-var", VariableType.JSON_OBJ) - my_var.assign_to(other_var.with_json_path("$.hello.there")) + my_var.assign(other_var.with_json_path("$.hello.there")) wfSpec = Workflow("obiwan", my_entrypoint).compile() entrypoint = wfSpec.thread_specs[wfSpec.entrypoint_thread_name] diff --git a/server/src/test/java/e2e/BasicTest.java b/server/src/test/java/e2e/BasicTest.java index 094d1ab96..6e55ff439 100644 --- a/server/src/test/java/e2e/BasicTest.java +++ b/server/src/test/java/e2e/BasicTest.java @@ -27,7 +27,7 @@ public void shouldDoBasic() { public Workflow getBasic() { return new WorkflowImpl("test-basic", thread -> { WfRunVariable asdf = thread.declareBool("asdf"); - asdf.assignTo(thread.execute("ag-one")); + asdf.assign(thread.execute("ag-one")); }); } diff --git a/server/src/test/java/e2e/ExpressionTest.java b/server/src/test/java/e2e/ExpressionTest.java index 13f5b5117..c9c4962a1 100644 --- a/server/src/test/java/e2e/ExpressionTest.java +++ b/server/src/test/java/e2e/ExpressionTest.java @@ -247,7 +247,7 @@ public Workflow getExpression() { // EXTEND a String test var myStr = wf.declareStr("my-str"); wf.doIf(myStr.isNotEqualTo(null), then -> { - myStr.assignTo(myStr.extend("-suffix")); + myStr.assign(myStr.extend("-suffix")); }); // Add an int and composite expressions @@ -255,14 +255,14 @@ public Workflow getExpression() { var intToAddResult = wf.declareInt("int-to-add-result"); wf.doIf(intToAdd.isNotEqualTo(null), then -> { // Tests compound expressions - intToAddResult.assignTo(wf.execute("expr-add-one", intToAdd.add(1))); + intToAddResult.assign(wf.execute("expr-add-one", intToAdd.add(1))); }); // Division By Zero test var thingToDivideByZero = wf.declareInt("thing-to-divide-by-zero"); var divideByZeroResult = wf.declareInt("divide-by-zero-result"); wf.doIf(thingToDivideByZero.isNotEqualTo(null), then -> { - divideByZeroResult.assignTo(thingToDivideByZero.divide(0)); + divideByZeroResult.assign(thingToDivideByZero.divide(0)); }); // Test precision of arithmetic. Make use of the fact that we don't have @@ -273,8 +273,8 @@ public Workflow getExpression() { var divisionResultInt = wf.declareInt("division-result-int"); wf.doIf(divisionTestJson.isNotEqualTo(null), then -> { LHExpression foobar = divisionTestJson.jsonPath("$.lhs").divide(divisionTestJson.jsonPath("$.rhs")); - divisionResult.assignTo(foobar); - divisionResultInt.assignTo(foobar); + divisionResult.assign(foobar); + divisionResultInt.assign(foobar); }); // This test uses a complex expression where the things we are computing over @@ -289,20 +289,20 @@ public Workflow getExpression() { // TotalPrice = Quantity * Price * (1 - DiscountPercentage / 100) LHExpression pedro = quantity.multiply(price).multiply(wf.subtract(1.0, discountPercentage.divide(100.0))); - totalPriceInt.assignTo(pedro); - totalPriceDouble.assignTo(pedro); + totalPriceInt.assign(pedro); + totalPriceDouble.assign(pedro); }); // Test mutating sub-fields of a json object var json = wf.declareJsonObj("json"); wf.doIf(json.isNotEqualTo(null), then -> { - json.jsonPath("$.foo").assignTo("bar"); + json.jsonPath("$.foo").assign("bar"); }); // Test mutating doubly-nested fields of a Json Object var nestedJson = wf.declareJsonObj("nested-json"); wf.doIf(nestedJson.isNotEqualTo(null), then -> { - nestedJson.jsonPath("$.foo.bar").assignTo("baz"); + nestedJson.jsonPath("$.foo.bar").assign("baz"); }); }); }