Skip to content

Commit f62dd49

Browse files
Clean up some test assertions and make sure naming is consistent.
1 parent 4e9cc06 commit f62dd49

56 files changed

Lines changed: 146 additions & 157 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

temporal-opentracing/src/test/java/io/temporal/opentracing/ActivityFailureTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.temporal.opentracing;
22

33
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNull;
45

56
import io.opentracing.Scope;
67
import io.opentracing.mock.MockSpan;
@@ -252,10 +253,10 @@ public void testBenignApplicationFailureSpanBehavior() {
252253

253254
// Second attempt: benign failure - should NOT have ERROR tag
254255
MockSpan secondAttemptSpan = activityRunSpans.get(1);
255-
assertEquals(null, secondAttemptSpan.tags().get(Tags.ERROR.getKey()));
256+
assertNull(secondAttemptSpan.tags().get(Tags.ERROR.getKey()));
256257

257258
// Third attempt: success - should not have ERROR tag
258259
MockSpan thirdAttemptSpan = activityRunSpans.get(2);
259-
assertEquals(null, thirdAttemptSpan.tags().get(Tags.ERROR.getKey()));
260+
assertNull(thirdAttemptSpan.tags().get(Tags.ERROR.getKey()));
260261
}
261262
}

temporal-sdk/src/test/java/io/temporal/activity/ActivityOptionsTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.temporal.activity;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
import static org.junit.Assert.assertTrue;
6-
import static org.junit.Assert.fail;
3+
import static org.junit.Assert.*;
74

85
import io.temporal.common.MethodRetry;
96
import io.temporal.common.RetryOptions;
@@ -49,8 +46,8 @@ public void testActivityOptions() {
4946
} catch (IllegalArgumentException e) {
5047
Assert.assertTrue(e instanceof IllegalArgumentException);
5148
Assert.assertEquals(
52-
e.getMessage(),
53-
"Both StartToCloseTimeout and ScheduleToCloseTimeout aren't specified for Activity1 activity. Please set at least one of the above through the ActivityStub or WorkflowImplementationOptions.");
49+
"Both StartToCloseTimeout and ScheduleToCloseTimeout aren't specified for Activity1 activity. Please set at least one of the above through the ActivityStub or WorkflowImplementationOptions.",
50+
e.getMessage());
5451
}
5552
}
5653

@@ -124,6 +121,6 @@ public void testLocalActivityOptions() {
124121
assertNotNull(retryOptions);
125122
assertEquals(2.0, retryOptions.getBackoffCoefficient(), 0e-5);
126123
assertEquals(Duration.ofSeconds(1), retryOptions.getInitialInterval());
127-
assertEquals(null, retryOptions.getMaximumInterval());
124+
assertNull(retryOptions.getMaximumInterval());
128125
}
129126
}

temporal-sdk/src/test/java/io/temporal/client/functional/UpdateTestTimeout.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
import org.junit.Rule;
1818
import org.junit.Test;
1919

20-
public class UpdateTestTimeout {
20+
public class UpdateTestTimeoutTest {
2121

2222
@Rule
2323
public SDKTestWorkflowRule testWorkflowRule =
2424
SDKTestWorkflowRule.newBuilder()
2525
.setUseTimeskipping(false)
26-
.setWorkflowTypes(UpdateTestTimeout.BlockingWorkflowImpl.class)
26+
.setWorkflowTypes(UpdateTestTimeoutTest.BlockingWorkflowImpl.class)
2727
.build();
2828

2929
@Test

temporal-sdk/src/test/java/io/temporal/client/schedules/ScheduleTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,37 +125,37 @@ public void pauseUnpauseSchedule() {
125125
ScheduleDescription description = handle.describe();
126126
// Verify the initial state of the schedule
127127
Assert.assertEquals("", description.getSchedule().getState().getNote());
128-
Assert.assertEquals(false, description.getSchedule().getState().isPaused());
128+
Assert.assertFalse(description.getSchedule().getState().isPaused());
129129
// Pause the schedule
130130
handle.pause();
131131
description = handle.describe();
132132
Assert.assertEquals("Paused via Java SDK", description.getSchedule().getState().getNote());
133-
Assert.assertEquals(true, description.getSchedule().getState().isPaused());
133+
Assert.assertTrue(description.getSchedule().getState().isPaused());
134134

135135
handle.unpause();
136136
description = handle.describe();
137137
Assert.assertEquals("Unpaused via Java SDK", description.getSchedule().getState().getNote());
138-
Assert.assertEquals(false, description.getSchedule().getState().isPaused());
138+
Assert.assertFalse(description.getSchedule().getState().isPaused());
139139

140140
handle.pause("pause via test");
141141
description = handle.describe();
142142
Assert.assertEquals("pause via test", description.getSchedule().getState().getNote());
143-
Assert.assertEquals(true, description.getSchedule().getState().isPaused());
143+
Assert.assertTrue(description.getSchedule().getState().isPaused());
144144

145145
handle.pause("");
146146
description = handle.describe();
147147
Assert.assertEquals("Paused via Java SDK", description.getSchedule().getState().getNote());
148-
Assert.assertEquals(true, description.getSchedule().getState().isPaused());
148+
Assert.assertTrue(description.getSchedule().getState().isPaused());
149149

150150
handle.unpause("unpause via test");
151151
description = handle.describe();
152152
Assert.assertEquals("unpause via test", description.getSchedule().getState().getNote());
153-
Assert.assertEquals(false, description.getSchedule().getState().isPaused());
153+
Assert.assertFalse(description.getSchedule().getState().isPaused());
154154

155155
handle.unpause("");
156156
description = handle.describe();
157157
Assert.assertEquals("Unpaused via Java SDK", description.getSchedule().getState().getNote());
158-
Assert.assertEquals(false, description.getSchedule().getState().isPaused());
158+
Assert.assertFalse(description.getSchedule().getState().isPaused());
159159
// Cleanup schedule
160160
handle.delete();
161161
// Try to unpause a deleted schedule
@@ -182,7 +182,7 @@ public void limitedActionSchedule() {
182182
// Verify all 3 actions have run
183183
ScheduleDescription description = handle.describe();
184184
Assert.assertEquals(0, description.getSchedule().getState().getRemainingActions());
185-
Assert.assertEquals(true, description.getSchedule().getState().isLimitedAction());
185+
Assert.assertTrue(description.getSchedule().getState().isLimitedAction());
186186
// Cleanup schedule
187187
handle.delete();
188188
}
@@ -463,7 +463,7 @@ public void updateSchedules() {
463463
Assert.assertEquals("memoval3", memoValue);
464464
//
465465
Assert.assertNotEquals(expectedUpdateTime, description.getInfo().getLastUpdatedAt());
466-
Assert.assertEquals(true, description.getSchedule().getState().isPaused());
466+
Assert.assertTrue(description.getSchedule().getState().isPaused());
467467
Assert.assertEquals(1, description.getTypedSearchAttributes().size());
468468
Assert.assertEquals(
469469
keywordSAValue, description.getTypedSearchAttributes().get(CUSTOM_KEYWORD_SA));
@@ -527,7 +527,7 @@ public void listSchedules() {
527527
Assert.assertEquals(scheduleId, listDescription.getScheduleId());
528528
// Verify the state
529529
Assert.assertEquals("schedule list", listDescription.getSchedule().getState().getNote());
530-
Assert.assertEquals(true, listDescription.getSchedule().getState().isPaused());
530+
Assert.assertTrue(listDescription.getSchedule().getState().isPaused());
531531
// Verify the spec
532532
Assert.assertEquals(
533533
ScheduleSpec.newBuilder(schedule.getSpec())

temporal-sdk/src/test/java/io/temporal/client/schedules/ScheduleWithTypedSearchAttributesTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ public void createScheduleWithTypedSearchAttributes() {
100100
// Verify the actions search attributes
101101
ScheduleActionStartWorkflow action =
102102
(ScheduleActionStartWorkflow) description.getSchedule().getAction();
103-
Assert.assertEquals(null, action.getOptions().getSearchAttributes());
103+
Assert.assertNull(action.getOptions().getSearchAttributes());
104104
Assert.assertEquals(3, action.getOptions().getTypedSearchAttributes().size());
105-
Assert.assertEquals(
106-
true, action.getOptions().getTypedSearchAttributes().containsKey(CUSTOM_DOUBLE_SA));
105+
Assert.assertTrue(action.getOptions().getTypedSearchAttributes().containsKey(CUSTOM_DOUBLE_SA));
107106
// Clean up schedule
108107
handle.delete();
109108
}

temporal-sdk/src/test/java/io/temporal/common/converter/JsonDataConverterTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.temporal.common.converter;
22

33
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNull;
45

56
import com.google.common.base.Objects;
67
import io.temporal.api.common.v1.Payloads;
@@ -118,9 +119,9 @@ public void MissingInputArgumentsArePopulatedWithDefaultValues() throws NoSuchMe
118119
converter.fromPayloads(data, m.getParameterTypes(), m.getGenericParameterTypes());
119120
assertEquals(5, deserializedArguments.length);
120121
assertEquals(1, (int) deserializedArguments[0]);
121-
assertEquals(null, deserializedArguments[1]);
122-
assertEquals(null, deserializedArguments[2]);
123-
assertEquals(null, deserializedArguments[3]);
124-
assertEquals(null, deserializedArguments[4]);
122+
assertNull(deserializedArguments[1]);
123+
assertNull(deserializedArguments[2]);
124+
assertNull(deserializedArguments[3]);
125+
assertNull(deserializedArguments[4]);
125126
}
126127
}

temporal-sdk/src/test/java/io/temporal/common/metadata/POJOWorkflowImplMetadataTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public void testMetadataDWithAdditionalInterface() {
9494
metadata ->
9595
assertNotEquals(
9696
"O is not a workflow interface and shouldn't be returned",
97-
metadata.getInterfaceClass(),
98-
POJOWorkflowInterfaceMetadataTest.O.class));
97+
POJOWorkflowInterfaceMetadataTest.O.class,
98+
metadata.getInterfaceClass()));
9999
}
100100

101101
@Test

temporal-sdk/src/test/java/io/temporal/internal/nexus/PayloadSerializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void testPayload() {
2424
@Test
2525
public void testNull() {
2626
PayloadSerializer.Content content = payloadSerializer.serialize(null);
27-
Assert.assertEquals(null, payloadSerializer.deserialize(content, String.class));
27+
Assert.assertNull(payloadSerializer.deserialize(content, String.class));
2828
}
2929

3030
@Test

temporal-sdk/src/test/java/io/temporal/internal/nexus/WorkflowRunTokenTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void loadWorkflowIdFromOperationToken() {
7171
OperationTokenUtil.loadWorkflowRunOperationToken(encoder.encodeToString(json.getBytes()));
7272
Assert.assertEquals("workflowId", token.getWorkflowId());
7373
Assert.assertEquals("namespace", token.getNamespace());
74-
Assert.assertEquals(null, token.getVersion());
74+
Assert.assertNull(token.getVersion());
7575
Assert.assertEquals(OperationTokenType.WORKFLOW_RUN, token.getType());
7676

7777
Assert.assertEquals(

temporal-sdk/src/test/java/io/temporal/internal/replay/WarnUnfinishedHandlers.java renamed to temporal-sdk/src/test/java/io/temporal/internal/replay/WarnUnfinishedHandlersTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.Test;
2222
import org.slf4j.LoggerFactory;
2323

24-
public class WarnUnfinishedHandlers {
24+
public class WarnUnfinishedHandlersTest {
2525

2626
@Rule
2727
public SDKTestWorkflowRule testWorkflowRule =
@@ -82,14 +82,14 @@ void assertLogs(Boolean expectLogs) {
8282
assertEquals(Level.WARN, logsList.get(0).getLevel());
8383
assertEquals(unfinishedSignalHandlesWarnMessage, logsList.get(0).getMessage());
8484
assertEquals(
85-
logsList.get(0).getMDCPropertyMap().get("Signals"),
86-
"[SignalHandlerInfo{eventId=5, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=9, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=13, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=17, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=21, name='warningSignalHandler', policy=WARN_AND_ABANDON}]");
85+
"[SignalHandlerInfo{eventId=5, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=9, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=13, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=17, name='warningSignalHandler', policy=WARN_AND_ABANDON}, SignalHandlerInfo{eventId=21, name='warningSignalHandler', policy=WARN_AND_ABANDON}]",
86+
logsList.get(0).getMDCPropertyMap().get("Signals"));
8787

8888
assertEquals(Level.WARN, logsList.get(1).getLevel());
8989
assertEquals(unfinishedUpdateHandlesWarnMessage, logsList.get(1).getMessage());
9090
assertEquals(
91-
logsList.get(1).getMDCPropertyMap().get("Updates"),
92-
"[UpdateHandlerInfo{updateId='0', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='1', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='2', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='3', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='4', name='warningUpdateHandler', policy=WARN_AND_ABANDON}]");
91+
"[UpdateHandlerInfo{updateId='0', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='1', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='2', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='3', name='warningUpdateHandler', policy=WARN_AND_ABANDON}, UpdateHandlerInfo{updateId='4', name='warningUpdateHandler', policy=WARN_AND_ABANDON}]",
92+
logsList.get(1).getMDCPropertyMap().get("Updates"));
9393
} else {
9494
assertEquals(0, logsList.size());
9595
}

0 commit comments

Comments
 (0)