Skip to content

Commit 6d76d41

Browse files
authored
fix unimplementented methods of TestWorkflowEnvironment (#945)
What changed? Fixed unsupported methods of TestWorkflowEnvironment to throw unsupported exception Added unit test coverage for all unsupported method as well Why? part of unit test coverage How did you test it? unit test
1 parent 5a908a5 commit 6d76d41

File tree

3 files changed

+168
-7
lines changed

3 files changed

+168
-7
lines changed

src/main/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternal.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -780,16 +780,22 @@ public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallbac
780780
}
781781

782782
@Override
783-
public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
783+
public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {
784+
impl.GetClusterInfo(resultHandler);
785+
}
784786

785787
@Override
786788
public void ListTaskListPartitions(
787789
ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler)
788-
throws TException {}
790+
throws TException {
791+
impl.ListTaskListPartitions(request, resultHandler);
792+
}
789793

790794
@Override
791795
public void RefreshWorkflowTasks(
792-
RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
796+
RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {
797+
impl.RefreshWorkflowTasks(request, resultHandler);
798+
}
793799

794800
@Override
795801
public void RegisterDomain(RegisterDomainRequest registerRequest)

src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,9 @@ public void ListWorkflowExecutions(
11201120
@Override
11211121
public void ListArchivedWorkflowExecutions(
11221122
ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1123-
throws TException {}
1123+
throws TException {
1124+
throw new UnsupportedOperationException("not implemented");
1125+
}
11241126

11251127
@Override
11261128
public void ScanWorkflowExecutions(
@@ -1175,15 +1177,21 @@ public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallbac
11751177
}
11761178

11771179
@Override
1178-
public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
1180+
public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {
1181+
throw new UnsupportedOperationException("not implemented");
1182+
}
11791183

11801184
@Override
11811185
public void ListTaskListPartitions(
1182-
ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
1186+
ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {
1187+
throw new UnsupportedOperationException("not implemented");
1188+
}
11831189

11841190
@Override
11851191
public void RefreshWorkflowTasks(
1186-
RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
1192+
RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {
1193+
throw new UnsupportedOperationException("not implemented");
1194+
}
11871195

11881196
private <R> R requireNotNull(String fieldName, R value) throws BadRequestError {
11891197
if (value == null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/**
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* <p>Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
* except in compliance with the License. A copy of the License is located at
8+
*
9+
* <p>http://aws.amazon.com/apache2.0
10+
*
11+
* <p>or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
* specific language governing permissions and limitations under the License.
14+
*/
15+
package com.uber.cadence.testing;
16+
17+
import static org.junit.Assert.assertThrows;
18+
19+
import com.uber.cadence.*;
20+
import com.uber.cadence.serviceclient.IWorkflowService;
21+
import junit.framework.TestCase;
22+
23+
public class TestWorkflowEnvironmentTest extends TestCase {
24+
TestWorkflowEnvironment testEnvironment;
25+
26+
public void setUp() throws Exception {
27+
testEnvironment = TestWorkflowEnvironment.newInstance();
28+
}
29+
30+
public void testWorkflowService() {
31+
IWorkflowService service = testEnvironment.getWorkflowService();
32+
// unimplemented
33+
assertThrows(
34+
UnsupportedOperationException.class,
35+
() -> service.RegisterDomain(new RegisterDomainRequest()));
36+
assertThrows(
37+
UnsupportedOperationException.class,
38+
() -> service.DescribeDomain(new DescribeDomainRequest()));
39+
assertThrows(
40+
UnsupportedOperationException.class, () -> service.ListDomains(new ListDomainsRequest()));
41+
assertThrows(
42+
UnsupportedOperationException.class, () -> service.UpdateDomain(new UpdateDomainRequest()));
43+
assertThrows(
44+
UnsupportedOperationException.class,
45+
() -> service.DeprecateDomain(new DeprecateDomainRequest()));
46+
assertThrows(
47+
UnsupportedOperationException.class,
48+
() -> service.RestartWorkflowExecution(new RestartWorkflowExecutionRequest()));
49+
assertThrows(
50+
UnsupportedOperationException.class,
51+
() -> service.GetTaskListsByDomain(new GetTaskListsByDomainRequest()));
52+
assertThrows(
53+
UnsupportedOperationException.class,
54+
() -> service.TerminateWorkflowExecution(new TerminateWorkflowExecutionRequest()));
55+
assertThrows(
56+
UnsupportedOperationException.class,
57+
() -> service.ListWorkflowExecutions(new ListWorkflowExecutionsRequest()));
58+
assertThrows(
59+
UnsupportedOperationException.class,
60+
() -> service.ListArchivedWorkflowExecutions(new ListArchivedWorkflowExecutionsRequest()));
61+
assertThrows(
62+
UnsupportedOperationException.class,
63+
() -> service.ScanWorkflowExecutions(new ListWorkflowExecutionsRequest()));
64+
assertThrows(
65+
UnsupportedOperationException.class,
66+
() -> service.CountWorkflowExecutions(new CountWorkflowExecutionsRequest()));
67+
assertThrows(UnsupportedOperationException.class, () -> service.GetSearchAttributes());
68+
assertThrows(
69+
UnsupportedOperationException.class,
70+
() -> service.ResetStickyTaskList(new ResetStickyTaskListRequest()));
71+
assertThrows(
72+
UnsupportedOperationException.class,
73+
() -> service.DescribeWorkflowExecution(new DescribeWorkflowExecutionRequest()));
74+
assertThrows(
75+
UnsupportedOperationException.class,
76+
() -> service.DescribeTaskList(new DescribeTaskListRequest()));
77+
assertThrows(UnsupportedOperationException.class, () -> service.GetClusterInfo());
78+
assertThrows(
79+
UnsupportedOperationException.class,
80+
() -> service.ResetStickyTaskList(new ResetStickyTaskListRequest()));
81+
assertThrows(
82+
UnsupportedOperationException.class,
83+
() -> service.ListTaskListPartitions(new ListTaskListPartitionsRequest()));
84+
assertThrows(
85+
UnsupportedOperationException.class,
86+
() -> service.RefreshWorkflowTasks(new RefreshWorkflowTasksRequest()));
87+
88+
assertThrows(
89+
UnsupportedOperationException.class,
90+
() -> service.RegisterDomain(new RegisterDomainRequest(), null));
91+
assertThrows(
92+
UnsupportedOperationException.class,
93+
() -> service.DescribeDomain(new DescribeDomainRequest(), null));
94+
assertThrows(
95+
UnsupportedOperationException.class,
96+
() -> service.ListDomains(new ListDomainsRequest(), null));
97+
assertThrows(
98+
UnsupportedOperationException.class,
99+
() -> service.UpdateDomain(new UpdateDomainRequest(), null));
100+
assertThrows(
101+
UnsupportedOperationException.class,
102+
() -> service.DeprecateDomain(new DeprecateDomainRequest(), null));
103+
assertThrows(
104+
UnsupportedOperationException.class,
105+
() -> service.RestartWorkflowExecution(new RestartWorkflowExecutionRequest(), null));
106+
assertThrows(
107+
UnsupportedOperationException.class,
108+
() -> service.GetTaskListsByDomain(new GetTaskListsByDomainRequest(), null));
109+
assertThrows(
110+
UnsupportedOperationException.class,
111+
() -> service.TerminateWorkflowExecution(new TerminateWorkflowExecutionRequest(), null));
112+
assertThrows(
113+
UnsupportedOperationException.class,
114+
() -> service.ListWorkflowExecutions(new ListWorkflowExecutionsRequest(), null));
115+
assertThrows(
116+
UnsupportedOperationException.class,
117+
() ->
118+
service.ListArchivedWorkflowExecutions(
119+
new ListArchivedWorkflowExecutionsRequest(), null));
120+
assertThrows(
121+
UnsupportedOperationException.class,
122+
() -> service.ScanWorkflowExecutions(new ListWorkflowExecutionsRequest(), null));
123+
assertThrows(
124+
UnsupportedOperationException.class,
125+
() -> service.CountWorkflowExecutions(new CountWorkflowExecutionsRequest(), null));
126+
assertThrows(UnsupportedOperationException.class, () -> service.GetSearchAttributes(null));
127+
assertThrows(
128+
UnsupportedOperationException.class,
129+
() -> service.ResetStickyTaskList(new ResetStickyTaskListRequest(), null));
130+
assertThrows(
131+
UnsupportedOperationException.class,
132+
() -> service.DescribeWorkflowExecution(new DescribeWorkflowExecutionRequest(), null));
133+
assertThrows(
134+
UnsupportedOperationException.class,
135+
() -> service.DescribeTaskList(new DescribeTaskListRequest(), null));
136+
assertThrows(UnsupportedOperationException.class, () -> service.GetClusterInfo(null));
137+
assertThrows(
138+
UnsupportedOperationException.class,
139+
() -> service.ResetStickyTaskList(new ResetStickyTaskListRequest(), null));
140+
assertThrows(
141+
UnsupportedOperationException.class,
142+
() -> service.ListTaskListPartitions(new ListTaskListPartitionsRequest(), null));
143+
assertThrows(
144+
UnsupportedOperationException.class,
145+
() -> service.RefreshWorkflowTasks(new RefreshWorkflowTasksRequest(), null));
146+
}
147+
}

0 commit comments

Comments
 (0)