diff --git a/src/main/java/com/uber/cadence/internal/compatibility/proto/RequestMapper.java b/src/main/java/com/uber/cadence/internal/compatibility/proto/RequestMapper.java index 30f00330b..d15746f0a 100644 --- a/src/main/java/com/uber/cadence/internal/compatibility/proto/RequestMapper.java +++ b/src/main/java/com/uber/cadence/internal/compatibility/proto/RequestMapper.java @@ -169,6 +169,12 @@ public static RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecuti .setDomain(t.getDomain()) .setWorkflowExecution(workflowExecution(t.getWorkflowExecution())) .setRequestId(t.getRequestId()); + if (t.getCause() != null) { + builder.setCause(t.getCause()); + } + if (t.getFirstExecutionRunID() != null) { + builder.setFirstExecutionRunId(t.getFirstExecutionRunID()); + } if (t.getIdentity() != null) { builder.setIdentity(t.getIdentity()); } @@ -437,7 +443,8 @@ public static SignalWithStartWorkflowExecutionRequest signalWithStartWorkflowExe .setRequestId(t.getRequestId()) .setMemo(memo(t.getMemo())) .setSearchAttributes(searchAttributes(t.getSearchAttributes())) - .setHeader(header(t.getHeader())); + .setHeader(header(t.getHeader())) + .setJitterStart(secondsToDuration(t.getJitterStartSeconds())); if (t.getRetryPolicy() != null) { builder.setRetryPolicy(retryPolicy(t.getRetryPolicy())); } @@ -521,7 +528,8 @@ public static StartWorkflowExecutionRequest startWorkflowExecutionRequest( .setMemo(memo(t.getMemo())) .setSearchAttributes(searchAttributes(t.getSearchAttributes())) .setHeader(header(t.getHeader())) - .setDelayStart(secondsToDuration(t.getDelayStartSeconds())); + .setDelayStart(secondsToDuration(t.getDelayStartSeconds())) + .setJitterStart(secondsToDuration(t.getJitterStartSeconds())); if (t.getRetryPolicy() != null) { request.setRetryPolicy(retryPolicy(t.getRetryPolicy())); } @@ -561,6 +569,9 @@ public static TerminateWorkflowExecutionRequest terminateWorkflowExecutionReques if (t.getIdentity() != null) { builder.setIdentity(t.getIdentity()); } + if (t.getFirstExecutionRunID() != null) { + builder.setFirstExecutionRunId(t.getFirstExecutionRunID()); + } return builder.build(); } diff --git a/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java b/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java index 4e23f7ba0..cda73db7d 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java @@ -874,6 +874,16 @@ public final class ProtoObjects { .setRequestId("requestId") .setIdentity("identity") .build(); + public static final RequestCancelWorkflowExecutionRequest + REQUEST_CANCEL_WORKFLOW_EXECUTION_REQUEST_FULL = + RequestCancelWorkflowExecutionRequest.newBuilder() + .setDomain("domain") + .setWorkflowExecution(WORKFLOW_EXECUTION) + .setRequestId("requestId") + .setIdentity("identity") + .setFirstExecutionRunId("firstExecutionRunID") + .setCause("cancel cause") + .build(); public static final ResetStickyTaskListRequest RESET_STICKY_TASK_LIST_REQUEST = ResetStickyTaskListRequest.newBuilder() .setDomain("domain") @@ -1005,6 +1015,7 @@ public final class ProtoObjects { .setSearchAttributes(SEARCH_ATTRIBUTES) .setHeader(HEADER) .setDelayStart(seconds(3)) + .setJitterStart(seconds(0)) .build(); public static final SignalWithStartWorkflowExecutionRequest SIGNAL_WITH_START_WORKFLOW_EXECUTION = @@ -1044,6 +1055,16 @@ public final class ProtoObjects { .setIdentity("identity") .build(); + public static final TerminateWorkflowExecutionRequest TERMINATE_WORKFLOW_EXECUTION_REQUEST_FULL = + TerminateWorkflowExecutionRequest.newBuilder() + .setDomain("domain") + .setWorkflowExecution(WORKFLOW_EXECUTION) + .setReason("reason") + .setDetails(payload("details")) + .setIdentity("identity") + .setFirstExecutionRunId("firstExecutionRunID") + .build(); + public static final DeprecateDomainRequest DEPRECATE_DOMAIN_REQUEST = DeprecateDomainRequest.newBuilder() .setName("domain") diff --git a/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java b/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java index f52a3a866..7737f01bb 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java @@ -746,6 +746,15 @@ public final class ThriftObjects { .setWorkflowExecution(WORKFLOW_EXECUTION) .setRequestId("requestId") .setIdentity("identity"); + public static final RequestCancelWorkflowExecutionRequest + REQUEST_CANCEL_WORKFLOW_EXECUTION_REQUEST_FULL = + new RequestCancelWorkflowExecutionRequest() + .setDomain("domain") + .setWorkflowExecution(WORKFLOW_EXECUTION) + .setRequestId("requestId") + .setIdentity("identity") + .setFirstExecutionRunID("firstExecutionRunID") + .setCause("cancel cause"); public static final ResetStickyTaskListRequest RESET_STICKY_TASK_LIST_REQUEST = new ResetStickyTaskListRequest().setDomain("domain").setExecution(WORKFLOW_EXECUTION); public static final ResetWorkflowExecutionRequest RESET_WORKFLOW_EXECUTION_REQUEST = @@ -863,6 +872,7 @@ public final class ThriftObjects { .setMemo(MEMO) .setSearchAttributes(SEARCH_ATTRIBUTES) .setHeader(HEADER) + .setJitterStartSeconds(0) .setDelayStartSeconds(3); public static final com.uber.cadence.SignalWithStartWorkflowExecutionRequest SIGNAL_WITH_START_WORKFLOW_EXECUTION = @@ -885,7 +895,8 @@ public final class ThriftObjects { .setMemo(MEMO) .setSearchAttributes(SEARCH_ATTRIBUTES) .setHeader(HEADER) - .setDelayStartSeconds(3); + .setDelayStartSeconds(3) + .setJitterStartSeconds(0); public static final StartWorkflowExecutionAsyncRequest START_WORKFLOW_EXECUTION_ASYNC_REQUEST = new StartWorkflowExecutionAsyncRequest().setRequest(START_WORKFLOW_EXECUTION); @@ -913,6 +924,15 @@ public final class ThriftObjects { .setDetails(utf8("details")) .setIdentity("identity"); + public static final TerminateWorkflowExecutionRequest TERMINATE_WORKFLOW_EXECUTION_REQUEST_FULL = + new TerminateWorkflowExecutionRequest() + .setDomain("domain") + .setWorkflowExecution(WORKFLOW_EXECUTION) + .setReason("reason") + .setDetails(utf8("details")) + .setIdentity("identity") + .setFirstExecutionRunID("firstExecutionRunID"); + public static final DeprecateDomainRequest DEPRECATE_DOMAIN_REQUEST = new DeprecateDomainRequest().setName("domain").setSecurityToken("securityToken"); diff --git a/src/test/java/com/uber/cadence/internal/compatibility/proto/RequestMapperTest.java b/src/test/java/com/uber/cadence/internal/compatibility/proto/RequestMapperTest.java index d560e2caf..db5345f33 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/proto/RequestMapperTest.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/proto/RequestMapperTest.java @@ -96,8 +96,12 @@ public static Iterable cases() { ThriftObjects.REQUEST_CANCEL_WORKFLOW_EXECUTION_REQUEST, ProtoObjects.REQUEST_CANCEL_WORKFLOW_EXECUTION_REQUEST, RequestMapper::requestCancelWorkflowExecutionRequest, - "firstExecutionRunID", - "cause"), + "firstExecutionRunID", // optional field + "cause"), // optional field + testCase( + ThriftObjects.REQUEST_CANCEL_WORKFLOW_EXECUTION_REQUEST_FULL, + ProtoObjects.REQUEST_CANCEL_WORKFLOW_EXECUTION_REQUEST_FULL, + RequestMapper::requestCancelWorkflowExecutionRequest), testCase( ThriftObjects.RESET_STICKY_TASK_LIST_REQUEST, ProtoObjects.RESET_STICKY_TASK_LIST_REQUEST, @@ -157,13 +161,11 @@ public static Iterable cases() { testCase( ThriftObjects.START_WORKFLOW_EXECUTION, ProtoObjects.START_WORKFLOW_EXECUTION, - RequestMapper::startWorkflowExecutionRequest, - "jitterStartSeconds"), + RequestMapper::startWorkflowExecutionRequest), testCase( ThriftObjects.SIGNAL_WITH_START_WORKFLOW_EXECUTION, ProtoObjects.SIGNAL_WITH_START_WORKFLOW_EXECUTION, - RequestMapper::signalWithStartWorkflowExecutionRequest, - "jitterStartSeconds"), + RequestMapper::signalWithStartWorkflowExecutionRequest), testCase( ThriftObjects.START_WORKFLOW_EXECUTION_ASYNC_REQUEST, ProtoObjects.START_WORKFLOW_EXECUTION_ASYNC_REQUEST, @@ -180,7 +182,11 @@ public static Iterable cases() { ThriftObjects.TERMINATE_WORKFLOW_EXECUTION_REQUEST, ProtoObjects.TERMINATE_WORKFLOW_EXECUTION_REQUEST, RequestMapper::terminateWorkflowExecutionRequest, - "firstExecutionRunID"), + "firstExecutionRunID"), // optional field + testCase( + ThriftObjects.TERMINATE_WORKFLOW_EXECUTION_REQUEST_FULL, + ProtoObjects.TERMINATE_WORKFLOW_EXECUTION_REQUEST_FULL, + RequestMapper::terminateWorkflowExecutionRequest), testCase( ThriftObjects.DEPRECATE_DOMAIN_REQUEST, ProtoObjects.DEPRECATE_DOMAIN_REQUEST, @@ -189,12 +195,12 @@ public static Iterable cases() { ThriftObjects.DESCRIBE_DOMAIN_BY_ID_REQUEST, ProtoObjects.DESCRIBE_DOMAIN_BY_ID_REQUEST, RequestMapper::describeDomainRequest, - "name"), + "name"), // Not needed for query by ID testCase( ThriftObjects.DESCRIBE_DOMAIN_BY_NAME_REQUEST, ProtoObjects.DESCRIBE_DOMAIN_BY_NAME_REQUEST, RequestMapper::describeDomainRequest, - "uuid"), + "uuid"), // Not needed for query by name testCase( ThriftObjects.LIST_DOMAINS_REQUEST, ProtoObjects.LIST_DOMAINS_REQUEST, @@ -227,7 +233,7 @@ public static Iterable cases() { ThriftObjects.REGISTER_DOMAIN_REQUEST, ProtoObjects.REGISTER_DOMAIN_REQUEST, RequestMapper::registerDomainRequest, - "emitMetric"), + "emitMetric"), // Thrift has this field but proto doens't have it testCase( ThriftObjects.UPDATE_DOMAIN_REQUEST, // Data and replicationConfiguration are copied incorrectly due to a bug :(