@@ -584,3 +584,61 @@ describe("Handling the rejection and the revocation of a Relationship by the Req
584
584
return sRelationship ;
585
585
}
586
586
} ) ;
587
+
588
+ describe ( "Handle Multiple RelationshipTemplate loadings" , ( ) => {
589
+ const runtimeServiceProvider = new RuntimeServiceProvider ( ) ;
590
+ let sRuntimeServices : TestRuntimeServices ;
591
+ let rRuntimeServices : TestRuntimeServices ;
592
+
593
+ beforeAll ( async ( ) => {
594
+ const runtimeServices = await runtimeServiceProvider . launch ( 2 , { enableRequestModule : true , enableDeciderModule : true } ) ;
595
+
596
+ sRuntimeServices = runtimeServices [ 0 ] ;
597
+ rRuntimeServices = runtimeServices [ 1 ] ;
598
+ } , 30000 ) ;
599
+
600
+ beforeEach ( ( ) => {
601
+ sRuntimeServices . eventBus . reset ( ) ;
602
+ rRuntimeServices . eventBus . reset ( ) ;
603
+ } ) ;
604
+
605
+ afterEach ( ( ) => {
606
+ sRuntimeServices . eventBus . reset ( ) ;
607
+ rRuntimeServices . eventBus . reset ( ) ;
608
+ } ) ;
609
+
610
+ afterAll ( async ( ) => await runtimeServiceProvider . stop ( ) ) ;
611
+
612
+ test ( "no multiple open Requests that lead to a Relationship can exist for the same Identity" , async ( ) => {
613
+ const relationshipTemplateContent = RelationshipTemplateContent . from ( {
614
+ onNewRelationship : { "@type" : "Request" , items : [ { "@type" : "TestRequestItem" , mustBeAccepted : false } ] }
615
+ } ) . toJSON ( ) ;
616
+
617
+ const firstTemplate = await exchangeTemplate ( sRuntimeServices . transport , rRuntimeServices . transport , relationshipTemplateContent ) ;
618
+ await rRuntimeServices . eventBus . waitForRunningEventHandlers ( ) ;
619
+ await expect ( rRuntimeServices . eventBus ) . toHavePublished (
620
+ RelationshipTemplateProcessedEvent ,
621
+ ( e ) => e . data . result === RelationshipTemplateProcessedResult . ManualRequestDecisionRequired
622
+ ) ;
623
+
624
+ const requestForTemplate = ( await rRuntimeServices . consumption . incomingRequests . getRequests ( { query : { "source.reference" : firstTemplate . id } } ) ) . value [ 0 ] ;
625
+
626
+ rRuntimeServices . eventBus . reset ( ) ;
627
+
628
+ const secondTemplate = await exchangeTemplate ( sRuntimeServices . transport , rRuntimeServices . transport , relationshipTemplateContent ) ;
629
+ await rRuntimeServices . eventBus . waitForRunningEventHandlers ( ) ;
630
+
631
+ await expect ( rRuntimeServices . eventBus ) . not . toHavePublished (
632
+ RelationshipTemplateProcessedEvent ,
633
+ ( e ) => e . data . result === RelationshipTemplateProcessedResult . ManualRequestDecisionRequired
634
+ ) ;
635
+
636
+ await expect ( rRuntimeServices . eventBus ) . toHavePublished (
637
+ RelationshipTemplateProcessedEvent ,
638
+ ( e ) =>
639
+ e . data . result === RelationshipTemplateProcessedResult . NonCompletedRequestExists &&
640
+ e . data . template . id === secondTemplate . id &&
641
+ e . data . requestId === requestForTemplate . id
642
+ ) ;
643
+ } ) ;
644
+ } ) ;
0 commit comments