@@ -4037,42 +4037,29 @@ public String execute(String taskList) {
4037
4037
4038
4038
// Test adding a version check in non-replay code.
4039
4039
int version = Workflow .getVersion ("test_change" , Workflow .DEFAULT_VERSION , 1 );
4040
- String result = "" ;
4041
- if (version == Workflow .DEFAULT_VERSION ) {
4042
- result += "activity" + testActivities .activity1 (1 );
4043
- } else {
4044
- result += testActivities .activity2 ("activity2" , 2 ); // This is executed.
4045
- }
4040
+ assertEquals (version , 1 );
4041
+ String result = testActivities .activity2 ("activity2" , 2 );
4046
4042
4047
4043
// Test version change in non-replay code.
4048
4044
version = Workflow .getVersion ("test_change" , 1 , 2 );
4049
- if (version == 1 ) {
4050
- result += "activity" + testActivities .activity1 (1 ); // This is executed.
4051
- } else {
4052
- result += testActivities .activity2 ("activity2" , 2 );
4053
- }
4045
+ assertEquals (version , 1 );
4046
+ result += "activity" + testActivities .activity1 (1 );
4054
4047
4055
4048
// Test adding a version check in replay code.
4056
4049
if (!getVersionExecuted .contains (taskList + "-test_change_2" )) {
4057
4050
result += "activity" + testActivities .activity1 (1 ); // This is executed in non-replay mode.
4058
4051
getVersionExecuted .add (taskList + "-test_change_2" );
4059
4052
} else {
4060
4053
int version2 = Workflow .getVersion ("test_change_2" , Workflow .DEFAULT_VERSION , 1 );
4061
- if (version2 == Workflow .DEFAULT_VERSION ) {
4062
- result += "activity" + testActivities .activity1 (1 ); // This is executed in replay mode.
4063
- } else {
4064
- result += testActivities .activity2 ("activity2" , 2 );
4065
- }
4054
+ assertEquals (version2 , Workflow .DEFAULT_VERSION );
4055
+ result += "activity" + testActivities .activity1 (1 );
4066
4056
}
4067
4057
4068
4058
// Test get version in replay mode.
4069
4059
Workflow .sleep (1000 );
4070
4060
version = Workflow .getVersion ("test_change" , 1 , 2 );
4071
- if (version == 1 ) {
4072
- result += "activity" + testActivities .activity1 (1 ); // This is executed.
4073
- } else {
4074
- result += testActivities .activity2 ("activity2" , 2 );
4075
- }
4061
+ assertEquals (version , 1 );
4062
+ result += "activity" + testActivities .activity1 (1 );
4076
4063
4077
4064
return result ;
4078
4065
}
@@ -4097,6 +4084,40 @@ public void testGetVersion() {
4097
4084
"executeActivity customActivity1" );
4098
4085
}
4099
4086
4087
+ public static class TestGetVersionWorkflow2Impl implements TestWorkflow1 {
4088
+
4089
+ @ Override
4090
+ public String execute (String taskList ) {
4091
+ // Test adding a version check in replay code.
4092
+ if (!getVersionExecuted .contains (taskList + "-test_change_2" )) {
4093
+ getVersionExecuted .add (taskList + "-test_change_2" );
4094
+ Workflow .sleep (Duration .ofHours (1 ));
4095
+ } else {
4096
+ int version2 = Workflow .getVersion ("test_change_2" , Workflow .DEFAULT_VERSION , 1 );
4097
+ Workflow .sleep (Duration .ofHours (1 ));
4098
+ int version3 = Workflow .getVersion ("test_change_2" , Workflow .DEFAULT_VERSION , 1 );
4099
+
4100
+ assertEquals (version2 , version3 );
4101
+ }
4102
+
4103
+ return "test" ;
4104
+ }
4105
+ }
4106
+
4107
+ @ Test
4108
+ public void testGetVersion2 () {
4109
+ Assume .assumeFalse ("skipping for docker tests" , useExternalService );
4110
+
4111
+ startWorkerFor (TestGetVersionWorkflow2Impl .class );
4112
+ TestWorkflow1 workflowStub =
4113
+ workflowClient .newWorkflowStub (
4114
+ TestWorkflow1 .class ,
4115
+ newWorkflowOptionsBuilder (taskList )
4116
+ .setExecutionStartToCloseTimeout (Duration .ofHours (2 ))
4117
+ .build ());
4118
+ workflowStub .execute (taskList );
4119
+ }
4120
+
4100
4121
static CompletableFuture <Boolean > executionStarted = new CompletableFuture <>();
4101
4122
4102
4123
public static class TestGetVersionWithoutDecisionEventWorkflowImpl
0 commit comments