### Question:
PaymentBuilder { static Set<String> expandAccountDesignators(final Set<String> accountDesignators) { final Set<RequiredAccountAssignment> accountAssignmentsRequired = IndividualLendingPatternFactory.individualLendingPattern().getAccountAssignmentsRequired(); final Map<String, List<RequiredAccountAssignment>> accountAssignmentsByGroup = accountAssignmentsRequired.stream() .filter(x -> x.getGroup() != null) .collect(Collectors.groupingBy(RequiredAccountAssignment::getGroup, Collectors.toList())); final Set<String> groupExpansions = accountDesignators.stream() .flatMap(accountDesignator -> { final List<RequiredAccountAssignment> group = accountAssignmentsByGroup.get(accountDesignator); if (group != null) return group.stream(); else return Stream.empty(); }) .map(RequiredAccountAssignment::getAccountDesignator) .collect(Collectors.toSet()); final Set<String> ret = new HashSet<>(accountDesignators); ret.addAll(groupExpansions); return ret; } PaymentBuilder(final RunningBalances prePaymentBalances,
                 final boolean accrualAccounting); Payment buildPayment(
      final Action action,
      final Set<String> forAccountDesignators,
      final @Nullable LocalDate forDate); PlannedPayment accumulatePlannedPayment(
      final SimulatedRunningBalances balances,
      final @Nullable LocalDate forDate); Map<String, BigDecimal> getBalanceAdjustments(); BigDecimal getBalanceAdjustment(final String... accountDesignators);  }### Answer:
@Test public void expandAccountDesignators() { final Set<String> ret = PaymentBuilder.expandAccountDesignators(new HashSet<>(Arrays.asList(AccountDesignators.CUSTOMER_LOAN_GROUP, AccountDesignators.ENTRY))); final Set<String> expected = new HashSet<>(Arrays.asList( AccountDesignators.ENTRY, AccountDesignators.CUSTOMER_LOAN_GROUP, AccountDesignators.CUSTOMER_LOAN_PRINCIPAL, AccountDesignators.CUSTOMER_LOAN_FEES, AccountDesignators.CUSTOMER_LOAN_INTEREST)); Assert.assertEquals(expected, ret); }