From 44ff5cc1cffaeb5cac4bcc7d42ae77042a2f2eda Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Thu, 31 Oct 2024 15:00:53 -0700 Subject: [PATCH] fix incorrect exception for unsupported method in WorkflowService --- .../serviceclient/IWorkflowServiceBase.java | 188 ++++---- .../WorkflowServiceTChannel.java | 6 +- .../compatibility/EnumMapperTest.java | 14 + .../thrift/HistoryMapperEventTest.java | 14 + .../IWorkflowServiceBaseTest.java | 277 ++++++++++++ .../WorkflowServiceTChannelTest.java | 412 +++++++++++++++++- .../cadence/testUtils/CadenceTestContext.java | 14 + .../cadence/testUtils/CadenceTestRule.java | 14 + .../testUtils/RequiresDockerService.java | 14 + .../testUtils/RequiresTestService.java | 14 + .../cadence/testUtils/TestEnvironment.java | 14 + .../workflow/CrossDomainWorkflowTest.java | 14 + .../cadence/workflow/WorkflowReplayTest.java | 14 + 13 files changed, 910 insertions(+), 99 deletions(-) create mode 100644 src/test/java/com/uber/cadence/serviceclient/IWorkflowServiceBaseTest.java diff --git a/src/main/java/com/uber/cadence/serviceclient/IWorkflowServiceBase.java b/src/main/java/com/uber/cadence/serviceclient/IWorkflowServiceBase.java index b8ec90db7..db00bb728 100644 --- a/src/main/java/com/uber/cadence/serviceclient/IWorkflowServiceBase.java +++ b/src/main/java/com/uber/cadence/serviceclient/IWorkflowServiceBase.java @@ -26,42 +26,42 @@ public class IWorkflowServiceBase implements IWorkflowService { @Override public ClientOptions getOptions() { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RegisterDomain(RegisterDomainRequest registerRequest) throws BadRequestError, DomainAlreadyExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public ListDomainsResponse ListDomains(ListDomainsRequest listRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void DeprecateDomain(DeprecateDomainRequest deprecateRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -69,7 +69,7 @@ public RestartWorkflowExecutionResponse RestartWorkflowExecution( RestartWorkflowExecutionRequest restartRequest) throws BadRequestError, ServiceBusyError, DomainNotActiveError, LimitExceededError, EntityNotExistsError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -78,7 +78,7 @@ public StartWorkflowExecutionResponse StartWorkflowExecution( throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError, DomainNotActiveError, LimitExceededError, EntityNotExistsError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -87,7 +87,7 @@ public StartWorkflowExecutionAsyncResponse StartWorkflowExecutionAsync( throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError, DomainNotActiveError, LimitExceededError, EntityNotExistsError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -95,14 +95,14 @@ public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory( GetWorkflowExecutionHistoryRequest getRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest pollRequest) throws BadRequestError, ServiceBusyError, LimitExceededError, EntityNotExistsError, DomainNotActiveError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -111,7 +111,7 @@ public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted( throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -119,14 +119,14 @@ public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest failedReq throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest pollRequest) throws BadRequestError, ServiceBusyError, LimitExceededError, EntityNotExistsError, DomainNotActiveError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -135,7 +135,7 @@ public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat( throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -144,7 +144,7 @@ public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID( throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -152,7 +152,7 @@ public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest com throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -161,7 +161,7 @@ public void RespondActivityTaskCompletedByID( throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -169,7 +169,7 @@ public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest failReque throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -177,7 +177,7 @@ public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest f throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -185,7 +185,7 @@ public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest cance throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -194,7 +194,7 @@ public void RespondActivityTaskCanceledByID( throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -202,7 +202,7 @@ public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest throws BadRequestError, EntityNotExistsError, CancellationAlreadyRequestedError, ServiceBusyError, DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -210,7 +210,7 @@ public void SignalWorkflowExecution(SignalWorkflowExecutionRequest signalRequest throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -219,7 +219,7 @@ public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution( throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError, LimitExceededError, WorkflowExecutionAlreadyStartedError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -228,7 +228,7 @@ public SignalWithStartWorkflowExecutionAsyncResponse SignalWithStartWorkflowExec throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError, DomainNotActiveError, LimitExceededError, EntityNotExistsError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -236,7 +236,7 @@ public ResetWorkflowExecutionResponse ResetWorkflowExecution( ResetWorkflowExecutionRequest resetRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -244,7 +244,7 @@ public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest termina throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -252,7 +252,7 @@ public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions( ListOpenWorkflowExecutionsRequest listRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, LimitExceededError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -260,7 +260,7 @@ public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions( ListClosedWorkflowExecutionsRequest listRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -268,7 +268,7 @@ public ListWorkflowExecutionsResponse ListWorkflowExecutions( ListWorkflowExecutionsRequest listRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -276,7 +276,7 @@ public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions( ListArchivedWorkflowExecutionsRequest listRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -284,7 +284,7 @@ public ListWorkflowExecutionsResponse ScanWorkflowExecutions( ListWorkflowExecutionsRequest listRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -292,20 +292,20 @@ public CountWorkflowExecutionsResponse CountWorkflowExecutions( CountWorkflowExecutionsRequest countRequest) throws BadRequestError, EntityNotExistsError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public GetSearchAttributesResponse GetSearchAttributes() throws ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeRequest) throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError, DomainNotActiveError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -313,14 +313,14 @@ public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListReques throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError, DomainNotActiveError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest queryRequest) throws BadRequestError, EntityNotExistsError, QueryFailedError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -328,26 +328,26 @@ public DescribeWorkflowExecutionResponse DescribeWorkflowExecution( DescribeWorkflowExecutionRequest describeRequest) throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request) throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public GetTaskListsByDomainResponse GetTaskListsByDomain(GetTaskListsByDomainRequest request) throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -355,169 +355,169 @@ public ListTaskListPartitionsResponse ListTaskListPartitions( ListTaskListPartitionsRequest request) throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest request) throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RegisterDomain( RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void DescribeDomain( DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void DeprecateDomain( DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RestartWorkflowExecution( RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void StartWorkflowExecution( StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void StartWorkflowExecutionAsync( StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void GetWorkflowExecutionHistory( GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void PollForDecisionTask( PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondDecisionTaskCompleted( RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondDecisionTaskFailed( RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void PollForActivityTask( PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RecordActivityTaskHeartbeat( RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RecordActivityTaskHeartbeatByID( RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondActivityTaskCompleted( RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondActivityTaskCompletedByID( RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondActivityTaskFailed( RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondActivityTaskFailedByID( RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondActivityTaskCanceled( RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondActivityTaskCanceledByID( RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RequestCancelWorkflowExecution( RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void SignalWorkflowExecution( SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -525,7 +525,7 @@ public void SignalWithStartWorkflowExecution( SignalWithStartWorkflowExecutionRequest signalWithStartRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -533,129 +533,129 @@ public void SignalWithStartWorkflowExecutionAsync( SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ResetWorkflowExecution( ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void TerminateWorkflowExecution( TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ListOpenWorkflowExecutions( ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ListClosedWorkflowExecutions( ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ListWorkflowExecutions( ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ListArchivedWorkflowExecutions( ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ScanWorkflowExecutions( ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void CountWorkflowExecutions( CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RespondQueryTaskCompleted( RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ResetStickyTaskList( ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void DescribeWorkflowExecution( DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void GetTaskListsByDomain( GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void ListTaskListPartitions( ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void RefreshWorkflowTasks( RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public void close() { - throw new IllegalArgumentException(); + throw new UnsupportedOperationException(); } @Override @@ -664,7 +664,7 @@ public void StartWorkflowExecutionWithTimeout( AsyncMethodCallback resultHandler, Long timeoutInMillis) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -673,13 +673,13 @@ public void StartWorkflowExecutionAsyncWithTimeout( AsyncMethodCallback resultHandler, Long timeoutInMillis) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout( GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -688,7 +688,7 @@ public void GetWorkflowExecutionHistoryWithTimeout( AsyncMethodCallback resultHandler, Long timeoutInMillis) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -697,11 +697,11 @@ public void SignalWorkflowExecutionWithTimeout( AsyncMethodCallback resultHandler, Long timeoutInMillis) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override public CompletableFuture isHealthy() { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } } diff --git a/src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java b/src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java index 42cb974d7..d3ac4f1e5 100644 --- a/src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java +++ b/src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java @@ -524,7 +524,7 @@ public RestartWorkflowExecutionResponse RestartWorkflowExecution( RestartWorkflowExecutionRequest restartRequest) throws BadRequestError, ServiceBusyError, DomainNotActiveError, LimitExceededError, EntityNotExistsError, ClientVersionNotSupportedError, TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } private void deprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException { @@ -2808,7 +2808,7 @@ public void SignalWithStartWorkflowExecutionAsync( SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override @@ -2951,7 +2951,7 @@ public void DeprecateDomain( public void RestartWorkflowExecution( RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler) throws TException { - throw new IllegalArgumentException("unimplemented"); + throw new UnsupportedOperationException("unimplemented"); } @Override diff --git a/src/test/java/com/uber/cadence/internal/compatibility/EnumMapperTest.java b/src/test/java/com/uber/cadence/internal/compatibility/EnumMapperTest.java index 131a3579f..18040bee2 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/EnumMapperTest.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/EnumMapperTest.java @@ -1,3 +1,17 @@ +/** + * 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.compatibility; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/com/uber/cadence/internal/compatibility/thrift/HistoryMapperEventTest.java b/src/test/java/com/uber/cadence/internal/compatibility/thrift/HistoryMapperEventTest.java index 52d80c191..37fb3caf1 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/thrift/HistoryMapperEventTest.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/thrift/HistoryMapperEventTest.java @@ -1,3 +1,17 @@ +/** + * 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.compatibility.thrift; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/com/uber/cadence/serviceclient/IWorkflowServiceBaseTest.java b/src/test/java/com/uber/cadence/serviceclient/IWorkflowServiceBaseTest.java new file mode 100644 index 000000000..5e09f0297 --- /dev/null +++ b/src/test/java/com/uber/cadence/serviceclient/IWorkflowServiceBaseTest.java @@ -0,0 +1,277 @@ +/** + * 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.serviceclient; + +import static org.junit.Assert.assertThrows; + +import junit.framework.TestCase; + +public class IWorkflowServiceBaseTest extends TestCase { + + public final IWorkflowServiceBase service = new IWorkflowServiceBase(); + + public void testGetOptions() { + assertThrows(UnsupportedOperationException.class, () -> service.getOptions()); + } + + public void testRegisterDomain() { + assertThrows(UnsupportedOperationException.class, () -> service.RegisterDomain(null, null)); + } + + public void testDescribeDomain() { + assertThrows(UnsupportedOperationException.class, () -> service.DescribeDomain(null, null)); + } + + public void testListDomains() { + assertThrows(UnsupportedOperationException.class, () -> service.ListDomains(null, null)); + } + + public void testUpdateDomain() { + assertThrows(UnsupportedOperationException.class, () -> service.UpdateDomain(null, null)); + } + + public void testDeprecateDomain() { + assertThrows(UnsupportedOperationException.class, () -> service.DeprecateDomain(null, null)); + } + + public void testRestartWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, () -> service.RestartWorkflowExecution(null, null)); + } + + public void testStartWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, () -> service.StartWorkflowExecution(null, null)); + } + + public void testStartWorkflowExecutionAsync() { + assertThrows( + UnsupportedOperationException.class, () -> service.StartWorkflowExecutionAsync(null, null)); + } + + public void testGetWorkflowExecutionHistory() { + assertThrows( + UnsupportedOperationException.class, () -> service.GetWorkflowExecutionHistory(null, null)); + } + + public void testPollForDecisionTask() { + assertThrows( + UnsupportedOperationException.class, () -> service.PollForDecisionTask(null, null)); + } + + public void testRespondDecisionTaskCompleted() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RespondDecisionTaskCompleted(null, null)); + } + + public void testRespondDecisionTaskFailed() { + assertThrows( + UnsupportedOperationException.class, () -> service.RespondDecisionTaskFailed(null, null)); + } + + public void testPollForActivityTask() { + assertThrows( + UnsupportedOperationException.class, () -> service.PollForActivityTask(null, null)); + } + + public void testRecordActivityTaskHeartbeat() { + assertThrows( + UnsupportedOperationException.class, () -> service.RecordActivityTaskHeartbeat(null, null)); + } + + public void testRecordActivityTaskHeartbeatByID() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RecordActivityTaskHeartbeatByID(null, null)); + } + + public void testRespondActivityTaskCompleted() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RespondActivityTaskCompleted(null, null)); + } + + public void testRespondActivityTaskCompletedByID() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RespondActivityTaskCompletedByID(null, null)); + } + + public void testRespondActivityTaskFailed() { + assertThrows( + UnsupportedOperationException.class, () -> service.RespondActivityTaskFailed(null, null)); + } + + public void testRespondActivityTaskFailedByID() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RespondActivityTaskFailedByID(null, null)); + } + + public void testRespondActivityTaskCanceled() { + assertThrows( + UnsupportedOperationException.class, () -> service.RespondActivityTaskCanceled(null, null)); + } + + public void testRespondActivityTaskCanceledByID() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RespondActivityTaskCanceledByID(null, null)); + } + + public void testRequestCancelWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, + () -> service.RequestCancelWorkflowExecution(null, null)); + } + + public void testSignalWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, () -> service.SignalWorkflowExecution(null, null)); + } + + public void testSignalWithStartWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, + () -> service.SignalWithStartWorkflowExecution(null, null)); + } + + public void testSignalWithStartWorkflowExecutionAsync() { + assertThrows( + UnsupportedOperationException.class, + () -> service.SignalWithStartWorkflowExecutionAsync(null, null)); + } + + public void testResetWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, () -> service.ResetWorkflowExecution(null, null)); + } + + public void testTerminateWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, () -> service.TerminateWorkflowExecution(null, null)); + } + + public void testListOpenWorkflowExecutions() { + assertThrows( + UnsupportedOperationException.class, () -> service.ListOpenWorkflowExecutions(null, null)); + } + + public void testListClosedWorkflowExecutions() { + assertThrows( + UnsupportedOperationException.class, + () -> service.ListClosedWorkflowExecutions(null, null)); + } + + public void testListWorkflowExecutions() { + assertThrows( + UnsupportedOperationException.class, () -> service.ListWorkflowExecutions(null, null)); + } + + public void testListArchivedWorkflowExecutions() { + assertThrows( + UnsupportedOperationException.class, + () -> service.ListArchivedWorkflowExecutions(null, null)); + } + + public void testScanWorkflowExecutions() { + assertThrows( + UnsupportedOperationException.class, () -> service.ScanWorkflowExecutions(null, null)); + } + + public void testCountWorkflowExecutions() { + assertThrows( + UnsupportedOperationException.class, () -> service.CountWorkflowExecutions(null, null)); + } + + public void testGetSearchAttributes() { + assertThrows(UnsupportedOperationException.class, () -> service.GetSearchAttributes(null)); + } + + public void testRespondQueryTaskCompleted() { + assertThrows( + UnsupportedOperationException.class, () -> service.RespondQueryTaskCompleted(null, null)); + } + + public void testResetStickyTaskList() { + assertThrows( + UnsupportedOperationException.class, () -> service.ResetStickyTaskList(null, null)); + } + + public void testQueryWorkflow() { + assertThrows(UnsupportedOperationException.class, () -> service.QueryWorkflow(null, null)); + } + + public void testDescribeWorkflowExecution() { + assertThrows( + UnsupportedOperationException.class, () -> service.DescribeWorkflowExecution(null, null)); + } + + public void testDescribeTaskList() { + assertThrows(UnsupportedOperationException.class, () -> service.DescribeTaskList(null, null)); + } + + public void testGetClusterInfo() { + assertThrows(UnsupportedOperationException.class, () -> service.GetClusterInfo(null)); + } + + public void testGetTaskListsByDomain() { + assertThrows( + UnsupportedOperationException.class, () -> service.GetTaskListsByDomain(null, null)); + } + + public void testListTaskListPartitions() { + assertThrows( + UnsupportedOperationException.class, () -> service.ListTaskListPartitions(null, null)); + } + + public void testRefreshWorkflowTasks() { + assertThrows( + UnsupportedOperationException.class, () -> service.RefreshWorkflowTasks(null, null)); + } + + public void testClose() { + assertThrows(UnsupportedOperationException.class, () -> service.close()); + } + + public void testStartWorkflowExecutionWithTimeout() { + assertThrows( + UnsupportedOperationException.class, + () -> service.StartWorkflowExecutionWithTimeout(null, null, null)); + } + + public void testStartWorkflowExecutionAsyncWithTimeout() { + assertThrows( + UnsupportedOperationException.class, + () -> service.StartWorkflowExecutionAsyncWithTimeout(null, null, null)); + } + + public void testGetWorkflowExecutionHistoryWithTimeout() { + assertThrows( + UnsupportedOperationException.class, + () -> service.GetWorkflowExecutionHistoryWithTimeout(null, null)); + } + + public void testSignalWorkflowExecutionWithTimeout() { + assertThrows( + UnsupportedOperationException.class, + () -> service.SignalWorkflowExecutionWithTimeout(null, null, null)); + } + + public void testIsHealthy() { + assertThrows(UnsupportedOperationException.class, () -> service.isHealthy()); + } +} diff --git a/src/test/java/com/uber/cadence/serviceclient/WorkflowServiceTChannelTest.java b/src/test/java/com/uber/cadence/serviceclient/WorkflowServiceTChannelTest.java index 8c762f083..a3a2e739b 100644 --- a/src/test/java/com/uber/cadence/serviceclient/WorkflowServiceTChannelTest.java +++ b/src/test/java/com/uber/cadence/serviceclient/WorkflowServiceTChannelTest.java @@ -14,8 +14,7 @@ */ package com.uber.cadence.serviceclient; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.Assert.*; import static org.mockito.Mockito.*; import com.uber.cadence.*; @@ -26,8 +25,11 @@ import com.uber.tchannel.headers.ArgScheme; import com.uber.tchannel.messages.ThriftRequest; import com.uber.tchannel.messages.ThriftResponse; +import com.uber.tchannel.messages.generated.HealthStatus; +import com.uber.tchannel.messages.generated.Meta; import java.util.Arrays; import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; import org.junit.Before; import org.junit.Test; import org.junit.experimental.runners.Enclosed; @@ -37,6 +39,10 @@ @RunWith(Enclosed.class) public class WorkflowServiceTChannelTest { + interface RemoteCallAsync { + void apply(AsyncMethodCallback callback) throws TException; + } + private static class BaseTest { SubChannel mockSubChannel; WorkflowServiceTChannel service; @@ -79,6 +85,64 @@ void testHelper(WorkflowServiceTChannel.RemoteCall method) throws TException, assertEquals(expectedResponse, method.apply()); } } + + void testHelperWithCallback(RemoteCallAsync method) throws TChannelError, TException { + when(mockSubChannel.send(any(ThriftRequest.class))) + .thenReturn(mockResponse(responseCode, responseBody)); + method.apply( + new AsyncMethodCallback() { + @Override + public void onComplete(R r) { + if (expectedException != null) { + fail("Expected exception but got response: " + r); + } else { + assertEquals(expectedResponse, r); + } + } + + @Override + public void onError(Exception e) { + assertEquals(expectedException, e.getClass()); + } + }); + } + + void assertUnimplementedWithCallback(RemoteCallAsync method) { + assertThrows( + UnsupportedOperationException.class, + () -> + method.apply( + new AsyncMethodCallback() { + @Override + public void onComplete(R r) { + fail("shouldn't reach this line"); + } + + @Override + public void onError(Exception e) { + fail("shouldn't reach this line"); + } + })); + } + + void assertNoOpWithCallback(RemoteCallAsync method) { + try { + method.apply( + new AsyncMethodCallback() { + @Override + public void onComplete(R r) { + fail("shouldn't reach this line"); + } + + @Override + public void onError(Exception e) { + fail("shouldn't reach this line"); + } + }); + } catch (TException e) { + fail("should not throw exception:" + e); + } + } } @RunWith(Parameterized.class) @@ -127,6 +191,14 @@ public void testResponse() throws Exception { return null; }); } + + @Test + public void responseIsHandledCorrectlyWithCallback() throws Exception { + testHelperWithCallback( + callback -> { + service.SignalWorkflowExecution(new SignalWorkflowExecutionRequest(), callback); + }); + } } @RunWith(Parameterized.class) @@ -177,6 +249,12 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.DescribeDomain(new DescribeDomainRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.DescribeDomain(new DescribeDomainRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -213,6 +291,12 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ListDomains(new ListDomainsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.ListDomains(new ListDomainsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -257,6 +341,12 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ResetWorkflowExecution(new ResetWorkflowExecutionRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.ListDomains(new ListDomainsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -298,6 +388,14 @@ public void testResponse() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.TerminateWorkflowExecution( + new TerminateWorkflowExecutionRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -342,6 +440,14 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ListOpenWorkflowExecutions(new ListOpenWorkflowExecutionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.ListOpenWorkflowExecutions( + new ListOpenWorkflowExecutionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -388,6 +494,14 @@ public void testResponse() throws Exception { testHelper( () -> service.ListClosedWorkflowExecutions(new ListClosedWorkflowExecutionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.ListClosedWorkflowExecutions( + new ListClosedWorkflowExecutionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -432,6 +546,13 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ListWorkflowExecutions(new ListWorkflowExecutionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.ListWorkflowExecutions(new ListWorkflowExecutionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -479,6 +600,14 @@ public void testResponse() throws Exception { () -> service.ListArchivedWorkflowExecutions(new ListArchivedWorkflowExecutionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.ListArchivedWorkflowExecutions( + new ListArchivedWorkflowExecutionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -523,6 +652,13 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ScanWorkflowExecutions(new ListWorkflowExecutionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.ScanWorkflowExecutions(new ListWorkflowExecutionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -567,6 +703,13 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.CountWorkflowExecutions(new CountWorkflowExecutionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.CountWorkflowExecutions(new CountWorkflowExecutionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -610,6 +753,11 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.GetSearchAttributes()); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback(callback -> service.GetSearchAttributes(callback)); + } } @RunWith(Parameterized.class) @@ -651,6 +799,13 @@ public void testResponse() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondQueryTaskCompleted(new RespondQueryTaskCompletedRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -694,6 +849,12 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ResetStickyTaskList(new ResetStickyTaskListRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.ResetStickyTaskList(new ResetStickyTaskListRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -733,6 +894,12 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.QueryWorkflow(new QueryWorkflowRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.QueryWorkflow(new QueryWorkflowRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -777,6 +944,13 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.DescribeWorkflowExecution(new DescribeWorkflowExecutionRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.DescribeWorkflowExecution(new DescribeWorkflowExecutionRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -820,6 +994,12 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.DescribeTaskList(new DescribeTaskListRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.DescribeTaskList(new DescribeTaskListRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -862,6 +1042,11 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.GetClusterInfo()); } + + @Test + public void callbackIsNotSupported() { + assertNoOpWithCallback(callback -> service.GetClusterInfo(callback)); + } } @RunWith(Parameterized.class) @@ -906,6 +1091,13 @@ public static Iterable data() { public void testResponse() throws Exception { testHelper(() -> service.ListTaskListPartitions(new ListTaskListPartitionsRequest())); } + + @Test + public void callbackIsNotSupported() { + assertNoOpWithCallback( + callback -> + service.ListTaskListPartitions(new ListTaskListPartitionsRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -956,6 +1148,12 @@ public static Iterable data() { public void responseIsHandledCorrectly() throws Exception { testHelper(() -> service.UpdateDomain(new UpdateDomainRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.UpdateDomain(new UpdateDomainRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1017,6 +1215,14 @@ public void responseIsHandledCorrectly() throws Exception { service.GetWorkflowExecutionHistoryWithTimeout( new GetWorkflowExecutionHistoryRequest(), 1000L)); } + + @Test + public void responseIsHandledCorrectlyWithCallback() throws Exception { + testHelperWithCallback( + callback -> + service.GetWorkflowExecutionHistoryWithTimeout( + new GetWorkflowExecutionHistoryRequest(), callback, 1000L)); + } } @RunWith(Parameterized.class) @@ -1100,6 +1306,16 @@ public void responseIsHandledCorrectly() throws Exception { new StartWorkflowExecutionAsyncRequest() .setRequest(new StartWorkflowExecutionRequest()))); } + + @Test + public void responseIsHandledCorrectWithCallback() throws TChannelError, TException { + testHelperWithCallback( + callback -> + service.StartWorkflowExecutionAsync( + new StartWorkflowExecutionAsyncRequest() + .setRequest(new StartWorkflowExecutionRequest()), + callback)); + } } @RunWith(Parameterized.class) @@ -1179,6 +1395,13 @@ public static Iterable data() { public void responseIsHandledCorrectly() throws Exception { testHelper(() -> service.StartWorkflowExecution(new StartWorkflowExecutionRequest())); } + + @Test + public void responseIsHandledCorrectWithCallback() throws TChannelError, TException { + testHelperWithCallback( + callback -> + service.StartWorkflowExecution(new StartWorkflowExecutionRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1243,6 +1466,12 @@ public static Iterable data() { public void responseIsHandledCorrectly() throws Exception { testHelper(() -> service.GetTaskListsByDomain(new GetTaskListsByDomainRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.GetTaskListsByDomain(new GetTaskListsByDomainRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1298,6 +1527,12 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.DeprecateDomain(new DeprecateDomainRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1348,6 +1583,12 @@ public static Iterable data() { public void responseIsHandledCorrectly() throws Exception { testHelper(() -> service.PollForDecisionTask(new PollForDecisionTaskRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.PollForDecisionTask(new PollForDecisionTaskRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1401,6 +1642,14 @@ public void responseIsHandledCorrectly() throws Exception { testHelper( () -> service.RespondDecisionTaskCompleted(new RespondDecisionTaskCompletedRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondDecisionTaskCompleted( + new RespondDecisionTaskCompletedRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1451,6 +1700,12 @@ public static Iterable data() { public void responseIsHandledCorrectly() throws Exception { testHelper(() -> service.PollForActivityTask(new PollForActivityTaskRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> service.PollForActivityTask(new PollForActivityTaskRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1503,6 +1758,14 @@ public void responseIsHandledCorrectly() throws Exception { testHelper( () -> service.RecordActivityTaskHeartbeat(new RecordActivityTaskHeartbeatRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RecordActivityTaskHeartbeat( + new RecordActivityTaskHeartbeatRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1558,6 +1821,14 @@ public void responseIsHandledCorrectly() throws Exception { service.RecordActivityTaskHeartbeatByID( new RecordActivityTaskHeartbeatByIDRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RecordActivityTaskHeartbeatByID( + new RecordActivityTaskHeartbeatByIDRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1608,6 +1879,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondActivityTaskCompleted( + new RespondActivityTaskCompletedRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1661,6 +1940,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondActivityTaskCompletedByID( + new RespondActivityTaskCompletedByIDRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1709,6 +1996,13 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondActivityTaskFailed(new RespondActivityTaskFailedRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1762,6 +2056,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondActivityTaskFailedByID( + new RespondActivityTaskFailedByIDRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1810,6 +2112,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondActivityTaskCanceled( + new RespondActivityTaskCanceledRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1863,6 +2173,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondActivityTaskCanceledByID( + new RespondActivityTaskCanceledByIDRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1916,6 +2234,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RequestCancelWorkflowExecution( + new RequestCancelWorkflowExecutionRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -1964,6 +2290,14 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void responseIsHandledCorrectlyWithCallback() throws Exception { + testHelperWithCallback( + callback -> { + service.SignalWorkflowExecution(new SignalWorkflowExecutionRequest(), callback); + }); + } } @RunWith(Parameterized.class) @@ -2018,6 +2352,14 @@ public void responseIsHandledCorrectly() throws Exception { service.SignalWithStartWorkflowExecution( new SignalWithStartWorkflowExecutionRequest())); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.SignalWithStartWorkflowExecution( + new SignalWithStartWorkflowExecutionRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -2073,6 +2415,12 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertNoOpWithCallback( + callback -> service.RefreshWorkflowTasks(new RefreshWorkflowTasksRequest(), callback)); + } } @RunWith(Parameterized.class) @@ -2129,6 +2477,16 @@ public void responseIsHandledCorrectly() throws Exception { new SignalWithStartWorkflowExecutionAsyncRequest() .setRequest(new SignalWithStartWorkflowExecutionRequest()))); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.SignalWithStartWorkflowExecutionAsync( + new SignalWithStartWorkflowExecutionAsyncRequest() + .setRequest(new SignalWithStartWorkflowExecutionRequest()), + callback)); + } } @RunWith(Parameterized.class) @@ -2185,5 +2543,55 @@ public void responseIsHandledCorrectly() throws Exception { return null; }); } + + @Test + public void callbackIsNotSupported() { + assertUnimplementedWithCallback( + callback -> + service.RespondDecisionTaskFailed(new RespondDecisionTaskFailedRequest(), callback)); + } + } + + public static class ConstructorTest { + @Test + public void testDefault() { + IWorkflowService service = new WorkflowServiceTChannel(ClientOptions.newBuilder().build()); + assertNotNull(service); + } + } + + @RunWith(Parameterized.class) + public static class IsHealthyTest extends BaseTest { + @Parameterized.Parameters(name = "{index}: Response Code {0}, Response {1}") + public static Iterable data() { + return Arrays.asList( + new Object[][] { + { + ResponseCode.OK, + new Meta.health_result().setSuccess(new HealthStatus().setOk(true)), + null, + Boolean.TRUE + }, + { + ResponseCode.OK, + new Meta.health_result().setSuccess(new HealthStatus().setOk(false)), + null, + Boolean.FALSE + }, + }); + } + + @Test + public void testResult() throws TException, TChannelError { + testHelper( + () -> { + try { + return service.isHealthy().get(); + } catch (Exception e) { + fail("should not throw exception: " + e); + } + return null; + }); + } } } diff --git a/src/test/java/com/uber/cadence/testUtils/CadenceTestContext.java b/src/test/java/com/uber/cadence/testUtils/CadenceTestContext.java index 67f40c08c..a9976169b 100644 --- a/src/test/java/com/uber/cadence/testUtils/CadenceTestContext.java +++ b/src/test/java/com/uber/cadence/testUtils/CadenceTestContext.java @@ -1,3 +1,17 @@ +/** + * 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.testUtils; import com.uber.cadence.FeatureFlags; diff --git a/src/test/java/com/uber/cadence/testUtils/CadenceTestRule.java b/src/test/java/com/uber/cadence/testUtils/CadenceTestRule.java index ad1bad0df..a4d78a03c 100644 --- a/src/test/java/com/uber/cadence/testUtils/CadenceTestRule.java +++ b/src/test/java/com/uber/cadence/testUtils/CadenceTestRule.java @@ -1,3 +1,17 @@ +/** + * 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.testUtils; import com.uber.cadence.activity.ActivityOptions; diff --git a/src/test/java/com/uber/cadence/testUtils/RequiresDockerService.java b/src/test/java/com/uber/cadence/testUtils/RequiresDockerService.java index 49088e9fa..a4f9a369a 100644 --- a/src/test/java/com/uber/cadence/testUtils/RequiresDockerService.java +++ b/src/test/java/com/uber/cadence/testUtils/RequiresDockerService.java @@ -1,3 +1,17 @@ +/** + * 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.testUtils; import java.lang.annotation.ElementType; diff --git a/src/test/java/com/uber/cadence/testUtils/RequiresTestService.java b/src/test/java/com/uber/cadence/testUtils/RequiresTestService.java index 6a4580893..7cba4826d 100644 --- a/src/test/java/com/uber/cadence/testUtils/RequiresTestService.java +++ b/src/test/java/com/uber/cadence/testUtils/RequiresTestService.java @@ -1,3 +1,17 @@ +/** + * 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.testUtils; import java.lang.annotation.ElementType; diff --git a/src/test/java/com/uber/cadence/testUtils/TestEnvironment.java b/src/test/java/com/uber/cadence/testUtils/TestEnvironment.java index ed20804f9..a12a07526 100644 --- a/src/test/java/com/uber/cadence/testUtils/TestEnvironment.java +++ b/src/test/java/com/uber/cadence/testUtils/TestEnvironment.java @@ -1,3 +1,17 @@ +/** + * 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.testUtils; public final class TestEnvironment { diff --git a/src/test/java/com/uber/cadence/workflow/CrossDomainWorkflowTest.java b/src/test/java/com/uber/cadence/workflow/CrossDomainWorkflowTest.java index ed60d3891..0bf7e94c3 100644 --- a/src/test/java/com/uber/cadence/workflow/CrossDomainWorkflowTest.java +++ b/src/test/java/com/uber/cadence/workflow/CrossDomainWorkflowTest.java @@ -1,3 +1,17 @@ +/** + * 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.workflow; import static com.uber.cadence.testUtils.TestEnvironment.DOMAIN2; diff --git a/src/test/java/com/uber/cadence/workflow/WorkflowReplayTest.java b/src/test/java/com/uber/cadence/workflow/WorkflowReplayTest.java index 3406c075b..c1f84bf5f 100644 --- a/src/test/java/com/uber/cadence/workflow/WorkflowReplayTest.java +++ b/src/test/java/com/uber/cadence/workflow/WorkflowReplayTest.java @@ -1,3 +1,17 @@ +/** + * 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.workflow; import com.uber.cadence.testing.WorkflowReplayer;