@Test void convert() { FreeIpaServerResponse freeIpaServerResponse = new FreeIpaServerResponse(); Stack stack = createStack(); ImageEntity image = new ImageEntity(); FreeIpa freeIpa = new FreeIpa(); freeIpa.setDomain(DOMAIN); UserSyncStatus userSyncStatus = new UserSyncStatus(); when(authenticationResponseConverter.convert(stack.getStackAuthentication())).thenReturn(STACK_AUTHENTICATION_RESPONSE); when(imageSettingsResponseConverter.convert(image)).thenReturn(IMAGE_SETTINGS_RESPONSE); when(freeIpaServerResponseConverter.convert(freeIpa)).thenReturn(freeIpaServerResponse); when(instanceGroupConverter.convert(stack.getInstanceGroups())).thenReturn(INSTANCE_GROUP_RESPONSES); when(userSyncStatusConverter.convert(userSyncStatus)).thenReturn(USERSYNC_STATUS_RESPONSE); when(balancedDnsAvailabilityChecker.isBalancedDnsAvailable(stack)).thenReturn(true); DescribeFreeIpaResponse result = underTest.convert(stack, image, freeIpa, userSyncStatus); assertThat(result) .returns(NAME, DescribeFreeIpaResponse::getName) .returns(ENV_CRN, DescribeFreeIpaResponse::getEnvironmentCrn) .returns(RESOURCE_CRN, DescribeFreeIpaResponse::getCrn) .returns(CLOUD_PLATFORM, DescribeFreeIpaResponse::getCloudPlatform) .returns(STACK_AUTHENTICATION_RESPONSE, DescribeFreeIpaResponse::getAuthentication) .returns(IMAGE_SETTINGS_RESPONSE, DescribeFreeIpaResponse::getImage) .returns(freeIpaServerResponse, DescribeFreeIpaResponse::getFreeIpa) .returns(INSTANCE_GROUP_RESPONSES, DescribeFreeIpaResponse::getInstanceGroups) .returns(STATUS, DescribeFreeIpaResponse::getStatus) .returns(STATUS_REASON, DescribeFreeIpaResponse::getStatusReason) .returns(STATUS_STRING, DescribeFreeIpaResponse::getStatusString) .returns(APP_VERSION, DescribeFreeIpaResponse::getAppVersion) .returns(USERSYNC_STATUS_RESPONSE, DescribeFreeIpaResponse::getUserSyncStatus); assertThat(freeIpaServerResponse) .returns(Set.of(SERVER_IP), FreeIpaServerResponse::getServerIp) .returns(FREEIPA_HOST, FreeIpaServerResponse::getFreeIpaHost) .returns(GATEWAY_PORT, FreeIpaServerResponse::getFreeIpaPort); }
public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus) { DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse(); describeFreeIpaResponse.setName(stack.getName()); describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn()); describeFreeIpaResponse.setCrn(stack.getResourceCrn()); describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform()); describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication())); Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i))); Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f))); describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack)); describeFreeIpaResponse.setPlacement(convert(stack)); describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups())); describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus()); describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString()); describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason()); decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups()); decoreateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa); describeFreeIpaResponse.setAppVersion(stack.getAppVersion()); decorateWithCloudStorgeAndTelemetry(stack, describeFreeIpaResponse); Optional.ofNullable(userSyncStatus).ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u))); return describeFreeIpaResponse; }
StackToDescribeFreeIpaResponseConverter { public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus) { DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse(); describeFreeIpaResponse.setName(stack.getName()); describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn()); describeFreeIpaResponse.setCrn(stack.getResourceCrn()); describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform()); describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication())); Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i))); Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f))); describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack)); describeFreeIpaResponse.setPlacement(convert(stack)); describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups())); describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus()); describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString()); describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason()); decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups()); decoreateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa); describeFreeIpaResponse.setAppVersion(stack.getAppVersion()); decorateWithCloudStorgeAndTelemetry(stack, describeFreeIpaResponse); Optional.ofNullable(userSyncStatus).ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u))); return describeFreeIpaResponse; } }
StackToDescribeFreeIpaResponseConverter { public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus) { DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse(); describeFreeIpaResponse.setName(stack.getName()); describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn()); describeFreeIpaResponse.setCrn(stack.getResourceCrn()); describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform()); describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication())); Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i))); Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f))); describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack)); describeFreeIpaResponse.setPlacement(convert(stack)); describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups())); describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus()); describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString()); describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason()); decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups()); decoreateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa); describeFreeIpaResponse.setAppVersion(stack.getAppVersion()); decorateWithCloudStorgeAndTelemetry(stack, describeFreeIpaResponse); Optional.ofNullable(userSyncStatus).ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u))); return describeFreeIpaResponse; }  }
StackToDescribeFreeIpaResponseConverter { public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus) { DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse(); describeFreeIpaResponse.setName(stack.getName()); describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn()); describeFreeIpaResponse.setCrn(stack.getResourceCrn()); describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform()); describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication())); Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i))); Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f))); describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack)); describeFreeIpaResponse.setPlacement(convert(stack)); describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups())); describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus()); describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString()); describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason()); decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups()); decoreateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa); describeFreeIpaResponse.setAppVersion(stack.getAppVersion()); decorateWithCloudStorgeAndTelemetry(stack, describeFreeIpaResponse); Optional.ofNullable(userSyncStatus).ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u))); return describeFreeIpaResponse; }  DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus); }
StackToDescribeFreeIpaResponseConverter { public DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus) { DescribeFreeIpaResponse describeFreeIpaResponse = new DescribeFreeIpaResponse(); describeFreeIpaResponse.setName(stack.getName()); describeFreeIpaResponse.setEnvironmentCrn(stack.getEnvironmentCrn()); describeFreeIpaResponse.setCrn(stack.getResourceCrn()); describeFreeIpaResponse.setCloudPlatform(stack.getCloudPlatform()); describeFreeIpaResponse.setAuthentication(authenticationResponseConverter.convert(stack.getStackAuthentication())); Optional.ofNullable(image).ifPresent(i -> describeFreeIpaResponse.setImage(imageSettingsResponseConverter.convert(i))); Optional.ofNullable(freeIpa).ifPresent(f -> describeFreeIpaResponse.setFreeIpa(freeIpaServerResponseConverter.convert(f))); describeFreeIpaResponse.setNetwork(networkResponseConverter.convert(stack)); describeFreeIpaResponse.setPlacement(convert(stack)); describeFreeIpaResponse.setInstanceGroups(instanceGroupConverter.convert(stack.getInstanceGroups())); describeFreeIpaResponse.setStatus(stack.getStackStatus().getStatus()); describeFreeIpaResponse.setStatusString(stack.getStackStatus().getStatusString()); describeFreeIpaResponse.setStatusReason(stack.getStackStatus().getStatusReason()); decorateFreeIpaServerResponseWithIps(describeFreeIpaResponse.getFreeIpa(), describeFreeIpaResponse.getInstanceGroups()); decoreateFreeIpaServerResponseWithLoadBalancedHost(stack, describeFreeIpaResponse.getFreeIpa(), freeIpa); describeFreeIpaResponse.setAppVersion(stack.getAppVersion()); decorateWithCloudStorgeAndTelemetry(stack, describeFreeIpaResponse); Optional.ofNullable(userSyncStatus).ifPresent(u -> describeFreeIpaResponse.setUserSyncStatus(userSyncStatusConverter.convert(u))); return describeFreeIpaResponse; }  DescribeFreeIpaResponse convert(Stack stack, ImageEntity image, FreeIpa freeIpa, UserSyncStatus userSyncStatus);  }