Skip to content

Commit eb20e12

Browse files
authored
Added unit tests for TerminateWorkflowExecutionParameters (#981)
1 parent 0e1916e commit eb20e12

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Modifications copyright (C) 2017 Uber Technologies, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not
7+
* use this file except in compliance with the License. A copy of the License is
8+
* located at
9+
*
10+
* http://aws.amazon.com/apache2.0
11+
*
12+
* or in the "license" file accompanying this file. This file is distributed on
13+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14+
* express or implied. See the License for the specific language governing
15+
* permissions and limitations under the License.
16+
*/
17+
18+
package com.uber.cadence.internal.common;
19+
20+
import static org.junit.Assert.*;
21+
22+
import com.uber.cadence.WorkflowExecution;
23+
import java.util.Arrays;
24+
import java.util.Collection;
25+
import org.junit.Test;
26+
import org.junit.runner.RunWith;
27+
import org.junit.runners.Parameterized;
28+
29+
@RunWith(Parameterized.class)
30+
public class TerminateWorkflowExecutionParametersTest {
31+
32+
private final WorkflowExecution workflowExecution;
33+
private final String reason;
34+
private final byte[] details;
35+
36+
public TerminateWorkflowExecutionParametersTest(
37+
WorkflowExecution workflowExecution, String reason, byte[] details) {
38+
this.workflowExecution = workflowExecution;
39+
this.reason = reason;
40+
this.details = details;
41+
}
42+
43+
@Parameterized.Parameters
44+
public static Collection<Object[]> data() {
45+
return Arrays.asList(
46+
new Object[][] {
47+
{new WorkflowExecution(), "Test Reason 1", new byte[] {1, 2, 3}},
48+
{new WorkflowExecution(), "Test Reason 2", new byte[] {4, 5, 6}},
49+
{null, null, null}
50+
});
51+
}
52+
53+
@Test
54+
public void testParameterizedConstructor() {
55+
TerminateWorkflowExecutionParameters params =
56+
new TerminateWorkflowExecutionParameters(workflowExecution, reason, details);
57+
58+
assertEquals(workflowExecution, params.getWorkflowExecution());
59+
assertEquals(reason, params.getReason());
60+
assertArrayEquals(details, params.getDetails());
61+
}
62+
63+
@Test
64+
public void testSettersAndGetters() {
65+
TerminateWorkflowExecutionParameters params = new TerminateWorkflowExecutionParameters();
66+
params.setWorkflowExecution(workflowExecution);
67+
params.setReason(reason);
68+
params.setDetails(details);
69+
70+
assertEquals(workflowExecution, params.getWorkflowExecution());
71+
assertEquals(reason, params.getReason());
72+
assertArrayEquals(details, params.getDetails());
73+
}
74+
75+
@Test
76+
public void testFluentSetters() {
77+
TerminateWorkflowExecutionParameters params =
78+
new TerminateWorkflowExecutionParameters()
79+
.withWorkflowExecution(workflowExecution)
80+
.withReason(reason)
81+
.withDetails(details);
82+
83+
assertEquals(workflowExecution, params.getWorkflowExecution());
84+
assertEquals(reason, params.getReason());
85+
assertArrayEquals(details, params.getDetails());
86+
}
87+
}

0 commit comments

Comments
 (0)