@Test void getByEnvironmentCrnAndAccountIdWithListsShouldReturnByChildEnvironmentCrn() { when(stackRepository.findByEnvironmentCrnAndAccountIdWithList(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(Optional.empty()); when(stackRepository.findByChildEnvironmentCrnAndAccountIdWithList(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(Optional.of(stack)); Stack result = underTest.getByEnvironmentCrnAndAccountIdWithLists(ENVIRONMENT_CRN, ACCOUNT_ID); verify(stackRepository).findByEnvironmentCrnAndAccountIdWithList(ENVIRONMENT_CRN, ACCOUNT_ID); verify(stackRepository).findByChildEnvironmentCrnAndAccountIdWithList(ENVIRONMENT_CRN, ACCOUNT_ID); assertEquals(stack, result); }
public Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId) { return stackRepository.findByEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId) .or(() -> stackRepository.findByChildEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId)) .orElseThrow(() -> new NotFoundException(String.format("Stack by environment [%s] not found", environmentCrn))); }
StackService implements ResourceBasedCrnProvider { public Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId) { return stackRepository.findByEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId) .or(() -> stackRepository.findByChildEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId)) .orElseThrow(() -> new NotFoundException(String.format("Stack by environment [%s] not found", environmentCrn))); } }
StackService implements ResourceBasedCrnProvider { public Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId) { return stackRepository.findByEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId) .or(() -> stackRepository.findByChildEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId)) .orElseThrow(() -> new NotFoundException(String.format("Stack by environment [%s] not found", environmentCrn))); }  }
StackService implements ResourceBasedCrnProvider { public Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId) { return stackRepository.findByEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId) .or(() -> stackRepository.findByChildEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId)) .orElseThrow(() -> new NotFoundException(String.format("Stack by environment [%s] not found", environmentCrn))); }  List<Stack> findAllRunning(); List<Stack> findAllForAutoSync(); Stack getByIdWithListsInTransaction(Long id); Stack getStackById(Long id); Stack save(Stack stack); Stack getByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); Optional<Stack> findByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); Stack getByEnvironmentCrnAndAccountIdEvenIfTerminated(String environmentCrn, String accountId); Optional<Stack> findByEnvironmentCrnAndAccountIdEvenIfTerminated(String environmentCrn, String accountId); List<Stack> getMultipleByEnvironmentCrnOrChildEnvironmantCrnAndAccountId(Collection<String> environmentCrns, String accountId); List<Stack> findAllByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); List<Long> findAllIdByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId); Stack getByOwnEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId); List<Stack> getAllByAccountId(String accountId); List<StackIdWithStatus> getStatuses(Set<Long> stackIds); List<Stack> findAllWithStatuses(Collection<Status> statuses); List<Stack> findAllByAccountIdWithStatuses(String accountId, Collection<Status> statuses); List<Stack> findMultipleByEnvironmentCrnAndAccountIdWithStatuses(Collection<String> environmentCrns, String accountId, Collection<Status> statuses); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType(); }
StackService implements ResourceBasedCrnProvider { public Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId) { return stackRepository.findByEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId) .or(() -> stackRepository.findByChildEnvironmentCrnAndAccountIdWithList(environmentCrn, accountId)) .orElseThrow(() -> new NotFoundException(String.format("Stack by environment [%s] not found", environmentCrn))); }  List<Stack> findAllRunning(); List<Stack> findAllForAutoSync(); Stack getByIdWithListsInTransaction(Long id); Stack getStackById(Long id); Stack save(Stack stack); Stack getByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); Optional<Stack> findByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); Stack getByEnvironmentCrnAndAccountIdEvenIfTerminated(String environmentCrn, String accountId); Optional<Stack> findByEnvironmentCrnAndAccountIdEvenIfTerminated(String environmentCrn, String accountId); List<Stack> getMultipleByEnvironmentCrnOrChildEnvironmantCrnAndAccountId(Collection<String> environmentCrns, String accountId); List<Stack> findAllByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); List<Long> findAllIdByEnvironmentCrnAndAccountId(String environmentCrn, String accountId); Stack getByEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId); Stack getByOwnEnvironmentCrnAndAccountIdWithLists(String environmentCrn, String accountId); List<Stack> getAllByAccountId(String accountId); List<StackIdWithStatus> getStatuses(Set<Long> stackIds); List<Stack> findAllWithStatuses(Collection<Status> statuses); List<Stack> findAllByAccountIdWithStatuses(String accountId, Collection<Status> statuses); List<Stack> findMultipleByEnvironmentCrnAndAccountIdWithStatuses(Collection<String> environmentCrns, String accountId, Collection<Status> statuses); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType();  }