package Ġnet . cord a . bn . flows . composite Ċ Ċ import Ġnet . cord a . bn . flows . Membership Management Flow Test Ċ import Ġnet . cord a . bn . flows . identity Ċ import Ġnet . cord a . bn . states . Group State Ċ import Ġnet . cord a . bn . states . Membership State Ċ import Ġorg . junit . Test Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertTrue Ċ Ċ class ĠBatch Activate Membership Flow Test Ġ: ĠMembers hip Management Flow Test ( numberOf Author ised Members Ġ= Ġ 1 , ĠnumberOf Regular Members Ġ= Ġ 3 ) Ġ{ ĊĊĠĠĠ Ġ@ Test ( timeout Ġ= Ġ 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` batch Ġactivate Ġmembership Ġflow Ġwith Ġall Ġmembers Ġadded Ġto Ġthe Ġdefault Ġgroup `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġauthor ised Member Ġ= Ġauthor ised Members . first () ĊĊĠĠĠĠĠĠĠ Ġval Ġnetwork Id Ġ= Ġ( run Create Business Network Flow ( author ised Member ). tx . output States . single () Ġas ĠMembers hip State ). network Id ĊĠĠĠĠĠĠĠ Ġval Ġmembership s Ġ= Ġregular Members . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( run Request Membership Flow ( it , Ġauthor ised Member , Ġnetwork Id ). tx . output States . single () Ġas ĠMembers hip State ). linear Id ĊĠĠĠĠĠĠĠ Ġ}. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActivation Info ( it ) ĊĠĠĠĠĠĠĠ Ġ}. toSet () ĊĊĠĠĠĠĠĠĠ Ġval Ġdefault GroupId Ġ= ĠgetAll Groups From Vault ( author ised Member , Ġnetwork Id ). single (). linear Id ĊĠĠĠĠĠĠĠ Ġrun Batch Activate Membership Flow ( author ised Member , Ġmembership s , Ġdefault GroupId ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġall Ġmembers ' Ġled gers ĊĠĠĠĠĠĠĠ Ġ( regular Members Ġ+ Ġauthor ised Member ). forEach Ġ{ Ġmember Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexpected Id entities Ġ= Ġ( regular Members Ġ+ Ġauthor ised Member ). map Ġ{ Ġit . identity () Ġ}. toSet () ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Membership s From Vault ( member , Ġnetwork Id ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġsize , Ġ" Vault Ġsize Ġassertion Ġfailed Ġfor Ġ${ member . identity () }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( all Ġ{ Ġit . participants . toSet () Ġ== Ġexpected Id entities Ġ}, Ġ" Membership Ġparticipants Ġassertion Ġfailed Ġfor Ġ${ member . identity () }' s Ġvault ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Groups From Vault ( member , Ġnetwork Id ). single (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Id entities , Ġparticipants . toSet (), Ġ" Group Ġparticipants Ġassertion Ġfailed Ġfor Ġ${ member . identity () }") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout Ġ= Ġ 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` batch Ġactivate Ġmembership Ġflow Ġwith Ġmembers Ġadded Ġto Ġspecific Ġgroups `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġauthor ised Member Ġ= Ġauthor ised Members . first () ĊĊĠĠĠĠĠĠĠ Ġval Ġnetwork Id Ġ= Ġ( run Create Business Network Flow ( author ised Member ). tx . output States . single () Ġas ĠMembers hip State ). network Id ĊĠĠĠĠĠĠĠ Ġval Ġdefault GroupId Ġ= ĠgetAll Groups From Vault ( author ised Member , Ġnetwork Id ). single (). linear Id ĊĊĠĠĠĠĠĠĠ Ġval Ġmembership s Ġ= Ġregular Members . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( run Request Membership Flow ( it , Ġauthor ised Member , Ġnetwork Id ). tx . output States . single () Ġas ĠMembers hip State ). linear Id ĊĠĠĠĠĠĠĠ Ġ}. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval ĠgroupId Ġ= Ġ( run Create Group Flow ( author ised Member , Ġnetwork Id ). tx . output States . single () Ġas ĠGroup State ). linear Id ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActivation Info ( it , ĠgroupId ) ĊĠĠĠĠĠĠĠ Ġ}. toSet () ĊĊĠĠĠĠĠĠĠ Ġrun Batch Activate Membership Flow ( author ised Member , Ġmembership s , Ġdefault GroupId ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġauthor ised Ġmember 's Ġledger ĊĠĠĠĠĠĠĠ Ġval Ġexpected Id entities Ġ= Ġ( regular Members Ġ+ Ġauthor ised Member ). map Ġ{ Ġit . identity () Ġ}. toSet () ĊĠĠĠĠĠĠĠ ĠgetAll Membership s From Vault ( author ised Member , Ġnetwork Id ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġsize ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Id entities , Ġmap Ġ{ Ġit . identity . cord a Identity Ġ}. toSet ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠgetAll Groups From Vault ( author ised Member , Ġnetwork Id ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġsize ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġregular Ġmembers ' Ġled gers ĊĠĠĠĠĠĠĠ Ġregular Members . forEach Ġ{ Ġmember Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexpected Id entities Ġ= Ġset Of ( author ised Member . identity (), Ġmember . identity ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmembership Ġ= ĠgetAll Membership s From Vault ( member , Ġnetwork Id ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġsize , Ġ" Vault Ġsize Ġassertion Ġfailed Ġfor Ġ${ member . identity () }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Id entities , Ġmap Ġ{ Ġit . identity . cord a Identity Ġ}. toSet (), Ġ" Expected Ġmembership s Ġfrom Ġvault Ġassertion Ġfailed Ġfor Ġ${ member . identity () }") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}. find Ġ{ Ġit . identity . cord a Identity Ġ== Ġmember . identity () Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Groups From Vault ( member , Ġnetwork Id ). single (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexpected GroupId Ġ= Ġmembership s . find Ġ{ Ġit . membership Id Ġ== Ġmembership ?. linear Id Ġ} ?. groupId ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected GroupId , Ġlinear Id , Ġ" Group ĠID Ġassertion Ġfailed Ġfor Ġ${ member . identity () }") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Id entities , Ġparticipants . toSet (), Ġ" Group Ġparticipants Ġassertion Ġfailed Ġfor Ġ${ member . identity () }") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( timeout Ġ= Ġ 3 0 0 _ 0 0 0 ) ĊĠĠĠ Ġfun Ġ` batch Ġactivate Ġmembership Ġflow Ġwith Ġmember Ġactivation Ġsub low Ġfails `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġauthor ised Member Ġ= Ġauthor ised Members . first () ĊĊĠĠĠĠĠĠĠ Ġval Ġnetwork Id Ġ= Ġ( run Create Business Network Flow ( author ised Member ). tx . output States . single () Ġas ĠMembers hip State ). network Id ĊĠĠĠĠĠĠĠ Ġval Ġmembership s Ġ= Ġregular Members . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( run Request Membership Flow ( it , Ġauthor ised Member , Ġnetwork Id ). tx . output States . single () Ġas ĠMembers hip State ). linear Id ĊĠĠĠĠĠĠĠ Ġ}. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠActivation Info ( it ) ĊĠĠĠĠĠĠĠ Ġ}. toSet () ĊĊĠĠĠĠĠĠĠ Ġ// Ġverify Ġflow Ġwill Ġnot Ġfail Ġif Ġa Ġsub flow Ġfails ĊĠĠĠĠĠĠĠ Ġval Ġdefault GroupId Ġ= ĠgetAll Groups From Vault ( author ised Member , Ġnetwork Id ). single (). linear Id ĊĠĠĠĠĠĠĠ Ġrun Batch Activate Membership Flow ( author ised Member , Ġmembership s , Ġdefault GroupId , Ġauthor ised Member . identity ()) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġauthor ised Ġmember 's Ġledger ĊĠĠĠĠĠĠĠ ĠgetAll Membership s From Vault ( author ised Member , Ġnetwork Id ). single Ġ{ Ġit . isActive () Ġ}. apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( author ised Member . identity (), Ġidentity . cord a Identity ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠgetAll Groups From Vault ( author ised Member , Ġnetwork Id ). single (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( listOf ( author ised Member . identity ()), Ġparticipants ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġregular Ġmembers ' Ġled gers ĊĠĠĠĠĠĠĠ Ġregular Members . forEach Ġ{ Ġmember Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( getAll Membership s From Vault ( member , Ġnetwork Id ). none Ġ{ Ġit . isActive () Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( getAll Groups From Vault ( member , Ġnetwork Id ). isEmpty ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }