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 .SetDataAttributeWorkflow .DATA_OBJECT_KEY ;
27+ import static io .iworkflow .integ .persistence .SetDataAttributeWorkflow .DATA_OBJECT_KEY_PREFIX ;
28+ import static io .iworkflow .integ .persistence .SetDataAttributeWorkflow .DATA_OBJECT_MODEL_KEY ;
2829import static io .iworkflow .integ .persistence .SetSearchAttributeWorkflow .SEARCH_ATTRIBUTE_BOOL ;
2930import static io .iworkflow .integ .persistence .SetSearchAttributeWorkflow .SEARCH_ATTRIBUTE_DATE_TIME ;
3031import static io .iworkflow .integ .persistence .SetSearchAttributeWorkflow .SEARCH_ATTRIBUTE_DOUBLE ;
@@ -80,16 +81,16 @@ public void testPersistenceWorkflow() throws InterruptedException {
8081 Assertions .assertEquals (
8182 "query-start-query-decide" , map2 .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
8283
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" ));
84+ Map <String , Object > allDataAttributes = client .getAllDataAttributes (BasicPersistenceWorkflow .class , wfId , runId );
85+ Assertions .assertEquals (5 , allDataAttributes .size ());
86+ Assertions .assertEquals ("query-start-query-decide" , allDataAttributes .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
87+ Assertions .assertEquals (11L , allDataAttributes .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_PREFIX + "1" ));
8788
8889 // 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" ));
90+ Map <String , Object > allDataAttributes2 = client .getAllDataAttributes (BasicPersistenceWorkflow .class , wfId );
91+ Assertions .assertEquals (5 , allDataAttributes2 .size ());
92+ Assertions .assertEquals ("query-start-query-decide" , allDataAttributes2 .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_KEY ));
93+ Assertions .assertEquals (11L , allDataAttributes .get (BasicPersistenceWorkflow .TEST_DATA_OBJECT_PREFIX + "1" ));
9394
9495 final Map <String , Object > searchAttributes1 = client .getWorkflowSearchAttributes (BasicPersistenceWorkflow .class ,
9596 wfId , "" , Arrays .asList (TEST_SEARCH_ATTRIBUTE_KEYWORD , TEST_SEARCH_ATTRIBUTE_INT ));
@@ -106,14 +107,17 @@ public void testPersistenceWorkflow() throws InterruptedException {
106107 .put (TEST_SEARCH_ATTRIBUTE_KEYWORD , "keyword-2" )
107108 .build (), searchAttributes2 );
108109
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);
110+ client .waitForWorkflowCompletion (wfId );
111+
112+ final Map <String , Object > finalSearchAttributes = client .getAllSearchAttributes (BasicPersistenceWorkflow .class ,
113+ wfId );
114+
115+ Assertions .assertEquals (ImmutableMap .builder ()
116+ .put (TEST_SEARCH_ATTRIBUTE_INT , 2L )
117+ .put (TEST_SEARCH_ATTRIBUTE_KEYWORD , "keyword-2" )
118+ // .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
119+ .put (TEST_SEARCH_ATTRIBUTE_DATE_TIME , "2023-04-17T21:17:49Z" )
120+ .build (), finalSearchAttributes );
117121 }
118122
119123 @ Test
@@ -178,39 +182,40 @@ public void testSetSearchAttributes() {
178182 SEARCH_ATTRIBUTE_INT , INTEGER_VALUE_1 ,
179183 SEARCH_ATTRIBUTE_BOOL , BOOLEAN_VALUE_1 ,
180184 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
185+ // 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
186+ SEARCH_ATTRIBUTE_DATE_TIME , "2024-11-13T00:00:01.731455544Z"
182187 );
183188 Assertions .assertEquals (expectedSearchAttributes , returnedSearchAttributes );
184189 }
185190
186191 @ Test
187- public void testSetDataObjects () {
192+ public void testSetDataAttributes () {
188193 final Client client = new Client (WorkflowRegistry .registry , ClientOptions .localDefault );
189194 final String wfId = "set-data-objects-test-id" + System .currentTimeMillis () / 1000 ;
190195 final String runId = client .startWorkflow (
191- SetDataObjectWorkflow .class , wfId , 10 , "start" );
196+ SetDataAttributeWorkflow .class , wfId , 10 , "start" );
192197
193- final String dataObjectKeyWithPrefix = DATA_OBJECT_KEY_PREFIX + "1" ;
194- final Map <String , Object > dataObjects = ImmutableMap .of (
198+ final String dataAttributeKeyWithPrefix = DATA_OBJECT_KEY_PREFIX + "1" ;
199+ final Map <String , Object > dataAttributes = ImmutableMap .of (
195200 DATA_OBJECT_KEY , "query-start" ,
196201 DATA_OBJECT_MODEL_KEY , new io .iworkflow .gen .models .Context (),
197- dataObjectKeyWithPrefix , 20L );
202+ dataAttributeKeyWithPrefix , 20L );
198203
199204 client .setWorkflowDataAttributes (
200- SetDataObjectWorkflow .class ,
205+ SetDataAttributeWorkflow .class ,
201206 wfId ,
202207 runId ,
203- dataObjects );
208+ dataAttributes );
204209
205210 //Wait for workflow to complete to ensure data objects values were added
206211 final String result = client .waitForWorkflowCompletion (String .class , wfId );
207212 Assertions .assertEquals ("test-result" , result );
208213
209- final Map <String , Object > actualDataObjects = client .getWorkflowDataAttributes (
210- SetDataObjectWorkflow .class ,
214+ final Map <String , Object > actualDataAttributes = client .getWorkflowDataAttributes (
215+ SetDataAttributeWorkflow .class ,
211216 wfId ,
212- Arrays .asList (DATA_OBJECT_KEY , DATA_OBJECT_MODEL_KEY , dataObjectKeyWithPrefix ));
213- Assertions .assertEquals (dataObjects , actualDataObjects );
217+ Arrays .asList (DATA_OBJECT_KEY , DATA_OBJECT_MODEL_KEY , dataAttributeKeyWithPrefix ));
218+ Assertions .assertEquals (dataAttributes , actualDataAttributes );
214219 }
215220
216221}
0 commit comments