@@ -546,6 +546,73 @@ public void testStartProcessWithVariables() throws Exception {
546
546
);
547
547
}
548
548
549
+ @ Test
550
+ @ Deployment (resources = { "org/flowable/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" })
551
+ public void testStartProcessWithJsonVariable () throws Exception {
552
+ ObjectNode request = objectMapper .createObjectNode ();
553
+ request .put ("processDefinitionKey" , "processOne" );
554
+ ArrayNode variablesNode = request .putArray ("variables" );
555
+
556
+ ObjectNode customerVariable = variablesNode .addObject ();
557
+ customerVariable .put ("name" , "customer" );
558
+ customerVariable .put ("type" , "json" );
559
+ customerVariable .putObject ("value" )
560
+ .put ("name" , "kermit" )
561
+ .put ("age" , 30 )
562
+ .putObject ("address" )
563
+ .put ("city" , "New York" );
564
+
565
+ HttpPost httpPost = new HttpPost (SERVER_URL_PREFIX + RestUrls .createRelativeResourceUrl (RestUrls .URL_PROCESS_INSTANCE_COLLECTION ));
566
+ httpPost .setEntity (new StringEntity (request .toString ()));
567
+ CloseableHttpResponse response = executeRequest (httpPost , HttpStatus .SC_CREATED );
568
+
569
+ JsonNode responseNode = objectMapper .readTree (response .getEntity ().getContent ());
570
+ closeResponse (response );
571
+ assertThatJson (responseNode )
572
+ .when (Option .IGNORING_EXTRA_FIELDS )
573
+ .isEqualTo ("{"
574
+ + " ended: false"
575
+ + "}" );
576
+ assertThatJson (responseNode )
577
+ .inPath ("variables" )
578
+ .isEqualTo ("""
579
+ [
580
+ {
581
+ name: 'customer',
582
+ type: 'json',
583
+ scope: 'local',
584
+ value: {
585
+ name: 'kermit',
586
+ age: 30,
587
+ address: {
588
+ city: 'New York'
589
+ }
590
+ }
591
+ }
592
+ ]
593
+ """ );
594
+
595
+ ProcessInstance processInstance = runtimeService .createProcessInstanceQuery ().singleResult ();
596
+ assertThat (processInstance ).isNotNull ();
597
+
598
+ // Check if engine has correct variables set
599
+ Map <String , Object > processVariables = runtimeService .getVariables (processInstance .getId ());
600
+ assertThat (processVariables ).containsOnlyKeys ("customer" );
601
+
602
+ assertThat (processVariables .get ("customer" ))
603
+ .isInstanceOf (JsonNode .class );
604
+ assertThatJson (processVariables .get ("customer" ))
605
+ .isEqualTo ("""
606
+ {
607
+ name: 'kermit',
608
+ age: 30,
609
+ address: {
610
+ city: 'New York'
611
+ }
612
+ }
613
+ """ );
614
+ }
615
+
549
616
/**
550
617
* Test starting a process instance passing in variables to set.
551
618
*/
0 commit comments