77import io .iworkflow .gen .models .SearchAttribute ;
88import io .iworkflow .gen .models .SearchAttributeValueType ;
99import io .iworkflow .integ .persistence .BasicPersistenceWorkflow ;
10- import io .iworkflow .integ .persistence .SetDataObjectWorkflow ;
10+ import io .iworkflow .integ .persistence .SetDataAttributeWorkflow ;
1111import io .iworkflow .integ .persistence .SetSearchAttributeWorkflow ;
1212import io .iworkflow .spring .TestSingletonWorkerService ;
1313import io .iworkflow .spring .controller .WorkflowRegistry ;
2020import java .util .Map ;
2121import java .util .concurrent .ExecutionException ;
2222
23+ import static io .iworkflow .integ .persistence .BasicPersistenceWorkflow .TEST_SEARCH_ATTRIBUTE_DATE_TIME ;
2324import static io .iworkflow .integ .persistence .BasicPersistenceWorkflow .TEST_SEARCH_ATTRIBUTE_INT ;
2425import static io .iworkflow .integ .persistence .BasicPersistenceWorkflow .TEST_SEARCH_ATTRIBUTE_KEYWORD ;
25- import static io .iworkflow .integ .persistence .SetDataObjectWorkflow .DATA_OBJECT_KEY ;
26- import static io .iworkflow .integ .persistence .SetDataObjectWorkflow .DATA_OBJECT_KEY_PREFIX ;
27- import static io .iworkflow .integ .persistence .SetDataObjectWorkflow .DATA_OBJECT_MODEL_KEY ;
26+ import static io .iworkflow .integ .persistence .BasicPersistenceWorkflowState1 .testDateTimeValue ;
27+ import static io .iworkflow .integ .persistence .SetDataAttributeWorkflow .DATA_OBJECT_KEY ;
28+ import static io .iworkflow .integ .persistence .SetDataAttributeWorkflow .DATA_OBJECT_KEY_PREFIX ;
29+ import static io .iworkflow .integ .persistence .SetDataAttributeWorkflow .DATA_OBJECT_MODEL_KEY ;
2830import static io .iworkflow .integ .persistence .SetSearchAttributeWorkflow .SEARCH_ATTRIBUTE_BOOL ;
2931import static io .iworkflow .integ .persistence .SetSearchAttributeWorkflow .SEARCH_ATTRIBUTE_DATE_TIME ;
3032import static io .iworkflow .integ .persistence .SetSearchAttributeWorkflow .SEARCH_ATTRIBUTE_DOUBLE ;
@@ -80,16 +82,16 @@ public void testPersistenceWorkflow() throws InterruptedException {
8082 Assertions .assertEquals (
8183 "query-start-query-decide" , map2 .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
8284
83- Map <String , Object > allDataObjects = client .getAllDataAttributes (BasicPersistenceWorkflow .class , wfId , runId );
84- Assertions .assertEquals (5 , allDataObjects .size ());
85- Assertions .assertEquals ("query-start-query-decide" , allDataObjects .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
86- Assertions .assertEquals (11L , allDataObjects .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_PREFIX + "1" ));
85+ Map <String , Object > allDataAttributes = client .getAllDataAttributes (BasicPersistenceWorkflow .class , wfId , runId );
86+ Assertions .assertEquals (5 , allDataAttributes .size ());
87+ Assertions .assertEquals ("query-start-query-decide" , allDataAttributes .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
88+ Assertions .assertEquals (11L , allDataAttributes .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_PREFIX + "1" ));
8789
8890 // test no runId
89- Map <String , Object > allDataObjects2 = client .getAllDataAttributes (BasicPersistenceWorkflow .class , wfId );
90- Assertions .assertEquals (5 , allDataObjects2 .size ());
91- Assertions .assertEquals ("query-start-query-decide" , allDataObjects2 .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
92- Assertions .assertEquals (11L , allDataObjects .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_PREFIX + "1" ));
91+ Map <String , Object > allDataAttributes2 = client .getAllDataAttributes (BasicPersistenceWorkflow .class , wfId );
92+ Assertions .assertEquals (5 , allDataAttributes2 .size ());
93+ Assertions .assertEquals ("query-start-query-decide" , allDataAttributes2 .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
94+ Assertions .assertEquals (11L , allDataAttributes .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_PREFIX + "1" ));
9395
9496 final Map <String , Object > searchAttributes1 = client .getWorkflowSearchAttributes (BasicPersistenceWorkflow .class ,
9597 wfId , "" , Arrays .asList (TEST_SEARCH_ATTRIBUTE_KEYWORD , TEST_SEARCH_ATTRIBUTE_INT ));
@@ -106,14 +108,17 @@ public void testPersistenceWorkflow() throws InterruptedException {
106108 .put (TEST_SEARCH_ATTRIBUTE_KEYWORD , "keyword-2" )
107109 .build (), searchAttributes2 );
108110
109- // TODO fix
110- // Expected :{CustomIntField=2, CustomKeywordField=keyword-2, CustomDatetimeField=2023-04-17T21:17:49-00:00}
111- // Actual :{CustomDatetimeField=2023-04-17T21:17:49Z, CustomIntField=2, CustomKeywordField=keyword-2}
112- // Assertions.assertEquals(ImmutableMap.builder()
113- // .put(TEST_SEARCH_ATTRIBUTE_INT, 2L)
114- // .put(TEST_SEARCH_ATTRIBUTE_KEYWORD, "keyword-2")
115- // .put(TEST_SEARCH_ATTRIBUTE_DATE_TIME, testDateTimeValue)
116- // .build(), searchAttributes2);
111+ client .waitForWorkflowCompletion (wfId );
112+
113+ final Map <String , Object > finalSearchAttributes = client .getAllSearchAttributes (BasicPersistenceWorkflow .class ,
114+ wfId );
115+
116+ Assertions .assertEquals (ImmutableMap .builder ()
117+ .put (TEST_SEARCH_ATTRIBUTE_INT , 2L )
118+ .put (TEST_SEARCH_ATTRIBUTE_KEYWORD , "keyword-2" )
119+ // .put(TEST_SEARCH_ATTRIBUTE_DATE_TIME, "2023-04-17T16:17:49-05:00") // This is a bug. The iwf-server always returns utc time. See https://github.com/indeedeng/iwf/issues/261
120+ .put (TEST_SEARCH_ATTRIBUTE_DATE_TIME , testDateTimeValue )
121+ .build (), finalSearchAttributes );
117122 }
118123
119124 @ Test
@@ -178,39 +183,40 @@ public void testSetSearchAttributes() {
178183 SEARCH_ATTRIBUTE_INT , INTEGER_VALUE_1 ,
179184 SEARCH_ATTRIBUTE_BOOL , BOOLEAN_VALUE_1 ,
180185 SEARCH_ATTRIBUTE_KEYWORD_ARRAY , ARRAY_STRING_VALUE_1 ,
181- SEARCH_ATTRIBUTE_DATE_TIME , "2024-11-13T00:00:01.731455544Z" //This is a bug. The iwf-server always returns utc time. See https://github.com/indeedeng/iwf/issues/261
186+ // SEARCH_ATTRIBUTE_DATE_TIME, "2024-11-12T18:00:01.731455544-06:00" //This is a bug. The iwf-server always returns utc time. See https://github.com/indeedeng/iwf/issues/261
187+ SEARCH_ATTRIBUTE_DATE_TIME , "2024-11-13T00:00:01.731455544Z"
182188 );
183189 Assertions .assertEquals (expectedSearchAttributes , returnedSearchAttributes );
184190 }
185191
186192 @ Test
187- public void testSetDataObjects () {
193+ public void testSetDataAttributes () {
188194 final Client client = new Client (WorkflowRegistry .registry , ClientOptions .localDefault );
189195 final String wfId = "set-data-objects-test-id" + System .currentTimeMillis () / 1000 ;
190196 final String runId = client .startWorkflow (
191- SetDataObjectWorkflow .class , wfId , 10 , "start" );
197+ SetDataAttributeWorkflow .class , wfId , 10 , "start" );
192198
193- final String dataObjectKeyWithPrefix = DATA_OBJECT_KEY_PREFIX + "1" ;
194- final Map <String , Object > dataObjects = ImmutableMap .of (
199+ final String dataAttributeKeyWithPrefix = DATA_OBJECT_KEY_PREFIX + "1" ;
200+ final Map <String , Object > dataAttributes = ImmutableMap .of (
195201 DATA_OBJECT_KEY , "query-start" ,
196202 DATA_OBJECT_MODEL_KEY , new io .iworkflow .gen .models .Context (),
197- dataObjectKeyWithPrefix , 20L );
203+ dataAttributeKeyWithPrefix , 20L );
198204
199205 client .setWorkflowDataAttributes (
200- SetDataObjectWorkflow .class ,
206+ SetDataAttributeWorkflow .class ,
201207 wfId ,
202208 runId ,
203- dataObjects );
209+ dataAttributes );
204210
205211 //Wait for workflow to complete to ensure data objects values were added
206212 final String result = client .waitForWorkflowCompletion (String .class , wfId );
207213 Assertions .assertEquals ("test-result" , result );
208214
209- final Map <String , Object > actualDataObjects = client .getWorkflowDataAttributes (
210- SetDataObjectWorkflow .class ,
215+ final Map <String , Object > actualDataAttributes = client .getWorkflowDataAttributes (
216+ SetDataAttributeWorkflow .class ,
211217 wfId ,
212- Arrays .asList (DATA_OBJECT_KEY , DATA_OBJECT_MODEL_KEY , dataObjectKeyWithPrefix ));
213- Assertions .assertEquals (dataObjects , actualDataObjects );
218+ Arrays .asList (DATA_OBJECT_KEY , DATA_OBJECT_MODEL_KEY , dataAttributeKeyWithPrefix ));
219+ Assertions .assertEquals (dataAttributes , actualDataAttributes );
214220 }
215221
216222}
0 commit comments