From 376141453df07ee03f52a12af8af80584287ed99 Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Wed, 6 Nov 2024 10:54:47 -0800 Subject: [PATCH 1/2] fix unimplementented methods of TestWorkflowEnvironment --- .../sync/TestWorkflowEnvironmentInternal.java | 12 +- .../testservice/TestWorkflowService.java | 16 +- .../TestWorkflowEnvironmentInternalTest.java | 26 ++++ .../testing/TestWorkflowEnvironmentTest.java | 147 ++++++++++++++++++ 4 files changed, 194 insertions(+), 7 deletions(-) create mode 100644 src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java create mode 100644 src/test/java/com/uber/cadence/testing/TestWorkflowEnvironmentTest.java diff --git a/src/main/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternal.java b/src/main/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternal.java index 2df05171c..4c337e7df 100644 --- a/src/main/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternal.java +++ b/src/main/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternal.java @@ -780,16 +780,22 @@ public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallbac } @Override - public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {} + public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException { + impl.GetClusterInfo(resultHandler); + } @Override public void ListTaskListPartitions( ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) - throws TException {} + throws TException { + impl.ListTaskListPartitions(request, resultHandler); + } @Override public void RefreshWorkflowTasks( - RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {} + RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException { + impl.RefreshWorkflowTasks(request, resultHandler); + } @Override public void RegisterDomain(RegisterDomainRequest registerRequest) diff --git a/src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java b/src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java index e487bd884..8af30e9d6 100644 --- a/src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java +++ b/src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java @@ -1120,7 +1120,9 @@ public void ListWorkflowExecutions( @Override public void ListArchivedWorkflowExecutions( ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler) - throws TException {} + throws TException { + throw new UnsupportedOperationException("not implemented"); + } @Override public void ScanWorkflowExecutions( @@ -1175,15 +1177,21 @@ public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallbac } @Override - public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {} + public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException { + throw new UnsupportedOperationException("not implemented"); + } @Override public void ListTaskListPartitions( - ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {} + ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException { + throw new UnsupportedOperationException("not implemented"); + } @Override public void RefreshWorkflowTasks( - RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {} + RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException { + throw new UnsupportedOperationException("not implemented"); + } private R requireNotNull(String fieldName, R value) throws BadRequestError { if (value == null) { diff --git a/src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java b/src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java new file mode 100644 index 000000000..26c89a14b --- /dev/null +++ b/src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java @@ -0,0 +1,26 @@ +/** + * 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.sync; + +import junit.framework.TestCase; + +public class TestWorkflowEnvironmentInternalTest extends TestCase { + + public void setUp() throws Exception { + super.setUp(); + } + + public void testGetWorkflowService() {} +} diff --git a/src/test/java/com/uber/cadence/testing/TestWorkflowEnvironmentTest.java b/src/test/java/com/uber/cadence/testing/TestWorkflowEnvironmentTest.java new file mode 100644 index 000000000..e6459b3bc --- /dev/null +++ b/src/test/java/com/uber/cadence/testing/TestWorkflowEnvironmentTest.java @@ -0,0 +1,147 @@ +/** + * 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.testing; + +import static org.junit.Assert.assertThrows; + +import com.uber.cadence.*; +import com.uber.cadence.serviceclient.IWorkflowService; +import junit.framework.TestCase; + +public class TestWorkflowEnvironmentTest extends TestCase { + TestWorkflowEnvironment testEnvironment; + + public void setUp() throws Exception { + testEnvironment = TestWorkflowEnvironment.newInstance(); + } + + public void testWorkflowService() { + IWorkflowService service = testEnvironment.getWorkflowService(); + // unimplemented + assertThrows( + UnsupportedOperationException.class, + () -> service.RegisterDomain(new RegisterDomainRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.DescribeDomain(new DescribeDomainRequest())); + assertThrows( + UnsupportedOperationException.class, () -> service.ListDomains(new ListDomainsRequest())); + assertThrows( + UnsupportedOperationException.class, () -> service.UpdateDomain(new UpdateDomainRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.DeprecateDomain(new DeprecateDomainRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.RestartWorkflowExecution(new RestartWorkflowExecutionRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.GetTaskListsByDomain(new GetTaskListsByDomainRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.TerminateWorkflowExecution(new TerminateWorkflowExecutionRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.ListWorkflowExecutions(new ListWorkflowExecutionsRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.ListArchivedWorkflowExecutions(new ListArchivedWorkflowExecutionsRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.ScanWorkflowExecutions(new ListWorkflowExecutionsRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.CountWorkflowExecutions(new CountWorkflowExecutionsRequest())); + assertThrows(UnsupportedOperationException.class, () -> service.GetSearchAttributes()); + assertThrows( + UnsupportedOperationException.class, + () -> service.ResetStickyTaskList(new ResetStickyTaskListRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.DescribeWorkflowExecution(new DescribeWorkflowExecutionRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.DescribeTaskList(new DescribeTaskListRequest())); + assertThrows(UnsupportedOperationException.class, () -> service.GetClusterInfo()); + assertThrows( + UnsupportedOperationException.class, + () -> service.ResetStickyTaskList(new ResetStickyTaskListRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.ListTaskListPartitions(new ListTaskListPartitionsRequest())); + assertThrows( + UnsupportedOperationException.class, + () -> service.RefreshWorkflowTasks(new RefreshWorkflowTasksRequest())); + + assertThrows( + UnsupportedOperationException.class, + () -> service.RegisterDomain(new RegisterDomainRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.DescribeDomain(new DescribeDomainRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.ListDomains(new ListDomainsRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.UpdateDomain(new UpdateDomainRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.DeprecateDomain(new DeprecateDomainRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.RestartWorkflowExecution(new RestartWorkflowExecutionRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.GetTaskListsByDomain(new GetTaskListsByDomainRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.TerminateWorkflowExecution(new TerminateWorkflowExecutionRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.ListWorkflowExecutions(new ListWorkflowExecutionsRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> + service.ListArchivedWorkflowExecutions( + new ListArchivedWorkflowExecutionsRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.ScanWorkflowExecutions(new ListWorkflowExecutionsRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.CountWorkflowExecutions(new CountWorkflowExecutionsRequest(), null)); + assertThrows(UnsupportedOperationException.class, () -> service.GetSearchAttributes(null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.ResetStickyTaskList(new ResetStickyTaskListRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.DescribeWorkflowExecution(new DescribeWorkflowExecutionRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.DescribeTaskList(new DescribeTaskListRequest(), null)); + assertThrows(UnsupportedOperationException.class, () -> service.GetClusterInfo(null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.ResetStickyTaskList(new ResetStickyTaskListRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.ListTaskListPartitions(new ListTaskListPartitionsRequest(), null)); + assertThrows( + UnsupportedOperationException.class, + () -> service.RefreshWorkflowTasks(new RefreshWorkflowTasksRequest(), null)); + } +} From d9b2408316b997eef934a2d50b7b86755c88379e Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Wed, 6 Nov 2024 11:00:55 -0800 Subject: [PATCH 2/2] remove unneeded file --- .../TestWorkflowEnvironmentInternalTest.java | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java diff --git a/src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java b/src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java deleted file mode 100644 index 26c89a14b..000000000 --- a/src/test/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternalTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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.sync; - -import junit.framework.TestCase; - -public class TestWorkflowEnvironmentInternalTest extends TestCase { - - public void setUp() throws Exception { - super.setUp(); - } - - public void testGetWorkflowService() {} -}