### Question:
DesignatorToAccountIdentifierMapper { public Stream<GroupNeedingLedger> getGroupsNeedingLedgers() { final Set<String> accountAssignmentGroups = IndividualLendingPatternFactory.individualLendingPattern().getAccountAssignmentGroups(); final Set<RequiredAccountAssignment> accountAssignmentsRequired = IndividualLendingPatternFactory.individualLendingPattern().getAccountAssignmentsRequired(); return accountAssignmentGroups.stream() .filter(groupName -> !mapToProductAccountAssignment(groupName).isPresent()) .map(groupName -> { final Stream<RequiredAccountAssignment> requiredAccountAssignmentsInThisGroup = accountAssignmentsRequired.stream().filter(x -> groupName.equals(x.getGroup())); final List<String> ledgersAssignedToThem = requiredAccountAssignmentsInThisGroup .map(requiredAccountAssignment -> mapToProductAccountAssignment(requiredAccountAssignment.getAccountDesignator())) .map(optionalAccountAssignment -> optionalAccountAssignment.map(AccountAssignment::getLedgerIdentifier)) .distinct() .filter(Optional::isPresent) .map(Optional::get) .limit(2) .collect(Collectors.toList()); if (ledgersAssignedToThem.size() == 1) { return new GroupNeedingLedger(groupName, ledgersAssignedToThem.get(0)); } else return null; }) .filter(Objects::nonNull); } DesignatorToAccountIdentifierMapper(final @Nonnull DataContextOfAction dataContextOfAction);   DesignatorToAccountIdentifierMapper(
      final @Nonnull Set<ProductAccountAssignmentEntity> productAccountAssignments,
      final @Nonnull Set<CaseAccountAssignmentEntity> caseAccountAssignments,
      final @Nonnull List<AccountAssignment> oneTimeAccountAssignments); Optional<String> map(final @Nonnull String accountDesignator); String mapOrThrow(final @Nonnull String accountDesignator); Stream<GroupNeedingLedger> getGroupsNeedingLedgers(); Stream<AccountAssignment> getLedgersNeedingAccounts();  }### Answer:
@Test public void getGroupsNeedingLedgers() { Set<DesignatorToAccountIdentifierMapper.GroupNeedingLedger> ret = testSubject.getGroupsNeedingLedgers().collect(Collectors.toSet()); ret.toString(); Assert.assertEquals(testCase.expectedGroupsNeedingLedgers, ret); }