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,19 @@ 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+ System .out .println (finalSearchAttributes .get (TEST_SEARCH_ATTRIBUTE_DATE_TIME ));
117+
118+ Assertions .assertEquals (ImmutableMap .builder ()
119+ .put (TEST_SEARCH_ATTRIBUTE_INT , 2L )
120+ .put (TEST_SEARCH_ATTRIBUTE_KEYWORD , "keyword-2" )
121+ // .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
122+ .put (TEST_SEARCH_ATTRIBUTE_DATE_TIME , testDateTimeValue )
123+ .build (), finalSearchAttributes );
117124 }
118125
119126 @ Test
@@ -178,39 +185,40 @@ public void testSetSearchAttributes() {
178185 SEARCH_ATTRIBUTE_INT , INTEGER_VALUE_1 ,
179186 SEARCH_ATTRIBUTE_BOOL , BOOLEAN_VALUE_1 ,
180187 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
188+ // 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
189+ SEARCH_ATTRIBUTE_DATE_TIME , "2024-11-13T00:00:01.731455544Z"
182190 );
183191 Assertions .assertEquals (expectedSearchAttributes , returnedSearchAttributes );
184192 }
185193
186194 @ Test
187- public void testSetDataObjects () {
195+ public void testSetDataAttributes () {
188196 final Client client = new Client (WorkflowRegistry .registry , ClientOptions .localDefault );
189197 final String wfId = "set-data-objects-test-id" + System .currentTimeMillis () / 1000 ;
190198 final String runId = client .startWorkflow (
191- SetDataObjectWorkflow .class , wfId , 10 , "start" );
199+ SetDataAttributeWorkflow .class , wfId , 10 , "start" );
192200
193- final String dataObjectKeyWithPrefix = DATA_OBJECT_KEY_PREFIX + "1" ;
194- final Map <String , Object > dataObjects = ImmutableMap .of (
201+ final String dataAttributeKeyWithPrefix = DATA_OBJECT_KEY_PREFIX + "1" ;
202+ final Map <String , Object > dataAttributes = ImmutableMap .of (
195203 DATA_OBJECT_KEY , "query-start" ,
196204 DATA_OBJECT_MODEL_KEY , new io .iworkflow .gen .models .Context (),
197- dataObjectKeyWithPrefix , 20L );
205+ dataAttributeKeyWithPrefix , 20L );
198206
199207 client .setWorkflowDataAttributes (
200- SetDataObjectWorkflow .class ,
208+ SetDataAttributeWorkflow .class ,
201209 wfId ,
202210 runId ,
203- dataObjects );
211+ dataAttributes );
204212
205213 //Wait for workflow to complete to ensure data objects values were added
206214 final String result = client .waitForWorkflowCompletion (String .class , wfId );
207215 Assertions .assertEquals ("test-result" , result );
208216
209- final Map <String , Object > actualDataObjects = client .getWorkflowDataAttributes (
210- SetDataObjectWorkflow .class ,
217+ final Map <String , Object > actualDataAttributes = client .getWorkflowDataAttributes (
218+ SetDataAttributeWorkflow .class ,
211219 wfId ,
212- Arrays .asList (DATA_OBJECT_KEY , DATA_OBJECT_MODEL_KEY , dataObjectKeyWithPrefix ));
213- Assertions .assertEquals (dataObjects , actualDataObjects );
220+ Arrays .asList (DATA_OBJECT_KEY , DATA_OBJECT_MODEL_KEY , dataAttributeKeyWithPrefix ));
221+ Assertions .assertEquals (dataAttributes , actualDataAttributes );
214222 }
215223
216224}
0 commit comments