Skip to content
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

fix bug in QueryWorkflowParameters.toString #948

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public void setInput(byte[] input) {
this.input = input;
}

public QueryWorkflowParameters withInput(byte[] input) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly, but isn't the withX pattern preferable to setters because it's chainable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right but they are currently unused though

this.input = input;
return this;
}

public String getRunId() {
return runId;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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 + ", ");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* <p>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
*
* <p>http://aws.amazon.com/apache2.0
*
* <p>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;
import junit.framework.TestCase;

public class QueryWorkflowParametersTest extends TestCase {
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());
}
}