### Question:
EnvironmentService extends AbstractAccountAwareResourceService<Environment> implements ResourceIdProvider, ResourceBasedCrnProvider { public void setRegions(Environment environment, Set<String> requestedRegions, CloudRegions cloudRegions) { Set<Region> regionSet = new HashSet<>(); LOGGER.debug("Setting regions for environment. Regions: [{}].", String.join(", ", requestedRegions)); setRegionsFromCloudCoordinates(requestedRegions, cloudRegions, regionSet); if (regionSet.isEmpty()) { setRegionsFromCloudRegions(requestedRegions, cloudRegions, regionSet); } environment.setRegions(regionSet); } 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();  }### Answer:
@Test public void setRegions() { environmentServiceUnderTest.setRegions(environment, Set.of("r1"), EnvironmentTestData.getCloudRegions()); String resultText = environment.getRegions().getValue(); assertTrue(resultText.contains("{\"name\":\"region-1\",\"displayName\":\"Here\"}")); assertFalse(resultText.contains("{\"name\":\"region2\",\"displayName\":\"region 2\"}")); }
@Test public void setRegionsTwoRegions() { environmentServiceUnderTest.setRegions(environment, Set.of("r1", "r2"), EnvironmentTestData.getCloudRegions()); String resultText = environment.getRegions().getValue(); assertTrue(resultText.contains("{\"name\":\"region-1\",\"displayName\":\"Here\"}")); assertTrue(resultText.contains("{\"name\":\"region-2\",\"displayName\":\"There\"}")); }