@@ -221,4 +221,36 @@ public void testGetInputsFromPreviousSteps() {
221
221
assertEquals ("Missing required inputs [not-here] in workflow [workflowId] node [nodeId]" , e .getMessage ());
222
222
assertEquals (RestStatus .BAD_REQUEST , e .getRestStatus ());
223
223
}
224
+
225
+ public void testParseIfExistsWithBooleanClass () {
226
+ Map <String , Object > inputs = new HashMap <>();
227
+ inputs .put ("key1" , "true" );
228
+ inputs .put ("key2" , "false" );
229
+ inputs .put ("key3" , "true" );
230
+
231
+ assertEquals (Boolean .TRUE , ParseUtils .parseIfExists (inputs , "key1" , Boolean .class ));
232
+ assertEquals (Boolean .FALSE , ParseUtils .parseIfExists (inputs , "key2" , Boolean .class ));
233
+ assertNull (ParseUtils .parseIfExists (inputs , "keyThatDoesntExist" , Boolean .class ));
234
+
235
+ }
236
+
237
+ public void testParseIfExistsWithFloatClass () {
238
+ Map <String , Object > inputs = new HashMap <>();
239
+ inputs .put ("key1" , "3.14" );
240
+ inputs .put ("key2" , "0.01" );
241
+ inputs .put ("key3" , "90.22" );
242
+
243
+ assertEquals (Float .valueOf ("3.14" ), ParseUtils .parseIfExists (inputs , "key1" , Float .class ));
244
+ assertEquals (Float .valueOf ("0.01" ), ParseUtils .parseIfExists (inputs , "key2" , Float .class ));
245
+ assertNull (ParseUtils .parseIfExists (inputs , "keyThatDoesntExist" , Float .class ));
246
+
247
+ }
248
+
249
+ public void testParseIfExistWhenWrongTypeIsPassed () {
250
+
251
+ Map <String , Object > inputs = new HashMap <>();
252
+ inputs .put ("key1" , "3.14" );
253
+
254
+ assertThrows (IllegalArgumentException .class , () -> ParseUtils .parseIfExists (inputs , "key1" , Integer .class ));
255
+ }
224
256
}
0 commit comments