From 5588c994d7e4cc71054c4add924cc41b839439be Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Wed, 6 Nov 2024 10:59:54 -0800 Subject: [PATCH 1/3] wip --- .../internal/replay/QueryWorkflowParametersTest.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java diff --git a/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java b/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java new file mode 100644 index 000000000..f104e88ea --- /dev/null +++ b/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java @@ -0,0 +1,7 @@ +package com.uber.cadence.internal.replay; + +import junit.framework.TestCase; + +public class QueryWorkflowParametersTest extends TestCase { + +} \ No newline at end of file From ea937bb3946afd1fb140c68eaa13d91f440abfc0 Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Wed, 6 Nov 2024 14:21:08 -0800 Subject: [PATCH 2/3] fix bug in QueryWorkflowParameters.toString --- .../replay/QueryWorkflowParameters.java | 37 ++-------------- .../replay/QueryWorkflowParametersTest.java | 43 ++++++++++++++++++- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/uber/cadence/internal/replay/QueryWorkflowParameters.java b/src/main/java/com/uber/cadence/internal/replay/QueryWorkflowParameters.java index 041ae53fa..253286f59 100644 --- a/src/main/java/com/uber/cadence/internal/replay/QueryWorkflowParameters.java +++ b/src/main/java/com/uber/cadence/internal/replay/QueryWorkflowParameters.java @@ -45,11 +45,6 @@ public void setInput(byte[] input) { this.input = input; } - public QueryWorkflowParameters withInput(byte[] input) { - this.input = input; - return this; - } - public String getRunId() { return runId; } @@ -58,11 +53,6 @@ public void setRunId(String runId) { this.runId = runId; } - public QueryWorkflowParameters withRunId(String runId) { - this.runId = runId; - return this; - } - public String getQueryType() { return queryType; } @@ -71,11 +61,6 @@ public void setQueryType(String queryType) { this.queryType = queryType; } - public QueryWorkflowParameters withQueryType(String queryType) { - this.queryType = queryType; - return this; - } - public String getWorkflowId() { return workflowId; } @@ -84,11 +69,6 @@ public void setWorkflowId(String workflowId) { this.workflowId = workflowId; } - public QueryWorkflowParameters withWorkflowId(String workflowId) { - this.workflowId = workflowId; - return this; - } - public QueryRejectCondition getQueryRejectCondition() { return queryRejectCondition; } @@ -97,12 +77,6 @@ public void setQueryRejectCondition(QueryRejectCondition queryRejectCondition) { this.queryRejectCondition = queryRejectCondition; } - public QueryWorkflowParameters withQueryRejectCondition( - QueryRejectCondition queryRejectCondition) { - this.queryRejectCondition = queryRejectCondition; - return this; - } - public QueryConsistencyLevel getQueryConsistencyLevel() { return queryConsistencyLevel; } @@ -111,18 +85,15 @@ public void setQueryConsistencyLevel(QueryConsistencyLevel queryConsistencyLevel this.queryConsistencyLevel = queryConsistencyLevel; } - public QueryWorkflowParameters withQueryConsistencyLevel( - QueryConsistencyLevel queryConsistencyLevel) { - this.queryConsistencyLevel = queryConsistencyLevel; - return this; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); sb.append("QueryName: " + queryType + ", "); - sb.append("Input: " + new String(input, 0, 512, StandardCharsets.UTF_8) + ", "); + sb.append( + "Input: " + + new String(input, 0, Math.min(512, input.length), StandardCharsets.UTF_8) + + ", "); sb.append("WorkflowId: " + workflowId + ", "); sb.append("RunId: " + runId + ", "); sb.append("QueryRejectCondition: " + queryRejectCondition + ", "); diff --git a/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java b/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java index f104e88ea..fa741d745 100644 --- a/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java +++ b/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java @@ -1,7 +1,48 @@ +<<<<<<< Updated upstream package com.uber.cadence.internal.replay; +======= +/** + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + *

Modifications copyright (C) 2017 Uber Technologies, Inc. + * + *

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file + * except in compliance with the License. A copy of the License is located at + * + *

http://aws.amazon.com/apache2.0 + * + *

or in the "license" file accompanying this file. This file 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 com.uber.cadence.internal.replay; + +import com.uber.cadence.QueryConsistencyLevel; +import com.uber.cadence.QueryRejectCondition; +>>>>>>> Stashed changes import junit.framework.TestCase; public class QueryWorkflowParametersTest extends TestCase { -} \ No newline at end of file +<<<<<<< Updated upstream +} +======= + QueryWorkflowParameters p; + + public void setUp() throws Exception { + p = new QueryWorkflowParameters(); + p.setInput("input".getBytes()); + p.setWorkflowId("workflowid"); + p.setQueryType("querytype"); + p.setRunId("runid"); + p.setQueryConsistencyLevel(QueryConsistencyLevel.EVENTUAL); + p.setQueryRejectCondition(QueryRejectCondition.NOT_OPEN); + } + + public void testCopy() { + QueryWorkflowParameters copied = p.copy(); + assertEquals(copied.toString(), p.toString()); + } +} +>>>>>>> Stashed changes From 70f81a0d89d40b060c9d08aa0e83fa8e160f0efa Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Wed, 6 Nov 2024 14:24:50 -0800 Subject: [PATCH 3/3] fix format --- .../internal/replay/QueryWorkflowParametersTest.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java b/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java index fa741d745..57a893a51 100644 --- a/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java +++ b/src/test/java/com/uber/cadence/internal/replay/QueryWorkflowParametersTest.java @@ -1,7 +1,3 @@ -<<<<<<< Updated upstream -package com.uber.cadence.internal.replay; - -======= /** * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * @@ -20,14 +16,9 @@ import com.uber.cadence.QueryConsistencyLevel; import com.uber.cadence.QueryRejectCondition; ->>>>>>> Stashed changes import junit.framework.TestCase; public class QueryWorkflowParametersTest extends TestCase { - -<<<<<<< Updated upstream -} -======= QueryWorkflowParameters p; public void setUp() throws Exception { @@ -45,4 +36,3 @@ public void testCopy() { assertEquals(copied.toString(), p.toString()); } } ->>>>>>> Stashed changes