@Test public void listByAccountId() { Set<Environment> twoEnvironment = Set.of(new Environment(), new Environment()); final int twoInvocations = 2; when(environmentRepository.findByAccountId(eq(TestConstants.ACCOUNT_ID))).thenReturn(twoEnvironment); environmentServiceUnderTest.listByAccountId(TestConstants.ACCOUNT_ID); verify(environmentRepository).findByAccountId(eq(TestConstants.ACCOUNT_ID)); verify(environmentDtoConverter, times(twoInvocations)).environmentToDto(any()); }
public List<EnvironmentDto> listByAccountId(String accountId) { LOGGER.debug("Listing environments by account id '{}'.", accountId); Set<Environment> environments = environmentRepository.findByAccountId(accountId); return environments.stream().map(environmentDtoConverter::environmentToDto).collect(Collectors.toList()); }
EnvironmentService extends AbstractAccountAwareResourceService<Environment> implements ResourceIdProvider, ResourceBasedCrnProvider { public List<EnvironmentDto> listByAccountId(String accountId) { LOGGER.debug("Listing environments by account id '{}'.", accountId); Set<Environment> environments = environmentRepository.findByAccountId(accountId); return environments.stream().map(environmentDtoConverter::environmentToDto).collect(Collectors.toList()); } }
EnvironmentService extends AbstractAccountAwareResourceService<Environment> implements ResourceIdProvider, ResourceBasedCrnProvider { public List<EnvironmentDto> listByAccountId(String accountId) { LOGGER.debug("Listing environments by account id '{}'.", accountId); Set<Environment> environments = environmentRepository.findByAccountId(accountId); return environments.stream().map(environmentDtoConverter::environmentToDto).collect(Collectors.toList()); } EnvironmentService(
            EnvironmentValidatorService validatorService,
            EnvironmentRepository environmentRepository,
            PlatformParameterService platformParameterService,
            EnvironmentDtoConverter environmentDtoConverter,
            DelegatingCliEnvironmentRequestConverter delegatingCliEnvironmentRequestConverter,
            GrpcUmsClient grpcUmsClient,
            TransactionService transactionService); }
EnvironmentService extends AbstractAccountAwareResourceService<Environment> implements ResourceIdProvider, ResourceBasedCrnProvider { public List<EnvironmentDto> listByAccountId(String accountId) { LOGGER.debug("Listing environments by account id '{}'.", accountId); Set<Environment> environments = environmentRepository.findByAccountId(accountId); return environments.stream().map(environmentDtoConverter::environmentToDto).collect(Collectors.toList()); } EnvironmentService(
            EnvironmentValidatorService validatorService,
            EnvironmentRepository environmentRepository,
            PlatformParameterService platformParameterService,
            EnvironmentDtoConverter environmentDtoConverter,
            DelegatingCliEnvironmentRequestConverter delegatingCliEnvironmentRequestConverter,
            GrpcUmsClient grpcUmsClient,
            TransactionService transactionService); Environment save(Environment environment); Environment saveWithOwnerRoleAssignment(Environment environment); EnvironmentDto getEnvironmentDto(Environment environment); EnvironmentDto getByNameAndAccountId(String environmentName, String accountId); EnvironmentDto getByCrnAndAccountId(String crn, String accountId); List<EnvironmentDto> listByAccountId(String accountId); void setRegions(Environment environment, Set<String> requestedRegions, CloudRegions cloudRegions); CloudRegions getRegionsByEnvironment(Environment environment); Environment findEnvironmentByIdOrThrow(Long id); Optional<Environment> findEnvironmentById(Long id); Optional<EnvironmentDto> findById(Long id); void setLocation(Environment environment, RegionWrapper regionWrapper, CloudRegions cloudRegions); List<EnvironmentDto> findAllByIdInAndStatusIn(Collection<Long> resourceIds, Collection<EnvironmentStatus> environmentStatuses); List<EnvironmentDto> findAllByStatusIn(Collection<EnvironmentStatus> environmentStatuses); Object getCreateEnvironmentForCli(EnvironmentRequest environmentRequest, String cloudPlatform); Object getCreateEnvironmentForCli(EnvironmentDto environmentDto); void setAdminGroupName(Environment environment, String adminGroupName); Collection<Environment> findByResourceCrnInAndAccountIdAndArchivedIsFalse(Collection<String> crns, String accountId); Collection<Environment> findByNameInAndAccountIdAndArchivedIsFalse(Collection<String> environmentNames, String accountId); String getCrnByNameAndAccountId(String environmentName, String accountId); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType(); List<String> findNameWithAccountIdAndParentEnvIdAndArchivedIsFalse(String accountId, Long parentEnvironmentId); List<Environment> findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(String accountId, Long parentEnvironmentId); void assignEnvironmentAdminRole(String userCrn, String environmentCrn); List<Environment> findAllForAutoSync(); }
EnvironmentService extends AbstractAccountAwareResourceService<Environment> implements ResourceIdProvider, ResourceBasedCrnProvider { public List<EnvironmentDto> listByAccountId(String accountId) { LOGGER.debug("Listing environments by account id '{}'.", accountId); Set<Environment> environments = environmentRepository.findByAccountId(accountId); return environments.stream().map(environmentDtoConverter::environmentToDto).collect(Collectors.toList()); } EnvironmentService(
            EnvironmentValidatorService validatorService,
            EnvironmentRepository environmentRepository,
            PlatformParameterService platformParameterService,
            EnvironmentDtoConverter environmentDtoConverter,
            DelegatingCliEnvironmentRequestConverter delegatingCliEnvironmentRequestConverter,
            GrpcUmsClient grpcUmsClient,
            TransactionService transactionService); Environment save(Environment environment); Environment saveWithOwnerRoleAssignment(Environment environment); EnvironmentDto getEnvironmentDto(Environment environment); EnvironmentDto getByNameAndAccountId(String environmentName, String accountId); EnvironmentDto getByCrnAndAccountId(String crn, String accountId); List<EnvironmentDto> listByAccountId(String accountId); void setRegions(Environment environment, Set<String> requestedRegions, CloudRegions cloudRegions); CloudRegions getRegionsByEnvironment(Environment environment); Environment findEnvironmentByIdOrThrow(Long id); Optional<Environment> findEnvironmentById(Long id); Optional<EnvironmentDto> findById(Long id); void setLocation(Environment environment, RegionWrapper regionWrapper, CloudRegions cloudRegions); List<EnvironmentDto> findAllByIdInAndStatusIn(Collection<Long> resourceIds, Collection<EnvironmentStatus> environmentStatuses); List<EnvironmentDto> findAllByStatusIn(Collection<EnvironmentStatus> environmentStatuses); Object getCreateEnvironmentForCli(EnvironmentRequest environmentRequest, String cloudPlatform); Object getCreateEnvironmentForCli(EnvironmentDto environmentDto); void setAdminGroupName(Environment environment, String adminGroupName); Collection<Environment> findByResourceCrnInAndAccountIdAndArchivedIsFalse(Collection<String> crns, String accountId); Collection<Environment> findByNameInAndAccountIdAndArchivedIsFalse(Collection<String> environmentNames, String accountId); String getCrnByNameAndAccountId(String environmentName, String accountId); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType(); List<String> findNameWithAccountIdAndParentEnvIdAndArchivedIsFalse(String accountId, Long parentEnvironmentId); List<Environment> findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(String accountId, Long parentEnvironmentId); void assignEnvironmentAdminRole(String userCrn, String environmentCrn); List<Environment> findAllForAutoSync();  }