### Question:
FreeIpaConfigService { public FreeIpaConfigView createFreeIpaConfigs(Stack stack, Set<Node> hosts, ProxyConfig proxyConfig) { final FreeIpaConfigView.Builder builder = new FreeIpaConfigView.Builder(); FreeIpa freeIpa = freeIpaService.findByStack(stack); Map<String, String> subnetWithCidr = networkService.getFilteredSubnetWithCidr(stack); String reverseZones = reverseDnsZoneCalculator.reverseDnsZoneForCidrs(subnetWithCidr.values()); return builder .withRealm(freeIpa.getDomain().toUpperCase()) .withDomain(freeIpa.getDomain()) .withPassword(freeIpa.getAdminPassword()) .withDnssecValidationEnabled(isDnsSecValidationEnabled(stack.getCloudPlatform())) .withReverseZones(reverseZones) .withAdminUser(freeIpaClientFactory.getAdminUser()) .withFreeIpaToReplicate(gatewayConfigService.getPrimaryGatewayConfig(stack)) .withHosts(hosts) .withBackupConfig(determineAndSetBackup(stack, proxyConfig)) .build(); }  FreeIpaConfigView createFreeIpaConfigs(Stack stack, Set<Node> hosts, ProxyConfig proxyConfig);  }### Answer:
@Test public void testCreateFreeIpaConfigs() { String backupLocation = "s3: Backup backup = new Backup(); backup.setStorageLocation(backupLocation); backup.setS3(new S3CloudStorageV1Parameters()); FreeIpa freeIpa = new FreeIpa(); freeIpa.setDomain(DOMAIN); freeIpa.setAdminPassword(PASSWORD); Stack stack = new Stack(); stack.setCloudPlatform(CloudPlatform.AWS.name()); stack.setBackup(backup); when(freeIpaService.findByStack(any())).thenReturn(freeIpa); when(freeIpaClientFactory.getAdminUser()).thenReturn(ADMIN); when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(SUBNET_WITH_CIDR); when(reverseDnsZoneCalculator.reverseDnsZoneForCidrs(any())).thenReturn(REVERSE_ZONE); when(environment.getProperty("freeipa.platform.dnssec.validation.AWS", "true")).thenReturn("true"); GatewayConfig gatewayConfig = mock(GatewayConfig.class); when(gatewayConfig.getHostname()).thenReturn(HOSTNAME); when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig); Node node = new Node(PRIVATE_IP, null, null, null, HOSTNAME, DOMAIN, null); Map<String, String> expectedHost = Map.of("ip", PRIVATE_IP, "fqdn", HOSTNAME); Set<Object> expectedHosts = ImmutableSet.of(expectedHost); FreeIpaConfigView freeIpaConfigView = freeIpaConfigService.createFreeIpaConfigs( stack, ImmutableSet.of(node), null); assertEquals(DOMAIN.toUpperCase(), freeIpaConfigView.getRealm()); assertEquals(DOMAIN, freeIpaConfigView.getDomain()); assertEquals(PASSWORD, freeIpaConfigView.getPassword()); assertEquals(REVERSE_ZONE, freeIpaConfigView.getReverseZones()); assertEquals(ADMIN, freeIpaConfigView.getAdminUser()); assertEquals(HOSTNAME, freeIpaConfigView.getFreeipaToReplicate()); assertEquals(backupLocation, freeIpaConfigView.getBackup().getLocation()); assertEquals(CloudPlatform.AWS.name(), freeIpaConfigView.getBackup().getPlatform()); assertEquals(expectedHosts, freeIpaConfigView.getHosts()); }