Array.fromFormatted

This commit is contained in:
Michael Hoennig 2022-10-10 09:33:17 +02:00
parent 639925e834
commit de0c8dcfbc
4 changed files with 13 additions and 10 deletions

View File

@ -112,14 +112,17 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest {
"hs_office_bankaccount#sometempaccC.admin", "hs_office_bankaccount#sometempaccC.admin",
"hs_office_bankaccount#sometempaccC.tenant" "hs_office_bankaccount#sometempaccC.tenant"
)); ));
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.from( assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromFormatted(
initialGrantNames, initialGrantNames,
"{ grant role hs_office_bankaccount#sometempaccC.owner to role global#global.admin by system and assume }",
"{ grant perm delete on hs_office_bankaccount#sometempaccC to role hs_office_bankaccount#sometempaccC.owner by system and assume }", "{ grant perm delete on hs_office_bankaccount#sometempaccC to role hs_office_bankaccount#sometempaccC.owner by system and assume }",
"{ grant role hs_office_bankaccount#sometempaccC.tenant to role hs_office_bankaccount#sometempaccC.admin by system and assume }", "{ grant role hs_office_bankaccount#sometempaccC.owner to role global#global.admin by system and assume }",
"{ grant role hs_office_bankaccount#sometempaccC.owner to user selfregistered-user-drew@hostsharing.org by global#global.admin and assume }",
"{ grant role hs_office_bankaccount#sometempaccC.admin to role hs_office_bankaccount#sometempaccC.owner by system and assume }", "{ grant role hs_office_bankaccount#sometempaccC.admin to role hs_office_bankaccount#sometempaccC.owner by system and assume }",
"{ grant perm view on hs_office_bankaccount#sometempaccC to role hs_office_bankaccount#sometempaccC.tenant by system and assume }", "{ grant perm view on hs_office_bankaccount#sometempaccC to role hs_office_bankaccount#sometempaccC.tenant by system and assume }",
"{ grant role hs_office_bankaccount#sometempaccC.owner to user selfregistered-user-drew@hostsharing.org by global#global.admin and assume }" "{ grant role hs_office_bankaccount#sometempaccC.tenant to role hs_office_bankaccount#sometempaccC.admin by system and assume }",
null
)); ));
} }

View File

@ -120,7 +120,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
"hs_office_debitor#20002Fourthe.G.-forthcontact.admin", "hs_office_debitor#20002Fourthe.G.-forthcontact.admin",
"hs_office_debitor#20002Fourthe.G.-forthcontact.owner", "hs_office_debitor#20002Fourthe.G.-forthcontact.owner",
"hs_office_debitor#20002Fourthe.G.-forthcontact.tenant")); "hs_office_debitor#20002Fourthe.G.-forthcontact.tenant"));
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromSkippingNull( assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromFormatted(
initialGrantNames, initialGrantNames,
"{ grant perm * on hs_office_debitor#20002Fourthe.G.-forthcontact to role hs_office_debitor#20002Fourthe.G.-forthcontact.owner by system and assume }", "{ grant perm * on hs_office_debitor#20002Fourthe.G.-forthcontact to role hs_office_debitor#20002Fourthe.G.-forthcontact.owner by system and assume }",
"{ grant role hs_office_debitor#20002Fourthe.G.-forthcontact.owner to role global#global.admin by system and assume }", "{ grant role hs_office_debitor#20002Fourthe.G.-forthcontact.owner to role global#global.admin by system and assume }",

View File

@ -121,7 +121,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
"hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.admin", "hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.admin",
"hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.owner", "hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.owner",
"hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.tenant")); "hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.tenant"));
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromSkippingNull( assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromFormatted(
initialGrantNames, initialGrantNames,
"{ grant perm * on hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita to role hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.owner by system and assume }", "{ grant perm * on hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita to role hs_office_relationship#BesslerAnita-with-JOINT_AGENT-BesslerAnita.owner by system and assume }",

View File

@ -22,7 +22,7 @@ public class Array {
return resultList.toArray(String[]::new); return resultList.toArray(String[]::new);
} }
public static String[] fromSkippingNull(final List<String> initialList, final String... additionalStrings) { public static String[] fromFormatted(final List<String> initialList, final String... additionalStrings) {
final var resultList = new ArrayList<>(initialList); final var resultList = new ArrayList<>(initialList);
resultList.addAll(Arrays.stream(additionalStrings) resultList.addAll(Arrays.stream(additionalStrings)
.filter(Objects::nonNull) .filter(Objects::nonNull)