From 6590dc850ab21df22ee3c23ea97a594828c89f1b Mon Sep 17 00:00:00 2001 From: Angelo Date: Tue, 2 Dec 2025 14:45:37 +0100 Subject: [PATCH] Ensure it is possible to define livesystem referring to pre-existing Fractal --- .../com/yanchware/fractal/sdk/Automaton.java | 171 +++-- .../configuration/EnvVarSdkConfiguration.java | 30 +- .../InstantiationConfiguration.java | 18 +- .../InstantiationWaitConfiguration.java | 3 +- .../fractal/sdk/domain/Component.java | 190 ++--- .../fractal/sdk/domain/ComponentLink.java | 4 +- .../yanchware/fractal/sdk/domain/Service.java | 51 +- .../fractal/sdk/domain/Validatable.java | 1 + .../domain/blueprint/BlueprintAggregate.java | 41 -- .../domain/blueprint/BlueprintComponent.java | 4 - .../domain/blueprint/BlueprintFactory.java | 33 - .../CreateBlueprintCommandRequest.java | 12 - .../UpdateBlueprintCommandRequest.java | 31 - .../service/dtos/BlueprintComponentDto.java | 71 -- .../domain/environment/BaseEnvironment.java | 51 +- .../sdk/domain/environment/CiCdProfile.java | 23 +- .../domain/environment/CloudAgentEntity.java | 298 ++++---- .../sdk/domain/environment/Environment.java | 6 +- .../environment/EnvironmentAggregate.java | 456 ++++++------ .../environment/EnvironmentIdValue.java | 34 +- .../domain/environment/EnvironmentType.java | 10 +- .../environment/EnvironmentsFactory.java | 6 +- .../environment/ManagementEnvironment.java | 36 +- .../environment/OperationalEnvironment.java | 13 +- .../sdk/domain/environment/Secret.java | 7 +- .../domain/environment/aws/AwsCloudAgent.java | 163 ++-- .../environment/azure/AzureCloudAgent.java | 176 ++--- .../domain/environment/gcp/GcpCloudAgent.java | 163 ++-- .../hetzner/HetznerCloudAgent.java | 145 ++-- .../domain/environment/oci/OciCloudAgent.java | 161 ++-- .../service/EnvironmentService.java | 132 ++-- .../service/RestEnvironmentService.java | 425 ++++++----- .../AwsAccountInitializationRequest.java | 4 +- ...zureSubscriptionInitializationRequest.java | 11 +- .../commands/CreateCiCdProfileRequest.java | 29 +- .../commands/CreateEnvironmentRequest.java | 10 +- .../service/commands/CreateSecretRequest.java | 5 +- .../GcpProjectInitializationRequest.java | 6 +- .../HetznerProjectInitializationRequest.java | 4 +- .../OciCompartmentInitializationRequest.java | 6 +- .../commands/UpdateEnvironmentRequest.java | 12 +- .../service/dtos/CiCdProfileResponse.java | 18 +- .../service/dtos/EnvironmentResponse.java | 4 +- .../dtos/InitializationRunResponse.java | 6 +- .../service/dtos/InitializationRunRoot.java | 3 +- .../dtos/InitializationStepResponse.java | 6 +- .../service/dtos/SecretResponse.java | 18 +- .../ComponentInstantiationException.java | 18 +- .../exceptions/EnvironmentException.java | 18 +- .../EnvironmentInitializationException.java | 26 +- .../EnvironmentNotFoundException.java | 16 +- .../exceptions/InstantiatorException.java | 16 +- .../domain/exceptions/ProviderException.java | 26 +- .../domain/fractal/BlueprintComponent.java | 4 + .../sdk/domain/fractal/FractalAggregate.java | 84 +++ .../FractalIdValue.java | 12 +- .../sdk/domain/fractal/FractalsFactory.java | 70 ++ .../caas/CaaSAPIGateway.java | 4 +- .../caas/CaaSComponent.java | 89 +-- .../caas/CaaSLogging.java | 4 +- .../caas/CaaSMonitoring.java | 4 +- .../caas/CaaSSearch.java | 6 +- .../caas/CaaSServiceMeshSecurity.java | 4 +- .../caas/CaaSWorkload.java | 4 +- .../iaas/DnsARecord.java | 22 +- .../iaas/DnsAaaaRecord.java | 25 +- .../iaas/DnsCNameRecord.java | 21 +- .../iaas/DnsCaaRecord.java | 6 +- .../iaas/DnsCaaRecordData.java | 21 +- .../iaas/DnsMxRecord.java | 2 +- .../iaas/DnsMxRecordData.java | 26 +- .../iaas/DnsNsRecord.java | 10 +- .../iaas/DnsPtrRecord.java | 22 +- .../iaas/DnsRecord.java | 45 +- .../iaas/DnsSrvRecord.java | 26 +- .../iaas/DnsSrvRecordData.java | 38 +- .../iaas/DnsTxtRecord.java | 9 +- .../{blueprint => fractal}/iaas/DnsZone.java | 10 +- .../paas/PaaSColumnOrientedDbms.java | 4 +- .../paas/PaaSContainerPlatform.java | 4 +- .../paas/PaaSDataStorage.java | 4 +- .../paas/PaaSDocumentDatabase.java | 4 +- .../paas/PaaSDocumentDbms.java | 4 +- .../paas/PaaSFileShare.java | 4 +- .../paas/PaaSGraphDatabase.java | 4 +- .../paas/PaaSGraphDbms.java | 4 +- .../paas/PaaSKeyValueDbms.java | 4 +- .../paas/PaaSKeyValueEntity.java | 4 +- .../paas/PaaSMessageEntity.java | 4 +- .../paas/PaaSMessaging.java | 4 +- .../paas/PaaSNetworkCdnProfile.java | 4 +- .../paas/PaaSRelationalDatabase.java | 4 +- .../paas/PaaSRelationalDbms.java | 4 +- .../paas/PaaSStorageContainer.java | 4 +- .../paas/PaaSWorkload.java | 4 +- .../paas/PaaSWorkloadDeploymentSlot.java | 4 +- .../saas/UnmanagedBrokerComponent.java | 4 +- .../saas/UnmanagedSecurityComponent.java | 4 +- .../saas/UnmanagedStorageComponent.java | 4 +- .../service/BlueprintService.java | 34 +- .../CreateBlueprintCommandRequest.java | 14 + .../UpdateBlueprintCommandRequest.java | 34 + .../service/dtos/BlueprintComponentDto.java | 72 ++ .../service/dtos/BlueprintDto.java | 2 +- .../service/dtos/BlueprintStatusDto.java | 2 +- .../sdk/domain/livesystem/CustomWorkload.java | 22 +- .../livesystem/CustomWorkloadBuilder.java | 17 +- .../livesystem/EnvironmentReference.java | 3 +- .../livesystem/LiveSystemAggregate.java | 284 +++---- .../livesystem/LiveSystemComponent.java | 2 +- .../domain/livesystem/LiveSystemIdValue.java | 2 +- .../domain/livesystem/LiveSystemsFactory.java | 186 ++--- .../domain/livesystem/SourceControlType.java | 2 +- .../livesystem/caas/CaaSAPIGatewayImpl.java | 10 +- .../livesystem/caas/CaaSAmbassador.java | 23 +- .../livesystem/caas/CaaSElasticDataStore.java | 18 +- .../livesystem/caas/CaaSElasticLogging.java | 21 +- .../caas/CaaSKubernetesWorkload.java | 289 ++++---- .../livesystem/caas/CaaSLoggingImpl.java | 40 +- .../livesystem/caas/CaaSMonitoringImpl.java | 18 +- .../livesystem/caas/CaaSPrometheus.java | 5 +- .../livesystem/caas/CaaSSearchImpl.java | 44 +- .../caas/CaaSServiceMeshSecurityImpl.java | 61 +- .../domain/livesystem/caas/CaaSTraefik.java | 20 +- .../livesystem/caas/ContainerResources.java | 35 +- .../domain/livesystem/caas/JaegerTracing.java | 6 +- .../domain/livesystem/caas/PriorityClass.java | 5 +- .../livesystem/caas/ResourceManagement.java | 22 +- .../domain/livesystem/caas/TaintEffect.java | 4 +- .../domain/livesystem/caas/Toleration.java | 22 +- .../livesystem/caas/TolerationOperator.java | 4 +- .../livesystem/caas/TraefikTracing.java | 2 +- .../operationalservicewindow/Blackout.java | 9 +- .../operationalservicewindow/OneOffRule.java | 6 +- .../OperationalServiceWindow.java | 6 +- .../operationalservicewindow/Rule.java | 6 +- .../operationalservicewindow/WeeklyRule.java | 6 +- .../livesystem/paas/KubernetesCluster.java | 60 +- .../domain/livesystem/paas/PaaSCassandra.java | 24 +- .../livesystem/paas/PaaSDataStorage.java | 29 +- .../paas/PaaSPostgreSqlDatabase.java | 129 ++-- .../livesystem/paas/PaaSPostgreSqlDbms.java | 38 +- .../livesystem/paas/PodManagedIdentity.java | 15 +- .../livesystem/paas/ResourceEntity.java | 10 +- .../aws/AwsElasticKubernetesService.java | 371 +++++----- .../paas/providers/aws/AwsRegion.java | 100 +-- .../paas/providers/aws/AwsResourceEntity.java | 1 + .../providers/azure/AzureIdentityType.java | 2 +- .../providers/azure/AzureMachineType.java | 2 +- .../paas/providers/azure/AzureOsSku.java | 16 +- .../paas/providers/azure/AzureOsType.java | 28 +- .../azure/AzurePostgreSqlDatabase.java | 31 +- .../providers/azure/AzurePostgreSqlDbms.java | 26 +- .../paas/providers/azure/AzureRegion.java | 2 +- .../paas/providers/azure/AzureResource.java | 18 +- .../providers/azure/AzureResourceEntity.java | 3 + .../providers/azure/AzureResourceGroup.java | 20 +- .../paas/providers/azure/AzureTlsVersion.java | 6 +- .../azure/BackupStorageRedundancy.java | 6 +- .../aks/AzureActiveDirectoryProfile.java | 19 +- .../azure/aks/AzureKubernetesAddon.java | 9 +- .../aks/AzureKubernetesAddonProfile.java | 17 +- .../azure/aks/AzureKubernetesService.java | 45 +- .../providers/azure/aks/AzureNodePool.java | 78 +- .../providers/azure/aks/AzureOutboundIp.java | 15 +- .../azure/aks/ManagedClusterSkuTier.java | 2 +- .../azure/appservice/AzureAppServicePlan.java | 69 +- .../appservice/AzureConnectionStringType.java | 2 +- .../appservice/AzureKeyVaultCertificate.java | 31 +- .../appservice/AzureSiteLoadBalancing.java | 4 +- .../azure/appservice/AzureWebApp.java | 353 ++++----- .../appservice/AzureWebAppCloningInfo.java | 23 +- .../appservice/AzureWebAppConfiguration.java | 19 +- .../appservice/AzureWebAppDeploymentSlot.java | 52 +- .../AzureWebAppIpSecurityRestriction.java | 11 +- .../AzureWebAppLinuxRuntimeStack.java | 2 +- .../appservice/AzureWebAppPushSettings.java | 6 +- .../appservice/AzureWebAppRuntimeStack.java | 8 +- .../AzureWebAppWindowsRuntimeStack.java | 1 + .../AzureAppServiceClientCertMode.java | 30 +- .../AzureAppServiceRedundancyMode.java | 34 +- .../valueobjects/AzureFtpsState.java | 26 +- .../providers/azure/cdn/AzureCdnProfile.java | 55 +- .../cdn/AzureManagedServiceIdentity.java | 8 +- .../azure/cosmos/AzureCosmosAccount.java | 6 +- .../cosmos/AzureCosmosAccountBuilder.java | 3 +- .../azure/cosmos/AzureCosmosBackupPolicy.java | 38 +- .../cosmos/AzureCosmosBackupPolicyType.java | 8 +- .../cosmos/AzureCosmosCassandraCluster.java | 10 +- .../azure/cosmos/AzureCosmosEntity.java | 14 +- .../cosmos/AzureCosmosEntityBuilder.java | 10 +- .../cosmos/AzureCosmosGremlinDatabase.java | 71 +- .../azure/cosmos/AzureCosmosGremlinDbms.java | 15 +- .../cosmos/AzureCosmosMongoDatabase.java | 71 +- .../azure/cosmos/AzureCosmosMongoDbms.java | 15 +- .../cosmos/AzureCosmosNoSqlDatabase.java | 69 +- .../azure/cosmos/AzureCosmosNoSqlDbms.java | 15 +- .../cosmos/AzureCosmosPostgreSqlDbms.java | 32 +- .../azure/cosmos/AzureCosmosTableDbms.java | 15 +- .../azure/cosmos/AzureCosmosTableEntity.java | 69 +- .../azure/servicebus/AzureRelay.java | 6 +- .../azure/servicebus/AzureServiceBus.java | 16 +- .../servicebus/AzureServiceBusQueue.java | 22 +- .../servicebus/AzureServiceBusTopic.java | 12 +- .../storageaccount/AzureBlobContainer.java | 64 +- ...ntainerImmutableStorageWithVersioning.java | 12 +- .../AzureBlobContainerPublicAccess.java | 18 +- .../AzureBlobStorageAccount.java | 7 +- .../AzureBlockBlobStorageAccount.java | 9 +- .../azure/storageaccount/AzureBypass.java | 4 +- .../storageaccount/AzureExpirationAction.java | 2 +- .../azure/storageaccount/AzureFileShare.java | 9 +- .../AzureFileShareAccessPolicy.java | 10 +- .../AzureFileShareAccessTier.java | 4 +- .../AzureFileShareEnabledProtocols.java | 2 +- .../AzureFileShareSignedIdentifier.java | 8 +- .../AzureFileStorageAccount.java | 7 +- ...AzureFilesIdentityBasedAuthentication.java | 9 +- .../AzureImmutableStorageAccount.java | 10 +- .../azure/storageaccount/AzureIpRule.java | 4 +- .../AzureLegacyStorageAccount.java | 2 +- .../storageaccount/AzureNetworkAction.java | 1 + .../storageaccount/AzureNetworkRuleSet.java | 6 +- .../AzureResourceAccessRule.java | 2 +- .../storageaccount/AzureRoutingChoice.java | 2 +- .../storageaccount/AzureStorageAccount.java | 2 +- .../AzureStorageAccountBackup.java | 12 +- .../AzureStorageAccountCustomDomain.java | 2 +- .../AzureStorageAccountEncryption.java | 8 +- ...AzureStorageAccountEncryptionIdentity.java | 2 +- .../AzureStorageAccountEncryptionService.java | 8 +- .../AzureStorageAccountIdentity.java | 15 +- ...geAccountImmutabilityPolicyProperties.java | 18 +- ...AzureStorageAccountKeyVaultProperties.java | 6 +- .../AzureStorageAccountRoutingPreference.java | 8 +- .../AzureStorageAccountSasPolicy.java | 4 +- .../AzureUserAssignedIdentity.java | 4 +- .../AzureVirtualNetworkRule.java | 6 +- .../BaseAzureStorageAccount.java | 37 +- .../AzureAccountImmutabilityPolicyState.java | 14 +- .../AzureActiveDirectoryAccountType.java | 2 +- .../AzureDefaultSharePermission.java | 12 +- .../valueobjects/AzureDnsEndpointType.java | 4 +- .../AzureLargeFileSharesState.java | 2 +- .../AzurePublicNetworkAccess.java | 4 +- ...overyServicesBackupPolicyWorkloadType.java | 46 +- .../AzureRecoveryServicesSkuName.java | 36 +- .../valueobjects/AzureState.java | 10 +- .../AzureStorageAccountAccessTier.java | 4 +- .../AzureStorageAccountSkuName.java | 2 +- .../providers/gcp/GcpPostgreSqlDatabase.java | 24 +- .../paas/providers/gcp/GcpPostgreSqlDbms.java | 15 +- .../paas/providers/gcp/GcpRegion.java | 118 +-- .../providers/gcp/GoogleKubernetesEngine.java | 10 +- .../providers/hetzner/HetznerKubernetes.java | 121 +-- .../hetzner/HetznerResourceEntity.java | 1 + .../paas/providers/oci/Compartment.java | 172 ++--- .../oci/OciContainerEngineForKubernetes.java | 124 ++-- .../paas/providers/oci/OciResourceEntity.java | 3 + .../saas/UnmanagedBrokerComponent.java | 10 +- .../saas/UnmanagedSecurityComponent.java | 12 +- .../saas/UnmanagedStorageComponent.java | 14 +- .../livesystem/service/LiveSystemService.java | 393 +++++----- .../InstantiateLiveSystemCommandRequest.java | 13 +- .../UpdateLiveSystemCommandRequest.java | 17 +- .../service/dtos/EnvironmentDto.java | 4 +- .../service/dtos/EnvironmentIdDto.java | 9 +- .../service/dtos/LiveSystemComponentDto.java | 73 +- .../dtos/LiveSystemComponentMutationDto.java | 6 +- .../dtos/LiveSystemComponentStatusDto.java | 12 +- .../service/dtos/LiveSystemDto.java | 24 +- .../service/dtos/LiveSystemMutationDto.java | 6 +- .../livesystem/service/dtos/ProviderType.java | 14 +- .../services/contracts/ComponentDto.java | 4 +- .../sdk/domain/values/ComponentId.java | 78 +- .../sdk/domain/values/ResourceGroupId.java | 5 +- .../fractal/sdk/utils/CollectionUtils.java | 6 +- .../fractal/sdk/utils/ExtendableEnum.java | 16 +- .../fractal/sdk/utils/HttpUtils.java | 102 +-- .../sdk/utils/ReflectionClassUnder.java | 12 +- .../fractal/sdk/utils/ReflectionUtils.java | 453 ++++++------ .../sdk/utils/RegexValidationUtils.java | 26 +- .../fractal/sdk/utils/SerializationUtils.java | 6 +- .../fractal/sdk/utils/StringHelper.java | 16 +- .../fractal/sdk/utils/ValidationUtils.java | 15 +- .../yanchware/fractal/sdk/AutomatonTest.java | 13 +- .../fractal/sdk/TestWithFixture.java | 29 +- .../sdk/aggregates/LiveSystemTest.java | 3 +- .../InstantiationWaitConfigurationTest.java | 10 +- .../fractal/sdk/domain/ComponentLinkTest.java | 150 ++-- .../service/BlueprintServiceTest.java | 78 -- .../CreateBlueprintCommandRequestTest.java | 21 - .../domain/environment/CiCdProfileTest.java | 244 +++--- .../domain/environment/DnsARecordTest.java | 34 +- .../domain/environment/DnsAaaaRecordTest.java | 16 +- .../environment/DnsCaaRecordDataTest.java | 34 +- .../domain/environment/DnsCaaRecordTest.java | 6 +- .../environment/DnsMxRecordDataTest.java | 34 +- .../environment/DnsSrvRecordDataTest.java | 68 +- .../domain/environment/DnsSrvRecordTest.java | 40 +- .../sdk/domain/environment/DnsZoneTest.java | 70 +- .../environment/EnvironmentAggregateTest.java | 30 +- .../environment/EnvironmentServiceTest.java | 329 +++++---- .../environment/EnvironmentTypeTest.java | 94 +-- .../ManagementEnvironmentTest.java | 435 +++++------ .../OperationalEnvironmentTest.java | 624 ++++++++-------- .../sdk/domain/environment/SecretTest.java | 51 +- .../fractal/service/BlueprintServiceTest.java | 78 ++ .../CreateBlueprintCommandRequestTest.java | 22 + .../dtos/BlueprintComponentDtoTest.java | 270 +++---- ...stantiateLiveSystemCommandRequestTest.java | 63 +- .../livesystem/LiveSystemAggregateTest.java | 148 ++-- .../LiveSystemAksComponentDtoTest.java | 84 +-- .../LiveSystemEksComponentDtoTest.java | 66 +- .../LiveSystemGkeComponentDtoTest.java | 90 +-- .../LiveSystemHetznerKubernetesDtoTest.java | 69 +- .../LiveSystemOkeComponentDtoTest.java | 66 +- .../LiveSystemPostgresComponentDtoTest.java | 106 +-- .../livesystem/LiveSystemServiceTest.java | 148 ++-- .../OperationalServiceWindowTest.java | 8 +- .../livesystem/SourceControlTypeTest.java | 28 +- .../livesystem/caas/CaaSAmbassadorTest.java | 33 +- .../caas/CaaSElasticDataStoreTest.java | 186 ++--- .../caas/CaaSElasticLoggingTest.java | 185 ++--- .../livesystem/caas/CaaSKafkaClusterTest.java | 3 +- .../CaaSKubernetesCustomWorkloadTest.java | 110 +-- .../livesystem/caas/CaaSOcelotTest.java | 87 +-- .../livesystem/caas/CaaSPrometheusTest.java | 9 +- .../livesystem/caas/CaaSTraefikTest.java | 319 ++++---- .../caas/ContainerResourcesTest.java | 34 +- .../caas/ResourceManagementTest.java | 16 +- .../domain/livesystem/caas/RoleTypeTest.java | 8 +- .../livesystem/caas/TolerationTest.java | 40 +- .../paas/SupportedTlsVersionsTest.java | 6 +- .../aws/AwsElasticKubernetesServiceTest.java | 620 ++++++++-------- .../paas/providers/aws/AwsRegionTest.java | 204 +++--- .../paas/providers/azure/AzureActionTest.java | 12 +- .../AzureActiveDirectoryProfileTest.java | 54 +- ...AzureKubernetesPodManagedIdentityTest.java | 90 +-- .../AzureKubernetesServiceIpRangeTest.java | 64 +- .../azure/AzureKubernetesServiceTest.java | 140 ++-- .../providers/azure/AzureMachineTypeTest.java | 4 +- .../providers/azure/AzureNodePoolTest.java | 190 ++--- .../paas/providers/azure/AzureOsSkuTest.java | 2 +- .../azure/AzurePostgreSQLDBTest.java | 107 +-- .../providers/azure/AzurePostgreSqlTest.java | 84 +-- .../paas/providers/azure/AzureRegionTest.java | 560 +++++++------- .../azure/AzureResourceGroupTest.java | 30 +- .../providers/azure/AzureTlsVersionTest.java | 16 +- .../providers/azure/CosmosAccountTest.java | 229 +++--- .../providers/azure/CosmosCassandraTest.java | 5 +- .../providers/azure/CosmosEntityTest.java | 50 +- .../azure/CosmosGremlinAccountTest.java | 1 - .../azure/CosmosGremlinDatabaseTest.java | 1 - .../azure/CosmosMongoAccountTest.java | 1 - .../azure/CosmosMongoDatabaseTest.java | 1 - .../azure/CosmosNoSqlAccountTest.java | 1 - .../azure/CosmosNoSqlDatabaseTest.java | 1 - .../azure/CosmosPostgreSqlAccountTest.java | 7 +- .../azure/CosmosTableAccountTest.java | 1 - .../azure/CosmosTableEntityTest.java | 1 - .../aks/AzureKubernetesAddonProfileTest.java | 30 +- .../azure/aks/AzureKubernetesAddonTest.java | 22 +- .../azure/aks/AzureOutboundIpTest.java | 27 +- .../azure/aks/ManagedClusterSkuTierTest.java | 20 +- .../appservice/AzureAppServicePlanTest.java | 76 +- .../azure/appservice/AzureAppServiceTest.java | 407 +++++----- .../AzureConnectionStringTypeTest.java | 23 +- .../appservice/AzureDeploymentSlotTest.java | 16 +- .../appservice/AzureIpFilterTagTest.java | 6 +- .../AzureKeyVaultCertificateTest.java | 80 +- .../AzureManagedPipelineModeTest.java | 4 +- .../AzureSiteLoadBalancingTest.java | 16 +- .../AzureWebAppLinuxRuntimeStackTest.java | 86 ++- .../AzureWebAppWindowsRuntimeStackTest.java | 69 +- .../valueobjects/AzureFtpsStateTest.java | 6 +- .../providers/azure/cdn/AzureCdnSkuTest.java | 60 +- .../azure/servicebus/AzureRelayTest.java | 24 +- .../azure/servicebus/AzureServiceBusTest.java | 129 ++-- .../AzureBlobStorageAccountTest.java | 18 +- .../AzureBlockBlobStorageAccountTest.java | 18 +- .../azure/storageaccount/AzureBypassTest.java | 42 +- .../AzureExpirationActionTest.java | 12 +- .../AzureFileShareAccessPolicyTest.java | 42 +- .../AzureFileShareAccessTierTest.java | 32 +- .../AzureFileShareEnabledProtocolsTest.java | 24 +- .../AzureFileShareRootSquashTypeTest.java | 32 +- .../AzureFileShareSignedIdentifierTest.java | 38 +- .../storageaccount/AzureFileShareTest.java | 98 +-- .../AzureFileStorageAccountTest.java | 72 +- .../storageaccount/AzureIpRuleActionTest.java | 12 +- .../AzureLegacyStorageAccountTest.java | 693 +++++++++--------- .../AzureRoutingChoiceTest.java | 22 +- ...orageAccountExtendedLocationTypesTest.java | 12 +- .../AzureStorageAccountKeySourceTest.java | 22 +- .../AzureStorageAccountTest.java | 16 +- ...ureAccountImmutabilityPolicyStateTest.java | 34 +- .../AzureActiveDirectoryAccountTypeTest.java | 22 +- .../AzureDefaultSharePermissionTest.java | 49 +- .../AzureDirectoryServiceOptionsTest.java | 44 +- .../AzureDnsEndpointTypeTest.java | 20 +- .../valueobjects/AzureIdentityTypeTest.java | 43 +- .../AzureLargeFileSharesStateTest.java | 24 +- .../AzurePublicNetworkAccessTest.java | 24 +- .../valueobjects/AzureStateTest.java | 57 +- ...ureStorageAccountAllowedCopyScopeTest.java | 24 +- .../valueobjects/AzureStorageKeyTypeTest.java | 22 +- .../valueobjects/AzureStorageSkuNameTest.java | 86 +-- .../paas/providers/gcp/GcpNodePoolTest.java | 49 +- .../paas/providers/gcp/GcpProgreSqlTest.java | 224 +++--- .../paas/providers/gcp/GcpRegionTest.java | 256 +++---- .../gcp/GoogleKubernetesEngineTest.java | 97 +-- .../paas/providers/oci/OciRegionTest.java | 248 +++---- .../saas/UnmanagedMessageBrokerTest.java | 23 +- .../saas/UnmanagedSecurityComponentTest.java | 20 +- .../saas/UnmanagedStorageAccountTest.java | 29 +- .../LiveSystemKubernetesComponentDtoTest.java | 253 ++++--- .../values/ComponentIdNegativeTests.java | 35 +- .../values/ComponentIdPositiveTests.java | 35 +- .../sdk/utils/CollectionUtilsTest.java | 16 +- .../sdk/utils/LocalSdkConfiguration.java | 4 +- .../fractal/sdk/utils/StringHandler.java | 2 +- .../fractal/sdk/utils/TestUtils.java | 544 +++++++------- 423 files changed, 11362 insertions(+), 10403 deletions(-) delete mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintAggregate.java delete mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintComponent.java delete mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintFactory.java delete mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequest.java delete mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/UpdateBlueprintCommandRequest.java delete mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDto.java create mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/BlueprintComponent.java create mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalAggregate.java rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/FractalIdValue.java (50%) create mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalsFactory.java rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSAPIGateway.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSComponent.java (79%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSLogging.java (68%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSMonitoring.java (69%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSSearch.java (53%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSServiceMeshSecurity.java (71%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/caas/CaaSWorkload.java (68%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsARecord.java (81%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsAaaaRecord.java (76%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsCNameRecord.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsCaaRecord.java (91%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsCaaRecordData.java (85%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsMxRecord.java (96%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsMxRecordData.java (74%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsNsRecord.java (82%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsPtrRecord.java (77%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsRecord.java (55%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsSrvRecord.java (76%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsSrvRecordData.java (75%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsTxtRecord.java (90%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/iaas/DnsZone.java (90%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSColumnOrientedDbms.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSContainerPlatform.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSDataStorage.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSDocumentDatabase.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSDocumentDbms.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSFileShare.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSGraphDatabase.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSGraphDbms.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSKeyValueDbms.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSKeyValueEntity.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSMessageEntity.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSMessaging.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSNetworkCdnProfile.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSRelationalDatabase.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSRelationalDbms.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSStorageContainer.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSWorkload.java (72%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/paas/PaaSWorkloadDeploymentSlot.java (74%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/saas/UnmanagedBrokerComponent.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/saas/UnmanagedSecurityComponent.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/saas/UnmanagedStorageComponent.java (73%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/service/BlueprintService.java (74%) create mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequest.java create mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/UpdateBlueprintCommandRequest.java create mode 100644 fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDto.java rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/service/dtos/BlueprintDto.java (85%) rename fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/service/dtos/BlueprintStatusDto.java (62%) delete mode 100644 fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintServiceTest.java delete mode 100644 fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequestTest.java create mode 100644 fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintServiceTest.java create mode 100644 fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequestTest.java rename fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/{blueprint => fractal}/service/dtos/BlueprintComponentDtoTest.java (61%) diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/Automaton.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/Automaton.java index 6ccf31a2..a9cd6386 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/Automaton.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/Automaton.java @@ -4,12 +4,12 @@ import com.yanchware.fractal.sdk.configuration.EnvVarSdkConfiguration; import com.yanchware.fractal.sdk.configuration.SdkConfiguration; import com.yanchware.fractal.sdk.configuration.instantiation.InstantiationConfiguration; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintFactory; import com.yanchware.fractal.sdk.domain.environment.EnvironmentAggregate; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; import com.yanchware.fractal.sdk.domain.environment.EnvironmentsFactory; import com.yanchware.fractal.sdk.domain.exceptions.ComponentInstantiationException; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; +import com.yanchware.fractal.sdk.domain.fractal.FractalsFactory; import com.yanchware.fractal.sdk.domain.livesystem.EnvironmentReference; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemAggregate; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemIdValue; @@ -37,16 +37,17 @@ @Slf4j public class Automaton { private static Automaton instance; - private static BlueprintFactory blueprintFactory; + private static FractalsFactory fractalsFactory; private static LiveSystemsFactory liveSystemFactory; private static EnvironmentsFactory environmentsFactory; private static RetryRegistry serviceRetryRegistry; private Automaton(HttpClient httpClient, SdkConfiguration sdkConfiguration) { Automaton.serviceRetryRegistry = getDefaultRetryRegistry(); - Automaton.blueprintFactory = new BlueprintFactory(httpClient, sdkConfiguration, Automaton.serviceRetryRegistry); + Automaton.fractalsFactory = new FractalsFactory(httpClient, sdkConfiguration, Automaton.serviceRetryRegistry); Automaton.liveSystemFactory = new LiveSystemsFactory(httpClient, sdkConfiguration, Automaton.serviceRetryRegistry); - Automaton.environmentsFactory = new EnvironmentsFactory(httpClient, sdkConfiguration, Automaton.serviceRetryRegistry); + Automaton.environmentsFactory = new EnvironmentsFactory(httpClient, sdkConfiguration, + Automaton.serviceRetryRegistry); } /** @@ -62,10 +63,19 @@ public static Automaton getInstance() throws InstantiatorException { return instance; } + /** + * Get builder for Blueprint Aggregate + * + * @return an instance of EnvironmentsFactory.EnvironmentBuilder to configure and build environments + */ + public FractalsFactory.FractalBuilder getFractalBuilder() { + return fractalsFactory.builder(); + } + /** * Get builder for Environment Aggregate * - * @return + * @return an instance of EnvironmentsFactory.EnvironmentBuilder to configure and build environments */ public EnvironmentsFactory.EnvironmentBuilder getEnvironmentBuilder() { return environmentsFactory.builder(); @@ -74,7 +84,7 @@ public EnvironmentsFactory.EnvironmentBuilder getEnvironmentBuilder() { /** * Get builder for LiveSystem Aggregate * - * @return + * @return an instance of LiveSystemsFactory.LiveSystemBuilder to build and configure live systems. */ public LiveSystemsFactory.LiveSystemBuilder getLiveSystemBuilder() { return liveSystemFactory.builder(); @@ -98,7 +108,7 @@ public void instantiate(EnvironmentAggregate environment) throws InstantiatorExc */ public void instantiate(List liveSystems) throws InstantiatorException { for (var liveSystem : liveSystems) { - instantiateLiveSystem(liveSystem); + instantiateLiveSystem(liveSystem, true); } } @@ -110,19 +120,20 @@ public void instantiate(List liveSystems) throws Instantiat * @throws InstantiatorException if an error occurs during instantiation */ public void instantiate(List liveSystems, InstantiationConfiguration config) - throws InstantiatorException + throws InstantiatorException { var liveSystemsMutations = new ArrayList>(); for (var liveSystem : liveSystems) { - liveSystemsMutations.add(new ImmutablePair<>(liveSystem, instantiateLiveSystem(liveSystem))); + liveSystemsMutations.add(new ImmutablePair<>(liveSystem, instantiateLiveSystem(liveSystem, + config.createOrUpdateBlueprint))); } if (config != null && config.waitConfiguration != null && config.getWaitConfiguration().waitForInstantiation) { for (var liveSystemMutation : liveSystemsMutations) { waitForMutationInstantiation( - liveSystemMutation.getKey(), - liveSystemMutation.getValue()); + liveSystemMutation.getKey(), + liveSystemMutation.getValue()); } } } @@ -133,14 +144,17 @@ public void instantiate(List liveSystems, InstantiationConf * @param liveSystemIds the list of ids of the live systems to be deleted * @throws InstantiatorException if an error occurs during deletion */ - public void delete(EnvironmentIdValue environmentId, List liveSystemIds) throws InstantiatorException { + public void delete( + EnvironmentIdValue environmentId, + List liveSystemIds) throws InstantiatorException + { for (var liveSystemId : liveSystemIds) { var liveSystemAggregate = getLiveSystemBuilder() - .withId(liveSystemId) - .withEnvironmentId(environmentId) - // This is ignored for deletion. - .withStandardProvider(ProviderType.SAAS) - .build(); + .withId(liveSystemId) + .withEnvironmentId(environmentId) + // This is ignored for deletion. + .withStandardProvider(ProviderType.SAAS) + .build(); liveSystemAggregate.delete(); } } @@ -152,26 +166,34 @@ public void delete(EnvironmentIdValue environmentId, List liv *

This method performs the following steps:

* *
    - *
  1. Parameter Validation: Ensures that all input parameters are valid and not null or empty.
  2. - *
  3. Component Instantiation: Initiates the instantiation of the custom workload component within the live system.
  4. - *
  5. Optional Deployment Wait: If the provided `config` specifies waiting for instantiation, the method will wait until the deployment is complete.
  6. - *
  7. Commit ID Verification: If waiting is enabled, the method verifies that the deployed component's commit ID matches the `commitId` parameter. + *
  8. Parameter Validation: Ensures that all input parameters are valid and not null or empty + * .
  9. + *
  10. Component Instantiation: Initiates the instantiation of the custom workload component + * within the live system.
  11. + *
  12. Optional Deployment Wait: If the provided `config` specifies waiting for instantiation, + * the method will wait until the deployment is complete.
  13. + *
  14. Commit ID Verification: If waiting is enabled, the method verifies that the deployed + * component's commit ID matches the `commitId` parameter. * If there's a mismatch but the component is active, the deployment is re-triggered.
  15. - *
  16. Output Fields Logging: If the deployment is successful, the component's output fields are logged for informational purposes.
  17. + *
  18. Output Fields Logging: If the deployment is successful, the component's output fields are + * logged for informational purposes.
  19. *
* - * @param liveSystemId The ID of the live system. - * @param customWorkloadComponentId The ID of the custom workload component to deploy. - * @param commitId The expected commit ID to be deployed. - * @param config The instantiation configuration, which can specify whether to wait for deployment completion. - * - * @throws ComponentInstantiationException If ny of the required parameters are null or empty, the component is not found, the deployment fails, or an error occurs while waiting for deployment completion. + * @param liveSystemId The ID of the live system. + * @param customWorkloadComponentId The ID of the custom workload component to deploy. + * @param commitId The expected commit ID to be deployed. + * @param config The instantiation configuration, which can specify whether to wait for + * deployment completion. + * @throws ComponentInstantiationException If ny of the required parameters are null or empty, the component is not + * found, the deployment fails, or an error occurs while waiting for deployment completion. */ - public void deployCustomWorkload(LiveSystemIdValue liveSystemId, - String customWorkloadComponentId, - String commitId, - InstantiationConfiguration config) - throws ComponentInstantiationException, InstantiatorException { + public void deployCustomWorkload( + LiveSystemIdValue liveSystemId, + String customWorkloadComponentId, + String commitId, + InstantiationConfiguration config) + throws ComponentInstantiationException, InstantiatorException + { if (liveSystemId.resourceGroupId() == null) { throw new ComponentInstantiationException("Resource group ID cannot be blank."); } @@ -189,15 +211,15 @@ public void deployCustomWorkload(LiveSystemIdValue liveSystemId, } var liveSystem = liveSystemFactory.builder() - .withId(liveSystemId) - .build(); + .withId(liveSystemId) + .build(); var componentMutationDto = liveSystem.instantiateComponent(customWorkloadComponentId); if (componentMutationDto == null) { throw new ComponentInstantiationException( - String.format("Component [id: '%s'] not found in LiveSystem [id: '%s']", - customWorkloadComponentId, liveSystemId)); + String.format("Component [id: '%s'] not found in LiveSystem [id: '%s']", + customWorkloadComponentId, liveSystemId)); } // Optional waiting based on configuration @@ -209,11 +231,13 @@ public void deployCustomWorkload(LiveSystemIdValue liveSystemId, var componentStatus = component.getStatus(); if (componentStatus == LiveSystemComponentStatusDto.Active && - (!component.getOutputFields().containsKey(GIT_COMMIT_ID_KEY) || - !component.getOutputFields().get(GIT_COMMIT_ID_KEY).equals(commitId))) { + (!component.getOutputFields().containsKey(GIT_COMMIT_ID_KEY) || + !component.getOutputFields().get(GIT_COMMIT_ID_KEY).equals(commitId))) + { - log.info("Component is active but at a different commit ID. Expected: '{}', Current: '{}'. Re-triggering deployment", - commitId, component.getOutputFields().get(GIT_COMMIT_ID_KEY)); + log.info("Component is active but at a different commit ID. Expected: '{}', Current: '{}'. Re-triggering " + + "deployment", + commitId, component.getOutputFields().get(GIT_COMMIT_ID_KEY)); deployCustomWorkload(liveSystemId, customWorkloadComponentId, commitId, config); } else if (componentStatus != LiveSystemComponentStatusDto.Active) { @@ -236,19 +260,21 @@ public void deployCustomWorkload(LiveSystemIdValue liveSystemId, *

This method performs the following steps:

* *
    - *
  1. Parameter Validation: Ensures that all input parameters are valid and not null or empty.
  2. - *
  3. Component Instantiation: Initiates the instantiation of the custom workload component within the live system.
  4. + *
  5. Parameter Validation: Ensures that all input parameters are valid and not null or empty + * .
  6. + *
  7. Component Instantiation: Initiates the instantiation of the custom workload component + * within the live system.
  8. *
* *

Note: This method does not wait for deployment completion or verify the commit ID.

* - * @param liveSystemId The ID of the live system. - * @param customWorkloadComponentId The ID of the custom workload component to deploy. - * - * @throws ComponentInstantiationException If any of the required parameters are null or empty or the component is not found. + * @param liveSystemId The ID of the live system. + * @param customWorkloadComponentId The ID of the custom workload component to deploy. + * @throws ComponentInstantiationException If any of the required parameters are null or empty or the component is + * not found. */ public void deployCustomWorkload(LiveSystemIdValue liveSystemId, String customWorkloadComponentId) - throws ComponentInstantiationException, InstantiatorException + throws ComponentInstantiationException, InstantiatorException { if (liveSystemId.resourceGroupId() == null) { throw new ComponentInstantiationException("Resource group ID cannot be blank."); @@ -263,15 +289,15 @@ public void deployCustomWorkload(LiveSystemIdValue liveSystemId, String customWo } var liveSystem = liveSystemFactory.builder() - .withId(liveSystemId) - .build(); + .withId(liveSystemId) + .build(); var componentMutationDto = liveSystem.instantiateComponent(customWorkloadComponentId); if (componentMutationDto == null) { throw new ComponentInstantiationException( - String.format("Component [id: '%s'] not found in LiveSystem [id: '%s']", - customWorkloadComponentId, liveSystemId)); + String.format("Component [id: '%s'] not found in LiveSystem [id: '%s']", + customWorkloadComponentId, liveSystemId)); } } @@ -292,21 +318,21 @@ protected static void initializeAutomaton(HttpClient httpClient, SdkConfiguratio */ protected static void initializeAutomaton(SdkConfiguration sdkConfiguration) { var builder = HttpClient - .newBuilder() - .version(HttpClient.Version.HTTP_2); + .newBuilder() + .version(HttpClient.Version.HTTP_2); initializeAutomaton(builder.build(), sdkConfiguration); } private static RetryRegistry getDefaultRetryRegistry() { return RetryRegistry.of(RetryConfig.custom() - .maxAttempts(5) - .intervalFunction(IntervalFunction.ofExponentialBackoff(5000L)) - .build()); + .maxAttempts(5) + .intervalFunction(IntervalFunction.ofExponentialBackoff(5000L)) + .build()); } private static void waitForMutationInstantiation(LiveSystemAggregate liveSystem, LiveSystemMutationDto mutation) - throws InstantiatorException + throws InstantiatorException { liveSystem.checkLiveSystemMutationStatus(mutation.id()); } @@ -316,31 +342,38 @@ private static String environmentToJsonString(EnvironmentReference environment) return serialize(environment); } catch (JsonProcessingException e) { var errorMessage = String.format("Unable to serialize Instantiate LiveSystem environment. %s", - e.getLocalizedMessage()); + e.getLocalizedMessage()); log.error(errorMessage, e); throw new InstantiatorException(errorMessage, e); } } - private LiveSystemMutationDto instantiateLiveSystem(LiveSystemAggregate liveSystem) - throws InstantiatorException { - createOrUpdateBlueprint(liveSystem); + private LiveSystemMutationDto instantiateLiveSystem(LiveSystemAggregate liveSystem, boolean createOrUpdateBlueprint) + throws InstantiatorException + { + + if (createOrUpdateBlueprint) { + createOrUpdateFractal(liveSystem); + } return liveSystem.instantiate(); } - private static void createOrUpdateBlueprint(LiveSystemAggregate liveSystem) throws InstantiatorException { - var blueprintAggregate = blueprintFactory.getBlueprintAggregate(liveSystem); - blueprintAggregate.createOrUpdate(); + private static void createOrUpdateFractal(LiveSystemAggregate liveSystem) throws InstantiatorException { + var fractalAggregate = fractalsFactory.builder() + .fromLiveSystem(liveSystem) + .build(); + fractalAggregate.createOrUpdate(); } private static LiveSystemComponentMutationDto waitForCustomWorkloadDeploymentCompletion( - LiveSystemAggregate liveSystemAggregate, - LiveSystemComponentMutationDto componentMutationDto) throws InstantiatorException { + LiveSystemAggregate liveSystemAggregate, + LiveSystemComponentMutationDto componentMutationDto) throws InstantiatorException + { return liveSystemAggregate.getComponentMutationStatus( - componentMutationDto.component().getId(), - componentMutationDto.id()); + componentMutationDto.component().getId(), + componentMutationDto.id()); } private static void instantiateEnvironment(EnvironmentAggregate environment) throws InstantiatorException { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/EnvVarSdkConfiguration.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/EnvVarSdkConfiguration.java index 85a07fb2..b03d3348 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/EnvVarSdkConfiguration.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/EnvVarSdkConfiguration.java @@ -42,7 +42,8 @@ public EnvVarSdkConfiguration() throws URISyntaxException { /** * Gets the BOT client ID or Cloud Agent Client ID from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#CI_CD_SERVICE_ACCOUNT_NAME_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#CI_CD_SERVICE_ACCOUNT_NAME_KEY}. * * @return the BOT client ID or Cloud Agent Client ID * @throws IllegalArgumentException if the client ID environment variable is not set @@ -52,14 +53,16 @@ public String getClientId() { var clientId = System.getenv(CI_CD_SERVICE_ACCOUNT_NAME_KEY); if (isBlank(clientId)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", CI_CD_SERVICE_ACCOUNT_NAME_KEY)); + String.format("The environment variable %s is required and it has not been defined", + CI_CD_SERVICE_ACCOUNT_NAME_KEY)); } return clientId; } /** * Gets the BOT client secret or Cloud Agent Client secret from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#CI_CD_SERVICE_ACCOUNT_SECRET_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#CI_CD_SERVICE_ACCOUNT_SECRET_KEY}. * * @return the BOT client secret or Cloud Agent Client secret * @throws IllegalArgumentException if the client secret environment variable is not set @@ -69,7 +72,8 @@ public String getClientSecret() { var clientSecret = System.getenv(CI_CD_SERVICE_ACCOUNT_SECRET_KEY); if (isBlank(clientSecret)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", CI_CD_SERVICE_ACCOUNT_SECRET_KEY)); + String.format("The environment variable %s is required and it has not been defined", + CI_CD_SERVICE_ACCOUNT_SECRET_KEY)); } return clientSecret; } @@ -87,7 +91,8 @@ public String getAzureSpClientId() { /** * Gets the Azure service principal client secret from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#AZURE_SP_CLIENT_SECRET_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#AZURE_SP_CLIENT_SECRET_KEY}. * * @return the Azure service principal client secret */ @@ -120,7 +125,8 @@ public URI getLiveSystemEndpoint() { /** * Gets the URI of the environments endpoint from environment variables or default. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#ENVIRONMENTS_ENDPOINT_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#ENVIRONMENTS_ENDPOINT_KEY}. * * @return the URI of the environments endpoint */ @@ -164,7 +170,8 @@ public String getAwsSessionToken() { /** * Gets the GCP service account email from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#GCP_SERVICE_ACCOUNT_EMAIL_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#GCP_SERVICE_ACCOUNT_EMAIL_KEY}. * * @return the GCP service account email */ @@ -175,7 +182,8 @@ public String getGcpServiceAccountEMail() { /** * Gets the GCP service account credentials from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#GCP_SERVICE_ACCOUNT_CREDENTIALS_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#GCP_SERVICE_ACCOUNT_CREDENTIALS_KEY}. * * @return the GCP service account credentials */ @@ -186,7 +194,8 @@ public String getGcpServiceAccountCredentials() { /** * Gets the OCI service account ID from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#OCI_SERVICE_ACCOUNT_ID_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#OCI_SERVICE_ACCOUNT_ID_KEY}. * * @return the OCI service account ID */ @@ -197,7 +206,8 @@ public String getOciServiceAccountId() { /** * Gets the OCI service account credentials from environment variables. - * The environment variable key is {@value com.yanchware.fractal.sdk.configuration.Constants#OCI_SERVICE_ACCOUNT_CREDENTIALS_KEY}. + * The environment variable key is + * {@value com.yanchware.fractal.sdk.configuration.Constants#OCI_SERVICE_ACCOUNT_CREDENTIALS_KEY}. * * @return the OCI service account credentials */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationConfiguration.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationConfiguration.java index 4466636c..9cc87b82 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationConfiguration.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationConfiguration.java @@ -7,9 +7,17 @@ @Builder(setterPrefix = "with") public class InstantiationConfiguration { - /** - * Defines the wait configuration for the instantiation process. - * By default the instantiation terminates without waiting. - */ - public InstantiationWaitConfiguration waitConfiguration; + /** + * Defines the wait configuration for the instantiation process. + * By default, the instantiation terminates without waiting. + */ + public InstantiationWaitConfiguration waitConfiguration; + + /** + * Indicates whether to create or update a blueprint during the instantiation process. + * This variable is used to control the behavior of blueprint management. + * If set to true, an existing blueprint will be updated or a new blueprint will + * be created as part of the Live System instantiation. + */ + public boolean createOrUpdateBlueprint; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfiguration.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfiguration.java index 06217a27..6a528b2d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfiguration.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfiguration.java @@ -50,7 +50,8 @@ public InstantiationWaitConfigurationBuilder withTimeoutMinutes(int timeoutMinut public InstantiationWaitConfiguration build() { if (configuration.waitForInstantiation - && configuration.timeoutMinutes == null) { + && configuration.timeoutMinutes == null) + { configuration.setTimeoutMinutes(DEFAULT_LIVE_SYSTEM_INSTANTIATION_WAIT_TIMEOUT_MINUTES); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Component.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Component.java index d566d001..9c49f9eb 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Component.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Component.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSAPIGateway; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSAPIGateway; import com.yanchware.fractal.sdk.domain.livesystem.caas.CaaSKubernetesWorkload; import com.yanchware.fractal.sdk.domain.values.ComponentId; import com.yanchware.fractal.sdk.domain.values.ComponentType; @@ -66,19 +66,20 @@ public Builder() { } protected abstract T createComponent(); + protected abstract B getBuilder(); /** *
      * Sets the display name for the current {@link Component} instance.
-     * 
-     * This method allows setting a human-readable name for a component, 
-     * which can be useful for identification and management purposes within 
-     * the Fractal Cloud infrastructure. The display name is used across the 
-     * Fractal Cloud interface and other areas where a more descriptive, 
+     *
+     * This method allows setting a human-readable name for a component,
+     * which can be useful for identification and management purposes within
+     * the Fractal Cloud infrastructure. The display name is used across the
+     * Fractal Cloud interface and other areas where a more descriptive,
      * human-friendly name for a component is preferable over its technical identifier.
* - * @param displayName A String representing the new display name for the component. + * @param displayName A String representing the new display name for the component. * This cannot be null or empty. * @see Component */ @@ -90,17 +91,17 @@ public B withDisplayName(String displayName) { /** *
      * Sets the unique identifier for the current {@link Component} instance using a {@link ComponentId}.
-     * 
-     * The method validates the provided ComponentId against a series of rules defined in the 
-     * {@link ComponentId} class. These rules ensure that the ID is not null, not empty, starts with a 
-     * lowercase letter, contains only lowercase letters, digits, and hyphens, and adheres to length 
+     *
+     * The method validates the provided ComponentId against a series of rules defined in the
+     * {@link ComponentId} class. These rules ensure that the ID is not null, not empty, starts with a
+     * lowercase letter, contains only lowercase letters, digits, and hyphens, and adheres to length
      * constraints (between 3 and 63 characters).
      *
      * If the ComponentId fails validation, an {@link IllegalArgumentException} is thrown,
      * detailing the reason for failure based on the specific validation rule(s) the provided ID violated.
* * @param id The {@link ComponentId} to set as the identifier for the component. Must not be null. - * @throws IllegalArgumentException if the id is null or doesn't meet the validation + * @throws IllegalArgumentException if the id is null or doesn't meet the validation * criteria set by {@link ComponentId#validate(String)}. */ public B withId(ComponentId id) { @@ -112,20 +113,20 @@ public B withId(ComponentId id) { *
      * Sets the unique identifier for the current {@link Component} instance by converting a String
      * to a {@link ComponentId}.
-     * 
-     * This convenience method facilitates the direct assignment of a component's ID using a string value. 
-     * It internally converts the string to a {@link ComponentId} instance, leveraging the validation rules 
-     * defined within the {@link ComponentId} class. These rules ensure the ID is properly formatted—starting 
-     * with a lowercase letter, containing only lowercase letters, digits, and hyphens, and conforming to 
+     *
+     * This convenience method facilitates the direct assignment of a component's ID using a string value.
+     * It internally converts the string to a {@link ComponentId} instance, leveraging the validation rules
+     * defined within the {@link ComponentId} class. These rules ensure the ID is properly formatted—starting
+     * with a lowercase letter, containing only lowercase letters, digits, and hyphens, and conforming to
      * length constraints (between 3 and 63 characters).
-     * 
+     *
      * If the provided string fails to meet these validation criteria, an {@link IllegalArgumentException}
-     * is thrown, indicating the specific validation failure(s). This ensures that only valid identifiers 
+     * is thrown, indicating the specific validation failure(s). This ensures that only valid identifiers
      * are set for components, maintaining integrity within the Fractal Cloud infrastructure.
* - * @param id A String representing the desired identifier for the component. This string is + * @param id A String representing the desired identifier for the component. This string is * converted to a {@link ComponentId}, and must adhere to the {@link ComponentId} validation rules. - * @throws IllegalArgumentException if the id string is null, empty, or violates the + * @throws IllegalArgumentException if the id string is null, empty, or violates the * validation rules defined by {@link ComponentId#validate(String)}. */ public B withId(String id) { @@ -136,19 +137,19 @@ public B withId(String id) { /** *
      * Assigns the version to the current {@link Component} instance.
-     * 
-     * This method sets the version string for a component, intended for future use to distinguish 
+     *
+     * This method sets the version string for a component, intended for future use to distinguish
      * between different stages or configurations of a component's lifecycle. Currently, if a null
-     * version is provided, the version is set to a default value of "1.0". This defaulting behavior 
-     * ensures backward compatibility and facilitates the future introduction of version management 
+     * version is provided, the version is set to a default value of "1.0". This defaulting behavior
+     * ensures backward compatibility and facilitates the future introduction of version management
      * without affecting existing components.
      *
-     * The versioning feature, once in use, will allow for precise management and differentiation 
-     * between component iterations within the Fractal Cloud infrastructure, ensuring that operations 
+     * The versioning feature, once in use, will allow for precise management and differentiation
+     * between component iterations within the Fractal Cloud infrastructure, ensuring that operations
      * utilize the correct component version.
* - * @param version A String representing the new version for the component. If null, - * the version is set to the default value of "1.0". Future implementations will enforce + * @param version A String representing the new version for the component. If null, + * the version is set to the default value of "1.0". Future implementations will enforce * specific format compliance with the application's versioning scheme. */ public B withVersion(String version) { @@ -158,21 +159,21 @@ public B withVersion(String version) { /** *
-     * Locks the current {@link Component}, setting it to prevent hard deletions and enabling its removal 
-     * from the Fractal Cloud list of components by the customer without deleting the actual resource from 
+     * Locks the current {@link Component}, setting it to prevent hard deletions and enabling its removal
+     * from the Fractal Cloud list of components by the customer without deleting the actual resource from
      * the cloud provider.
-     * 
-     * When a component is locked, it is marked as immutable within Fractal Cloud, meaning that no operations 
-     * can lead to its hard deletion from the underlying cloud provider. This status allows the component to be 
-     * manually removed from the Fractal Cloud list of components by the customer as needed, without affecting 
-     * the component's actual resources on the cloud provider. The locked state is especially critical for 
-     * ensuring the component's persistence and availability in the cloud, even as it gets unlisted from 
+     *
+     * When a component is locked, it is marked as immutable within Fractal Cloud, meaning that no operations
+     * can lead to its hard deletion from the underlying cloud provider. This status allows the component to be
+     * manually removed from the Fractal Cloud list of components by the customer as needed, without affecting
+     * the component's actual resources on the cloud provider. The locked state is especially critical for
+     * ensuring the component's persistence and availability in the cloud, even as it gets unlisted from
      * Fractal Cloud UI.
      *
-     * This approach is ideal for components that need to be preserved outside the active management scope of 
-     * Fractal Cloud, such as for archival purposes or during periods of maintenance or transition. It is 
-     * important to note that while the component will no longer appear within Fractal Cloud's active component 
-     * list following its deletion by the customer, its resources remain intact and unmodified on the cloud 
+     * This approach is ideal for components that need to be preserved outside the active management scope of
+     * Fractal Cloud, such as for archival purposes or during periods of maintenance or transition. It is
+     * important to note that while the component will no longer appear within Fractal Cloud's active component
+     * list following its deletion by the customer, its resources remain intact and unmodified on the cloud
      * provider's platform.
*/ public B lock() { @@ -182,15 +183,15 @@ public B lock() { /** *
-     * Unlocks the current {@link Component}, enabling it for standard management procedures within Fractal Cloud, 
-     * including the potential for hard deletion. This method reinstates the component as fully managed by Fractal Cloud, 
+     * Unlocks the current {@link Component}, enabling it for standard management procedures within Fractal Cloud,
+     * including the potential for hard deletion. This method reinstates the component as fully managed by Fractal Cloud,
      * preparing it for any operational workflows that include its management and potential deletion.
      *
-     * Warning: Unlocking can only be applied to components that have not been permanently deleted. 
+     * Warning: Unlocking can only be applied to components that have not been permanently deleted.
      * It is crucial to ensure that the component is still present and has not undergone a hard deletion process.
      *
-     * Use this method with caution to avoid unintended consequences, particularly with components critical to 
-     * operational stability. Ensure that the component is in a state that should be managed and potentially 
+     * Use this method with caution to avoid unintended consequences, particularly with components critical to
+     * operational stability. Ensure that the component is in a state that should be managed and potentially
      * deleted by Fractal Cloud before proceeding with unlocking.
*/ public B unlock() { @@ -201,19 +202,19 @@ public B unlock() { /** *
      * Adds a collection of dependencies to the current {@link Component}.
-     * 
-     * This method allows for the specification of dependencies that must be instantiated before 
-     * the current component, ensuring all necessary resources are ready and available for the 
-     * component's instantiation. Dependencies are managed as a set, avoiding duplicate entries 
+     *
+     * This method allows for the specification of dependencies that must be instantiated before
+     * the current component, ensuring all necessary resources are ready and available for the
+     * component's instantiation. Dependencies are managed as a set, avoiding duplicate entries
      * and ensuring each dependency is only considered once.
* - * @param dependencies A collection of {@link ComponentId} representing the dependencies to be - * added to the component. This collection must not be null, and each - * ComponentId within it represents a unique component dependency + * @param dependencies A collection of {@link ComponentId} representing the dependencies to be + * added to the component. This collection must not be null, and each + * ComponentId within it represents a unique component dependency * that must be available prior to the instantiation of the current component. */ public B withDependencies(Collection dependencies) { - if(component.getDependencies() == null) { + if (component.getDependencies() == null) { component.setDependencies(new HashSet<>()); } @@ -225,7 +226,7 @@ public B withDependencies(Collection dependencies) { /** *
      * Adds a single dependency to the current {@link Component}.
-     * 
+     *
      * This method provides a convenient way to add a single dependency to the component, ensuring that
      * this dependency is instantiated before the component itself. It leverages the {@link #withDependencies(Collection)}
      * method, wrapping the single dependency in a set and passing it on for addition. This approach
@@ -248,22 +249,23 @@ public B withDependency(ComponentId dependency) {
     /**
      * 
      * Adds a collection of links to the current {@link Component}.
-     * 
-     * Utilizes {@link ComponentLink} objects to define connections or relationships between this component 
-     * and others within the system. Each link specifies a target component through its ID and includes 
-     * an optional map of settings to configure the relationship's properties. The method ensures all links 
+     *
+     * Utilizes {@link ComponentLink} objects to define connections or relationships between this component
+     * and others within the system. Each link specifies a target component through its ID and includes
+     * an optional map of settings to configure the relationship's properties. The method ensures all links
      * are valid and adhere to the constraints defined in {@link ComponentLink#validate()} before adding them
      * to the component.
* - * @param links A collection of {@link ComponentLink} objects representing the links to be added. - * Each link must pass validation checks as defined in {@link ComponentLink#validate()}, - * ensuring that all specified component IDs are valid and that the settings map adheres + * @param links A collection of {@link ComponentLink} objects representing the links to be added. + * Each link must pass validation checks as defined in {@link ComponentLink#validate()}, + * ensuring that all specified component IDs are valid and that the settings map adheres * to expected formats and values. - * @throws IllegalArgumentException If any {@link ComponentLink} in the collection fails validation, - * indicating problems with the component ID validity or settings map configuration. + * @throws IllegalArgumentException If any {@link ComponentLink} in the collection fails validation, + * indicating problems with the component ID validity or settings map + * configuration. */ public B withLinks(Collection links) { - if(component.getLinks() == null) { + if (component.getLinks() == null) { component.setLinks(new HashSet<>()); } @@ -283,10 +285,10 @@ public B withLinks(Collection links) { * it adheres to the necessary standards before being added to the component. *
* - * @param link A {@link ComponentLink} object representing the link to be added. The link must pass - * validation checks as outlined in {@link ComponentLink#validate()}, confirming the validity + * @param link A {@link ComponentLink} object representing the link to be added. The link must pass + * validation checks as outlined in {@link ComponentLink#validate()}, confirming the validity * of the specified component ID and the appropriateness of any settings. - * @throws IllegalArgumentException If the {@link ComponentLink} fails validation, indicating issues + * @throws IllegalArgumentException If the {@link ComponentLink} fails validation, indicating issues * with the component ID's validity or the configuration of the settings map. */ public B withLink(ComponentLink link) { @@ -300,11 +302,11 @@ public B withLink(ComponentLink link) { * a default description is generated based on the component's type, ensuring the component always has * a meaningful description. * - * This method facilitates the provision of detailed information about the component's purpose, usage, or + * This method facilitates the provision of detailed information about the component's purpose, usage, or * any other relevant details. In cases where the description is not explicitly provided or is deemed invalid - * (e.g., empty or null), the component is assigned a default description formatted as + * (e.g., empty or null), the component is assigned a default description formatted as * "[ComponentType] generated via SDK", where [ComponentType] is the identifier of the component's type. - * This ensures that every component managed by the SDK has a descriptive text, enhancing clarity and + * This ensures that every component managed by the SDK has a descriptive text, enhancing clarity and * manageability within the system. * * @param description A String representing the description to set for the component. If this parameter @@ -318,24 +320,24 @@ public B withDescription(String description) { /** *
      * Configures the current {@link Component} to be either recreated or not in the event of a failure.
-     * 
-     * This method sets a flag determining whether the component should be automatically recreated 
-     * upon encountering a failure during its lifecycle. This feature is crucial for maintaining 
-     * high availability and resilience, particularly for critical components where automatic recovery 
-     * is preferred to manual intervention. By default, components do not automatically recreate on failure 
-     * (recreateOnFailure = false). However, this behavior is overridden to true in specific 
-     * subclasses, such as {@link CaaSAPIGateway} and {@link CaaSKubernetesWorkload}, to enhance their 
+     *
+     * This method sets a flag determining whether the component should be automatically recreated
+     * upon encountering a failure during its lifecycle. This feature is crucial for maintaining
+     * high availability and resilience, particularly for critical components where automatic recovery
+     * is preferred to manual intervention. By default, components do not automatically recreate on failure
+     * (recreateOnFailure = false). However, this behavior is overridden to true in specific
+     * subclasses, such as {@link CaaSAPIGateway} and {@link CaaSKubernetesWorkload}, to enhance their
      * reliability and self-healing capabilities.
      *
-     * Setting this flag to true enables the component for automatic recreation following a failure, 
-     * while false disables this behavior, necessitating manual remediation to resolve 
-     * failures. This setting permits tailored lifecycle and resilience strategies for different 
-     * component types within the system, accommodating both automated recovery needs and scenarios 
+     * Setting this flag to true enables the component for automatic recreation following a failure,
+     * while false disables this behavior, necessitating manual remediation to resolve
+     * failures. This setting permits tailored lifecycle and resilience strategies for different
+     * component types within the system, accommodating both automated recovery needs and scenarios
      * where manual intervention is preferred.
* - * @param recreateOnFailure A boolean value indicating whether the component should be - * recreated on failure (true) or not (false). The default - * behavior may vary based on the component's type or subclass, with certain + * @param recreateOnFailure A boolean value indicating whether the component should be + * recreated on failure (true) or not (false). The default + * behavior may vary based on the component's type or subclass, with certain * types defaulting to automatic recreation to ensure continuity and resilience. */ public B withRecreateOnFailure(boolean recreateOnFailure) { @@ -345,21 +347,21 @@ public B withRecreateOnFailure(boolean recreateOnFailure) { /** *
-     * Finalizes the building process of the {@link Component}, ensuring it meets all necessary validation 
+     * Finalizes the building process of the {@link Component}, ensuring it meets all necessary validation
      * criteria before instantiation.
-     * 
-     * This method performs a final validation check on the component to ensure that all required fields 
-     * and configurations meet the system's specifications. If any validation errors are found, an 
-     * {@link IllegalArgumentException} is thrown, detailing the reasons for failure. This approach guarantees 
+     *
+     * This method performs a final validation check on the component to ensure that all required fields
+     * and configurations meet the system's specifications. If any validation errors are found, an
+     * {@link IllegalArgumentException} is thrown, detailing the reasons for failure. This approach guarantees
      * that only fully compliant and correctly configured components are created.
      *
-     * If the component's description is not explicitly set, a default description is generated based on 
-     * the component's type to ensure every component is accompanied by descriptive text. Additionally, if 
-     * the version is not specified, it defaults to DEFAULT_VERSION, which is currently "1.0". This 
+     * If the component's description is not explicitly set, a default description is generated based on
+     * the component's type to ensure every component is accompanied by descriptive text. Additionally, if
+     * the version is not specified, it defaults to DEFAULT_VERSION, which is currently "1.0". This
      * standardizes the component versioning, simplifying management and integration within the system.
* * @return The fully constructed and validated {@link Component} instance, ready for use within the system. - * @throws IllegalArgumentException if the component fails any validation checks, with a detailed + * @throws IllegalArgumentException if the component fails any validation checks, with a detailed * message of the validation errors encountered. */ public T build() { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/ComponentLink.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/ComponentLink.java index 3b73455b..eb572e2b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/ComponentLink.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/ComponentLink.java @@ -76,8 +76,8 @@ public ComponentLink build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "ComponentLink validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "ComponentLink validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return componentLink; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Service.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Service.java index c8f8fe55..5be9a2d6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Service.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Service.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.yanchware.fractal.sdk.configuration.SdkConfiguration; -import com.yanchware.fractal.sdk.domain.exceptions.EnvironmentException; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; import com.yanchware.fractal.sdk.utils.StringHelper; import io.github.resilience4j.retry.Retry; @@ -33,11 +32,12 @@ protected Service(HttpClient client, SdkConfiguration sdkConfiguration, RetryReg } protected static void executeRequestWithRetries( - String requestName, - HttpClient client, - RetryRegistry retryRegistry, - HttpRequest request, - int[] acceptedResponses) throws InstantiatorException { + String requestName, + HttpClient client, + RetryRegistry retryRegistry, + HttpRequest request, + int[] acceptedResponses) throws InstantiatorException + { Retry retry = retryRegistry.retry(requestName); @@ -50,19 +50,20 @@ protected static void executeRequestWithRetries( }).get(); } catch (Throwable ex) { throw new InstantiatorException( - String.format("All attempts to %s failed", StringHelper.toWords(requestName)), - ex); + String.format("All attempts to %s failed", StringHelper.toWords(requestName)), + ex); } } protected static T executeRequestWithRetries( - String requestName, - String entityId, - HttpClient client, - RetryRegistry retryRegistry, - HttpRequest request, - int[] acceptedResponses, - Class classRef) throws InstantiatorException { + String requestName, + String entityId, + HttpClient client, + RetryRegistry retryRegistry, + HttpRequest request, + int[] acceptedResponses, + Class classRef) throws InstantiatorException + { Retry retry = retryRegistry.retry(requestName); @@ -73,9 +74,11 @@ protected static T executeRequestWithRetries( HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() == 401) { - var message = String.format("Invalid credentials provided. Please ensure the '%s' and '%s' environment variables are correctly set. Contact Fractal Cloud support if you need assistance with these credentials.", - CI_CD_SERVICE_ACCOUNT_NAME_KEY, CI_CD_SERVICE_ACCOUNT_SECRET_KEY); - + var message = String.format("Invalid credentials provided. Please ensure the '%s' and '%s' environment " + + "variables are correctly set. Contact Fractal Cloud support if you need assistance with these " + + "credentials.", + CI_CD_SERVICE_ACCOUNT_NAME_KEY, CI_CD_SERVICE_ACCOUNT_SECRET_KEY); + String errorMessage = formatErrorMessage(requestName, message, entityId); log.error(errorMessage); @@ -94,13 +97,13 @@ protected static T executeRequestWithRetries( log.error("Attempted {} has come up with empty or null body contents", requestNameLog); return null; } - - if(requestName.equals("fetchEnvironmentById")) { - if(bodyContents.contains("Guid should contain 32 digits")) { + + if (requestName.equals("fetchEnvironmentById")) { + if (bodyContents.contains("Guid should contain 32 digits")) { return null; } } - + try { return deserialize(bodyContents, classRef); } catch (JsonProcessingException e) { @@ -112,8 +115,8 @@ protected static T executeRequestWithRetries( } catch (Throwable ex) { log.error("All attempts failed. {}", ex.getMessage()); // Improved log message throw new InstantiatorException( - String.format("%s. Please try again later or contact Fractal Cloud support if the issue persists.", - ex.getMessage())); // Improved exception message + String.format("%s. Please try again later or contact Fractal Cloud support if the issue persists.", + ex.getMessage())); // Improved exception message } } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Validatable.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Validatable.java index 068d8534..d785cb91 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Validatable.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/Validatable.java @@ -7,6 +7,7 @@ public interface Validatable { /** * Perform a validation on the current instance of the class. * Returns a list of validation errors or an empty list if validation is successful. + * * @return Error list or empty list in case of successful validation. */ Collection validate(); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintAggregate.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintAggregate.java deleted file mode 100644 index b8b98b76..00000000 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintAggregate.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint; - -import com.yanchware.fractal.sdk.configuration.SdkConfiguration; -import com.yanchware.fractal.sdk.domain.blueprint.service.BlueprintService; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; -import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; -import io.github.resilience4j.retry.RetryRegistry; -import lombok.Getter; - -import java.net.http.HttpClient; -import java.util.Collection; - -@Getter -public class BlueprintAggregate { - private final BlueprintService service; - private final FractalIdValue fractalId; - private final String description; - private final boolean isPrivate; - private final Collection components; - - public BlueprintAggregate( - HttpClient client, - SdkConfiguration sdkConfiguration, - RetryRegistry retryRegistry, - FractalIdValue fractalId, - String description, - boolean isPrivate, - // TODO FRA-1870: We should find a way to fix this instead to have DTOs in the Aggregate 🤮 - Collection components) - { - this.fractalId = fractalId; - this.description = description; - this.isPrivate = isPrivate; - this.components = components; - this.service = new BlueprintService(client, sdkConfiguration, retryRegistry); - } - - public void createOrUpdate() throws InstantiatorException { - service.createOrUpdate(fractalId, description, isPrivate, components); - } -} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintComponent.java deleted file mode 100644 index e546491b..00000000 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintComponent.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint; - -public interface BlueprintComponent { -} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintFactory.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintFactory.java deleted file mode 100644 index bd14e9ed..00000000 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/BlueprintFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint; - -import com.yanchware.fractal.sdk.configuration.SdkConfiguration; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; -import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemAggregate; -import io.github.resilience4j.retry.RetryRegistry; - -import java.net.http.HttpClient; - -public class BlueprintFactory { - private final HttpClient client; - private final SdkConfiguration sdkConfiguration; - private final RetryRegistry retryRegistry; - - public BlueprintFactory(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) { - - this.client = client; - this.sdkConfiguration = sdkConfiguration; - this.retryRegistry = retryRegistry; - } - - public BlueprintAggregate getBlueprintAggregate(LiveSystemAggregate liveSystem) { - var fractalId = liveSystem.getFractalId(); - return new BlueprintAggregate( - client, - sdkConfiguration, - retryRegistry, - fractalId, - String.format("Blueprint created via SDK from LiveSystem with Fractal ID: %s", fractalId), - true, - BlueprintComponentDto.fromLiveSystemComponents(liveSystem.getComponents())); - } -} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequest.java deleted file mode 100644 index 93be5ebf..00000000 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequest.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.commands; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; - -import java.util.Collection; - -public record CreateBlueprintCommandRequest ( - String description, - @JsonProperty("private") - boolean isPrivate, - Collection components) { } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/UpdateBlueprintCommandRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/UpdateBlueprintCommandRequest.java deleted file mode 100644 index 14522121..00000000 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/UpdateBlueprintCommandRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.commands; - -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; -import lombok.Builder; -import lombok.Data; - -import java.util.Collection; - -@Data -@Builder -public class UpdateBlueprintCommandRequest { - private String resourceGroupId; - private String fractalName; - private String fractalVersion; - private String description; - private boolean isPrivate; - Collection components; - - public static UpdateBlueprintCommandRequest fromCreateCommand(CreateBlueprintCommandRequest command, FractalIdValue fractalId) { - String[] splitId = fractalId.toString().split("[/:]"); - return UpdateBlueprintCommandRequest.builder() - .resourceGroupId(String.format("%s/%s/%s", splitId[0], splitId[1], splitId[2])) - .fractalName(splitId[3]) - .fractalVersion(splitId[4]) - .description(command.description()) - .isPrivate(command.isPrivate()) - .components(command.components()) - .build(); - } -} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDto.java deleted file mode 100644 index 7e80d122..00000000 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDto.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.dtos; - -import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; -import com.yanchware.fractal.sdk.domain.services.contracts.ComponentDto; -import com.yanchware.fractal.sdk.utils.ReflectionUtils; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.ToString; -import lombok.extern.slf4j.Slf4j; - -import java.util.*; - -import static com.yanchware.fractal.sdk.configuration.Constants.BLUEPRINT_TYPE; -import static java.util.Collections.emptySet; - -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@NoArgsConstructor -@Slf4j -public class BlueprintComponentDto extends ComponentDto { - private Set outputFields; - - public static BlueprintComponentDtoBuilder builder() { - return new BlueprintComponentDtoBuilder(); - } - - public static class BlueprintComponentDtoBuilder extends Builder { - - @Override - protected BlueprintComponentDto createComponent() { - return new BlueprintComponentDto(); - } - - @Override - protected BlueprintComponentDtoBuilder getBuilder() { - return this; - } - - public BlueprintComponentDtoBuilder withOutputFields(Collection outputFields) { - if (componentDto.getOutputFields() == null) { - componentDto.setOutputFields(new HashSet<>()); - } - - componentDto.getOutputFields().addAll(outputFields); - - return builder; - } - } - - public static List fromLiveSystemComponents(Collection components) { - List blueprintComponentDtoList = new ArrayList<>(); - for (LiveSystemComponent component : components) { - List> listOfComponents = ReflectionUtils.buildComponents(component); - for (var componentMap : listOfComponents) { - BlueprintComponentDto componentDto = BlueprintComponentDto.toBlueprintComponentDto(componentMap); - blueprintComponentDtoList.add(componentDto); - } - } - return blueprintComponentDtoList; - } - - private static BlueprintComponentDto toBlueprintComponentDto(Map allFields) { - return BlueprintComponentDto.builder() - .withFields(allFields) - .withType(String.valueOf(allFields.get(BLUEPRINT_TYPE))) - .withOutputFields(emptySet()) - .build(); - } -} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/BaseEnvironment.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/BaseEnvironment.java index f7e379b1..45b3b209 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/BaseEnvironment.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/BaseEnvironment.java @@ -2,12 +2,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.yanchware.fractal.sdk.domain.Validatable; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsZone; import com.yanchware.fractal.sdk.domain.environment.aws.AwsCloudAgent; import com.yanchware.fractal.sdk.domain.environment.azure.AzureCloudAgent; import com.yanchware.fractal.sdk.domain.environment.gcp.GcpCloudAgent; import com.yanchware.fractal.sdk.domain.environment.hetzner.HetznerCloudAgent; import com.yanchware.fractal.sdk.domain.environment.oci.OciCloudAgent; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsZone; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.aws.AwsRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.gcp.GcpRegion; @@ -22,7 +22,7 @@ import java.util.*; -import static com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsZone.DNS_ZONES_PARAM_KEY; +import static com.yanchware.fractal.sdk.domain.fractal.iaas.DnsZone.DNS_ZONES_PARAM_KEY; @Getter @Setter @@ -30,11 +30,15 @@ public abstract class BaseEnvironment implements Environment, Validatable { private static final String CLOUD_AGENTS_PARAM_KEY = "agents"; private static final String TAGS_PARAM_KEY = "tags"; protected final static String SHORT_NAME_IS_NULL = "Environment ShortName has not been defined and it is required"; - private final static String RESOURCE_GROUPS_IS_EMPTY = "Environment ResourceGroups has not been defined and it is required"; + private final static String RESOURCE_GROUPS_IS_EMPTY = "Environment ResourceGroups has not been defined and it is " + + "required"; private final static String SECRET_IS_NULL = "[Secret Validation] The secret cannot be null"; - private final static String DEFAULT_CI_CD_PROFILE_IS_NULL = "[CI/CD Profile Validation] The default CI/CD profile cannot be null"; - private final static String DEFAULT_CI_CD_PROFILE_IS_MISSING = "[CI/CD Profile Validation] A default CI/CD profile must be set if additional CI/CD profiles are defined"; - private final static String CI_CD_PROFILE_SHORT_NAME_NOT_UNIQUE = "[CI/CD Profile Validation] CI/CD profile short names must be unique, including the default profile"; + private final static String DEFAULT_CI_CD_PROFILE_IS_NULL = "[CI/CD Profile Validation] The default CI/CD profile " + + "cannot be null"; + private final static String DEFAULT_CI_CD_PROFILE_IS_MISSING = "[CI/CD Profile Validation] A default CI/CD profile " + + "must be set if additional CI/CD profiles are defined"; + private final static String CI_CD_PROFILE_SHORT_NAME_NOT_UNIQUE = "[CI/CD Profile Validation] CI/CD profile short " + + "names must be unique, including the default profile"; private final static String SECRET_SHORT_NAMES_NOT_UNIQUE = "[Secret Validation] Secret short names must be unique"; private final Map parameters; @@ -86,12 +90,12 @@ public void addTags(Map tags) { this.tags.putAll(tags); } - public void addDnsZones(Collection dnsZones){ + public void addDnsZones(Collection dnsZones) { try { parameters.put(DNS_ZONES_PARAM_KEY, - SerializationUtils.deserialize( - SerializationUtils.serialize(dnsZones), - DnsZone[].class)); + SerializationUtils.deserialize( + SerializationUtils.serialize(dnsZones), + DnsZone[].class)); } catch (JsonProcessingException e) { throw new RuntimeException(e); @@ -123,9 +127,8 @@ protected void registerHetznerCloudAgent(HetznerRegion region, String projectId) registerCloudAgent(agent); } - private void registerCloudAgent(CloudAgentEntity cloudAgent){ - if (cloudAgentByProviderType.containsKey(cloudAgent.getProvider())) - { + private void registerCloudAgent(CloudAgentEntity cloudAgent) { + if (cloudAgentByProviderType.containsKey(cloudAgent.getProvider())) { if (!cloudAgent.equals(cloudAgentByProviderType.get(cloudAgent.getProvider()))) { throw new IllegalArgumentException( String.format("A Cloud agent for Provider %s has already been defined", cloudAgent.getProvider())); @@ -136,7 +139,8 @@ private void registerCloudAgent(CloudAgentEntity cloudAgent){ cloudAgentByProviderType.put(cloudAgent.getProvider(), cloudAgent); - Collection> existingAgents = (Collection>) getParameters().get(CLOUD_AGENTS_PARAM_KEY); + Collection> existingAgents = + (Collection>) getParameters().get(CLOUD_AGENTS_PARAM_KEY); if (existingAgents == null) { existingAgents = new ArrayList<>(); getParameters().put(CLOUD_AGENTS_PARAM_KEY, existingAgents); @@ -145,7 +149,7 @@ private void registerCloudAgent(CloudAgentEntity cloudAgent){ existingAgents.add(cloudAgent.getConfigurationForEnvironmentParameters()); } - public static abstract class EnvironmentBuilder> { + public static abstract class EnvironmentBuilder> { protected T environment; // Protected to allow access in subclasses protected B builder; @@ -153,9 +157,10 @@ public EnvironmentBuilder() { environment = createEnvironment(); builder = getBuilder(); } - + protected abstract T createEnvironment(); + protected abstract B getBuilder(); public B withName(String name) { @@ -202,28 +207,26 @@ public B withTag(String key, String value) { /** *
-     * Adds a single secret to the environment. This secret can be referenced by its name in 
+     * Adds a single secret to the environment. This secret can be referenced by its name in
      * custom workload components that require access to sensitive information.
* * @param secret The secret to add. - * * @return The builder instance. */ public B withSecret(Secret secret) { if (secret == null) { throw new IllegalArgumentException(SECRET_IS_NULL); } - + return withSecrets(List.of(secret)); } /** *
-     * Adds a collection of secrets to the environment. These secrets can be referenced by their 
+     * Adds a collection of secrets to the environment. These secrets can be referenced by their
      * names in custom workload components that require access to sensitive information.
* * @param secrets The collection of secrets to add. - * * @return The builder instance. */ public B withSecrets(Collection secrets) { @@ -245,7 +248,7 @@ public B withDefaultCiCdProfile(CiCdProfile ciCdProfile) { if (ciCdProfile == null) { throw new IllegalArgumentException(DEFAULT_CI_CD_PROFILE_IS_NULL); } - + environment.setDefaultCiCdProfile(ciCdProfile); return builder; } @@ -280,8 +283,8 @@ public T build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "Environment validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "Environment validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return environment; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfile.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfile.java index e1465c25..10806fb1 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfile.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfile.java @@ -8,10 +8,15 @@ import static com.yanchware.fractal.sdk.utils.RegexValidationUtils.isValidAlphanumericsHyphens; -public record CiCdProfile(String shortName, String displayName, String description, String sshPrivateKeyData, String sshPrivateKeyPassphrase) { - private final static String SHORT_NAME_NOT_VALID = "[CI/CD Profile Validation] The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"; - private final static String DISPLAY_NAME_NOT_VALID = "[CI/CD Profile Validation] The Display Name cannot be empty or null"; - private final static String SSH_PRIVATE_KEY_DATA_NOT_VALID = "[CI/CD Profile Validation] The SSH Private Key Data cannot be empty or null"; +public record CiCdProfile(String shortName, String displayName, String description, String sshPrivateKeyData, + String sshPrivateKeyPassphrase) +{ + private final static String SHORT_NAME_NOT_VALID = "[CI/CD Profile Validation] The Short Name only allow " + + "alphanumeric characters and hyphens, cannot start or end in a hyphen"; + private final static String DISPLAY_NAME_NOT_VALID = "[CI/CD Profile Validation] The Display Name cannot be empty " + + "or null"; + private final static String SSH_PRIVATE_KEY_DATA_NOT_VALID = "[CI/CD Profile Validation] The SSH Private Key Data " + + "cannot be empty or null"; /** * Creates a new CI/CD profile with the specified parameters, without a description. @@ -37,7 +42,8 @@ public CiCdProfile(String shortName, String displayName, String sshPrivateKeyDat * Creates a new CI/CD profile with the specified parameters. * *

This constructor allows for the creation of a CI/CD profile with description. - * If a description is not needed, you can use the constructor overload that omits the {@code description} parameter.

+ * If a description is not needed, you can use the constructor overload that omits the {@code description} + * parameter.

* * @param shortName The short name of the CI/CD profile, which must adhere to the following constraints: *
    @@ -56,8 +62,8 @@ public CiCdProfile(String shortName, String displayName, String sshPrivateKeyDat if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "CI/CD Profile validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "CI/CD Profile validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } } @@ -79,8 +85,7 @@ private Collection validate(String shortName, String displayName, String errors.add(SHORT_NAME_NOT_VALID); } } - - + if (StringUtils.isBlank(displayName)) { errors.add(DISPLAY_NAME_NOT_VALID); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CloudAgentEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CloudAgentEntity.java index c080862e..81335897 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CloudAgentEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/CloudAgentEntity.java @@ -21,154 +21,162 @@ @Slf4j public abstract class CloudAgentEntity { - public static final String PROVIDER_PARAM_KEY = "provider"; - protected static final Duration RETRIES_DELAY = Duration.ofSeconds(30); - protected static final Duration TOTAL_ALLOWED_DURATION = Duration.ofMinutes(55); - protected final EnvironmentIdValue environmentId; - protected final Map tags; - - public abstract ProviderType getProvider(); - public abstract void initialize(EnvironmentService environmentService) throws InstantiatorException; - public abstract void initialize(EnvironmentService environmentService, EnvironmentIdValue managedEnvironmentId) throws InstantiatorException; - protected abstract Map getConfigurationForEnvironmentParameters(); - - protected CloudAgentEntity( - EnvironmentIdValue environmentId, - Map tags) { - this.tags = tags; - this.environmentId = environmentId; + public static final String PROVIDER_PARAM_KEY = "provider"; + protected static final Duration RETRIES_DELAY = Duration.ofSeconds(30); + protected static final Duration TOTAL_ALLOWED_DURATION = Duration.ofMinutes(55); + protected final EnvironmentIdValue environmentId; + protected final Map tags; + + public abstract ProviderType getProvider(); + + public abstract void initialize(EnvironmentService environmentService) throws InstantiatorException; + + public abstract void initialize( + EnvironmentService environmentService, + EnvironmentIdValue managedEnvironmentId) throws InstantiatorException; + + protected abstract Map getConfigurationForEnvironmentParameters(); + + protected CloudAgentEntity( + EnvironmentIdValue environmentId, + Map tags) + { + this.tags = tags; + this.environmentId = environmentId; + } + + protected void checkInitializationStatus(Supplier fetchCurrentInitialization) throws InstantiatorException { + int maxAttempts = (int) (TOTAL_ALLOWED_DURATION.toMillis() / RETRIES_DELAY.toMillis()); + + var retryConfig = RetryConfig.custom() + .retryExceptions(InstantiatorException.class) + .maxAttempts(maxAttempts) + .waitDuration(RETRIES_DELAY) + .build(); + + var retry = RetryRegistry.of(retryConfig).retry("checkInitializationStatus"); + + try { + Retry.decorateCheckedSupplier(retry, () -> { + InitializationRunResponse currentInitialization = fetchCurrentInitialization.get(); + printInitializationStatus(currentInitialization); + validateInitializationStatus(currentInitialization); + + return currentInitialization; + }).get(); + } catch (Throwable ex) { + throw new InstantiatorException(ex.getLocalizedMessage()); } - - protected void checkInitializationStatus(Supplier fetchCurrentInitialization) throws InstantiatorException { - int maxAttempts = (int) (TOTAL_ALLOWED_DURATION.toMillis() / RETRIES_DELAY.toMillis()); - - var retryConfig = RetryConfig.custom() - .retryExceptions(InstantiatorException.class) - .maxAttempts(maxAttempts) - .waitDuration(RETRIES_DELAY) - .build(); - - var retry = RetryRegistry.of(retryConfig).retry("checkInitializationStatus"); - - try { - Retry.decorateCheckedSupplier(retry, () -> { - InitializationRunResponse currentInitialization = fetchCurrentInitialization.get(); - printInitializationStatus(currentInitialization); - validateInitializationStatus(currentInitialization); - - return currentInitialization; - }).get(); - } catch (Throwable ex) { - throw new InstantiatorException(ex.getLocalizedMessage()); - } - } - - private void validateInitializationStatus(InitializationRunResponse initializationRun) throws InstantiatorException, EnvironmentInitializationException { - var environmentId = initializationRun.environmentId().toString(); - var providerType = StringHelper.convertToTitleCase(getProvider().toString()); - - switch (initializationRun.status()) { - case "Completed" -> log.info("{} Cloud Agent initialization completed successfully [EnvironmentId: '{}']", - providerType, - environmentId); - case "Failed" -> { - var messageToThrow = getFailedStepsMessageToThrow(providerType, environmentId, initializationRun); - if (isBlank(messageToThrow)) { - logCloudAgentInitializationInProgress(providerType, environmentId); - throw new InstantiatorException("Initialization is in progress, retrying..."); - } else { - throw new EnvironmentInitializationException(messageToThrow); - } - } - case "Cancelled" -> { - log.warn("{} cloud agent initialization cancelled [EnvironmentId: '{}']", providerType, environmentId); - throw new EnvironmentInitializationException("Initialization was cancelled."); - } - case "InProgress" -> { - logCloudAgentInitializationInProgress(providerType, environmentId); - throw new InstantiatorException("Initialization is in progress, retrying..."); - } - default -> { - log.warn("{} cloud agent initialization in an unknown state [EnvironmentId: '{}']", providerType, - environmentId); - throw new EnvironmentInitializationException( - String.format("Unknown initialization status: [%s]", initializationRun.status())); - } - } - } - - private void logCloudAgentInitializationInProgress(String providerType, String environmentId) { - log.info("{} Cloud Agent initialization [status: 'InProgress', EnvironmentId: '{}']. Next check in {} seconds...", - providerType, environmentId, RETRIES_DELAY.toSeconds()); - } - - private String getFailedStepsMessageToThrow( - String providerType, - String environmentId, - InitializationRunResponse initializationRun) { - var failedSteps = initializationRun.steps() - .stream() - .filter(step -> "Failed".equals(step.status())) - .toList(); - - if (failedSteps.isEmpty()) { - return ""; + } + + private void validateInitializationStatus(InitializationRunResponse initializationRun) throws InstantiatorException + , EnvironmentInitializationException { + var environmentId = initializationRun.environmentId().toString(); + var providerType = StringHelper.convertToTitleCase(getProvider().toString()); + + switch (initializationRun.status()) { + case "Completed" -> log.info("{} Cloud Agent initialization completed successfully [EnvironmentId: '{}']", + providerType, + environmentId); + case "Failed" -> { + var messageToThrow = getFailedStepsMessageToThrow(providerType, environmentId, initializationRun); + if (isBlank(messageToThrow)) { + logCloudAgentInitializationInProgress(providerType, environmentId); + throw new InstantiatorException("Initialization is in progress, retrying..."); } else { - var messageToThrow = new StringBuilder(); - messageToThrow.append( - String.format("%s cloud agent initialization failed [EnvironmentId: '%s'].\n Failed steps:\n", - providerType, - environmentId)); - - for (var step : failedSteps) { - var errorMessage = step.lastOperationStatusMessage(); - - messageToThrow.append(String.format(" - Name: '%s', Status: '%s', ErrorMessage: '%s'\n", - step.resourceName(), - step.status(), - errorMessage)); - } - - messageToThrow.deleteCharAt(messageToThrow.length() - 1); - return messageToThrow.toString(); + throw new EnvironmentInitializationException(messageToThrow); } + } + case "Cancelled" -> { + log.warn("{} cloud agent initialization cancelled [EnvironmentId: '{}']", providerType, environmentId); + throw new EnvironmentInitializationException("Initialization was cancelled."); + } + case "InProgress" -> { + logCloudAgentInitializationInProgress(providerType, environmentId); + throw new InstantiatorException("Initialization is in progress, retrying..."); + } + default -> { + log.warn("{} cloud agent initialization in an unknown state [EnvironmentId: '{}']", providerType, + environmentId); + throw new EnvironmentInitializationException( + String.format("Unknown initialization status: [%s]", initializationRun.status())); + } } - - private void printInitializationStatus(InitializationRunResponse initializationRun) { - - initializationRun.steps().sort(Comparator.comparingInt(InitializationStepResponse::order)); - - var logMessage = new StringBuilder(); - initializationRun.steps() - .forEach(step -> { - String status = step.status(); - String resourceName = step.resourceName(); - String resourceType = step.resourceType(); - - String statusSymbol = switch (status) { - case "Completed" -> "✅"; - case "InProgress" -> "🚧"; - case "Failed" -> "❌"; - case "NotStarted" -> "⏳"; - default -> ""; // For "NotStarted" or other unknown statuses - }; - - // Append each step's information to the log message - logMessage.append(String.format(" %s Name: '%s', Type: '%s'\n", - statusSymbol, - resourceName, - resourceType)); - }); - - if (!logMessage.isEmpty()) { - logMessage.deleteCharAt(logMessage.length() - 1); - - var status = String.format("%s Cloud Agent initialization [status: '%s', EnvironmentId: '%s'], steps:\n", - initializationRun.cloudProvider(), - initializationRun.status(), - initializationRun.environmentId()); - - log.info("{}{}", status, logMessage); - } + } + + private void logCloudAgentInitializationInProgress(String providerType, String environmentId) { + log.info("{} Cloud Agent initialization [status: 'InProgress', EnvironmentId: '{}']. Next check in {} seconds...", + providerType, environmentId, RETRIES_DELAY.toSeconds()); + } + + private String getFailedStepsMessageToThrow( + String providerType, + String environmentId, + InitializationRunResponse initializationRun) + { + var failedSteps = initializationRun.steps() + .stream() + .filter(step -> "Failed".equals(step.status())) + .toList(); + + if (failedSteps.isEmpty()) { + return ""; + } else { + var messageToThrow = new StringBuilder(); + messageToThrow.append( + String.format("%s cloud agent initialization failed [EnvironmentId: '%s'].\n Failed steps:\n", + providerType, + environmentId)); + + for (var step : failedSteps) { + var errorMessage = step.lastOperationStatusMessage(); + + messageToThrow.append(String.format(" - Name: '%s', Status: '%s', ErrorMessage: '%s'\n", + step.resourceName(), + step.status(), + errorMessage)); + } + + messageToThrow.deleteCharAt(messageToThrow.length() - 1); + return messageToThrow.toString(); + } + } + + private void printInitializationStatus(InitializationRunResponse initializationRun) { + + initializationRun.steps().sort(Comparator.comparingInt(InitializationStepResponse::order)); + + var logMessage = new StringBuilder(); + initializationRun.steps() + .forEach(step -> { + String status = step.status(); + String resourceName = step.resourceName(); + String resourceType = step.resourceType(); + + String statusSymbol = switch (status) { + case "Completed" -> "✅"; + case "InProgress" -> "🚧"; + case "Failed" -> "❌"; + case "NotStarted" -> "⏳"; + default -> ""; // For "NotStarted" or other unknown statuses + }; + + // Append each step's information to the log message + logMessage.append(String.format(" %s Name: '%s', Type: '%s'\n", + statusSymbol, + resourceName, + resourceType)); + }); + + if (!logMessage.isEmpty()) { + logMessage.deleteCharAt(logMessage.length() - 1); + + var status = String.format("%s Cloud Agent initialization [status: '%s', EnvironmentId: '%s'], steps:\n", + initializationRun.cloudProvider(), + initializationRun.status(), + initializationRun.environmentId()); + + log.info("{}{}", status, logMessage); } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Environment.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Environment.java index b68f2b73..b24cbe81 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Environment.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Environment.java @@ -5,13 +5,17 @@ import java.util.Collection; import java.util.Map; -import java.util.UUID; public interface Environment { EnvironmentIdValue getId(); + String getName(); + Collection getResourceGroups(); + Map getTags(); + Map getParameters(); + EnvironmentDto toDto(); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregate.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregate.java index 1fd65b85..7252fbde 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregate.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregate.java @@ -21,270 +21,280 @@ @Slf4j @Setter(AccessLevel.PROTECTED) public class EnvironmentAggregate { - public static final String REGION_PARAM_KEY = "region"; - - private final EnvironmentService service; - - @Getter - private ManagementEnvironment managementEnvironment; - - public EnvironmentAggregate(EnvironmentService environmentService) { - this.service = environmentService; + public static final String REGION_PARAM_KEY = "region"; + + private final EnvironmentService service; + + @Getter + private ManagementEnvironment managementEnvironment; + + public EnvironmentAggregate(EnvironmentService environmentService) { + this.service = environmentService; + } + + public void createOrUpdate() throws InstantiatorException { + var managementEnvironmentId = managementEnvironment.getId(); + + var existingEnvironment = service.fetch(managementEnvironmentId); + if (shouldCreateEnvironment(existingEnvironment)) { + log.info("Creating new Management Environment [id: '{}']", managementEnvironmentId); + service.create( + null, + managementEnvironmentId, + managementEnvironment.getName(), + managementEnvironment.getResourceGroups(), + managementEnvironment.getParameters()); + } else { + if (doesNotNeedUpdate(managementEnvironment, existingEnvironment)) { + log.info("Management Environment [id: '{}'] already exists and is up-to-date.", managementEnvironmentId); + } else { + log.info("Updating existing Management Environment [id: '{}']", managementEnvironmentId); + service.update( + managementEnvironmentId, + managementEnvironmentId, + managementEnvironment.getName(), + managementEnvironment.getResourceGroups(), + managementEnvironment.getParameters(), + existingEnvironment.defaultCiCdProfileShortName()); + } } - public void createOrUpdate() throws InstantiatorException { - var managementEnvironmentId = managementEnvironment.getId(); - - var existingEnvironment = service.fetch(managementEnvironmentId); - if (shouldCreateEnvironment(existingEnvironment)) { - log.info("Creating new Management Environment [id: '{}']", managementEnvironmentId); - service.create( - null, - managementEnvironmentId, - managementEnvironment.getName(), - managementEnvironment.getResourceGroups(), - managementEnvironment.getParameters()); - } else { - if (doesNotNeedUpdate(managementEnvironment, existingEnvironment)) { - log.info("Management Environment [id: '{}'] already exists and is up-to-date.", managementEnvironmentId); - } else { - log.info("Updating existing Management Environment [id: '{}']", managementEnvironmentId); - service.update( - managementEnvironmentId, - managementEnvironmentId, - managementEnvironment.getName(), - managementEnvironment.getResourceGroups(), - managementEnvironment.getParameters(), - existingEnvironment.defaultCiCdProfileShortName()); - } - } - - for (var operationalEnvironment : managementEnvironment.getOperationalEnvironments()) { - initializeOperationalEnvironment(operationalEnvironment); - } + for (var operationalEnvironment : managementEnvironment.getOperationalEnvironments()) { + initializeOperationalEnvironment(operationalEnvironment); } + } - private boolean shouldCreateEnvironment(EnvironmentResponse existingEnvironment) { - if (existingEnvironment == null) { - return true; - } - - return existingEnvironment.status().equalsIgnoreCase("deleted"); + private boolean shouldCreateEnvironment(EnvironmentResponse existingEnvironment) { + if (existingEnvironment == null) { + return true; } - public void manageCiCdProfiles() throws InstantiatorException { - manageProfilesForEnvironment(managementEnvironment); // Manage profiles for management environment + return existingEnvironment.status().equalsIgnoreCase("deleted"); + } + + public void manageCiCdProfiles() throws InstantiatorException { + manageProfilesForEnvironment(managementEnvironment); // Manage profiles for management environment - for (var environment: managementEnvironment.getOperationalEnvironments()) { - manageProfilesForEnvironment(environment); // Manage profiles for each operational environment - } + for (var environment : managementEnvironment.getOperationalEnvironments()) { + manageProfilesForEnvironment(environment); // Manage profiles for each operational environment } + } - void manageProfilesForEnvironment(BaseEnvironment environment) throws InstantiatorException { - var environmentId = environment.getId(); - var defaultProfile = environment.getDefaultCiCdProfile(); + void manageProfilesForEnvironment(BaseEnvironment environment) throws InstantiatorException { + var environmentId = environment.getId(); + var defaultProfile = environment.getDefaultCiCdProfile(); - var existingEnvironment = service.fetch(environmentId); - var currentDefaultProfileShortName = existingEnvironment.defaultCiCdProfileShortName(); + var existingEnvironment = service.fetch(environmentId); + var currentDefaultProfileShortName = existingEnvironment.defaultCiCdProfileShortName(); - var environmentTier = environment instanceof ManagementEnvironment ? "Management" : "Operational"; + var environmentTier = environment instanceof ManagementEnvironment ? "Management" : "Operational"; - if (defaultProfile != null) { - handleDefaultProfile(environmentTier, environment, environmentId, defaultProfile, currentDefaultProfileShortName); - } else { - handleRemovedDefaultProfile(environmentTier, environment, environmentId, currentDefaultProfileShortName); - } + if (defaultProfile != null) { + handleDefaultProfile(environmentTier, environment, environmentId, defaultProfile, currentDefaultProfileShortName); + } else { + handleRemovedDefaultProfile(environmentTier, environment, environmentId, currentDefaultProfileShortName); } - - private void handleDefaultProfile(String environmentTier, - BaseEnvironment environment, - EnvironmentIdValue environmentId, - CiCdProfile defaultProfile, - String currentDefaultProfileShortName) throws InstantiatorException { - var requests = new ArrayList(); - requests.add(CreateCiCdProfileRequest.fromProfile(defaultProfile)); - - for (var profile: environment.getCiCdProfiles()) { - requests.add(CreateCiCdProfileRequest.fromProfile(profile)); - } - - log.info("Managing CI/CD profiles for {} environment [id: {}]", - environmentTier, environmentId); - - var profilesResponse = service.manageCiCdProfiles(environmentId, requests); - - log.info("Managed {} CI/CD profiles for {} environment [id: {}]", profilesResponse.length, - environmentTier, environmentId); - - if (!defaultProfile.shortName().equals(currentDefaultProfileShortName)) { - updateEnvironmentWithDefaultProfile(environmentTier, environment, environmentId, defaultProfile.shortName()); - } + } + + private void handleDefaultProfile( + String environmentTier, + BaseEnvironment environment, + EnvironmentIdValue environmentId, + CiCdProfile defaultProfile, + String currentDefaultProfileShortName) throws InstantiatorException + { + var requests = new ArrayList(); + requests.add(CreateCiCdProfileRequest.fromProfile(defaultProfile)); + + for (var profile : environment.getCiCdProfiles()) { + requests.add(CreateCiCdProfileRequest.fromProfile(profile)); } - private void updateEnvironmentWithDefaultProfile(String environmentTier, - BaseEnvironment environment, - EnvironmentIdValue environmentId, - String shortName) throws InstantiatorException { - var managementEnvironmentId = environmentId; + log.info("Managing CI/CD profiles for {} environment [id: {}]", + environmentTier, environmentId); - if (environment instanceof OperationalEnvironment operationalEnvironment) { - managementEnvironmentId = operationalEnvironment.getManagementEnvironmentId(); - } + var profilesResponse = service.manageCiCdProfiles(environmentId, requests); - log.info("Updating {} Environment [id: '{}'] with new default CI/CD profile short name", - environmentTier, - environmentId); + log.info("Managed {} CI/CD profiles for {} environment [id: {}]", profilesResponse.length, + environmentTier, environmentId); - service.update( - managementEnvironmentId, - environmentId, - environment.getName(), - environment.getResourceGroups(), - environment.getParameters(), - shortName); + if (!defaultProfile.shortName().equals(currentDefaultProfileShortName)) { + updateEnvironmentWithDefaultProfile(environmentTier, environment, environmentId, defaultProfile.shortName()); + } + } + + private void updateEnvironmentWithDefaultProfile( + String environmentTier, + BaseEnvironment environment, + EnvironmentIdValue environmentId, + String shortName) throws InstantiatorException + { + var managementEnvironmentId = environmentId; + + if (environment instanceof OperationalEnvironment operationalEnvironment) { + managementEnvironmentId = operationalEnvironment.getManagementEnvironmentId(); } - private void handleRemovedDefaultProfile(String environmentTier, - BaseEnvironment environment, - EnvironmentIdValue environmentId, - String currentDefaultProfileShortName) throws InstantiatorException { - if (StringUtils.isNotBlank(currentDefaultProfileShortName)) { - var managementEnvironmentId = environmentId; - - if (environment instanceof OperationalEnvironment operationalEnvironment) { - managementEnvironmentId = operationalEnvironment.getManagementEnvironmentId(); - environmentTier = "Operational"; - } - - log.info("Updating {} Environment [id: '{}'] to remove default CI/CD profile", environmentTier, environmentId); - - service.update( - managementEnvironmentId, - environmentId, - environment.getName(), - environment.getResourceGroups(), - environment.getParameters(), - null); - } + log.info("Updating {} Environment [id: '{}'] with new default CI/CD profile short name", + environmentTier, + environmentId); + + service.update( + managementEnvironmentId, + environmentId, + environment.getName(), + environment.getResourceGroups(), + environment.getParameters(), + shortName); + } + + private void handleRemovedDefaultProfile( + String environmentTier, + BaseEnvironment environment, + EnvironmentIdValue environmentId, + String currentDefaultProfileShortName) throws InstantiatorException + { + if (StringUtils.isNotBlank(currentDefaultProfileShortName)) { + var managementEnvironmentId = environmentId; + + if (environment instanceof OperationalEnvironment operationalEnvironment) { + managementEnvironmentId = operationalEnvironment.getManagementEnvironmentId(); + environmentTier = "Operational"; + } + + log.info("Updating {} Environment [id: '{}'] to remove default CI/CD profile", environmentTier, environmentId); + + service.update( + managementEnvironmentId, + environmentId, + environment.getName(), + environment.getResourceGroups(), + environment.getParameters(), + null); } + } - public void manageSecrets() throws InstantiatorException { - var managementEnvironmentId = managementEnvironment.getId(); + public void manageSecrets() throws InstantiatorException { + var managementEnvironmentId = managementEnvironment.getId(); - log.info("Managing Secrets for Management environment [id: {}]", managementEnvironmentId); + log.info("Managing Secrets for Management environment [id: {}]", managementEnvironmentId); - var secretsResponse = service.manageSecrets(managementEnvironmentId, managementEnvironment.getSecrets()); + var secretsResponse = service.manageSecrets(managementEnvironmentId, managementEnvironment.getSecrets()); - log.info("Managed {} Secrets for Management environment [id: {}]", secretsResponse.length, managementEnvironmentId); + log.info("Managed {} Secrets for Management environment [id: {}]", secretsResponse.length, managementEnvironmentId); - for (var environment : managementEnvironment.getOperationalEnvironments()) { - var environmentId = environment.getId(); - log.info("Managing Secrets for Operational environment [id: {}]", environmentId); + for (var environment : managementEnvironment.getOperationalEnvironments()) { + var environmentId = environment.getId(); + log.info("Managing Secrets for Operational environment [id: {}]", environmentId); - secretsResponse = service.manageSecrets(environmentId, environment.getSecrets()); + secretsResponse = service.manageSecrets(environmentId, environment.getSecrets()); - log.info("Managed {} Secrets for Operational environment [id: {}]", secretsResponse.length, environmentId); - } + log.info("Managed {} Secrets for Operational environment [id: {}]", secretsResponse.length, environmentId); } - - private void initializeOperationalEnvironment(OperationalEnvironment operationalEnvironment) throws InstantiatorException { - var environmentId = operationalEnvironment.getId(); - - var existingEnvironment = service.fetch(environmentId); - - if (shouldCreateEnvironment(existingEnvironment)) { - log.info("Creating new Operational Environment [id: '{}']", environmentId); - service.create( - managementEnvironment.getId(), - environmentId, - operationalEnvironment.getName(), - operationalEnvironment.getResourceGroups(), - operationalEnvironment.getParameters()); - } else { - if (doesNotNeedUpdate(operationalEnvironment, existingEnvironment)) { - log.info("Operational Environment [id: '{}'] already exists and is up-to-date.", environmentId); - } else { - log.info("Updating existing Operational Environment [id: '{}']", environmentId); - service.update( - managementEnvironment.getId(), - environmentId, - operationalEnvironment.getName(), - operationalEnvironment.getResourceGroups(), - operationalEnvironment.getParameters(), - existingEnvironment.defaultCiCdProfileShortName()); - } - } + } + + private void initializeOperationalEnvironment(OperationalEnvironment operationalEnvironment) throws InstantiatorException { + var environmentId = operationalEnvironment.getId(); + + var existingEnvironment = service.fetch(environmentId); + + if (shouldCreateEnvironment(existingEnvironment)) { + log.info("Creating new Operational Environment [id: '{}']", environmentId); + service.create( + managementEnvironment.getId(), + environmentId, + operationalEnvironment.getName(), + operationalEnvironment.getResourceGroups(), + operationalEnvironment.getParameters()); + } else { + if (doesNotNeedUpdate(operationalEnvironment, existingEnvironment)) { + log.info("Operational Environment [id: '{}'] already exists and is up-to-date.", environmentId); + } else { + log.info("Updating existing Operational Environment [id: '{}']", environmentId); + service.update( + managementEnvironment.getId(), + environmentId, + operationalEnvironment.getName(), + operationalEnvironment.getResourceGroups(), + operationalEnvironment.getParameters(), + existingEnvironment.defaultCiCdProfileShortName()); + } } - - /** - * Compares this environment response with another environment object. - * - * @param existingEnvironmentResponse the environment response to compare with current entity - * @return true if the environments are equal, false otherwise - */ - private boolean doesNotNeedUpdate(Environment environment, - EnvironmentResponse existingEnvironmentResponse) { - if (existingEnvironmentResponse == null) return false; - - var environmentIdInResponse = existingEnvironmentResponse.id(); - - - return Objects.equals(environmentIdInResponse.type().toString(), environment.getId().type().toString()) && - Objects.equals(environmentIdInResponse.ownerId(), environment.getId().ownerId()) && - Objects.equals(environmentIdInResponse.shortName(), environment.getId().shortName()) && - Objects.equals(existingEnvironmentResponse.name(), environment.getName()) && - Objects.equals(existingEnvironmentResponse.resourceGroups(), environment.getResourceGroups()) && - mapsEqual(existingEnvironmentResponse.parameters(), environment.getParameters()); + } + + /** + * Compares this environment response with another environment object. + * + * @param existingEnvironmentResponse the environment response to compare with current entity + * @return true if the environments are equal, false otherwise + */ + private boolean doesNotNeedUpdate( + Environment environment, + EnvironmentResponse existingEnvironmentResponse) + { + if (existingEnvironmentResponse == null) { + return false; } - /** - * Compares two maps for equality using JSON serialization. - * - * @param map1 the first map to compare - * @param map2 the second map to compare - * @return true if the maps are equal, false otherwise - */ - private boolean mapsEqual(Map map1, Map map2) { - try { - String json1 = SerializationUtils.serializeSortedJson(map1); - String json2 = SerializationUtils.serializeSortedJson(map2); - return json1.equals(json2); - } catch (JsonProcessingException e) { - return false; - } + var environmentIdInResponse = existingEnvironmentResponse.id(); + + + return Objects.equals(environmentIdInResponse.type().toString(), environment.getId().type().toString()) && + Objects.equals(environmentIdInResponse.ownerId(), environment.getId().ownerId()) && + Objects.equals(environmentIdInResponse.shortName(), environment.getId().shortName()) && + Objects.equals(existingEnvironmentResponse.name(), environment.getName()) && + Objects.equals(existingEnvironmentResponse.resourceGroups(), environment.getResourceGroups()) && + mapsEqual(existingEnvironmentResponse.parameters(), environment.getParameters()); + } + + /** + * Compares two maps for equality using JSON serialization. + * + * @param map1 the first map to compare + * @param map2 the second map to compare + * @return true if the maps are equal, false otherwise + */ + private boolean mapsEqual(Map map1, Map map2) { + try { + String json1 = SerializationUtils.serializeSortedJson(map1); + String json2 = SerializationUtils.serializeSortedJson(map2); + return json1.equals(json2); + } catch (JsonProcessingException e) { + return false; } + } - public void initializeAgents() { - var managementAgents = managementEnvironment.getCloudAgentByProviderType().values(); + public void initializeAgents() { + var managementAgents = managementEnvironment.getCloudAgentByProviderType().values(); - // 1. Initialize Management Environment Agents - try (ExecutorService executor = Executors.newFixedThreadPool(managementAgents.size())) { - for (var managementAgent : managementAgents) { - executor.execute(() -> { - try { + // 1. Initialize Management Environment Agents + try (ExecutorService executor = Executors.newFixedThreadPool(managementAgents.size())) { + for (var managementAgent : managementAgents) { + executor.execute(() -> { + try { - var providerType = managementAgent.getProvider(); + var providerType = managementAgent.getProvider(); - managementAgent.initialize(service); + managementAgent.initialize(service); - for (var operationalEnvironment : managementEnvironment.getOperationalEnvironments()) { + for (var operationalEnvironment : managementEnvironment.getOperationalEnvironments()) { - var operationalAgent = operationalEnvironment.getCloudAgentByProviderType() - .values() - .stream().filter(a -> a.getProvider() == providerType) - .findFirst(); + var operationalAgent = operationalEnvironment.getCloudAgentByProviderType() + .values() + .stream().filter(a -> a.getProvider() == providerType) + .findFirst(); - if (operationalAgent.isPresent()) { - operationalAgent.get().initialize(service, managementEnvironment.getId()); - } - } - } catch (InstantiatorException e) { - log.error(e.getMessage()); - System.exit(1); - } - }); + if (operationalAgent.isPresent()) { + operationalAgent.get().initialize(service, managementEnvironment.getId()); + } } - } + } catch (InstantiatorException e) { + log.error(e.getMessage()); + System.exit(1); + } + }); + } } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentIdValue.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentIdValue.java index f9298d66..ae3e0812 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentIdValue.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentIdValue.java @@ -9,23 +9,23 @@ public record EnvironmentIdValue(EnvironmentType type, UUID ownerId, String shortName) { - @NotNull - @Override - public String toString(){ - return String.format("%s/%s/%s", StringHelper.convertToTitleCase(type.name()), ownerId, shortName); - } + @NotNull + @Override + public String toString() { + return String.format("%s/%s/%s", StringHelper.convertToTitleCase(type.name()), ownerId, shortName); + } - public EnvironmentIdDto toDto() { - return new EnvironmentIdDto( - EnvironmentTypeDto.fromString(type.toString()), - ownerId(), - shortName()); - } + public EnvironmentIdDto toDto() { + return new EnvironmentIdDto( + EnvironmentTypeDto.fromString(type.toString()), + ownerId(), + shortName()); + } - public static EnvironmentIdValue fromDto(EnvironmentIdDto dto) { - return new EnvironmentIdValue( - EnvironmentType.fromString(dto.type().toString()), - dto.ownerId(), - dto.shortName()); - } + public static EnvironmentIdValue fromDto(EnvironmentIdDto dto) { + return new EnvironmentIdValue( + EnvironmentType.fromString(dto.type().toString()), + dto.ownerId(), + dto.shortName()); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentType.java index c5fdd02a..5e2aeddd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentType.java @@ -22,10 +22,10 @@ public String getEnvironmentType() { } public static EnvironmentType fromString(String text) { - if(isBlank(text)) { + if (isBlank(text)) { throw new IllegalArgumentException( - String.format("Environment type cannot be null or blank. Allowed values: %s", - Arrays.toString(EnvironmentType.values()))); + String.format("Environment type cannot be null or blank. Allowed values: %s", + Arrays.toString(EnvironmentType.values()))); } for (var item : EnvironmentType.values()) { @@ -35,8 +35,8 @@ public static EnvironmentType fromString(String text) { } throw new IllegalArgumentException( - String.format("Invalid environment type: '%s'. Allowed values: %s", - text, Arrays.toString(EnvironmentType.values()))); + String.format("Invalid environment type: '%s'. Allowed values: %s", + text, Arrays.toString(EnvironmentType.values()))); } @Override diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentsFactory.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentsFactory.java index 462add28..5c2ec4a0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentsFactory.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentsFactory.java @@ -29,7 +29,11 @@ public EnvironmentBuilder(HttpClient client, SdkConfiguration sdkConfiguration, builder = getBuilder(); } - protected EnvironmentAggregate create(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) { + protected EnvironmentAggregate create( + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) + { return new EnvironmentAggregate(new RestEnvironmentService(client, sdkConfiguration, retryRegistry)); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironment.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironment.java index d913a7ac..c991a46e 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironment.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironment.java @@ -62,7 +62,8 @@ public Collection validate() { } @SuppressWarnings("unchecked") - public static class ManagementEnvironmentBuilder extends EnvironmentBuilder { // Specify Builder type + public static class ManagementEnvironmentBuilder extends EnvironmentBuilder { // Specify Builder type public ManagementEnvironmentBuilder withId(EnvironmentIdValue environmentId) { environment.setId(environmentId); @@ -137,35 +138,35 @@ private void configureOperationalEnvironment(OperationalEnvironment operationalE Map config = entry.getValue(); CloudAgentEntity managementAgent = environment.getCloudAgentByProviderType().get(provider); - - if(managementAgent == null) { + + if (managementAgent == null) { continue; } switch (provider) { case AWS: operationalEnvironment.registerAwsCloudAgent( - (AwsRegion) config.get("region"), - getPropertyFromManagementAgent(provider, "organizationId"), - (String) config.get("accountId")); + (AwsRegion) config.get("region"), + getPropertyFromManagementAgent(provider, "organizationId"), + (String) config.get("accountId")); break; case AZURE: operationalEnvironment.registerAzureCloudAgent( - (AzureRegion) config.get("region"), - getPropertyFromManagementAgent(provider, "tenantId"), - (UUID) config.get("subscriptionId")); + (AzureRegion) config.get("region"), + getPropertyFromManagementAgent(provider, "tenantId"), + (UUID) config.get("subscriptionId")); break; case GCP: operationalEnvironment.registerGcpCloudAgent( - (GcpRegion) config.get("region"), - getPropertyFromManagementAgent(provider, "organizationId"), - (String) config.get("projectId")); + (GcpRegion) config.get("region"), + getPropertyFromManagementAgent(provider, "organizationId"), + (String) config.get("projectId")); break; case OCI: operationalEnvironment.registerOciCloudAgent( - (OciRegion) config.get("region"), - getPropertyFromManagementAgent(provider, "tenancyId"), - (String) config.get("compartmentId")); + (OciRegion) config.get("region"), + getPropertyFromManagementAgent(provider, "tenancyId"), + (String) config.get("compartmentId")); break; case HETZNER: operationalEnvironment.registerHetznerCloudAgent( @@ -188,10 +189,11 @@ private T getPropertyFromManagementAgent(ProviderType providerType, String p try { var field = cloudAgent.getClass().getDeclaredField(propertyName); field.setAccessible(true); - + return (T) field.get(cloudAgent); } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException("Error getting property " + propertyName + " from " + providerType + " Cloud Agent", e); + throw new RuntimeException("Error getting property " + propertyName + " from " + providerType + " Cloud " + + "Agent", e); } } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironment.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironment.java index 1bdd767e..ab44b4c5 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironment.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironment.java @@ -23,7 +23,7 @@ public class OperationalEnvironment extends BaseEnvironment { @JsonIgnore private final Map> cloudProviders = new HashMap<>(); - + @Setter(AccessLevel.PROTECTED) private EnvironmentIdValue managementEnvironmentId; @@ -32,13 +32,13 @@ public class OperationalEnvironment extends BaseEnvironment { @Override public EnvironmentIdValue getId() { - if(this.managementEnvironmentId == null) { + if (this.managementEnvironmentId == null) { return null; } - + return new EnvironmentIdValue(managementEnvironmentId.type(), - managementEnvironmentId.ownerId(), - shortName); + managementEnvironmentId.ownerId(), + shortName); } @Override @@ -68,7 +68,8 @@ public static OperationalEnvironmentBuilder builder() { return new OperationalEnvironmentBuilder(); } - public static class OperationalEnvironmentBuilder extends EnvironmentBuilder { + public static class OperationalEnvironmentBuilder extends EnvironmentBuilder { public OperationalEnvironmentBuilder withShortName(String shortName) { environment.setShortName(shortName); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Secret.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Secret.java index ee4c1fff..7cafd091 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Secret.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/Secret.java @@ -18,7 +18,8 @@ * Secret values cannot be empty or null. */ public record Secret(String shortName, String displayName, String description, String value) { - private final static String SHORT_NAME_NOT_VALID = "[Secret Validation] The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"; + private final static String SHORT_NAME_NOT_VALID = "[Secret Validation] The Short Name only allow alphanumeric " + + "characters and hyphens, cannot start or end in a hyphen"; private final static String DISPLAY_NAME_NOT_VALID = "[Secret Validation] The Display Name cannot be empty or null"; private final static String VALUE_NOT_VALID = "[Secret Validation] The value cannot be empty or null"; @@ -62,8 +63,8 @@ public Secret(String shortName, String displayName, String value) { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "Secret validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "Secret validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/aws/AwsCloudAgent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/aws/AwsCloudAgent.java index 63b756cd..01d6a2f5 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/aws/AwsCloudAgent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/aws/AwsCloudAgent.java @@ -2,7 +2,6 @@ import com.yanchware.fractal.sdk.domain.environment.CloudAgentEntity; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; -import com.yanchware.fractal.sdk.domain.environment.oci.OciCloudAgent; import com.yanchware.fractal.sdk.domain.environment.service.EnvironmentService; import com.yanchware.fractal.sdk.domain.environment.service.dtos.InitializationRunResponse; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; @@ -19,91 +18,99 @@ @Slf4j @Getter public class AwsCloudAgent extends CloudAgentEntity { - public static final String ORGANIZATION_ID_PARAM_KEY = "organizationId"; - public static final String ACCOUNT_ID_PARAM_KEY = "accountId"; - - private final AwsRegion region; - private final String organizationId; - private final String accountId; - - public AwsCloudAgent( - EnvironmentIdValue environmentId, - AwsRegion region, - String organizationId, - String accountId, - Map tags) + public static final String ORGANIZATION_ID_PARAM_KEY = "organizationId"; + public static final String ACCOUNT_ID_PARAM_KEY = "accountId"; + + private final AwsRegion region; + private final String organizationId; + private final String accountId; + + public AwsCloudAgent( + EnvironmentIdValue environmentId, + AwsRegion region, + String organizationId, + String accountId, + Map tags) + { + super(environmentId, tags); + this.region = region; + this.organizationId = organizationId; + this.accountId = accountId; + } + + @Override + public ProviderType getProvider() { + return ProviderType.AWS; + } + + @Override + public void initialize(EnvironmentService environmentService) throws InstantiatorException { + initialize(environmentService, null); + } + + @Override + public void initialize( + EnvironmentService environmentService, + EnvironmentIdValue managementEnvironmentId) throws InstantiatorException + { + var currentInitialization = environmentService.fetchCurrentAwsInitialization(environmentId); + + if (currentInitialization == null || + "Failed".equals(currentInitialization.status()) || + "Cancelled".equals(currentInitialization.status())) { - super(environmentId, tags); - this.region = region; - this.organizationId = organizationId; - this.accountId = accountId; - } - - @Override - public ProviderType getProvider() { - return ProviderType.AWS; - } - @Override - public void initialize(EnvironmentService environmentService) throws InstantiatorException { - initialize(environmentService, null); + environmentService.startAwsCloudAgentInitialization( + environmentId, + organizationId, + accountId, + region, + tags); + + log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); + checkInitializationStatus(() -> fetchCurrentAwsInitialization(environmentService)); + } else { + checkInitializationStatus(() -> fetchCurrentAwsInitialization(environmentService)); } - - @Override - public void initialize(EnvironmentService environmentService, EnvironmentIdValue managementEnvironmentId) throws InstantiatorException { - var currentInitialization = environmentService.fetchCurrentAwsInitialization(environmentId); - - if (currentInitialization == null || - "Failed".equals(currentInitialization.status()) || - "Cancelled".equals(currentInitialization.status())) { - - environmentService.startAwsCloudAgentInitialization( - environmentId, - organizationId, - accountId, - region, - tags); - - log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); - checkInitializationStatus(() -> fetchCurrentAwsInitialization(environmentService)); - } else { - checkInitializationStatus(() -> fetchCurrentAwsInitialization(environmentService)); - } + } + + @Override + protected Map getConfigurationForEnvironmentParameters() { + return Map.of( + PROVIDER_PARAM_KEY, getProvider(), + REGION_PARAM_KEY, region, + ORGANIZATION_ID_PARAM_KEY, organizationId, + ACCOUNT_ID_PARAM_KEY, accountId + ); + } + + private InitializationRunResponse fetchCurrentAwsInitialization(EnvironmentService environmentService) { + try { + return environmentService.fetchCurrentAwsInitialization(environmentId); + } catch (InstantiatorException e) { + throw new RuntimeException(e); } + } - @Override - protected Map getConfigurationForEnvironmentParameters() { - return Map.of( - PROVIDER_PARAM_KEY, getProvider(), - REGION_PARAM_KEY, region, - ORGANIZATION_ID_PARAM_KEY, organizationId, - ACCOUNT_ID_PARAM_KEY, accountId - ); + @Override + public boolean equals(Object o) { + if (this == o) { + return true; } - - private InitializationRunResponse fetchCurrentAwsInitialization(EnvironmentService environmentService) { - try { - return environmentService.fetchCurrentAwsInitialization(environmentId); - } catch (InstantiatorException e) { - throw new RuntimeException(e); - } + if (o == null || getClass() != o.getClass()) { + return false; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AwsCloudAgent member = (AwsCloudAgent) o; + AwsCloudAgent member = (AwsCloudAgent) o; - return region.equals(member.region) - && organizationId.equals(member.organizationId) - && accountId.equals(member.accountId) - && environmentId.equals(member.environmentId); - } + return region.equals(member.region) + && organizationId.equals(member.organizationId) + && accountId.equals(member.accountId) + && environmentId.equals(member.environmentId); + } - @Override - public int hashCode() { - return Objects.hash(region, organizationId, accountId, environmentId); - } + @Override + public int hashCode() { + return Objects.hash(region, organizationId, accountId, environmentId); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/azure/AzureCloudAgent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/azure/AzureCloudAgent.java index 3b70ddcf..6ad324f2 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/azure/AzureCloudAgent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/azure/AzureCloudAgent.java @@ -2,7 +2,6 @@ import com.yanchware.fractal.sdk.domain.environment.CloudAgentEntity; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; -import com.yanchware.fractal.sdk.domain.environment.oci.OciCloudAgent; import com.yanchware.fractal.sdk.domain.environment.service.EnvironmentService; import com.yanchware.fractal.sdk.domain.environment.service.dtos.InitializationRunResponse; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; @@ -20,97 +19,106 @@ @Slf4j @Getter public class AzureCloudAgent extends CloudAgentEntity { - public static final String TENANT_ID_PARAM_KEY = "tenantId"; - public static final String SUBSCRIPTION_ID_PARAM_KEY = "subscriptionId"; - public static final UUID EMPTY_UUID = new UUID(0L, 0L); - - private final AzureRegion region; - private final UUID tenantId; - private final UUID subscriptionId; - - public AzureCloudAgent( - EnvironmentIdValue environmentId, - AzureRegion region, - UUID tenantId, - UUID subscriptionId, - Map tags) { - super(environmentId, tags); - this.region = region; - this.tenantId = tenantId; - this.subscriptionId = subscriptionId; + public static final String TENANT_ID_PARAM_KEY = "tenantId"; + public static final String SUBSCRIPTION_ID_PARAM_KEY = "subscriptionId"; + public static final UUID EMPTY_UUID = new UUID(0L, 0L); + + private final AzureRegion region; + private final UUID tenantId; + private final UUID subscriptionId; + + public AzureCloudAgent( + EnvironmentIdValue environmentId, + AzureRegion region, + UUID tenantId, + UUID subscriptionId, + Map tags) + { + super(environmentId, tags); + this.region = region; + this.tenantId = tenantId; + this.subscriptionId = subscriptionId; + } + + @Override + public ProviderType getProvider() { + return ProviderType.AZURE; + } + + @Override + public void initialize(EnvironmentService environmentService) throws InstantiatorException { + initialize(environmentService, null); + } + + @Override + public void initialize( + EnvironmentService environmentService, + EnvironmentIdValue managementEnvironmentId) throws InstantiatorException + { + var currentInitialization = environmentService.fetchCurrentAzureInitialization(environmentId); + + if (currentInitialization != null && currentInitialization.status().equals("Completed")) { + log.info("{} Cloud Agent initialization for environment '{}' completed successfully.", + currentInitialization.cloudProvider(), currentInitialization.environmentId()); + return; } - @Override - public ProviderType getProvider() { - return ProviderType.AZURE; + if (currentInitialization == null || + currentInitialization.id().equals(EMPTY_UUID) || + "Failed".equals(currentInitialization.status()) || + "Cancelled".equals(currentInitialization.status())) + { + + environmentService.startAzureCloudAgentInitialization( + managementEnvironmentId, + environmentId, + tenantId, + subscriptionId, + region, + tags); + + checkInitializationStatus(() -> fetchCurrentAzureInitialization(environmentService)); + } else { + checkInitializationStatus(() -> fetchCurrentAzureInitialization(environmentService)); } - - @Override - public void initialize(EnvironmentService environmentService) throws InstantiatorException { - initialize(environmentService, null); - } - - @Override - public void initialize(EnvironmentService environmentService, EnvironmentIdValue managementEnvironmentId) throws InstantiatorException { - var currentInitialization = environmentService.fetchCurrentAzureInitialization(environmentId); - - if (currentInitialization != null && currentInitialization.status().equals("Completed")) { - log.info("{} Cloud Agent initialization for environment '{}' completed successfully.", - currentInitialization.cloudProvider(), currentInitialization.environmentId()); - return; - } - - if (currentInitialization == null || - currentInitialization.id().equals(EMPTY_UUID) || - "Failed".equals(currentInitialization.status()) || - "Cancelled".equals(currentInitialization.status())) { - - environmentService.startAzureCloudAgentInitialization( - managementEnvironmentId, - environmentId, - tenantId, - subscriptionId, - region, - tags); - - checkInitializationStatus(() -> fetchCurrentAzureInitialization(environmentService)); - } else { - checkInitializationStatus(() -> fetchCurrentAzureInitialization(environmentService)); - } + } + + @Override + public Map getConfigurationForEnvironmentParameters() { + return Map.of( + PROVIDER_PARAM_KEY, getProvider(), + REGION_PARAM_KEY, region, + TENANT_ID_PARAM_KEY, tenantId, + SUBSCRIPTION_ID_PARAM_KEY, subscriptionId); + } + + private InitializationRunResponse fetchCurrentAzureInitialization(EnvironmentService environmentService) { + try { + return environmentService.fetchCurrentAzureInitialization(environmentId); + } catch (InstantiatorException e) { + throw new RuntimeException(e); } + } - @Override - public Map getConfigurationForEnvironmentParameters() { - return Map.of( - PROVIDER_PARAM_KEY, getProvider(), - REGION_PARAM_KEY, region, - TENANT_ID_PARAM_KEY, tenantId, - SUBSCRIPTION_ID_PARAM_KEY, subscriptionId); + @Override + public boolean equals(Object o) { + if (this == o) { + return true; } - - private InitializationRunResponse fetchCurrentAzureInitialization(EnvironmentService environmentService) { - try { - return environmentService.fetchCurrentAzureInitialization(environmentId); - } catch (InstantiatorException e) { - throw new RuntimeException(e); - } + if (o == null || getClass() != o.getClass()) { + return false; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + AzureCloudAgent member = (AzureCloudAgent) o; - AzureCloudAgent member = (AzureCloudAgent) o; + return region.equals(member.region) + && tenantId.equals(member.tenantId) + && subscriptionId.equals(member.subscriptionId) + && environmentId.equals(member.environmentId); + } - return region.equals(member.region) - && tenantId.equals(member.tenantId) - && subscriptionId.equals(member.subscriptionId) - && environmentId.equals(member.environmentId); - } - - @Override - public int hashCode() { - return Objects.hash(region, tenantId, subscriptionId, environmentId); - } + @Override + public int hashCode() { + return Objects.hash(region, tenantId, subscriptionId, environmentId); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/gcp/GcpCloudAgent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/gcp/GcpCloudAgent.java index 8afcc87a..87b7281a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/gcp/GcpCloudAgent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/gcp/GcpCloudAgent.java @@ -2,7 +2,6 @@ import com.yanchware.fractal.sdk.domain.environment.CloudAgentEntity; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; -import com.yanchware.fractal.sdk.domain.environment.oci.OciCloudAgent; import com.yanchware.fractal.sdk.domain.environment.service.EnvironmentService; import com.yanchware.fractal.sdk.domain.environment.service.dtos.InitializationRunResponse; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; @@ -19,91 +18,99 @@ @Slf4j @Getter public class GcpCloudAgent extends CloudAgentEntity { - public static final String ORGANIZATION_ID_PARAM_KEY = "organizationId"; - public static final String PROJECT_ID_PARAM_KEY = "projectId"; - - private final GcpRegion region; - private final String organizationId; - private final String projectId; - - public GcpCloudAgent( - EnvironmentIdValue environmentId, - GcpRegion region, - String organizationId, - String projectId, - Map tags) + public static final String ORGANIZATION_ID_PARAM_KEY = "organizationId"; + public static final String PROJECT_ID_PARAM_KEY = "projectId"; + + private final GcpRegion region; + private final String organizationId; + private final String projectId; + + public GcpCloudAgent( + EnvironmentIdValue environmentId, + GcpRegion region, + String organizationId, + String projectId, + Map tags) + { + super(environmentId, tags); + this.region = region; + this.organizationId = organizationId; + this.projectId = projectId; + } + + @Override + public ProviderType getProvider() { + return ProviderType.GCP; + } + + @Override + public void initialize(EnvironmentService environmentService) throws InstantiatorException { + initialize(environmentService, null); + } + + @Override + public void initialize( + EnvironmentService environmentService, + EnvironmentIdValue managementEnvironmentId) throws InstantiatorException + { + var currentInitialization = environmentService.fetchCurrentGcpInitialization(environmentId); + + if (currentInitialization == null || + "Failed".equals(currentInitialization.status()) || + "Cancelled".equals(currentInitialization.status())) { - super(environmentId, tags); - this.region = region; - this.organizationId = organizationId; - this.projectId = projectId; - } - - @Override - public ProviderType getProvider() { - return ProviderType.GCP; - } - @Override - public void initialize(EnvironmentService environmentService) throws InstantiatorException { - initialize(environmentService, null); + environmentService.startGcpCloudAgentInitialization( + environmentId, + organizationId, + projectId, + region, + tags); + + log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); + checkInitializationStatus(() -> fetchCurrentGcpInitialization(environmentService)); + } else { + checkInitializationStatus(() -> fetchCurrentGcpInitialization(environmentService)); } - - @Override - public void initialize(EnvironmentService environmentService, EnvironmentIdValue managementEnvironmentId) throws InstantiatorException { - var currentInitialization = environmentService.fetchCurrentGcpInitialization(environmentId); - - if (currentInitialization == null || - "Failed".equals(currentInitialization.status()) || - "Cancelled".equals(currentInitialization.status())) { - - environmentService.startGcpCloudAgentInitialization( - environmentId, - organizationId, - projectId, - region, - tags); - - log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); - checkInitializationStatus(() -> fetchCurrentGcpInitialization(environmentService)); - } else { - checkInitializationStatus(() -> fetchCurrentGcpInitialization(environmentService)); - } + } + + @Override + protected Map getConfigurationForEnvironmentParameters() { + return Map.of( + PROVIDER_PARAM_KEY, getProvider(), + REGION_PARAM_KEY, region, + ORGANIZATION_ID_PARAM_KEY, organizationId, + PROJECT_ID_PARAM_KEY, projectId + ); + } + + private InitializationRunResponse fetchCurrentGcpInitialization(EnvironmentService environmentService) { + try { + return environmentService.fetchCurrentGcpInitialization(environmentId); + } catch (InstantiatorException e) { + throw new RuntimeException(e); } + } - @Override - protected Map getConfigurationForEnvironmentParameters() { - return Map.of( - PROVIDER_PARAM_KEY, getProvider(), - REGION_PARAM_KEY, region, - ORGANIZATION_ID_PARAM_KEY, organizationId, - PROJECT_ID_PARAM_KEY, projectId - ); + @Override + public boolean equals(Object o) { + if (this == o) { + return true; } - - private InitializationRunResponse fetchCurrentGcpInitialization(EnvironmentService environmentService) { - try { - return environmentService.fetchCurrentGcpInitialization(environmentId); - } catch (InstantiatorException e) { - throw new RuntimeException(e); - } + if (o == null || getClass() != o.getClass()) { + return false; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - GcpCloudAgent member = (GcpCloudAgent) o; + GcpCloudAgent member = (GcpCloudAgent) o; - return region.equals(member.region) - && organizationId.equals(member.organizationId) - && projectId.equals(member.projectId) - && environmentId.equals(member.environmentId); - } + return region.equals(member.region) + && organizationId.equals(member.organizationId) + && projectId.equals(member.projectId) + && environmentId.equals(member.environmentId); + } - @Override - public int hashCode() { - return Objects.hash(region, organizationId, projectId, environmentId); - } + @Override + public int hashCode() { + return Objects.hash(region, organizationId, projectId, environmentId); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/hetzner/HetznerCloudAgent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/hetzner/HetznerCloudAgent.java index 7d56a1e9..d1450246 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/hetzner/HetznerCloudAgent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/hetzner/HetznerCloudAgent.java @@ -18,82 +18,91 @@ @Slf4j @Getter public class HetznerCloudAgent extends CloudAgentEntity { - public static final String PROJECT_ID_PARAM_KEY = "projectId"; - - private final HetznerRegion region; - private final String projectId; - - public HetznerCloudAgent( - EnvironmentIdValue environmentId, - HetznerRegion region, - String projectId, - Map tags) + public static final String PROJECT_ID_PARAM_KEY = "projectId"; + + private final HetznerRegion region; + private final String projectId; + + public HetznerCloudAgent( + EnvironmentIdValue environmentId, + HetznerRegion region, + String projectId, + Map tags) + { + super(environmentId, tags); + this.region = region; + this.projectId = projectId; + } + + @Override + public ProviderType getProvider() { + return ProviderType.HETZNER; + } + + @Override + public void initialize(EnvironmentService environmentService) throws InstantiatorException { + initialize(environmentService, null); + } + + @Override + public void initialize( + EnvironmentService environmentService, + EnvironmentIdValue managementEnvironmentId) throws InstantiatorException + { + var currentInitialization = environmentService.fetchCurrentHetznerInitialization(environmentId); + + if (currentInitialization == null || + "Failed".equals(currentInitialization.status()) || + "Cancelled".equals(currentInitialization.status())) { - super(environmentId, tags); - this.region = region; - this.projectId = projectId; - } - - @Override - public ProviderType getProvider() { - return ProviderType.HETZNER; - } - @Override - public void initialize(EnvironmentService environmentService) throws InstantiatorException { - initialize(environmentService, null); - } + environmentService.startHetznerCloudAgentInitialization( + environmentId, + projectId, + region, + tags); - @Override - public void initialize(EnvironmentService environmentService, EnvironmentIdValue managementEnvironmentId) throws InstantiatorException { - var currentInitialization = environmentService.fetchCurrentHetznerInitialization(environmentId); - - if (currentInitialization == null || - "Failed".equals(currentInitialization.status()) || - "Cancelled".equals(currentInitialization.status())) { - - environmentService.startHetznerCloudAgentInitialization( - environmentId, - projectId, - region, - tags); - - log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); - checkInitializationStatus(() -> fetchCurrentHetznerInitialization(environmentService)); - } else { - checkInitializationStatus(() -> fetchCurrentHetznerInitialization(environmentService)); - } + log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); + checkInitializationStatus(() -> fetchCurrentHetznerInitialization(environmentService)); + } else { + checkInitializationStatus(() -> fetchCurrentHetznerInitialization(environmentService)); } - @Override - protected Map getConfigurationForEnvironmentParameters() { - return Map.of( - PROVIDER_PARAM_KEY, getProvider(), - REGION_PARAM_KEY, region, - PROJECT_ID_PARAM_KEY, projectId); + } + + @Override + protected Map getConfigurationForEnvironmentParameters() { + return Map.of( + PROVIDER_PARAM_KEY, getProvider(), + REGION_PARAM_KEY, region, + PROJECT_ID_PARAM_KEY, projectId); + } + + private InitializationRunResponse fetchCurrentHetznerInitialization(EnvironmentService environmentService) { + try { + return environmentService.fetchCurrentHetznerInitialization(environmentId); + } catch (InstantiatorException e) { + throw new RuntimeException(e); } + } - private InitializationRunResponse fetchCurrentHetznerInitialization(EnvironmentService environmentService) { - try { - return environmentService.fetchCurrentHetznerInitialization(environmentId); - } catch (InstantiatorException e) { - throw new RuntimeException(e); - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + HetznerCloudAgent member = (HetznerCloudAgent) o; - HetznerCloudAgent member = (HetznerCloudAgent) o; + return region.equals(member.region) + && projectId.equals(member.projectId) + && environmentId.equals(member.environmentId); + } - return region.equals(member.region) - && projectId.equals(member.projectId) - && environmentId.equals(member.environmentId); - } - - @Override - public int hashCode() { - return Objects.hash(region, projectId, environmentId); - } + @Override + public int hashCode() { + return Objects.hash(region, projectId, environmentId); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/oci/OciCloudAgent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/oci/OciCloudAgent.java index 735af30b..db5a76b5 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/oci/OciCloudAgent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/oci/OciCloudAgent.java @@ -18,90 +18,99 @@ @Slf4j @Getter public class OciCloudAgent extends CloudAgentEntity { - public static final String TENANCY_ID_PARAM_KEY = "tenancyId"; - public static final String COMPARTMENT_ID_PARAM_KEY = "compartmentId"; - - private final OciRegion region; - private final String tenancyId; - private final String compartmentId; - - public OciCloudAgent( - EnvironmentIdValue environmentId, - OciRegion region, - String tenancyId, - String compartmentId, - Map tags) + public static final String TENANCY_ID_PARAM_KEY = "tenancyId"; + public static final String COMPARTMENT_ID_PARAM_KEY = "compartmentId"; + + private final OciRegion region; + private final String tenancyId; + private final String compartmentId; + + public OciCloudAgent( + EnvironmentIdValue environmentId, + OciRegion region, + String tenancyId, + String compartmentId, + Map tags) + { + super(environmentId, tags); + this.region = region; + this.tenancyId = tenancyId; + this.compartmentId = compartmentId; + } + + @Override + public ProviderType getProvider() { + return ProviderType.OCI; + } + + @Override + public void initialize(EnvironmentService environmentService) throws InstantiatorException { + initialize(environmentService, null); + } + + @Override + public void initialize( + EnvironmentService environmentService, + EnvironmentIdValue managementEnvironmentId) throws InstantiatorException + { + var currentInitialization = environmentService.fetchCurrentOciInitialization(environmentId); + + if (currentInitialization == null || + "Failed".equals(currentInitialization.status()) || + "Cancelled".equals(currentInitialization.status())) { - super(environmentId, tags); - this.region = region; - this.tenancyId = tenancyId; - this.compartmentId = compartmentId; - } - @Override - public ProviderType getProvider() { - return ProviderType.OCI; + environmentService.startOciCloudAgentInitialization( + environmentId, + tenancyId, + compartmentId, + region, + tags); + + log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); + checkInitializationStatus(() -> fetchCurrentOciInitialization(environmentService)); + } else { + checkInitializationStatus(() -> fetchCurrentOciInitialization(environmentService)); } - - @Override - public void initialize(EnvironmentService environmentService) throws InstantiatorException { - initialize(environmentService, null); + } + + @Override + protected Map getConfigurationForEnvironmentParameters() { + return Map.of( + PROVIDER_PARAM_KEY, getProvider(), + REGION_PARAM_KEY, region, + TENANCY_ID_PARAM_KEY, tenancyId, + COMPARTMENT_ID_PARAM_KEY, compartmentId + ); + } + + private InitializationRunResponse fetchCurrentOciInitialization(EnvironmentService environmentService) { + try { + return environmentService.fetchCurrentOciInitialization(environmentId); + } catch (InstantiatorException e) { + throw new RuntimeException(e); } + } - @Override - public void initialize(EnvironmentService environmentService, EnvironmentIdValue managementEnvironmentId) throws InstantiatorException { - var currentInitialization = environmentService.fetchCurrentOciInitialization(environmentId); - - if (currentInitialization == null || - "Failed".equals(currentInitialization.status()) || - "Cancelled".equals(currentInitialization.status())) { - - environmentService.startOciCloudAgentInitialization( - environmentId, - tenancyId, - compartmentId, - region, - tags); - - log.info("New initialization started, checking initialization status for environment [id: '{}']", environmentId); - checkInitializationStatus(() -> fetchCurrentOciInitialization(environmentService)); - } else { - checkInitializationStatus(() -> fetchCurrentOciInitialization(environmentService)); - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; } - @Override - protected Map getConfigurationForEnvironmentParameters() { - return Map.of( - PROVIDER_PARAM_KEY, getProvider(), - REGION_PARAM_KEY, region, - TENANCY_ID_PARAM_KEY, tenancyId, - COMPARTMENT_ID_PARAM_KEY, compartmentId - ); - } - - private InitializationRunResponse fetchCurrentOciInitialization(EnvironmentService environmentService) { - try { - return environmentService.fetchCurrentOciInitialization(environmentId); - } catch (InstantiatorException e) { - throw new RuntimeException(e); - } + if (o == null || getClass() != o.getClass()) { + return false; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + OciCloudAgent member = (OciCloudAgent) o; - OciCloudAgent member = (OciCloudAgent) o; + return region.equals(member.region) + && tenancyId.equals(member.tenancyId) + && compartmentId.equals(member.compartmentId) + && environmentId.equals(member.environmentId); + } - return region.equals(member.region) - && tenancyId.equals(member.tenancyId) - && compartmentId.equals(member.compartmentId) - && environmentId.equals(member.environmentId); - } - - @Override - public int hashCode() { - return Objects.hash(region, tenancyId, compartmentId, environmentId); - } + @Override + public int hashCode() { + return Objects.hash(region, tenancyId, compartmentId, environmentId); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/EnvironmentService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/EnvironmentService.java index efcc174b..3b80bd69 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/EnvironmentService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/EnvironmentService.java @@ -20,65 +20,75 @@ import java.util.UUID; public interface EnvironmentService { - EnvironmentResponse create( - EnvironmentIdValue managementEnvironmentId, - EnvironmentIdValue environmentId, - String name, - Collection resourceGroups, - Map parameters) throws InstantiatorException; - - EnvironmentResponse update( - EnvironmentIdValue managementEnvironmentId, - EnvironmentIdValue environmentId, - String name, - Collection resourceGroups, - Map parameters, - String defaultCiCdProfileShortName) throws InstantiatorException; - - EnvironmentResponse fetch(EnvironmentIdValue environmentId) throws InstantiatorException; - - EnvironmentResponse tryGetById(EnvironmentIdValue environmentId); - - void startAzureCloudAgentInitialization( - EnvironmentIdValue managementEnvironmentId, - EnvironmentIdValue environmentId, - UUID tenantId, - UUID subscriptionId, - AzureRegion region, - Map tags) throws InstantiatorException; - - void startAwsCloudAgentInitialization( - EnvironmentIdValue environmentId, - String organizationId, - String accountId, - AwsRegion region, - Map tags) throws InstantiatorException; - - void startGcpCloudAgentInitialization( - EnvironmentIdValue environmentId, - String organizationId, - String projectId, - GcpRegion region, - Map tags) throws InstantiatorException; - - void startOciCloudAgentInitialization( - EnvironmentIdValue environmentId, - String tenancyId, - String compartmentId, - OciRegion region, - Map tags) throws InstantiatorException; - - void startHetznerCloudAgentInitialization( - EnvironmentIdValue environmentId, - String projectId, - HetznerRegion region, - Map tags) throws InstantiatorException; - - InitializationRunResponse fetchCurrentAwsInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; - InitializationRunResponse fetchCurrentAzureInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; - InitializationRunResponse fetchCurrentGcpInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; - InitializationRunResponse fetchCurrentOciInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; - InitializationRunResponse fetchCurrentHetznerInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; - CiCdProfileResponse[] manageCiCdProfiles(EnvironmentIdValue environmentId, Collection ciCdProfiles) throws InstantiatorException; - SecretResponse[] manageSecrets(EnvironmentIdValue environmentId, Collection secrets) throws InstantiatorException; + EnvironmentResponse create( + EnvironmentIdValue managementEnvironmentId, + EnvironmentIdValue environmentId, + String name, + Collection resourceGroups, + Map parameters) throws InstantiatorException; + + EnvironmentResponse update( + EnvironmentIdValue managementEnvironmentId, + EnvironmentIdValue environmentId, + String name, + Collection resourceGroups, + Map parameters, + String defaultCiCdProfileShortName) throws InstantiatorException; + + EnvironmentResponse fetch(EnvironmentIdValue environmentId) throws InstantiatorException; + + EnvironmentResponse tryGetById(EnvironmentIdValue environmentId); + + void startAzureCloudAgentInitialization( + EnvironmentIdValue managementEnvironmentId, + EnvironmentIdValue environmentId, + UUID tenantId, + UUID subscriptionId, + AzureRegion region, + Map tags) throws InstantiatorException; + + void startAwsCloudAgentInitialization( + EnvironmentIdValue environmentId, + String organizationId, + String accountId, + AwsRegion region, + Map tags) throws InstantiatorException; + + void startGcpCloudAgentInitialization( + EnvironmentIdValue environmentId, + String organizationId, + String projectId, + GcpRegion region, + Map tags) throws InstantiatorException; + + void startOciCloudAgentInitialization( + EnvironmentIdValue environmentId, + String tenancyId, + String compartmentId, + OciRegion region, + Map tags) throws InstantiatorException; + + void startHetznerCloudAgentInitialization( + EnvironmentIdValue environmentId, + String projectId, + HetznerRegion region, + Map tags) throws InstantiatorException; + + InitializationRunResponse fetchCurrentAwsInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; + + InitializationRunResponse fetchCurrentAzureInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; + + InitializationRunResponse fetchCurrentGcpInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; + + InitializationRunResponse fetchCurrentOciInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; + + InitializationRunResponse fetchCurrentHetznerInitialization(EnvironmentIdValue environmentId) throws InstantiatorException; + + CiCdProfileResponse[] manageCiCdProfiles( + EnvironmentIdValue environmentId, + Collection ciCdProfiles) throws InstantiatorException; + + SecretResponse[] manageSecrets( + EnvironmentIdValue environmentId, + Collection secrets) throws InstantiatorException; } \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/RestEnvironmentService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/RestEnvironmentService.java index 21ef83ac..b47b0edd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/RestEnvironmentService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/RestEnvironmentService.java @@ -34,55 +34,59 @@ @Slf4j public class RestEnvironmentService extends Service implements EnvironmentService { public RestEnvironmentService( - HttpClient client, - SdkConfiguration sdkConfiguration, - RetryRegistry retryRegistry) { + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) + { super(client, sdkConfiguration, retryRegistry); } @Override public EnvironmentResponse create( - EnvironmentIdValue managementEnvironmentId, - EnvironmentIdValue environmentId, - String name, - Collection resourceGroups, - Map parameters) throws InstantiatorException { + EnvironmentIdValue managementEnvironmentId, + EnvironmentIdValue environmentId, + String name, + Collection resourceGroups, + Map parameters) throws InstantiatorException + { return executeRequestWithRetries( - "createEnvironment", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getEnvironmentsUri(environmentId), - sdkConfiguration, - serializeSafely(new CreateEnvironmentRequest( - managementEnvironmentId, - name, - resourceGroups.stream().map(ResourceGroupId::toString).toList(), - parameters))), - new int[]{201}, - EnvironmentResponse.class); + "createEnvironment", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getEnvironmentsUri(environmentId), + sdkConfiguration, + serializeSafely(new CreateEnvironmentRequest( + managementEnvironmentId, + name, + resourceGroups.stream().map(ResourceGroupId::toString).toList(), + parameters))), + new int[]{201}, + EnvironmentResponse.class); } @Override public EnvironmentResponse update( - EnvironmentIdValue managementEnvironmentId, - EnvironmentIdValue environmentId, - String name, - Collection resourceGroups, - Map parameters, - String defaultCiCdProfileShortName) throws InstantiatorException { + EnvironmentIdValue managementEnvironmentId, + EnvironmentIdValue environmentId, + String name, + Collection resourceGroups, + Map parameters, + String defaultCiCdProfileShortName) throws InstantiatorException + { return executeRequestWithRetries( - "updateEnvironment", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPutRequest( - getEnvironmentsUri(environmentId), - sdkConfiguration, - serializeSafely(new UpdateEnvironmentRequest(managementEnvironmentId, name, resourceGroups.stream().map(ResourceGroupId::toString).toList(), parameters, defaultCiCdProfileShortName))), - new int[]{200}, - EnvironmentResponse.class); + "updateEnvironment", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPutRequest( + getEnvironmentsUri(environmentId), + sdkConfiguration, + serializeSafely(new UpdateEnvironmentRequest(managementEnvironmentId, name, + resourceGroups.stream().map(ResourceGroupId::toString).toList(), parameters, defaultCiCdProfileShortName))), + new int[]{200}, + EnvironmentResponse.class); } @Override @@ -90,63 +94,65 @@ public EnvironmentResponse fetch(EnvironmentIdValue environmentId) { try { return executeRequestWithRetries( - "fetchEnvironment", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildGetRequest( - getEnvironmentsUri(environmentId), - sdkConfiguration), - new int[]{200, 404}, - EnvironmentResponse.class); + "fetchEnvironment", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildGetRequest( + getEnvironmentsUri(environmentId), + sdkConfiguration), + new int[]{200, 404}, + EnvironmentResponse.class); } catch (Exception e) { log.error("An unexpected error occurred while fetching the environment [id: '{}']. " + - "Please try again later or contact Fractal Cloud support if the issue persists.", - environmentId); - + "Please try again later or contact Fractal Cloud support if the issue persists.", + environmentId); + System.exit(1); - + return null; - + } } @Override public EnvironmentResponse tryGetById(EnvironmentIdValue environmentId) { - try { - return executeRequestWithRetries( - "fetchEnvironmentById", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildGetRequest( - getEnvironmentsUri(environmentId), - sdkConfiguration), - new int[]{200, 400, 404}, - EnvironmentResponse.class); - } catch (InstantiatorException e) { - return null; - } + try { + return executeRequestWithRetries( + "fetchEnvironmentById", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildGetRequest( + getEnvironmentsUri(environmentId), + sdkConfiguration), + new int[]{200, 400, 404}, + EnvironmentResponse.class); + } catch (InstantiatorException e) { + return null; + } } @Override public void startAzureCloudAgentInitialization( - EnvironmentIdValue managementEnvironmentId, - EnvironmentIdValue environmentId, - UUID tenantId, - UUID subscriptionId, - AzureRegion region, - Map tags) throws InstantiatorException { + EnvironmentIdValue managementEnvironmentId, + EnvironmentIdValue environmentId, + UUID tenantId, + UUID subscriptionId, + AzureRegion region, + Map tags) throws InstantiatorException + { var azureSpClientId = sdkConfiguration.getAzureSpClientId(); if (isBlank(azureSpClientId)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", AZURE_SP_CLIENT_ID_KEY)); + String.format("The environment variable %s is required and it has not been defined", AZURE_SP_CLIENT_ID_KEY)); } var azureSpClientSecret = sdkConfiguration.getAzureSpClientSecret(); if (isBlank(azureSpClientSecret)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", AZURE_SP_CLIENT_SECRET_KEY)); + String.format("The environment variable %s is required and it has not been defined", + AZURE_SP_CLIENT_SECRET_KEY)); } Map additionalHeaders = new HashMap<>(); @@ -154,86 +160,90 @@ public void startAzureCloudAgentInitialization( additionalHeaders.put(X_AZURE_SP_CLIENT_SECRET_HEADER, azureSpClientSecret); executeRequestWithRetries( - "InitializeAzureSubscription", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getEnvironmentsUri(environmentId, "initializer/azure/initialize"), - sdkConfiguration, - serializeSafely(new AzureSubscriptionInitializationRequest( - managementEnvironmentId, - tenantId, - subscriptionId, - region.toString(), - tags)), - additionalHeaders), - new int[]{202}, - EnvironmentResponse.class); + "InitializeAzureSubscription", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getEnvironmentsUri(environmentId, "initializer/azure/initialize"), + sdkConfiguration, + serializeSafely(new AzureSubscriptionInitializationRequest( + managementEnvironmentId, + tenantId, + subscriptionId, + region.toString(), + tags)), + additionalHeaders), + new int[]{202}, + EnvironmentResponse.class); } @Override public void startAwsCloudAgentInitialization( - EnvironmentIdValue environmentId, - String organizationId, - String accountId, - AwsRegion region, - Map tags) throws InstantiatorException { + EnvironmentIdValue environmentId, + String organizationId, + String accountId, + AwsRegion region, + Map tags) throws InstantiatorException + { var awsAccessKeyId = sdkConfiguration.getAwsAccessKeyId(); if (isBlank(awsAccessKeyId)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", AWS_ACCESS_KEY_ID_KEY)); + String.format("The environment variable %s is required and it has not been defined", AWS_ACCESS_KEY_ID_KEY)); } var awsSecretAccessKey = sdkConfiguration.getAwsSecretAccessKey(); if (isBlank(awsSecretAccessKey)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", AWS_SECRET_ACCESS_KEY)); + String.format("The environment variable %s is required and it has not been defined", AWS_SECRET_ACCESS_KEY)); } var awsSessionToken = sdkConfiguration.getAwsSessionToken(); Map additionalHeaders = new HashMap<>(); additionalHeaders.put(X_AWS_ACCESS_KEY_ID_HEADER, awsAccessKeyId); additionalHeaders.put(X_AWS_SECRET_ACCESS_KEY_HEADER, awsSecretAccessKey); - if(!isBlank(awsSessionToken)) { + if (!isBlank(awsSessionToken)) { additionalHeaders.put(X_AWS_SESSION_TOKEN_HEADER, awsSessionToken); } executeRequestWithRetries( - "InitializeAwsAccount", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getEnvironmentsUri(environmentId, "initializer/aws/initialize"), - sdkConfiguration, - serializeSafely(new AwsAccountInitializationRequest( - organizationId, - accountId, - region.toString(), - tags)), - additionalHeaders), - new int[]{202}, - EnvironmentResponse.class); + "InitializeAwsAccount", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getEnvironmentsUri(environmentId, "initializer/aws/initialize"), + sdkConfiguration, + serializeSafely(new AwsAccountInitializationRequest( + organizationId, + accountId, + region.toString(), + tags)), + additionalHeaders), + new int[]{202}, + EnvironmentResponse.class); } @Override public void startGcpCloudAgentInitialization( - EnvironmentIdValue environmentId, - String organizationId, - String projectId, - GcpRegion region, - Map tags) throws InstantiatorException { + EnvironmentIdValue environmentId, + String organizationId, + String projectId, + GcpRegion region, + Map tags) throws InstantiatorException + { var gcpServiceAccountEMail = sdkConfiguration.getGcpServiceAccountEMail(); if (isBlank(gcpServiceAccountEMail)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", GCP_SERVICE_ACCOUNT_EMAIL_KEY)); + String.format("The environment variable %s is required and it has not been defined", + GCP_SERVICE_ACCOUNT_EMAIL_KEY)); } var gcpServiceAccountCredentials = sdkConfiguration.getGcpServiceAccountCredentials(); if (isBlank(gcpServiceAccountCredentials)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", GCP_SERVICE_ACCOUNT_CREDENTIALS_KEY)); + String.format("The environment variable %s is required and it has not been defined", + GCP_SERVICE_ACCOUNT_CREDENTIALS_KEY)); } Map additionalHeaders = new HashMap<>(); @@ -241,40 +251,43 @@ public void startGcpCloudAgentInitialization( additionalHeaders.put(X_GCP_SERVICE_ACCOUNT_CREDENTIALS_HEADER, gcpServiceAccountCredentials); executeRequestWithRetries( - "InitializeGcpProject", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getEnvironmentsUri(environmentId, "initializer/gcp/initialize"), - sdkConfiguration, - serializeSafely(new GcpProjectInitializationRequest( - organizationId, - projectId, - region.toString(), - tags)), - additionalHeaders), - new int[]{202}, - EnvironmentResponse.class); + "InitializeGcpProject", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getEnvironmentsUri(environmentId, "initializer/gcp/initialize"), + sdkConfiguration, + serializeSafely(new GcpProjectInitializationRequest( + organizationId, + projectId, + region.toString(), + tags)), + additionalHeaders), + new int[]{202}, + EnvironmentResponse.class); } @Override public void startOciCloudAgentInitialization( - EnvironmentIdValue environmentId, - String tenancyId, - String compartmentId, - OciRegion region, - Map tags) throws InstantiatorException { + EnvironmentIdValue environmentId, + String tenancyId, + String compartmentId, + OciRegion region, + Map tags) throws InstantiatorException + { var ociServiceAccountId = sdkConfiguration.getOciServiceAccountId(); if (isBlank(ociServiceAccountId)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", OCI_SERVICE_ACCOUNT_ID_KEY)); + String.format("The environment variable %s is required and it has not been defined", + OCI_SERVICE_ACCOUNT_ID_KEY)); } var ociServiceAccountCredentials = sdkConfiguration.getOciServiceAccountCredentials(); if (isBlank(ociServiceAccountCredentials)) { throw new IllegalArgumentException( - String.format("The environment variable %s is required and it has not been defined", OCI_SERVICE_ACCOUNT_CREDENTIALS_KEY)); + String.format("The environment variable %s is required and it has not been defined", + OCI_SERVICE_ACCOUNT_CREDENTIALS_KEY)); } Map additionalHeaders = new HashMap<>(); @@ -282,21 +295,21 @@ public void startOciCloudAgentInitialization( additionalHeaders.put(X_OCI_SERVICE_ACCOUNT_CREDENTIALS_HEADER, ociServiceAccountCredentials); executeRequestWithRetries( - "InitializeOciProject", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getEnvironmentsUri(environmentId, "initializer/oci/initialize"), - sdkConfiguration, - serializeSafely(new OciCompartmentInitializationRequest( - tenancyId, - compartmentId, - region.toString(), - tags)), - additionalHeaders), - new int[]{202}, - EnvironmentResponse.class); + "InitializeOciProject", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getEnvironmentsUri(environmentId, "initializer/oci/initialize"), + sdkConfiguration, + serializeSafely(new OciCompartmentInitializationRequest( + tenancyId, + compartmentId, + region.toString(), + tags)), + additionalHeaders), + new int[]{202}, + EnvironmentResponse.class); } @Override @@ -358,49 +371,56 @@ public InitializationRunResponse fetchCurrentHetznerInitialization(EnvironmentId } @Override - public CiCdProfileResponse[] manageCiCdProfiles(EnvironmentIdValue environmentId, Collection ciCdProfiles) throws InstantiatorException { + public CiCdProfileResponse[] manageCiCdProfiles( + EnvironmentIdValue environmentId, + Collection ciCdProfiles) throws InstantiatorException + { return executeRequestWithRetries( - "manageCiCdProfiles", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getCiCdProfilesBulkUri(environmentId), - sdkConfiguration, - serializeSafely(ciCdProfiles)), - new int[]{201, 404}, - CiCdProfileResponse[].class); + "manageCiCdProfiles", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getCiCdProfilesBulkUri(environmentId), + sdkConfiguration, + serializeSafely(ciCdProfiles)), + new int[]{201, 404}, + CiCdProfileResponse[].class); } @Override - public SecretResponse[] manageSecrets(EnvironmentIdValue environmentId, Collection secrets) throws InstantiatorException { + public SecretResponse[] manageSecrets( + EnvironmentIdValue environmentId, + Collection secrets) throws InstantiatorException + { return executeRequestWithRetries( - "manageSecrets", - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildPostRequest( - getSecretsBulkUri(environmentId), - sdkConfiguration, - serializeSafely(secrets)), - new int[]{201, 404}, - SecretResponse[].class); + "manageSecrets", + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildPostRequest( + getSecretsBulkUri(environmentId), + sdkConfiguration, + serializeSafely(secrets)), + new int[]{201, 404}, + SecretResponse[].class); } private InitializationRunResponse fetchCurrentInitialization( - EnvironmentIdValue environmentId, - ProviderType provider) throws InstantiatorException { + EnvironmentIdValue environmentId, + ProviderType provider) throws InstantiatorException + { var providerStr = StringHelper.convertToTitleCase(provider.toString()); var runRoot = executeRequestWithRetries( - String.format("fetchCurrent%sInitialization", providerStr), - environmentId.toString(), - client, - retryRegistry, - HttpUtils.buildGetRequest( - getEnvironmentsUri(environmentId, String.format("initializer/%s/status", providerStr.toLowerCase())), - sdkConfiguration), - new int[]{200, 404}, - InitializationRunRoot.class); + String.format("fetchCurrent%sInitialization", providerStr), + environmentId.toString(), + client, + retryRegistry, + HttpUtils.buildGetRequest( + getEnvironmentsUri(environmentId, String.format("initializer/%s/status", providerStr.toLowerCase())), + sdkConfiguration), + new int[]{200, 404}, + InitializationRunRoot.class); return runRoot == null ? null : runRoot.initializationRun(); } @@ -424,10 +444,10 @@ private URI getUriWithOptionalPath(String basePath, String path) { private URI getEnvironmentsUri(EnvironmentIdValue environmentId, String path) { var basePath = String.format("%s/%s/%s/%s", - sdkConfiguration.getEnvironmentsEndpoint(), - environmentId.type(), - environmentId.ownerId(), - environmentId.shortName()); + sdkConfiguration.getEnvironmentsEndpoint(), + environmentId.type(), + environmentId.ownerId(), + environmentId.shortName()); return getUriWithOptionalPath(basePath, path); } @@ -437,23 +457,22 @@ private URI getEnvironmentsUri(EnvironmentIdValue environmentId) { } - private URI getSecretsBulkUri(EnvironmentIdValue environmentId) { var basePath = String.format("%s/%s/%s/%s/secrets", - sdkConfiguration.getEnvironmentsEndpoint(), - environmentId.type(), - environmentId.ownerId(), - environmentId.shortName()); + sdkConfiguration.getEnvironmentsEndpoint(), + environmentId.type(), + environmentId.ownerId(), + environmentId.shortName()); return getUriWithOptionalPath(basePath, "bulk"); } private URI getCiCdProfilesBulkUri(EnvironmentIdValue environmentId) { var ciCdProfileEndpoint = String.format("%s/%s/%s/%s/ci-cd-profiles", - sdkConfiguration.getEnvironmentsEndpoint(), - environmentId.type(), - environmentId.ownerId(), - environmentId.shortName()); + sdkConfiguration.getEnvironmentsEndpoint(), + environmentId.type(), + environmentId.ownerId(), + environmentId.shortName()); return getUriWithOptionalPath(ciCdProfileEndpoint, "bulk"); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AwsAccountInitializationRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AwsAccountInitializationRequest.java index e88ab84b..2243211f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AwsAccountInitializationRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AwsAccountInitializationRequest.java @@ -6,4 +6,6 @@ public record AwsAccountInitializationRequest( String organizationId, String accountId, String region, - Map tags){} \ No newline at end of file + Map tags) +{ +} \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AzureSubscriptionInitializationRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AzureSubscriptionInitializationRequest.java index 82f78392..7d225702 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AzureSubscriptionInitializationRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/AzureSubscriptionInitializationRequest.java @@ -6,9 +6,10 @@ import java.util.UUID; public record AzureSubscriptionInitializationRequest( - EnvironmentIdValue ManagementEnvironmentId, - UUID tenantId, - UUID subscriptionId, - String region, - Map tags) { + EnvironmentIdValue ManagementEnvironmentId, + UUID tenantId, + UUID subscriptionId, + String region, + Map tags) +{ } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateCiCdProfileRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateCiCdProfileRequest.java index c82a02a8..c3189d8c 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateCiCdProfileRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateCiCdProfileRequest.java @@ -3,19 +3,20 @@ import com.yanchware.fractal.sdk.domain.environment.CiCdProfile; public record CreateCiCdProfileRequest( - String shortName, - String displayName, - String description, - String sshPrivateKeyData, - String sshPrivateKeyPassphrase){ + String shortName, + String displayName, + String description, + String sshPrivateKeyData, + String sshPrivateKeyPassphrase) +{ - public static CreateCiCdProfileRequest fromProfile(CiCdProfile profile) - { - return new CreateCiCdProfileRequest( - profile.shortName(), - profile.displayName(), - profile.description(), - profile.sshPrivateKeyData(), - profile.sshPrivateKeyPassphrase()); - } + public static CreateCiCdProfileRequest fromProfile(CiCdProfile profile) + { + return new CreateCiCdProfileRequest( + profile.shortName(), + profile.displayName(), + profile.description(), + profile.sshPrivateKeyData(), + profile.sshPrivateKeyPassphrase()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateEnvironmentRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateEnvironmentRequest.java index 66386b43..68b28b74 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateEnvironmentRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateEnvironmentRequest.java @@ -4,11 +4,11 @@ import java.util.Collection; import java.util.Map; -import java.util.UUID; public record CreateEnvironmentRequest( - EnvironmentIdValue managementEnvironmentId, - String name, - Collection resourceGroups, - Map parameters) { + EnvironmentIdValue managementEnvironmentId, + String name, + Collection resourceGroups, + Map parameters) +{ } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateSecretRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateSecretRequest.java index c0865a29..3591cb2a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateSecretRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/CreateSecretRequest.java @@ -1,8 +1,9 @@ package com.yanchware.fractal.sdk.domain.environment.service.commands; public record CreateSecretRequest( - String name, - String value) { + String name, + String value) +{ } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/GcpProjectInitializationRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/GcpProjectInitializationRequest.java index 52e2dc92..8cb56c04 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/GcpProjectInitializationRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/GcpProjectInitializationRequest.java @@ -2,10 +2,12 @@ import java.util.Map; -public record GcpProjectInitializationRequest ( +public record GcpProjectInitializationRequest( String organizationId, String projectId, String region, - Map tags){} + Map tags) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/HetznerProjectInitializationRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/HetznerProjectInitializationRequest.java index 6f976a7e..0bcec254 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/HetznerProjectInitializationRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/HetznerProjectInitializationRequest.java @@ -5,4 +5,6 @@ public record HetznerProjectInitializationRequest( String projectId, String region, - Map tags){} \ No newline at end of file + Map tags) +{ +} \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/OciCompartmentInitializationRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/OciCompartmentInitializationRequest.java index 03f77154..94797bf7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/OciCompartmentInitializationRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/OciCompartmentInitializationRequest.java @@ -2,8 +2,10 @@ import java.util.Map; -public record OciCompartmentInitializationRequest ( +public record OciCompartmentInitializationRequest( String tenancyId, String compartmentId, String region, - Map tags){} \ No newline at end of file + Map tags) +{ +} \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/UpdateEnvironmentRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/UpdateEnvironmentRequest.java index 33736280..1577a5b6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/UpdateEnvironmentRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/commands/UpdateEnvironmentRequest.java @@ -4,12 +4,12 @@ import java.util.Collection; import java.util.Map; -import java.util.UUID; public record UpdateEnvironmentRequest( - EnvironmentIdValue managementEnvironmentId, - String name, - Collection resourceGroups, - Map parameters, - String defaultCiCdProfileShortName) { + EnvironmentIdValue managementEnvironmentId, + String name, + Collection resourceGroups, + Map parameters, + String defaultCiCdProfileShortName) +{ } \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/CiCdProfileResponse.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/CiCdProfileResponse.java index 2df3c4de..08a34098 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/CiCdProfileResponse.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/CiCdProfileResponse.java @@ -6,11 +6,13 @@ import java.util.UUID; public record CiCdProfileResponse( - UUID id, - EnvironmentIdDto environmentId, - String shortName, - String displayName, - Date createdAt, - String createdBy, - Date updatedAt, - String updatedBy){ } + UUID id, + EnvironmentIdDto environmentId, + String shortName, + String displayName, + Date createdAt, + String createdBy, + Date updatedAt, + String updatedBy) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/EnvironmentResponse.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/EnvironmentResponse.java index 265930b0..03ff8a63 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/EnvironmentResponse.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/EnvironmentResponse.java @@ -17,6 +17,8 @@ public record EnvironmentResponse( Date createdAt, String createdBy, Date updatedAt, - String updatedBy){ } + String updatedBy) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunResponse.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunResponse.java index 63030b89..db717726 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunResponse.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunResponse.java @@ -6,12 +6,14 @@ import java.util.List; import java.util.UUID; -public record InitializationRunResponse ( +public record InitializationRunResponse( UUID id, EnvironmentIdDto environmentId, String cloudProvider, List steps, String status, String requester, - Date createdAt){ } + Date createdAt) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunRoot.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunRoot.java index 9f7aca07..2e6a0607 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunRoot.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationRunRoot.java @@ -1,3 +1,4 @@ package com.yanchware.fractal.sdk.domain.environment.service.dtos; -public record InitializationRunRoot(InitializationRunResponse initializationRun) { } +public record InitializationRunRoot(InitializationRunResponse initializationRun) { +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationStepResponse.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationStepResponse.java index 2a112301..6e4cb8f2 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationStepResponse.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/InitializationStepResponse.java @@ -4,7 +4,7 @@ import java.util.Map; import java.util.UUID; -public record InitializationStepResponse ( +public record InitializationStepResponse( UUID id, String name, String description, @@ -16,4 +16,6 @@ public record InitializationStepResponse ( String status, Integer retryCount, Date createdAt, - Date updatedAt){ } + Date updatedAt) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/SecretResponse.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/SecretResponse.java index 135ebd5a..60c2f623 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/SecretResponse.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/environment/service/dtos/SecretResponse.java @@ -6,13 +6,15 @@ import java.util.UUID; public record SecretResponse( - UUID id, - EnvironmentIdDto environmentId, - String name, - String value, - Date createdAt, - String createdBy, - Date updatedAt, - String updatedBy){ } + UUID id, + EnvironmentIdDto environmentId, + String name, + String value, + Date createdAt, + String createdBy, + Date updatedAt, + String updatedBy) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ComponentInstantiationException.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ComponentInstantiationException.java index 075d4b16..b5da9cf9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ComponentInstantiationException.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ComponentInstantiationException.java @@ -3,15 +3,15 @@ import java.io.Serial; public class ComponentInstantiationException extends Exception { - @Serial - private static final long serialVersionUID = 1L; - + @Serial + private static final long serialVersionUID = 1L; - public ComponentInstantiationException(String message) { - super(message); - } - public ComponentInstantiationException(String message, Throwable cause) { - super(message, cause); - } + public ComponentInstantiationException(String message) { + super(message); + } + + public ComponentInstantiationException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentException.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentException.java index e255d842..369bde80 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentException.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentException.java @@ -3,14 +3,14 @@ import java.io.Serial; public class EnvironmentException extends InstantiatorException { - @Serial - private static final long serialVersionUID = 1L; - - public EnvironmentException(String message) { - super(message); - } + @Serial + private static final long serialVersionUID = 1L; - public EnvironmentException(String message, Throwable cause) { - super(message, cause); - } + public EnvironmentException(String message) { + super(message); + } + + public EnvironmentException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentInitializationException.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentInitializationException.java index f935bcd9..45a37649 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentInitializationException.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentInitializationException.java @@ -5,22 +5,22 @@ import java.util.Collection; public class EnvironmentInitializationException extends Exception { - @Serial - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; - private Collection failedSteps = new ArrayList<>(); + private Collection failedSteps = new ArrayList<>(); - public EnvironmentInitializationException(String message) { - super(message); - } + public EnvironmentInitializationException(String message) { + super(message); + } - public EnvironmentInitializationException(String message, Throwable cause) { - super(message, cause); - } + public EnvironmentInitializationException(String message, Throwable cause) { + super(message, cause); + } - public EnvironmentInitializationException(Collection failedSteps, String message) { - super(message); - this.failedSteps = failedSteps; - } + public EnvironmentInitializationException(Collection failedSteps, String message) { + super(message); + this.failedSteps = failedSteps; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentNotFoundException.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentNotFoundException.java index b4a270f4..dafc199b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentNotFoundException.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/EnvironmentNotFoundException.java @@ -3,14 +3,14 @@ import java.io.Serial; public class EnvironmentNotFoundException extends InstantiatorException { - @Serial - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; - public EnvironmentNotFoundException(String message) { - super(message); - } + public EnvironmentNotFoundException(String message) { + super(message); + } - public EnvironmentNotFoundException(String message, Throwable cause) { - super(message, cause); - } + public EnvironmentNotFoundException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/InstantiatorException.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/InstantiatorException.java index 82776b31..5b7fb4cd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/InstantiatorException.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/InstantiatorException.java @@ -3,15 +3,15 @@ import java.io.Serial; public class InstantiatorException extends Exception { - @Serial - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; - public InstantiatorException(String message) { - super(message); - } + public InstantiatorException(String message) { + super(message); + } - public InstantiatorException(String message, Throwable cause) { - super(message, cause); - } + public InstantiatorException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ProviderException.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ProviderException.java index 5175898e..21a456c9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ProviderException.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/exceptions/ProviderException.java @@ -5,22 +5,22 @@ import java.util.Collection; public class ProviderException extends Exception { - @Serial - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; - private Collection failedComponents = new ArrayList<>(); + private Collection failedComponents = new ArrayList<>(); - public ProviderException(String message) { - super(message); - } + public ProviderException(String message) { + super(message); + } - public ProviderException(String message, Throwable cause) { - super(message, cause); - } + public ProviderException(String message, Throwable cause) { + super(message, cause); + } - public ProviderException(Collection failedComponentsIds, String message) { - super(message); - this.failedComponents = failedComponentsIds; - } + public ProviderException(Collection failedComponentsIds, String message) { + super(message); + this.failedComponents = failedComponentsIds; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/BlueprintComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/BlueprintComponent.java new file mode 100644 index 00000000..59042b6c --- /dev/null +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/BlueprintComponent.java @@ -0,0 +1,4 @@ +package com.yanchware.fractal.sdk.domain.fractal; + +public interface BlueprintComponent { +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalAggregate.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalAggregate.java new file mode 100644 index 00000000..5aabc5d9 --- /dev/null +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalAggregate.java @@ -0,0 +1,84 @@ +package com.yanchware.fractal.sdk.domain.fractal; + +import com.yanchware.fractal.sdk.configuration.SdkConfiguration; +import com.yanchware.fractal.sdk.domain.Validatable; +import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; +import com.yanchware.fractal.sdk.domain.fractal.service.BlueprintService; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; +import io.github.resilience4j.retry.RetryRegistry; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.net.http.HttpClient; +import java.util.ArrayList; +import java.util.Collection; + +import static org.apache.commons.lang3.StringUtils.isBlank; + +@Slf4j +@Setter(AccessLevel.PROTECTED) +public class FractalAggregate implements Validatable { + private final static String ID_IS_NULL = "[Fractal Validation] Id has not been defined and it is required"; + private final static String NAME_IS_NULL = "[Fractal Validation] Name has not been defined and it is required"; + private final static String VERSION_IS_NULL = "[Fractal Validation] Version has not been defined and it is required"; + private final static String RESOURCE_GROUP_ID_IS_NULL = "[Fractal Validation] ResourceGroupId has not been " + + "defined and it is required'"; + private final static String EMPTY_COMPONENT_LIST = "[Fractal Validation] Components list is null or empty and at" + + " least one component is required"; + + private final BlueprintService service; + + @Getter + private FractalIdValue id; + @Getter + private String description; + @Getter + private boolean isPrivate; + @Getter + // TODO FRA-1870: We should find a way to fix this instead to have DTOs in the Aggregate 🤮 + private Collection components; + + public FractalAggregate( + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) + { + this.service = new BlueprintService(client, sdkConfiguration, retryRegistry); + components = new ArrayList<>(); + } + + public void createOrUpdate() throws InstantiatorException { + if (components == null || components.isEmpty()) { + throw new InstantiatorException(EMPTY_COMPONENT_LIST); + } + + service.createOrUpdate(id, description, isPrivate, components); + } + + @Override + public Collection validate() { + Collection errors = new ArrayList<>(); + + if (id == null) { + errors.add(ID_IS_NULL); + return errors; + } + + if (isBlank(id.name())) { + errors.add(NAME_IS_NULL); + } + + if (isBlank(id.version())) { + errors.add(VERSION_IS_NULL); + } + + if (id.resourceGroupId() == null) { + errors.add(RESOURCE_GROUP_ID_IS_NULL); + } + + return errors; + } + +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/FractalIdValue.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalIdValue.java similarity index 50% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/FractalIdValue.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalIdValue.java index 88a72489..9e76383c 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/FractalIdValue.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalIdValue.java @@ -1,12 +1,12 @@ -package com.yanchware.fractal.sdk.domain.blueprint; +package com.yanchware.fractal.sdk.domain.fractal; import com.yanchware.fractal.sdk.domain.values.ResourceGroupId; import org.jetbrains.annotations.NotNull; public record FractalIdValue(ResourceGroupId resourceGroupId, String name, String version) { - @NotNull - @Override - public String toString(){ - return String.format("%s/%s:%s", resourceGroupId.toString(), name, version); - } + @NotNull + @Override + public String toString() { + return String.format("%s/%s:%s", resourceGroupId.toString(), name, version); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalsFactory.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalsFactory.java new file mode 100644 index 00000000..272c0ecd --- /dev/null +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/FractalsFactory.java @@ -0,0 +1,70 @@ +package com.yanchware.fractal.sdk.domain.fractal; + +import com.yanchware.fractal.sdk.configuration.SdkConfiguration; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; +import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemAggregate; +import io.github.resilience4j.retry.RetryRegistry; + +import java.net.http.HttpClient; +import java.util.Arrays; +import java.util.Collection; + +public class FractalsFactory { + private final HttpClient client; + private final SdkConfiguration sdkConfiguration; + private final RetryRegistry retryRegistry; + + public FractalsFactory(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) { + + this.client = client; + this.sdkConfiguration = sdkConfiguration; + this.retryRegistry = retryRegistry; + } + + public FractalBuilder builder() { + return new FractalBuilder(client, sdkConfiguration, retryRegistry); + } + + public static class FractalBuilder { + private final FractalAggregate fractal; + private final FractalBuilder builder; + + public FractalBuilder(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) { + fractal = createFractal(client, sdkConfiguration, retryRegistry); + builder = getBuilder(); + } + + public FractalBuilder fromLiveSystem(LiveSystemAggregate liveSystem) { + fractal.setId(liveSystem.getFractalId()); + fractal.setDescription(String.format("Blueprint created via SDK from LiveSystem with Fractal ID: %s", liveSystem.getFractalId())); + fractal.setPrivate(true); + fractal.setComponents(BlueprintComponentDto.fromLiveSystemComponents(liveSystem.getComponents())); + return builder; + } + + public FractalAggregate build() { + Collection errors = fractal.validate(); + + if (!errors.isEmpty()) { + throw new IllegalArgumentException(String.format( + "Fractal validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); + } + + return fractal; + } + + protected FractalBuilder getBuilder() { + return this; + } + + protected FractalAggregate createFractal( + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) + { + return new FractalAggregate(client, sdkConfiguration, retryRegistry); + } + } + +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSAPIGateway.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSAPIGateway.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSAPIGateway.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSAPIGateway.java index 7d05cfcb..6a7bdf85 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSAPIGateway.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSAPIGateway.java @@ -1,6 +1,6 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.CAAS_API_GATEWAY; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSComponent.java similarity index 79% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSComponent.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSComponent.java index 692cfcd5..d89ea350 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSComponent.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; import com.yanchware.fractal.sdk.domain.Component; import com.yanchware.fractal.sdk.domain.livesystem.caas.ResourceManagement; @@ -18,7 +18,10 @@ @Setter(AccessLevel.PUBLIC) @ToString(callSuper = true) public abstract class CaaSComponent extends Component { - private final static String DNS_ZONE_NAME_NOT_VALID = "[DnsRecords Validation] The dnsZoneName must contain no more than 253 characters, excluding a trailing period and must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period"; + private final static String DNS_ZONE_NAME_NOT_VALID = "[DnsRecords Validation] The dnsZoneName must contain no more" + + " than 253 characters, excluding a trailing period and must be between 2 and 34 labels. Each label must only " + + "contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a " + + "period"; private String containerPlatform; private String namespace; @@ -29,24 +32,27 @@ public abstract class CaaSComponent extends Component { private String priorityClassName; private String getNamespaceIsNullOrEmptyErrorMessage() { - return String.format("[%s Validation] Namespace has not been defined and it is required", this.getClass().getSimpleName()); + return String.format("[%s Validation] Namespace has not been defined and it is required", + this.getClass().getSimpleName()); } private String getContainerPlatformIsNullOrEmptyErrorMessage() { - return String.format("[%s Validation] ContainerPlatform defined was either empty or blank and it is required", this.getClass().getSimpleName()); + return String.format("[%s Validation] ContainerPlatform defined was either empty or blank and it is required", + this.getClass().getSimpleName()); } - public static abstract class Builder> extends Component.Builder { + public static abstract class Builder> extends Component.Builder { /** *
          * Configures resource management settings for the component, specifying CPU and memory requests and limits.
          * This ensures the component is allocated the necessary resources for optimal performance and does not exceed
          * specified usage thresholds.
    - * + * * @param resourceManagement The ResourceManagement settings for the component. - * - * @important.note Customizing resource management values offers flexibility, but you need to carefully consider + * @important.note Customizing resource management values offers flexibility, but you need to carefully + * consider * the implications. Fractal Cloud cannot guarantee the functionality of the deployment if these customizations * lead to resource constraints or conflicts. You are responsible for ensuring that your configurations are * appropriate for your application's needs and compatible with your cluster's capabilities. @@ -55,16 +61,17 @@ public B withResourceManagement(ResourceManagement resourceManagement) { component.setResourceManagement(resourceManagement); return builder; } - - /** + + /** *
    -     * Sets multiple node selectors at once. 
    +     * Sets multiple node selectors at once.
          * Each entry in the map represents a label and its desired value.
    * * @param selectors A map of label keys to label values defining the node selection criteria. - * - * @important.note Node selectors provide powerful control over pod scheduling, but incorrect or overly restrictive - * configurations may limit your deployment options. Fractal Cloud cannot guarantee the functionality of the deployment + * @important.note Node selectors provide powerful control over pod scheduling, but incorrect or overly + * restrictive + * configurations may limit your deployment options. Fractal Cloud cannot guarantee the functionality of the + * deployment * if node selector configurations prevent scheduling. You need to verify the accuracy and applicability of your * node label selections. */ @@ -72,22 +79,23 @@ public B withNodeSelectors(Map selectors) { if (component.getNodeSelectors() == null) { component.setNodeSelectors(new HashMap<>()); } - + component.getNodeSelectors().putAll(selectors); return builder; } /** *
    -     * Adds a single node selector. 
    +     * Adds a single node selector.
          * This method allows you to specify one label and its desired value at a time.
          * Can be called multiple times to add multiple selectors.
    * * @param label The label key representing a specific characteristic of nodes. * @param value The label value that nodes must have to match the selector. - * - * @important.note Node selectors provide powerful control over pod scheduling, but incorrect or overly restrictive - * configurations may limit your deployment options. Fractal Cloud cannot guarantee the functionality of the deployment + * @important.note Node selectors provide powerful control over pod scheduling, but incorrect or overly + * restrictive + * configurations may limit your deployment options. Fractal Cloud cannot guarantee the functionality of the + * deployment * if node selector configurations prevent scheduling. You need to verify the accuracy and applicability of your * node label selections. */ @@ -95,20 +103,20 @@ public B withNodeSelector(String label, String value) { if (component.getNodeSelectors() == null) { component.setNodeSelectors(new HashMap<>()); } - + component.getNodeSelectors().put(label, value); return builder; } - + /** *
          * Adds a list of tolerations for the component, enabling it to be scheduled on nodes with specific taints.
          * Tolerations are essential for running applications in environments with strict security or operational requirements.
    - * + * * @param tolerations A list of Toleration objects for the component. - * - * @important.note Toleration configurations must be carefully crafted to ensure compatibility with cluster taints. + * @important.note Toleration configurations must be carefully crafted to ensure compatibility with + * cluster taints. * Fractal Cloud cannot guarantee the functionality of the deployment if tolerations cause the component to be * unscheduled or scheduled on unsuitable nodes. You need to carefully review and test your toleration settings * to ensure they align with your deployment strategy and security requirements. @@ -124,12 +132,12 @@ public B withTolerations(List tolerations) { /** *
          * Adds a single toleration to the component, providing granular control over scheduling on nodes with certain taints.
    - * + * * @param toleration A Toleration object to add to the component. - * * @important.note Adding individual tolerations requires precision to avoid unintended scheduling outcomes. * Fractal Cloud cannot guarantee the functionality of the deployment if improper tolerations lead to deployment - * challenges. You need to ensure that tolerations are correctly configured for your operational environment. + * challenges. You need to ensure that tolerations are correctly configured for your operational environment + * .
    */ public B withToleration(Toleration toleration) { if (component.getTolerations() == null) { @@ -142,9 +150,8 @@ public B withToleration(Toleration toleration) { /** *
          * Specifies the priority class name for the component, affecting the scheduling and preemption of pods.
    - * + * * @param priorityClassName The name of the PriorityClass for the component. - * * @important.note Priority class names influence the scheduling and lifecycle of pods significantly. * Fractal Cloud cannot guarantee the functionality of the deployment if priority class names conflict with * cluster policies or other deployed applications. You need to ensure that priority class names are chosen @@ -155,7 +162,7 @@ public B withPriorityClassName(String priorityClassName) { return builder; } } - + @Override public Collection validate() { Collection errors = super.validate(); @@ -170,20 +177,20 @@ public Collection validate() { if (dnsZoneConfig != null) { dnsZoneConfig.keySet() - .forEach(dnsZoneName -> { - if (isBlank(dnsZoneName)) { - errors.add(DNS_ZONE_NAME_NOT_VALID); - } - if (StringUtils.isNotBlank(dnsZoneName)) { - var nameWithoutTrailingPeriod = StringUtils.stripEnd(dnsZoneName, "."); + .forEach(dnsZoneName -> { + if (isBlank(dnsZoneName)) { + errors.add(DNS_ZONE_NAME_NOT_VALID); + } + if (StringUtils.isNotBlank(dnsZoneName)) { + var nameWithoutTrailingPeriod = StringUtils.stripEnd(dnsZoneName, "."); - var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriods(dnsZoneName); + var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriods(dnsZoneName); - if (!hasValidCharacters || nameWithoutTrailingPeriod.length() > 253) { - errors.add(DNS_ZONE_NAME_NOT_VALID); - } + if (!hasValidCharacters || nameWithoutTrailingPeriod.length() > 253) { + errors.add(DNS_ZONE_NAME_NOT_VALID); } - }); + } + }); } return errors; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSLogging.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSLogging.java similarity index 68% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSLogging.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSLogging.java index 3efca947..b31ca7e0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSLogging.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSLogging.java @@ -1,6 +1,6 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.CAAS_LOGGING; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSMonitoring.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSMonitoring.java similarity index 69% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSMonitoring.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSMonitoring.java index cb8f516d..9a5b85c3 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSMonitoring.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSMonitoring.java @@ -1,6 +1,6 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.CAAS_MONITORING; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSSearch.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSSearch.java similarity index 53% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSSearch.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSSearch.java index edcf3df8..19d10632 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSSearch.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSSearch.java @@ -1,11 +1,11 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.CAAS_SEARCH; @ToString(callSuper = true) public class CaaSSearch extends CaaSComponent implements BlueprintComponent { - public static final String TYPE = CAAS_SEARCH.getId(); + public static final String TYPE = CAAS_SEARCH.getId(); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSServiceMeshSecurity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSServiceMeshSecurity.java similarity index 71% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSServiceMeshSecurity.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSServiceMeshSecurity.java index ecad2057..3e3f4d3f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSServiceMeshSecurity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSServiceMeshSecurity.java @@ -1,6 +1,6 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.CAAS_SERVICE_MESH_SECURITY; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSWorkload.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSWorkload.java similarity index 68% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSWorkload.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSWorkload.java index 92a7b9d7..0d148189 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/caas/CaaSWorkload.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/caas/CaaSWorkload.java @@ -1,6 +1,6 @@ -package com.yanchware.fractal.sdk.domain.blueprint.caas; +package com.yanchware.fractal.sdk.domain.fractal.caas; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.CAAS_WORKLOAD; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsARecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsARecord.java similarity index 81% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsARecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsARecord.java index 1af57c7e..ba9fadc6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsARecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsARecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -69,17 +69,17 @@ public Collection validate() { if (!isBlank(ipV4Addresses)) { ipV4Addresses.stream() - .filter(StringUtils::isNotBlank) - .forEach(ipV4Address -> { - var hasValidCharacters = isValidIpV4Address(ipV4Address); - if (!hasValidCharacters) { - errors.add(IP_V4_ADDRESS_NOT_VALID); - } - }); + .filter(StringUtils::isNotBlank) + .forEach(ipV4Address -> { + var hasValidCharacters = isValidIpV4Address(ipV4Address); + if (!hasValidCharacters) { + errors.add(IP_V4_ADDRESS_NOT_VALID); + } + }); } - + return errors.stream() - .map(error -> "[DnsARecord Validation] " + error) - .collect(Collectors.toList()); + .map(error -> "[DnsARecord Validation] " + error) + .collect(Collectors.toList()); } } \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsAaaaRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsAaaaRecord.java similarity index 76% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsAaaaRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsAaaaRecord.java index 412c2994..938927b9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsAaaaRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsAaaaRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import com.fasterxml.jackson.annotation.JsonTypeName; import lombok.AccessLevel; @@ -13,7 +13,7 @@ import java.util.Set; import java.util.stream.Collectors; -import static com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsAaaaRecord.AAAA_DNS_RECORD_TYPE; +import static com.yanchware.fractal.sdk.domain.fractal.iaas.DnsAaaaRecord.AAAA_DNS_RECORD_TYPE; import static com.yanchware.fractal.sdk.utils.CollectionUtils.isBlank; import static com.yanchware.fractal.sdk.utils.RegexValidationUtils.isValidIpV6Address; @@ -24,7 +24,8 @@ public class DnsAaaaRecord extends DnsRecord { public static final String AAAA_DNS_RECORD_TYPE = "AAAA"; - private final static String IP_V6_ADDRESS_NOT_VALID = "[DnsAaaaRecord Validation] ipV6Address does not contain a valid IP v6 address"; + private final static String IP_V6_ADDRESS_NOT_VALID = "[DnsAaaaRecord Validation] ipV6Address does not contain a " + + "valid IP v6 address"; private Set ipV6Addresses; @@ -72,17 +73,17 @@ public Collection validate() { if (!isBlank(ipV6Addresses)) { ipV6Addresses.stream() - .filter(StringUtils::isNotBlank) - .forEach(ipV6Address -> { - var hasValidCharacters = isValidIpV6Address(ipV6Address); - if (!hasValidCharacters) { - errors.add(IP_V6_ADDRESS_NOT_VALID); - } - }); + .filter(StringUtils::isNotBlank) + .forEach(ipV6Address -> { + var hasValidCharacters = isValidIpV6Address(ipV6Address); + if (!hasValidCharacters) { + errors.add(IP_V6_ADDRESS_NOT_VALID); + } + }); } return errors.stream() - .map(error -> "[DnsAaaaRecord Validation] " + error) - .collect(Collectors.toList()); + .map(error -> "[DnsAaaaRecord Validation] " + error) + .collect(Collectors.toList()); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCNameRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCNameRecord.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCNameRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCNameRecord.java index 95c676e9..477581cc 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCNameRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCNameRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -18,9 +18,12 @@ public class DnsCNameRecord extends DnsRecord { public static final String CNAME_DNS_RECORD_TYPE = "CNAME"; - private final static String ALIAS_NOT_VALID = "The alias value, concatenated with its zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period. Each label must contain between 1 and 63 characters."; + private final static String ALIAS_NOT_VALID = "The alias value, concatenated with its zone name, must contain no " + + "more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only " + + "contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a " + + "period. Each label must contain between 1 and 63 characters."; private final static String ALIAS_LABEL_NOT_VALID = "The alias label must contain between 1 and 63 characters"; - + private String alias; @@ -56,14 +59,14 @@ public DnsCNameRecord build() { public Collection validate() { var errors = super.validate(); - if(StringUtils.isNotBlank(alias)) { + if (StringUtils.isNotBlank(alias)) { var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriodsAndPeriodIsNotRequired(alias); if (alias.contains(".")) { Arrays.stream(alias.split("\\.")) - .filter(label -> label.length() > 63) - .map(label -> ALIAS_LABEL_NOT_VALID) - .forEach(errors::add); + .filter(label -> label.length() > 63) + .map(label -> ALIAS_LABEL_NOT_VALID) + .forEach(errors::add); } var withoutTrailingPeriod = StringUtils.stripEnd(alias, "."); @@ -74,8 +77,8 @@ public Collection validate() { } return errors.stream() - .map(error -> "[DnsCNameRecord Validation] " + error) - .collect(Collectors.toList()); + .map(error -> "[DnsCNameRecord Validation] " + error) + .collect(Collectors.toList()); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCaaRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCaaRecord.java similarity index 91% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCaaRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCaaRecord.java index a3e5c52d..2af5e33d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCaaRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCaaRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -69,7 +69,7 @@ public Collection validate() { } return errors.stream() - .map(error -> "[DnsCaaRecord Validation] " + error) - .collect(Collectors.toList()); + .map(error -> "[DnsCaaRecord Validation] " + error) + .collect(Collectors.toList()); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCaaRecordData.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCaaRecordData.java similarity index 85% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCaaRecordData.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCaaRecordData.java index 08b81e09..406b3d45 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsCaaRecordData.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsCaaRecordData.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import com.yanchware.fractal.sdk.domain.Validatable; import lombok.AccessLevel; @@ -19,10 +19,11 @@ public class DnsCaaRecordData implements Validatable { private final static String FLAGS_NOT_VALID = "The Flags value must be between 0 and 255"; private final static String TAG_NOT_DEFINED = "The tag has not been defined and it is required"; - private final static String TAG_NOT_VALID = "The Tag value must have a length of at most 15. It must contain characters 'a' through 'z', 'A' through 'Z', and the numbers 0 through 9"; + private final static String TAG_NOT_VALID = "The Tag value must have a length of at most 15. It must contain " + + "characters 'a' through 'z', 'A' through 'Z', and the numbers 0 through 9"; private final static String VALUE_NOT_DEFINED = "The value has not been defined and it is required"; private final static String VALUE_NOT_VALID = "The value must have a length of at most 1024"; - + public int flags; public String tag; public String value; @@ -60,8 +61,8 @@ public DnsCaaRecordData build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "CaaRecordData validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "CaaRecordData validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return recordData; @@ -72,12 +73,12 @@ public DnsCaaRecordData build() { public Collection validate() { var errors = new ArrayList(); - - if(flags < 0 || flags > 255) { + + if (flags < 0 || flags > 255) { errors.add(FLAGS_NOT_VALID); } - - if(StringUtils.isBlank(tag)) { + + if (StringUtils.isBlank(tag)) { errors.add(TAG_NOT_DEFINED); } else { var hasValidCharacters = isValidLettersAndNumbers(tag); @@ -87,7 +88,7 @@ public Collection validate() { } } - if(StringUtils.isBlank(value)) { + if (StringUtils.isBlank(value)) { errors.add(VALUE_NOT_DEFINED); } else { if (value.length() > 1024) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsMxRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsMxRecord.java similarity index 96% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsMxRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsMxRecord.java index ba56fa98..6b5c8e49 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsMxRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsMxRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsMxRecordData.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsMxRecordData.java similarity index 74% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsMxRecordData.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsMxRecordData.java index 31686eac..7f8a3162 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsMxRecordData.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsMxRecordData.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import com.yanchware.fractal.sdk.domain.Validatable; import lombok.AccessLevel; @@ -18,8 +18,12 @@ @NoArgsConstructor public class DnsMxRecordData implements Validatable { private final static String PRIORITY_NOT_VALID = "The Priority value must be between 0 and 65535"; - private final static String MAIL_EXCHANGE_NOT_VALID = "The mailExchange value, concatenated with its zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period. Each label must contain between 1 and 63 characters."; - private final static String MAIL_EXCHANGE_LABEL_NOT_VALID = "The mailExchange label must contain between 1 and 63 characters"; + private final static String MAIL_EXCHANGE_NOT_VALID = "The mailExchange value, concatenated with its zone name, " + + "must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each " + + "label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other " + + "labels by a period. Each label must contain between 1 and 63 characters."; + private final static String MAIL_EXCHANGE_LABEL_NOT_VALID = "The mailExchange label must contain between 1 and 63 " + + "characters"; private final static String MAIL_EXCHANGE_NOT_DEFINED = "The mailExchange has not been defined and it is required"; public int priority; @@ -53,8 +57,8 @@ public DnsMxRecordData build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "MxRecordData validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "MxRecordData validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return recordData; @@ -66,24 +70,24 @@ public Collection validate() { var errors = new ArrayList(); - if(priority < 0 || priority > 65535) { + if (priority < 0 || priority > 65535) { errors.add(PRIORITY_NOT_VALID); } - if(StringUtils.isBlank(mailExchange)) { + if (StringUtils.isBlank(mailExchange)) { errors.add(MAIL_EXCHANGE_NOT_DEFINED); } else { var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriodsAndPeriodIsNotRequired(mailExchange); if (mailExchange.contains(".")) { Arrays.stream(mailExchange.split("\\.")) - .filter(label -> label.length() > 63) - .map(label -> MAIL_EXCHANGE_LABEL_NOT_VALID) - .forEach(errors::add); + .filter(label -> label.length() > 63) + .map(label -> MAIL_EXCHANGE_LABEL_NOT_VALID) + .forEach(errors::add); } var withoutTrailingPeriod = StringUtils.stripEnd(mailExchange, "."); - + if (!hasValidCharacters || withoutTrailingPeriod.length() > 253) { errors.add(MAIL_EXCHANGE_NOT_VALID); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsNsRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsNsRecord.java similarity index 82% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsNsRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsNsRecord.java index a3407fcf..4e331b64 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsNsRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsNsRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -19,8 +19,12 @@ public class DnsNsRecord extends DnsRecord { public static final String NS_DNS_RECORD_TYPE = "NS"; - private final static String NAME_SERVER_NOT_VALID_PATTERN = "The nameServer value ['%s'], concatenated with its zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period. Each label must contain between 1 and 63 characters."; - private final static String NAME_SERVER_LABEL_NOT_VALID_PATTERN = "The nameServer ['%s'] label must contain between 1 and 63 characters"; + private final static String NAME_SERVER_NOT_VALID_PATTERN = "The nameServer value ['%s'], concatenated with its " + + "zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 " + + "labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be " + + "separated from other labels by a period. Each label must contain between 1 and 63 characters."; + private final static String NAME_SERVER_LABEL_NOT_VALID_PATTERN = "The nameServer ['%s'] label must contain between" + + " 1 and 63 characters"; private List nameServers; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsPtrRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsPtrRecord.java similarity index 77% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsPtrRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsPtrRecord.java index db1f6c69..23dbb503 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsPtrRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsPtrRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -20,8 +20,12 @@ public class DnsPtrRecord extends DnsRecord { public static final String PTR_DNS_RECORD_TYPE = "PTR"; - private final static String DOMAIN_NAME_NOT_VALID_PATTERN = "The domainName value ['%s'], concatenated with its zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period. Each label must contain between 1 and 63 characters."; - private final static String DOMAIN_NAME_LABEL_NOT_VALID_PATTERN = "The domainName ['%s'] label must contain between 1 and 63 characters"; + private final static String DOMAIN_NAME_NOT_VALID_PATTERN = "The domainName value ['%s'], concatenated with its " + + "zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 " + + "labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be " + + "separated from other labels by a period. Each label must contain between 1 and 63 characters."; + private final static String DOMAIN_NAME_LABEL_NOT_VALID_PATTERN = "The domainName ['%s'] label must contain between" + + " 1 and 63 characters"; private List domainNames; @@ -44,7 +48,7 @@ public DnsPtrRecordBuilder withDomainName(String domainName) { if (StringUtils.isBlank(domainName)) { return builder; } - + return withDomainNames(List.of(domainName)); } @@ -73,17 +77,17 @@ public Collection validate() { if (!isBlank(domainNames)) { for (var domainName : domainNames) { - if(StringUtils.isBlank(domainName)) { + if (StringUtils.isBlank(domainName)) { continue; } - + var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriodsAndPeriodIsNotRequired(domainName); if (domainName.contains(".")) { Arrays.stream(domainName.split("\\.")) - .filter(label -> label.length() > 63) - .map(label -> String.format(DOMAIN_NAME_LABEL_NOT_VALID_PATTERN, label)) - .forEach(errors::add); + .filter(label -> label.length() > 63) + .map(label -> String.format(DOMAIN_NAME_LABEL_NOT_VALID_PATTERN, label)) + .forEach(errors::add); } var withoutTrailingPeriod = StringUtils.stripEnd(domainName, "."); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsRecord.java similarity index 55% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsRecord.java index c6167246..845e8fc7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -13,32 +13,34 @@ import java.util.Arrays; import java.util.Collection; -import static com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsARecord.A_DNS_RECORD_TYPE; +import static com.yanchware.fractal.sdk.domain.fractal.iaas.DnsARecord.A_DNS_RECORD_TYPE; import static com.yanchware.fractal.sdk.utils.RegexValidationUtils.isValidLettersNumbersUnderscoresDashesAndPeriodsAndPeriodIsNotRequired; @Getter @Setter(AccessLevel.PROTECTED) @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "@type" + use = JsonTypeInfo.Id.NAME, + property = "@type" ) @JsonSubTypes({ - @JsonSubTypes.Type(value = DnsAaaaRecord.class, name = DnsAaaaRecord.AAAA_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsARecord.class, name = A_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsCaaRecord.class, name = DnsCaaRecord.CAA_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsCNameRecord.class, name = DnsCNameRecord.CNAME_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsMxRecord.class, name = DnsMxRecord.MX_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsNsRecord.class, name = DnsNsRecord.NS_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsPtrRecord.class, name = DnsPtrRecord.PTR_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsSrvRecord.class, name = DnsSrvRecord.SRV_DNS_RECORD_TYPE), - @JsonSubTypes.Type(value = DnsTxtRecord.class, name = DnsTxtRecord.TXT_DNS_RECORD_TYPE) + @JsonSubTypes.Type(value = DnsAaaaRecord.class, name = DnsAaaaRecord.AAAA_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsARecord.class, name = A_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsCaaRecord.class, name = DnsCaaRecord.CAA_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsCNameRecord.class, name = DnsCNameRecord.CNAME_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsMxRecord.class, name = DnsMxRecord.MX_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsNsRecord.class, name = DnsNsRecord.NS_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsPtrRecord.class, name = DnsPtrRecord.PTR_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsSrvRecord.class, name = DnsSrvRecord.SRV_DNS_RECORD_TYPE), + @JsonSubTypes.Type(value = DnsTxtRecord.class, name = DnsTxtRecord.TXT_DNS_RECORD_TYPE) }) public abstract class DnsRecord implements Validatable { private final static String NAME_NOT_VALID = "The Name must contain between 1 and 63 characters. " + - "It must only contain letters, numbers, underscores, and/or dashes. " + - "Each label should be separated from other labels by a period. " + - "A wildcard ('*' character) is permitted either as the single character in the name, or as the first label in the name. " + - "An empty value, or a single '@' character is permitted for record sets at the zone apex (except for CNAME record sets)"; + "It must only contain letters, numbers, underscores, and/or dashes. " + + "Each label should be separated from other labels by a period. " + + "A wildcard ('*' character) is permitted either as the single character in the name, or as the first label in the" + + " name. " + + "An empty value, or a single '@' character is permitted for record sets at the zone apex (except for CNAME record" + + " sets)"; private Duration ttl; @@ -54,6 +56,7 @@ record = createRecord(); } protected abstract T createRecord(); + protected abstract B getBuilder(); public B withName(String name) { @@ -71,9 +74,9 @@ public T build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "DnsRecord '%s' validation failed. Errors: %s", - this.getClass().getSimpleName(), - Arrays.toString(errors.toArray()))); + "DnsRecord '%s' validation failed. Errors: %s", + this.getClass().getSimpleName(), + Arrays.toString(errors.toArray()))); } return record; @@ -89,7 +92,7 @@ public Collection validate() { } if (StringUtils.isNotBlank(name)) { - if(!name.equals("@")) { + if (!name.equals("@")) { var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriodsAndPeriodIsNotRequired(name); if (!hasValidCharacters || name.length() > 63) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsSrvRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsSrvRecord.java similarity index 76% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsSrvRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsSrvRecord.java index 91ed5701..8e0aa16a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsSrvRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsSrvRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -18,14 +18,18 @@ public class DnsSrvRecord extends DnsRecord { public static final String SRV_DNS_RECORD_TYPE = "SRV"; - private final static String DOMAIN_NAME_NOT_VALID_PATTERN = "The domainName value ['%s'], concatenated with its zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period. Each label must contain between 1 and 63 characters."; - private final static String DOMAIN_NAME_LABEL_NOT_VALID_PATTERN = "The domainName ['%s'] label must contain between 1 and 63 characters"; + private final static String DOMAIN_NAME_NOT_VALID_PATTERN = "The domainName value ['%s'], concatenated with its " + + "zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 " + + "labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be " + + "separated from other labels by a period. Each label must contain between 1 and 63 characters."; + private final static String DOMAIN_NAME_LABEL_NOT_VALID_PATTERN = "The domainName ['%s'] label must contain between" + + " 1 and 63 characters"; private final static String SERVICE_NOT_DEFINED = "Service has not been defined and it is required"; - private final static String PROTOCOL_NAME_NOT_DEFINED= "ProtocolName has not been defined and it is required"; - + private final static String PROTOCOL_NAME_NOT_DEFINED = "ProtocolName has not been defined and it is required"; + private String service; private String protocolName; - + private List recordData; public static DnsSrvRecordBuilder builder() { @@ -72,7 +76,7 @@ public DnsSrvRecordBuilder withRecordData(Collection @Override public DnsSrvRecord build() { - if(StringUtils.isBlank(record.getName())) { + if (StringUtils.isBlank(record.getName())) { record.setName(String.format("%s.%s", record.getService(), record.getProtocolName())); } else { record.setName(String.format("%s.%s.%s", record.getService(), record.getProtocolName(), record.getName())); @@ -85,15 +89,14 @@ public DnsSrvRecord build() { public Collection validate() { var errors = super.validate(); - if(StringUtils.isBlank(service)) { + if (StringUtils.isBlank(service)) { errors.add(SERVICE_NOT_DEFINED); } - if(StringUtils.isBlank(protocolName)) { + if (StringUtils.isBlank(protocolName)) { errors.add(PROTOCOL_NAME_NOT_DEFINED); } - - + if (!isBlank(recordData)) { for (var data : recordData) { @@ -101,7 +104,6 @@ public Collection validate() { } } - return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsSrvRecordData.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsSrvRecordData.java similarity index 75% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsSrvRecordData.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsSrvRecordData.java index c94a6f5d..70296463 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsSrvRecordData.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsSrvRecordData.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import com.yanchware.fractal.sdk.domain.Validatable; import lombok.AccessLevel; @@ -21,11 +21,14 @@ public class DnsSrvRecordData implements Validatable { private final static String PRIORITY_NOT_VALID = "The priority value must be less than or equal to 65535"; private final static String WEIGHT_NOT_VALID = "The weight value must be less than or equal to 65535"; private final static String PORT_NOT_VALID = "The port value must be less than or equal to 65535"; - private final static String TARGET_NOT_VALID = "The target value, concatenated with its zone name, must contain no more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period. Each label must contain between 1 and 63 characters."; + private final static String TARGET_NOT_VALID = "The target value, concatenated with its zone name, must contain no " + + "more than 253 characters, excluding a trailing period. It must be between 2 and 34 labels. Each label must only " + + "contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a " + + "period. Each label must contain between 1 and 63 characters."; private final static String TARGET_LABEL_NOT_VALID = "The target label must contain between 1 and 63 characters"; - private final static String TARGET_NOT_DEFINED= "Target has not been defined and it is required"; - - private int priority; + private final static String TARGET_NOT_DEFINED = "Target has not been defined and it is required"; + + private int priority; private int weight; private int port; private String target; @@ -43,21 +46,22 @@ public DnsSrvRecordDataBuilder() { builder = this; } - - + public DnsSrvRecordDataBuilder withPriority(int priority) { recordData.setPriority(priority); return builder; } - + public DnsSrvRecordDataBuilder withWeight(int weight) { recordData.setWeight(weight); return builder; } + public DnsSrvRecordDataBuilder withPort(int port) { recordData.setPort(port); return builder; } + public DnsSrvRecordDataBuilder withTarget(String target) { recordData.setTarget(target); return builder; @@ -68,8 +72,8 @@ public DnsSrvRecordData build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "CaaRecordData validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "CaaRecordData validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return recordData; @@ -81,28 +85,28 @@ public Collection validate() { var errors = new ArrayList(); - if(priority < 0 || priority > 65535) { + if (priority < 0 || priority > 65535) { errors.add(PRIORITY_NOT_VALID); } - if(weight < 0 || weight > 65535) { + if (weight < 0 || weight > 65535) { errors.add(WEIGHT_NOT_VALID); } - if(port < 0 || port > 65535) { + if (port < 0 || port > 65535) { errors.add(PORT_NOT_VALID); } - if(StringUtils.isBlank(target)) { + if (StringUtils.isBlank(target)) { errors.add(TARGET_NOT_DEFINED); } else { var hasValidCharacters = isValidLettersNumbersUnderscoresDashesAndPeriodsAndPeriodIsNotRequired(target); if (target.contains(".")) { Arrays.stream(target.split("\\.")) - .filter(label -> label.length() > 63) - .map(label -> TARGET_LABEL_NOT_VALID) - .forEach(errors::add); + .filter(label -> label.length() > 63) + .map(label -> TARGET_LABEL_NOT_VALID) + .forEach(errors::add); } var withoutTrailingPeriod = StringUtils.stripEnd(target, "."); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsTxtRecord.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsTxtRecord.java similarity index 90% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsTxtRecord.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsTxtRecord.java index 2686b08d..78a40617 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsTxtRecord.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsTxtRecord.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import lombok.AccessLevel; import lombok.Getter; @@ -18,7 +18,8 @@ public class DnsTxtRecord extends DnsRecord { public static final String TXT_DNS_RECORD_TYPE = "TXT"; - private final static String VALUES_NOT_VALID = "The combined length of all TXT records in a record set may not exceed 1024 characters"; + private final static String VALUES_NOT_VALID = "The combined length of all TXT records in a record set may not " + + "exceed 1024 characters"; private List values; @@ -66,8 +67,8 @@ public Collection validate() { if (!isBlank(values)) { var combinedTxt = String.join("", values); - - if(combinedTxt.length() > 1024) { + + if (combinedTxt.length() > 1024) { errors.add(VALUES_NOT_VALID); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsZone.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsZone.java similarity index 90% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsZone.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsZone.java index adfd454f..03d1190b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/iaas/DnsZone.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/iaas/DnsZone.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.iaas; +package com.yanchware.fractal.sdk.domain.fractal.iaas; import com.yanchware.fractal.sdk.domain.Validatable; import lombok.AccessLevel; @@ -15,7 +15,9 @@ public class DnsZone implements Validatable { public final static String DNS_ZONES_PARAM_KEY = "dnsZones"; - private final static String NAME_NOT_VALID = "[DnsZone Validation] The name must contain no more than 253 characters, excluding a trailing period and must be between 2 and 34 labels. Each label must only contain letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period"; + private final static String NAME_NOT_VALID = "[DnsZone Validation] The name must contain no more than 253 " + + "characters, excluding a trailing period and must be between 2 and 34 labels. Each label must only contain " + + "letters, numbers, underscores, and/or dashes. Each label should be separated from other labels by a period"; private String name; private boolean isPrivate; @@ -53,7 +55,7 @@ public DnsZoneBuilder withRecord(String componentId, DnsRecord dnsRecord) { if (!dnsZone.getRecords().containsKey(componentId)) { dnsZone.getRecords().put(componentId, new ArrayList<>()); } - + dnsZone.getRecords().get(componentId).add(dnsRecord); return builder; @@ -102,7 +104,7 @@ public DnsZone build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("DnsZone validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return dnsZone; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSColumnOrientedDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSColumnOrientedDbms.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSColumnOrientedDbms.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSColumnOrientedDbms.java index 266e6e9f..1cd2a5ba 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSColumnOrientedDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSColumnOrientedDbms.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_COLUMN_ORIENTED_DBMS; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSContainerPlatform.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSContainerPlatform.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSContainerPlatform.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSContainerPlatform.java index c8e35452..e3527a1d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSContainerPlatform.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSContainerPlatform.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_CONTAINER_PLATFORM; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDataStorage.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDataStorage.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDataStorage.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDataStorage.java index d232e92a..d47d8c7e 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDataStorage.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDataStorage.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_DATA_STORAGE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDocumentDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDocumentDatabase.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDocumentDatabase.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDocumentDatabase.java index 34d40aba..2e3e15fd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDocumentDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDocumentDatabase.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_DOCUMENT_DATABASE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDocumentDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDocumentDbms.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDocumentDbms.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDocumentDbms.java index 1bc1fb1f..c0ed2fbe 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSDocumentDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSDocumentDbms.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_DOCUMENT_DBMS; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSFileShare.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSFileShare.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSFileShare.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSFileShare.java index 08b60331..35af9804 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSFileShare.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSFileShare.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_FILE_SHARE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSGraphDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSGraphDatabase.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSGraphDatabase.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSGraphDatabase.java index 2f2593ab..e6a76adc 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSGraphDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSGraphDatabase.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_GRAPH_DATABASE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSGraphDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSGraphDbms.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSGraphDbms.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSGraphDbms.java index 81281438..2f4e9c6e 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSGraphDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSGraphDbms.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_GRAPH_DBMS; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSKeyValueDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSKeyValueDbms.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSKeyValueDbms.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSKeyValueDbms.java index f4112c87..95a99627 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSKeyValueDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSKeyValueDbms.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_KEY_VALUE_DBMS; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSKeyValueEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSKeyValueEntity.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSKeyValueEntity.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSKeyValueEntity.java index c99ff220..35836442 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSKeyValueEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSKeyValueEntity.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_KEY_VALUE_ENTITY; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSMessageEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSMessageEntity.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSMessageEntity.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSMessageEntity.java index a84e4b1a..58b907ca 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSMessageEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSMessageEntity.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_MESSAGE_ENTITY; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSMessaging.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSMessaging.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSMessaging.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSMessaging.java index 95b9bccb..ede2a9e4 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSMessaging.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSMessaging.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_MESSAGE_BROKER; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSNetworkCdnProfile.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSNetworkCdnProfile.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSNetworkCdnProfile.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSNetworkCdnProfile.java index 4a14d09b..19e14cc0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSNetworkCdnProfile.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSNetworkCdnProfile.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_CDN_PROFILE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSRelationalDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSRelationalDatabase.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSRelationalDatabase.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSRelationalDatabase.java index 05ecca90..f68e4ab3 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSRelationalDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSRelationalDatabase.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_RELATIONAL_DATABASE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSRelationalDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSRelationalDbms.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSRelationalDbms.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSRelationalDbms.java index 598fa9d0..e0bd28c7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSRelationalDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSRelationalDbms.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_RELATIONAL_DBMS; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSStorageContainer.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSStorageContainer.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSStorageContainer.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSStorageContainer.java index fb4e5c5e..f91e8563 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSStorageContainer.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSStorageContainer.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_STORAGE_CONTAINER; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSWorkload.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSWorkload.java similarity index 72% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSWorkload.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSWorkload.java index 7eb5011a..56bc428b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSWorkload.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSWorkload.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_WORKLOAD; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSWorkloadDeploymentSlot.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSWorkloadDeploymentSlot.java similarity index 74% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSWorkloadDeploymentSlot.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSWorkloadDeploymentSlot.java index 497b067b..7bd10d92 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/paas/PaaSWorkloadDeploymentSlot.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/paas/PaaSWorkloadDeploymentSlot.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.paas; +package com.yanchware.fractal.sdk.domain.fractal.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_WORKLOAD_DEPLOYMENT_SLOT; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedBrokerComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedBrokerComponent.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedBrokerComponent.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedBrokerComponent.java index f3f999df..3d0eaa84 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedBrokerComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedBrokerComponent.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.saas; +package com.yanchware.fractal.sdk.domain.fractal.saas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.SAAS_UNMANAGED_BROKER; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedSecurityComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedSecurityComponent.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedSecurityComponent.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedSecurityComponent.java index 71130646..b083bf28 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedSecurityComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedSecurityComponent.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.saas; +package com.yanchware.fractal.sdk.domain.fractal.saas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.SAAS_UNMANAGED_SECURITY; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedStorageComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedStorageComponent.java similarity index 73% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedStorageComponent.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedStorageComponent.java index e072b6f3..2bd7601c 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/saas/UnmanagedStorageComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/saas/UnmanagedStorageComponent.java @@ -1,7 +1,7 @@ -package com.yanchware.fractal.sdk.domain.blueprint.saas; +package com.yanchware.fractal.sdk.domain.fractal.saas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import lombok.ToString; import static com.yanchware.fractal.sdk.domain.values.ComponentType.SAAS_UNMANAGED_STORAGE; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintService.java similarity index 74% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintService.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintService.java index 1b98e3e9..a763f764 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintService.java @@ -1,14 +1,14 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service; +package com.yanchware.fractal.sdk.domain.fractal.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.yanchware.fractal.sdk.configuration.SdkConfiguration; import com.yanchware.fractal.sdk.domain.Service; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; -import com.yanchware.fractal.sdk.domain.blueprint.service.commands.CreateBlueprintCommandRequest; -import com.yanchware.fractal.sdk.domain.blueprint.service.commands.UpdateBlueprintCommandRequest; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintDto; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; +import com.yanchware.fractal.sdk.domain.fractal.service.commands.CreateBlueprintCommandRequest; +import com.yanchware.fractal.sdk.domain.fractal.service.commands.UpdateBlueprintCommandRequest; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintDto; import com.yanchware.fractal.sdk.utils.HttpUtils; import io.github.resilience4j.retry.RetryRegistry; import lombok.extern.slf4j.Slf4j; @@ -28,10 +28,10 @@ public BlueprintService(HttpClient client, SdkConfiguration sdkConfiguration, Re } public void createOrUpdate( - FractalIdValue fractalId, - String description, - boolean isPrivate, - Collection components) throws InstantiatorException + FractalIdValue fractalId, + String description, + boolean isPrivate, + Collection components) throws InstantiatorException { var command = new CreateBlueprintCommandRequest(description, isPrivate, components); log.info("Create or update blueprint [FractalId: '{}']", fractalId); @@ -69,13 +69,13 @@ protected void update(UpdateBlueprintCommandRequest command, FractalIdValue frac protected BlueprintDto retrieve(FractalIdValue fractalId) throws InstantiatorException { return executeRequestWithRetries( - "retrieveBlueprint", - fractalId.toString(), - client, - retryRegistry, - HttpUtils.buildGetRequest(getBlueprintsUri(fractalId), sdkConfiguration), - new int[]{200, 404}, - BlueprintDto.class); + "retrieveBlueprint", + fractalId.toString(), + client, + retryRegistry, + HttpUtils.buildGetRequest(getBlueprintsUri(fractalId), sdkConfiguration), + new int[]{200, 404}, + BlueprintDto.class); } private URI getBlueprintsUri(FractalIdValue fractalId) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequest.java new file mode 100644 index 00000000..251fbecb --- /dev/null +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequest.java @@ -0,0 +1,14 @@ +package com.yanchware.fractal.sdk.domain.fractal.service.commands; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; + +import java.util.Collection; + +public record CreateBlueprintCommandRequest( + String description, + @JsonProperty("private") + boolean isPrivate, + Collection components) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/UpdateBlueprintCommandRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/UpdateBlueprintCommandRequest.java new file mode 100644 index 00000000..84ca03fb --- /dev/null +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/UpdateBlueprintCommandRequest.java @@ -0,0 +1,34 @@ +package com.yanchware.fractal.sdk.domain.fractal.service.commands; + +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; +import lombok.Builder; +import lombok.Data; + +import java.util.Collection; + +@Data +@Builder +public class UpdateBlueprintCommandRequest { + private String resourceGroupId; + private String fractalName; + private String fractalVersion; + private String description; + private boolean isPrivate; + Collection components; + + public static UpdateBlueprintCommandRequest fromCreateCommand( + CreateBlueprintCommandRequest command, + FractalIdValue fractalId) + { + String[] splitId = fractalId.toString().split("[/:]"); + return UpdateBlueprintCommandRequest.builder() + .resourceGroupId(String.format("%s/%s/%s", splitId[0], splitId[1], splitId[2])) + .fractalName(splitId[3]) + .fractalVersion(splitId[4]) + .description(command.description()) + .isPrivate(command.isPrivate()) + .components(command.components()) + .build(); + } +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDto.java new file mode 100644 index 00000000..4764667f --- /dev/null +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDto.java @@ -0,0 +1,72 @@ +package com.yanchware.fractal.sdk.domain.fractal.service.dtos; + +import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; +import com.yanchware.fractal.sdk.domain.services.contracts.ComponentDto; +import com.yanchware.fractal.sdk.utils.ReflectionUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; + +import static com.yanchware.fractal.sdk.configuration.Constants.BLUEPRINT_TYPE; +import static java.util.Collections.emptySet; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@NoArgsConstructor +@Slf4j +public class BlueprintComponentDto extends ComponentDto { + private Set outputFields; + + public static BlueprintComponentDtoBuilder builder() { + return new BlueprintComponentDtoBuilder(); + } + + public static class BlueprintComponentDtoBuilder extends Builder { + + @Override + protected BlueprintComponentDto createComponent() { + return new BlueprintComponentDto(); + } + + @Override + protected BlueprintComponentDtoBuilder getBuilder() { + return this; + } + + public BlueprintComponentDtoBuilder withOutputFields(Collection outputFields) { + if (componentDto.getOutputFields() == null) { + componentDto.setOutputFields(new HashSet<>()); + } + + componentDto.getOutputFields().addAll(outputFields); + + return builder; + } + } + + public static List fromLiveSystemComponents(Collection components) { + List blueprintComponentDtoList = new ArrayList<>(); + for (LiveSystemComponent component : components) { + List> listOfComponents = ReflectionUtils.buildComponents(component); + for (var componentMap : listOfComponents) { + BlueprintComponentDto componentDto = BlueprintComponentDto.toBlueprintComponentDto(componentMap); + blueprintComponentDtoList.add(componentDto); + } + } + return blueprintComponentDtoList; + } + + private static BlueprintComponentDto toBlueprintComponentDto(Map allFields) { + return BlueprintComponentDto.builder() + .withFields(allFields) + .withType(String.valueOf(allFields.get(BLUEPRINT_TYPE))) + .withOutputFields(emptySet()) + .build(); + } +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintDto.java similarity index 85% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintDto.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintDto.java index c01aec22..a3fca230 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintDto.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.dtos; +package com.yanchware.fractal.sdk.domain.fractal.service.dtos; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintStatusDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintStatusDto.java similarity index 62% rename from fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintStatusDto.java rename to fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintStatusDto.java index 558dfe12..9fc3bf19 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintStatusDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintStatusDto.java @@ -1,4 +1,4 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.dtos; +package com.yanchware.fractal.sdk.domain.fractal.service.dtos; public enum BlueprintStatusDto { UNKNOWN, diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkload.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkload.java index 4d911246..8dfde540 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkload.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkload.java @@ -10,44 +10,58 @@ public interface CustomWorkload { String getPrivateSSHKeyPassphraseEnvironmentSecretShortName(); + void setPrivateSSHKeyPassphraseEnvironmentSecretShortName(String privateSSHKeyPassphraseEnvironmentSecretShortName); String getPrivateSSHKeyEnvironmentSecretShortName(); + void setPrivateSSHKeyEnvironmentSecretShortName(String privateSSHKeyEnvironmentSecretShortName); String getSshRepositoryURI(); + void setSshRepositoryURI(String SshRepositoryURI); String getRepoId(); + void setRepoId(String repoId); String getBranchName(); + void setBranchName(String branchName); String getWorkloadSecretIdKey(); + void setWorkloadSecretIdKey(String workloadSecretIdKey); String getWorkloadSecretPasswordKey(); + void setWorkloadSecretPasswordKey(String WorkloadSecretPasswordKey); List getRoles(); + void setRoles(List roles); Map> getDnsZoneConfig(); + void setDnsZoneConfig(Map> getDnsZoneConfig); List getEnvironmentSecretShortNames(); + void setEnvironmentSecretShortNames(List secrets); String getCiCdProfileShortName(); + void setCiCdProfileShortName(String ciCdProfileShortName); - static Collection validateCustomWorkload(CustomWorkload customWorkload, String workloadType){ - final var SSH_REPO_URI_IS_EMPTY_TEMPLATE = "[%s Validation] sshRepositoryURI is either empty or blank and it is required"; + static Collection validateCustomWorkload(CustomWorkload customWorkload, String workloadType) { + final var SSH_REPO_URI_IS_EMPTY_TEMPLATE = "[%s Validation] sshRepositoryURI is either empty or blank and it is " + + "required"; final var REPO_ID_IS_EMPTY_TEMPLATE = "[%s Validation] repoId is either empty or blank and it is required"; final var BRANCH_NAME_IS_EMPTY_TEMPLATE = "[%s Validation] branchName is either empty or blank and it is required"; - final var WORKLOAD_SECRET_ID_KEY_IS_EMPTY_TEMPLATE = "[%s Validation] Workload Secret Id Key is either empty or blank and it is required"; - final var WORKLOAD_SECRET_PASSWORD_KEY_IS_EMPTY_TEMPLATE = "[%s Validation] Workload Secret Password Key is either empty or blank and it is required"; + final var WORKLOAD_SECRET_ID_KEY_IS_EMPTY_TEMPLATE = "[%s Validation] Workload Secret Id Key is either empty or " + + "blank and it is required"; + final var WORKLOAD_SECRET_PASSWORD_KEY_IS_EMPTY_TEMPLATE = "[%s Validation] Workload Secret Password Key is " + + "either empty or blank and it is required"; var errors = new ArrayList(); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkloadBuilder.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkloadBuilder.java index 4bdd1957..db03a051 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkloadBuilder.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/CustomWorkloadBuilder.java @@ -18,11 +18,12 @@ * our documentation page *

    */ -public abstract class CustomWorkloadBuilder> extends Component.Builder { +public abstract class CustomWorkloadBuilder> extends Component.Builder { /** *
    -   * Sets the short name of the environment secret containing the passphrase protecting the SSH private key 
    +   * Sets the short name of the environment secret containing the passphrase protecting the SSH private key
        * used to access the code repository.
        *
        * This secret should be defined at the Environment level.
    @@ -64,7 +65,7 @@ public B withSSHRepositoryURI(String sshRepositoryURI) {
     
       /**
        * 
    -   * The ID of the repository as it is in the version control solution of your choice. 
    +   * The ID of the repository as it is in the version control solution of your choice.
        * The repoId needs to match the repository ID that is being sent by the webhook.
        * 
    * @@ -78,7 +79,7 @@ public B withRepoId(String repoId) { /** *
    -   * Adds a role to the Custom Workload. 
    +   * Adds a role to the Custom Workload.
        * The role can vary from a specific Cloud Vendor Built-in role to an AppRoleAssignment or other custom role.
        * 
    *

    @@ -93,7 +94,7 @@ public B withRole(CustomWorkloadRole role) { /** *

    -   * Adds a list of roles to the Custom Workload. 
    +   * Adds a list of roles to the Custom Workload.
        * The roles can vary from specific Cloud Vendor Built-in roles to AppRoleAssignments or other custom roles.
        * 
    *

    @@ -156,7 +157,7 @@ public B withBranchName(String branchName) { /** *

    -   * Adds a single secret short name to the component. 
    +   * Adds a single secret short name to the component.
        * This secret should be defined in the environment associated with this component.
    * * @param environmentSecretShortNames The short name of the secret to add. @@ -168,7 +169,7 @@ public B withEnvironmentSecretShortName(String environmentSecretShortNames) { /** *
    -   * Adds a list of secret names to the component. 
    +   * Adds a list of secret names to the component.
        * These secrets should be defined in the environment associated with this component.
    * * @param environmentSecretShortNames The list of secret names to add. @@ -183,7 +184,7 @@ public B withEnvironmentSecretShortNames(List environmentSecretShortName } /** - * Adds a CI/CD profile short name to the component. + * Adds a CI/CD profile short name to the component. * This is to specify which CI/CD profile should be used by the component. * The profile should be defined at the Environment level. * This method only adds a reference to the profile by its short name. diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/EnvironmentReference.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/EnvironmentReference.java index 68573102..fefda228 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/EnvironmentReference.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/EnvironmentReference.java @@ -2,4 +2,5 @@ import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; -public record EnvironmentReference(EnvironmentIdValue id) {} \ No newline at end of file +public record EnvironmentReference(EnvironmentIdValue id) { +} \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregate.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregate.java index 07ef6f4c..79d4f8f9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregate.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregate.java @@ -2,13 +2,13 @@ import com.yanchware.fractal.sdk.configuration.SdkConfiguration; import com.yanchware.fractal.sdk.domain.Validatable; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; import com.yanchware.fractal.sdk.domain.environment.service.EnvironmentService; import com.yanchware.fractal.sdk.domain.environment.service.RestEnvironmentService; import com.yanchware.fractal.sdk.domain.exceptions.EnvironmentException; import com.yanchware.fractal.sdk.domain.exceptions.EnvironmentNotFoundException; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; import com.yanchware.fractal.sdk.domain.livesystem.operationalservicewindow.OperationalServiceWindow; import com.yanchware.fractal.sdk.domain.livesystem.service.LiveSystemService; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.*; @@ -29,155 +29,163 @@ @Slf4j @Setter(AccessLevel.PROTECTED) public class LiveSystemAggregate implements Validatable { - private final static String ID_IS_NULL = "[LiveSystem Validation] Id has not been defined and it is required"; - private final static String NAME_IS_NULL = "[LiveSystem Validation] Name has not been defined and it is required"; - private final static String RESOURCE_GROUP_ID_IS_NULL = "[LiveSystem Validation] ResourceGroupId has not been defined and it is required'"; - private final static String PROVIDER_ID_IS_NULL = "[LiveSystem Validation] Provider has not been defined and it is required'"; - private final static String EMPTY_COMPONENT_LIST = "[LiveSystem Validation] Components list is null or empty and at least one component is required"; - private final LiveSystemService service; - private final EnvironmentService environmentService; - - @Getter - private LiveSystemIdValue id; - @Getter - private FractalIdValue fractalId; - @Getter - private String description; - @Getter - private EnvironmentReference environment; - @Getter - private Date created; - @Getter - private Date lastUpdated; - @Getter - private Collection components; - @Getter - private ProviderType provider; - @Getter - private OperationalServiceWindow operationalServiceWindow; - - protected LiveSystemAggregate( - HttpClient client, - SdkConfiguration sdkConfiguration, - RetryRegistry retryRegistry) - { - service = new LiveSystemService(client, sdkConfiguration, retryRegistry); - environmentService = new RestEnvironmentService(client, sdkConfiguration, retryRegistry); - components = new ArrayList<>(); + private final static String ID_IS_NULL = "[LiveSystem Validation] Id has not been defined and it is required"; + private final static String NAME_IS_NULL = "[LiveSystem Validation] Name has not been defined and it is required"; + private final static String RESOURCE_GROUP_ID_IS_NULL = "[LiveSystem Validation] ResourceGroupId has not been " + + "defined and it is required'"; + private final static String PROVIDER_ID_IS_NULL = "[LiveSystem Validation] Provider has not been defined and it is " + + "required'"; + private final static String EMPTY_COMPONENT_LIST = "[LiveSystem Validation] Components list is null or empty and at" + + " least one component is required"; + private final LiveSystemService service; + private final EnvironmentService environmentService; + + @Getter + private LiveSystemIdValue id; + @Getter + private FractalIdValue fractalId; + @Getter + private String description; + @Getter + private EnvironmentReference environment; + @Getter + private Date created; + @Getter + private Date lastUpdated; + @Getter + private Collection components; + @Getter + private ProviderType provider; + @Getter + private OperationalServiceWindow operationalServiceWindow; + + protected LiveSystemAggregate( + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) + { + service = new LiveSystemService(client, sdkConfiguration, retryRegistry); + environmentService = new RestEnvironmentService(client, sdkConfiguration, retryRegistry); + components = new ArrayList<>(); + } + + // TODO FRA-1870: Use entity instead of LiveSystemComponentMutationDto + public LiveSystemComponentMutationDto instantiateComponent(String componentId) throws InstantiatorException { + var action = String.format("instantiate component [id: '%s']", componentId); + + ensureEnvironmentExists(environment.id(), action); + + return service.instantiateComponent(id, componentId); + } + + public LiveSystemComponentMutationDto getComponentMutationStatus(String componentId, String mutationId) + throws InstantiatorException + { + return service.getComponentMutationStatus(getId().toString(), componentId, mutationId); + } + + // TODO FRA-1870: Use entity instead of LiveSystemMutationDto + public LiveSystemMutationDto instantiate() throws InstantiatorException { + + if (components == null || components.isEmpty()) { + throw new InstantiatorException(EMPTY_COMPONENT_LIST); } - // TODO FRA-1870: Use entity instead of LiveSystemComponentMutationDto - public LiveSystemComponentMutationDto instantiateComponent(String componentId) throws InstantiatorException { - var action = String.format("instantiate component [id: '%s']", componentId); - - ensureEnvironmentExists(environment.id(), action); - - return service.instantiateComponent(id, componentId); - } - - public LiveSystemComponentMutationDto getComponentMutationStatus(String componentId, String mutationId) - throws InstantiatorException - { - return service.getComponentMutationStatus(getId().toString(), componentId, mutationId); + ensureEnvironmentExists(environment.id(), + String.format("instantiate LiveSystem [id: '%s']", id)); + + if (service.retrieveLiveSystem(getId()) != null) { + return service.updateLiveSystem( + getId().toString(), + fractalId, + description, + provider.toString(), + blueprintMapFromLiveSystemComponents(), + environment); } - // TODO FRA-1870: Use entity instead of LiveSystemMutationDto - public LiveSystemMutationDto instantiate() throws InstantiatorException { - - if (components == null || components.isEmpty()) { - throw new InstantiatorException(EMPTY_COMPONENT_LIST); - } - - ensureEnvironmentExists(environment.id(), - String.format("instantiate LiveSystem [id: '%s']", id)); - - if (service.retrieveLiveSystem(getId()) != null) { - return service.updateLiveSystem( - getId().toString(), - fractalId, - description, - provider.toString(), - blueprintMapFromLiveSystemComponents(), - environment); - } - - return service.instantiateLiveSystem( - getId().toString(), - fractalId, - description, - provider.toString(), - blueprintMapFromLiveSystemComponents(), - environment); + return service.instantiateLiveSystem( + getId().toString(), + fractalId, + description, + provider.toString(), + blueprintMapFromLiveSystemComponents(), + environment); + } + + public void checkLiveSystemMutationStatus(String liveSystemMutationId) throws InstantiatorException { + service.checkLiveSystemMutationStatus(getId(), liveSystemMutationId); + } + + protected Map blueprintMapFromLiveSystemComponents() { + Map map = new HashMap<>(); + for (LiveSystemComponent comp : getComponents()) { + List> listOfComponents = ReflectionUtils.buildComponents(comp); + for (var component : listOfComponents) { + LiveSystemComponentDto componentDto = toLiveSystemComponentDto(comp, component); + map.put(componentDto.getId(), componentDto); + } } - - public void checkLiveSystemMutationStatus(String liveSystemMutationId) throws InstantiatorException { - service.checkLiveSystemMutationStatus(getId(), liveSystemMutationId); - } - - protected Map blueprintMapFromLiveSystemComponents() { - Map map = new HashMap<>(); - for (LiveSystemComponent comp : getComponents()) { - List> listOfComponents = ReflectionUtils.buildComponents(comp); - for (var component : listOfComponents) { - LiveSystemComponentDto componentDto = toLiveSystemComponentDto(comp, component); - map.put(componentDto.getId(), componentDto); - } - } - return map; + return map; + } + + private static LiveSystemComponentDto toLiveSystemComponentDto( + LiveSystemComponent component, + Map allFields) + { + return LiveSystemComponentDto.builder() + .withFields(allFields) + .withType(String.valueOf(allFields.get(COMPONENT_TYPE))) + .withStatus(LiveSystemComponentStatusDto.Instantiating) + .withOutputFields(emptyMap()) + .withLastUpdated(new Date()) + .withProvider(component.getProvider()) + .build(); + } + + @Override + public Collection validate() { + Collection errors = new ArrayList<>(); + + if (id == null) { + errors.add(ID_IS_NULL); + return errors; } - private static LiveSystemComponentDto toLiveSystemComponentDto(LiveSystemComponent component, Map allFields) { - return LiveSystemComponentDto.builder() - .withFields(allFields) - .withType(String.valueOf(allFields.get(COMPONENT_TYPE))) - .withStatus(LiveSystemComponentStatusDto.Instantiating) - .withOutputFields(emptyMap()) - .withLastUpdated(new Date()) - .withProvider(component.getProvider()) - .build(); + if (isBlank(id.name())) { + errors.add(NAME_IS_NULL); } - - @Override - public Collection validate() { - Collection errors = new ArrayList<>(); - - if (id == null) { - errors.add(ID_IS_NULL); - return errors; - } - - if (isBlank(id.name())) { - errors.add(NAME_IS_NULL); - } - - if (id.resourceGroupId() == null) { - errors.add(RESOURCE_GROUP_ID_IS_NULL); - } - - if (provider == null) { - errors.add(PROVIDER_ID_IS_NULL); - } - - return errors; + if (id.resourceGroupId() == null) { + errors.add(RESOURCE_GROUP_ID_IS_NULL); } - public void delete() throws InstantiatorException { - ensureEnvironmentExists(environment.id(), String.format("delete LiveSystem [id: '%s']", id)); - service.deleteLiveSystem(getId().toString()); + if (provider == null) { + errors.add(PROVIDER_ID_IS_NULL); } - private void ensureEnvironmentExists(EnvironmentIdValue environmentId, String action) throws EnvironmentException, EnvironmentNotFoundException { - try { - var existingEnvironment = environmentService.tryGetById(environmentId); - if (existingEnvironment == null) { - throw new EnvironmentNotFoundException( - String.format("Unable to %s. Environment [id: '%s'] not found.", action, environmentId)); - } - } catch (EnvironmentNotFoundException e) { - throw e; - } catch (Exception e) { - throw new EnvironmentException("Failed to check environment existence", e); - } + return errors; + } + + public void delete() throws InstantiatorException { + ensureEnvironmentExists(environment.id(), String.format("delete LiveSystem [id: '%s']", id)); + service.deleteLiveSystem(getId().toString()); + } + + private void ensureEnvironmentExists( + EnvironmentIdValue environmentId, + String action) throws EnvironmentException, EnvironmentNotFoundException + { + try { + var existingEnvironment = environmentService.tryGetById(environmentId); + if (existingEnvironment == null) { + throw new EnvironmentNotFoundException( + String.format("Unable to %s. Environment [id: '%s'] not found.", action, environmentId)); + } + } catch (EnvironmentNotFoundException e) { + throw e; + } catch (Exception e) { + throw new EnvironmentException("Failed to check environment existence", e); } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemComponent.java index c9fec4a1..c87cfece 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemComponent.java @@ -3,5 +3,5 @@ import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; public interface LiveSystemComponent { - ProviderType getProvider(); + ProviderType getProvider(); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemIdValue.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemIdValue.java index 8dc41f3b..4174cf6d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemIdValue.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemIdValue.java @@ -7,7 +7,7 @@ public record LiveSystemIdValue(ResourceGroupId resourceGroupId, String name) { @NotNull @Override - public String toString(){ + public String toString() { return String.format("%s/%s", resourceGroupId.toString(), name); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemsFactory.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemsFactory.java index 25a8a81a..4f973d93 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemsFactory.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemsFactory.java @@ -1,8 +1,8 @@ package com.yanchware.fractal.sdk.domain.livesystem; import com.yanchware.fractal.sdk.configuration.SdkConfiguration; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; import com.yanchware.fractal.sdk.domain.livesystem.operationalservicewindow.OperationalServiceWindow; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import com.yanchware.fractal.sdk.utils.CollectionUtils; @@ -13,106 +13,106 @@ public class LiveSystemsFactory { - private final HttpClient client; - private final SdkConfiguration sdkConfiguration; - private final RetryRegistry retryRegistry; + private final HttpClient client; + private final SdkConfiguration sdkConfiguration; + private final RetryRegistry retryRegistry; + + public LiveSystemsFactory(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) + { + this.client = client; + this.sdkConfiguration = sdkConfiguration; + this.retryRegistry = retryRegistry; + } + + public LiveSystemBuilder builder() { + return new LiveSystemBuilder(client, sdkConfiguration, retryRegistry); + } + + public static class LiveSystemBuilder { + private final LiveSystemAggregate liveSystem; + private final LiveSystemBuilder builder; + + public LiveSystemBuilder(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) { + liveSystem = createLiveSystem(client, sdkConfiguration, retryRegistry); + builder = getBuilder(); + liveSystem.setCreated(new Date()); + } - public LiveSystemsFactory(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) + protected LiveSystemAggregate createLiveSystem( + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) { - this.client = client; - this.sdkConfiguration = sdkConfiguration; - this.retryRegistry = retryRegistry; + return new LiveSystemAggregate(client, sdkConfiguration, retryRegistry); + } + + protected LiveSystemBuilder getBuilder() { + return this; + } + + public LiveSystemBuilder withId(LiveSystemIdValue liveSystemId) { + liveSystem.setId(liveSystemId); + return builder; + } + + public LiveSystemBuilder withServiceWindow(OperationalServiceWindow serviceWindow) { + if (serviceWindow == null) { + throw new IllegalArgumentException("Service Window cannot be null"); + } + liveSystem.setOperationalServiceWindow(serviceWindow); + return builder; + } + + public LiveSystemBuilder withFractalId(FractalIdValue fractalId) { + if (fractalId == null) { + throw new IllegalArgumentException("Fractal id cannot be null or empty"); + } + liveSystem.setFractalId(fractalId); + return builder; + } + + public LiveSystemBuilder withDescription(String description) { + liveSystem.setDescription(description); + return builder; } - public LiveSystemBuilder builder() { - return new LiveSystemBuilder(client, sdkConfiguration, retryRegistry); + public LiveSystemBuilder withEnvironmentId(EnvironmentIdValue environmentId) { + liveSystem.setEnvironment(new EnvironmentReference(environmentId)); + return builder; } - public static class LiveSystemBuilder { - private final LiveSystemAggregate liveSystem; - private final LiveSystemBuilder builder; - - public LiveSystemBuilder(HttpClient client, SdkConfiguration sdkConfiguration, RetryRegistry retryRegistry) { - liveSystem = createLiveSystem(client, sdkConfiguration, retryRegistry); - builder = getBuilder(); - liveSystem.setCreated(new Date()); - } - - protected LiveSystemAggregate createLiveSystem( - HttpClient client, - SdkConfiguration sdkConfiguration, - RetryRegistry retryRegistry) - { - return new LiveSystemAggregate(client, sdkConfiguration, retryRegistry); - } - - protected LiveSystemBuilder getBuilder() { - return this; - } - - public LiveSystemBuilder withId(LiveSystemIdValue liveSystemId) { - liveSystem.setId(liveSystemId); - return builder; - } - - public LiveSystemBuilder withServiceWindow(OperationalServiceWindow serviceWindow) { - if(serviceWindow == null) { - throw new IllegalArgumentException("Service Window cannot be null"); - } - liveSystem.setOperationalServiceWindow(serviceWindow); + public LiveSystemBuilder withComponents(Collection components) { + if (CollectionUtils.isBlank(components)) { return builder; } - public LiveSystemBuilder withFractalId(FractalIdValue fractalId) { - if(fractalId == null) { - throw new IllegalArgumentException("Fractal id cannot be null or empty"); - } - liveSystem.setFractalId(fractalId); - return builder; - } - - public LiveSystemBuilder withDescription(String description) { - liveSystem.setDescription(description); - return builder; - } - - public LiveSystemBuilder withEnvironmentId(EnvironmentIdValue environmentId) { - liveSystem.setEnvironment(new EnvironmentReference(environmentId)); - return builder; - } - - public LiveSystemBuilder withComponents(Collection components) { - if (CollectionUtils.isBlank(components)) { - return builder; - } - - if (liveSystem.getComponents() == null) { - liveSystem.setComponents(new ArrayList<>()); - } - - liveSystem.getComponents().addAll(components); - return builder; - } - - public LiveSystemBuilder withComponent(LiveSystemComponent component) { - return withComponents(List.of(component)); - } - - public LiveSystemBuilder withStandardProvider(ProviderType provider) { - liveSystem.setProvider(provider); - return this; - } - - public LiveSystemAggregate build() { - Collection errors = liveSystem.validate(); - - if (!errors.isEmpty()) { - throw new IllegalArgumentException(String.format( - "LiveSystem validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); - } - - return liveSystem; - } + if (liveSystem.getComponents() == null) { + liveSystem.setComponents(new ArrayList<>()); + } + + liveSystem.getComponents().addAll(components); + return builder; + } + + public LiveSystemBuilder withComponent(LiveSystemComponent component) { + return withComponents(List.of(component)); + } + + public LiveSystemBuilder withStandardProvider(ProviderType provider) { + liveSystem.setProvider(provider); + return this; + } + + public LiveSystemAggregate build() { + Collection errors = liveSystem.validate(); + + if (!errors.isEmpty()) { + throw new IllegalArgumentException(String.format( + "LiveSystem validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); + } + + return liveSystem; } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlType.java index 25bde04e..033bad03 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlType.java @@ -20,7 +20,7 @@ public class SourceControlType extends ExtendableEnum { public static final SourceControlType TFS = fromString("Tfs"); public static final SourceControlType VSO = fromString("VSO"); public static final SourceControlType VSTSRM = fromString("VSTSRM"); - + public SourceControlType() { } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAPIGatewayImpl.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAPIGatewayImpl.java index ba550fb0..3b98be29 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAPIGatewayImpl.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAPIGatewayImpl.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSAPIGateway; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSAPIGateway; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.ToString; @@ -8,8 +8,8 @@ @ToString(callSuper = true) public abstract class CaaSAPIGatewayImpl extends CaaSAPIGateway implements LiveSystemComponent { - @Override - public ProviderType getProvider(){ - return ProviderType.CAAS; - } + @Override + public ProviderType getProvider() { + return ProviderType.CAAS; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassador.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassador.java index 350b1353..b079be5b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassador.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassador.java @@ -24,10 +24,14 @@ @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) public class CaaSAmbassador extends CaaSAPIGatewayImpl { - private final static String HOST_OWNER_EMAIL_IS_BLANK = "[CaaSAmbassador Validation] Host Owner Email has not been defined and it is required"; - private final static String ACME_PROVIDER_AUTHORITY_IS_BLANK = "[CaaSAmbassador Validation] Automated Certificate Management Environment (ACME) Provider Authority has not been defined and it is required"; - private final static String LICENSE_IS_BLANK = "[CaaSAmbassador Validation] License Key defined was either empty or blank and it is required"; - private final static String TLS_SECRET_IS_BLANK = "[CaaSAmbassador Validation] TLS Secret has not been defined and it is required"; + private final static String HOST_OWNER_EMAIL_IS_BLANK = "[CaaSAmbassador Validation] Host Owner Email has not been " + + "defined and it is required"; + private final static String ACME_PROVIDER_AUTHORITY_IS_BLANK = "[CaaSAmbassador Validation] Automated Certificate " + + "Management Environment (ACME) Provider Authority has not been defined and it is required"; + private final static String LICENSE_IS_BLANK = "[CaaSAmbassador Validation] License Key defined was either empty or" + + " blank and it is required"; + private final static String TLS_SECRET_IS_BLANK = "[CaaSAmbassador Validation] TLS Secret has not been defined and " + + "it is required"; private String host; private String hostOwnerEmail; @@ -76,7 +80,8 @@ public AmbassadorBuilder withContainerPlatform(String containerPlatform) { /** * Ambassador hostname *

    - * For more details please check Ambassador documentation + * For more details please check + * Ambassador documentation * * @param host */ @@ -88,7 +93,8 @@ public AmbassadorBuilder withHost(String host) { /** * Ambassador host owner email used for ACME TLS *

    - * For more details please check Ambassador documentation + * For more details please check + * Ambassador documentation * * @param hostOwnerEmail */ @@ -119,8 +125,9 @@ public AmbassadorBuilder withLicenseKey(String licenseKey) { /** * The name of the TLS secret that Ambassador will look for to use. - * - * For more details check Ambassador documentation + *

    + * For more details check + * Ambassador documentation * * @param tlsSecretName */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStore.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStore.java index bf175149..44ad261f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStore.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStore.java @@ -25,8 +25,10 @@ @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) public class CaaSElasticDataStore extends CaaSSearchImpl implements LiveSystemComponent { - private final static String ELASTIC_INSTANCES_NEGATIVE_OR_ZERO = "[CaaSElasticDataStore Validation] Elastic Instances defined was either 0 or negative and it needs to be greater than 0"; - private final static String VERSION_IS_BLANK = "[CaaSElasticDataStore Validation] Elastic Version has not been defined and it is required"; + private final static String ELASTIC_INSTANCES_NEGATIVE_OR_ZERO = "[CaaSElasticDataStore Validation] Elastic " + + "Instances defined was either 0 or negative and it needs to be greater than 0"; + private final static String VERSION_IS_BLANK = "[CaaSElasticDataStore Validation] Elastic Version has not been " + + "defined and it is required"; private boolean isKibanaRequired; private String elasticVersion; @@ -105,7 +107,8 @@ public ElasticDataStoreBuilder withInstances(int elasticInstances) { /** * Storage that will be used for PersistentVolumeClaim *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param storage */ @@ -119,7 +122,8 @@ public ElasticDataStoreBuilder withStorage(String storage) { *

    * Default: 'standard' *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param storageClassName */ @@ -132,7 +136,8 @@ public ElasticDataStoreBuilder withStorageClassName(String storageClassName) { * Amount of memory, in gigabytes, that will be used for requests and limits * Default: '8' *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param memory */ @@ -145,7 +150,8 @@ public ElasticDataStoreBuilder withMemory(int memory) { * CPU resources that will be used for requests and limits * Default: '8' *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param cpu */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLogging.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLogging.java index 67631de9..00f35019 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLogging.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLogging.java @@ -25,8 +25,10 @@ @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) public class CaaSElasticLogging extends CaaSLoggingImpl implements LiveSystemComponent { - private final static String ELASTIC_INSTANCES_NEGATIVE_OR_ZERO = "[CaaSElasticLogging Validation] Elastic Instances defined was either 0 or negative and it needs to be greater than 0"; - private final static String VERSION_IS_BLANK = "[CaaSElasticLogging Validation] Elastic Version has not been defined and it is required"; + private final static String ELASTIC_INSTANCES_NEGATIVE_OR_ZERO = "[CaaSElasticLogging Validation] Elastic Instances" + + " defined was either 0 or negative and it needs to be greater than 0"; + private final static String VERSION_IS_BLANK = "[CaaSElasticLogging Validation] Elastic Version has not been " + + "defined and it is required"; private boolean isApmRequired; private boolean isKibanaRequired; @@ -77,7 +79,8 @@ public ElasticLoggingBuilder withNamespace(String namespace) { /** * If true, APM will be instantiated part of the elastic logging solution *

    - * For more details check APM documentation + * For more details check + * APM documentation * * @param isApmRequired */ @@ -122,7 +125,8 @@ public ElasticLoggingBuilder withInstances(int elasticInstances) { /** * Storage that will be used for PersistentVolumeClaim *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param storage */ @@ -136,7 +140,8 @@ public ElasticLoggingBuilder withStorage(String storage) { *

    * Default: 'standard' *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param storageClassName */ @@ -149,7 +154,8 @@ public ElasticLoggingBuilder withStorageClassName(String storageClassName) { * Amount of memory, in gigabytes, that will be used for requests and limits * Default: '8' *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param memory */ @@ -162,7 +168,8 @@ public ElasticLoggingBuilder withMemory(int memory) { * CPU resources that will be used for requests and limits * Default: '8' *

    - * For more details check Elastic documentation + * For more details check + * Elastic documentation * * @param cpu */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesWorkload.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesWorkload.java index b075fd11..4937e8a1 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesWorkload.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesWorkload.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSWorkload; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsRecord; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSWorkload; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsRecord; import com.yanchware.fractal.sdk.domain.livesystem.CustomWorkload; import com.yanchware.fractal.sdk.domain.livesystem.CustomWorkloadBuilder; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; @@ -19,164 +19,165 @@ @Setter @ToString(callSuper = true) public class CaaSKubernetesWorkload extends CaaSWorkload implements LiveSystemComponent, CustomWorkload { - private String privateSSHKeyPassphraseEnvironmentSecretShortName; - private String privateSSHKeyEnvironmentSecretShortName; - private String sshRepositoryURI; - private String repoId; - private String branchName; - private List roles; - private String workloadSecretIdKey; - private String workloadSecretPasswordKey; - private String serviceAccountName; - private Boolean workloadIdentityEnabled; - private List environmentSecretShortNames; - private String ciCdProfileShortName; + private String privateSSHKeyPassphraseEnvironmentSecretShortName; + private String privateSSHKeyEnvironmentSecretShortName; + private String sshRepositoryURI; + private String repoId; + private String branchName; + private List roles; + private String workloadSecretIdKey; + private String workloadSecretPasswordKey; + private String serviceAccountName; + private Boolean workloadIdentityEnabled; + private List environmentSecretShortNames; + private String ciCdProfileShortName; + + @Override + public ProviderType getProvider() { + return ProviderType.CAAS; + } + + protected CaaSKubernetesWorkload() { + + roles = new ArrayList<>(); + this.setRecreateOnFailure(true); + } + + @Override + public Collection validate() { + Collection errors = super.validate(); + errors.addAll(CustomWorkload.validateCustomWorkload(this, "Kubernetes Workload")); + return errors; + } + + public static KubernetesWorkloadBuilder builder() { + return new KubernetesWorkloadBuilder(); + } + + + public static class KubernetesWorkloadBuilder extends CustomWorkloadBuilder { @Override - public ProviderType getProvider(){ - return ProviderType.CAAS; - } - - protected CaaSKubernetesWorkload() { - - roles = new ArrayList<>(); - this.setRecreateOnFailure(true); + protected CaaSKubernetesWorkload createComponent() { + return new CaaSKubernetesWorkload(); } @Override - public Collection validate() { - Collection errors = super.validate(); - errors.addAll(CustomWorkload.validateCustomWorkload(this, "Kubernetes Workload")); - return errors; + protected KubernetesWorkloadBuilder getBuilder() { + return this; } - public static KubernetesWorkloadBuilder builder() { - return new KubernetesWorkloadBuilder(); + /** + *

    +     * Sets the namespace where the workload will be instantiated.
    +     * 
    + * + * @param namespace The namespace for the workload. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withNamespace(String namespace) { + component.setNamespace(namespace); + return builder; } + /** + *
    +     * Sets the ID of the container platform where the workload will be instantiated.
    +     * 
    + * + * @param containerPlatform The ID of the container platform. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withContainerPlatform(String containerPlatform) { + component.setContainerPlatform(containerPlatform); + return builder; + } - public static class KubernetesWorkloadBuilder extends CustomWorkloadBuilder { - - @Override - protected CaaSKubernetesWorkload createComponent() { - return new CaaSKubernetesWorkload(); - } - - @Override - protected KubernetesWorkloadBuilder getBuilder() { - return this; - } - - /** - *
    -         * Sets the namespace where the workload will be instantiated.
    -         * 
    - * - * @param namespace The namespace for the workload. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withNamespace(String namespace) { - component.setNamespace(namespace); - return builder; - } - - /** - *
    -         * Sets the ID of the container platform where the workload will be instantiated.
    -         * 
    - * - * @param containerPlatform The ID of the container platform. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withContainerPlatform(String containerPlatform) { - component.setContainerPlatform(containerPlatform); - return builder; - } + /** + * Adds a DNS zone configuration with a single DNS record. + * + * @param dnsZoneName The name of the DNS zone. + * @param dnsRecord The DNS record to add. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withDnsZoneConfig(String dnsZoneName, DnsRecord dnsRecord) { + if (component.getDnsZoneConfig() == null) { + component.setDnsZoneConfig(new HashMap<>()); + } + + if (!component.getDnsZoneConfig().containsKey(dnsZoneName)) { + component.getDnsZoneConfig().put(dnsZoneName, new ArrayList<>()); + } + + component.getDnsZoneConfig().get(dnsZoneName).add(SerializationUtils.convertValueToMap(dnsRecord)); + + return builder; + } - /** - * Adds a DNS zone configuration with a single DNS record. - * - * @param dnsZoneName The name of the DNS zone. - * @param dnsRecord The DNS record to add. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withDnsZoneConfig(String dnsZoneName, DnsRecord dnsRecord) { - if (component.getDnsZoneConfig() == null) { - component.setDnsZoneConfig(new HashMap<>()); - } - - if (!component.getDnsZoneConfig().containsKey(dnsZoneName)) { - component.getDnsZoneConfig().put(dnsZoneName, new ArrayList<>()); - } - - component.getDnsZoneConfig().get(dnsZoneName).add(SerializationUtils.convertValueToMap(dnsRecord)); - - return builder; - } + /** + * Adds a DNS zone configuration with a collection of DNS records. + * + * @param dnsZoneName The name of the DNS zone. + * @param dnsRecords The collection of DNS records to add. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withDnsZoneConfig(String dnsZoneName, Collection dnsRecords) { + dnsRecords.forEach(dnsRecord -> withDnsZoneConfig(dnsZoneName, dnsRecord)); + return builder; + } - /** - * Adds a DNS zone configuration with a collection of DNS records. - * - * @param dnsZoneName The name of the DNS zone. - * @param dnsRecords The collection of DNS records to add. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withDnsZoneConfig(String dnsZoneName, Collection dnsRecords) { - dnsRecords.forEach(dnsRecord -> withDnsZoneConfig(dnsZoneName, dnsRecord)); - return builder; + /** + * Adds DNS zone configurations from a map of DNS zone names to collections of DNS records. + * + * @param dnsRecordsMap The map of DNS zone configurations. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withDnsZoneConfig(Map> dnsRecordsMap) { + if (dnsRecordsMap == null || dnsRecordsMap.isEmpty()) { + return builder; + } + + dnsRecordsMap.forEach((key, value) -> { + for (var dnsRecord : value) { + withDnsZoneConfig(key, dnsRecord); } + }); - /** - * Adds DNS zone configurations from a map of DNS zone names to collections of DNS records. - * - * @param dnsRecordsMap The map of DNS zone configurations. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withDnsZoneConfig(Map> dnsRecordsMap) { - if (dnsRecordsMap == null || dnsRecordsMap.isEmpty()) { - return builder; - } - - dnsRecordsMap.forEach((key, value) -> { - for (var dnsRecord : value) { - withDnsZoneConfig(key, dnsRecord); - } - }); - - return builder; - } + return builder; + } - /** - *
    -         * Sets the ServiceAccount name for the Kubernetes workload. 
    -         * This name is crucial for configuring workload identity by linking the Kubernetes ServiceAccount 
    -         * to Azure User Managed Identity.
    - * - * @param serviceAccountName The name of the ServiceAccount. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withServiceAccountName(String serviceAccountName) { - component.setServiceAccountName(serviceAccountName); - return builder; - } + /** + *
    +     * Sets the ServiceAccount name for the Kubernetes workload.
    +     * This name is crucial for configuring workload identity by linking the Kubernetes ServiceAccount
    +     * to Azure User Managed Identity.
    + * + * @param serviceAccountName The name of the ServiceAccount. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withServiceAccountName(String serviceAccountName) { + component.setServiceAccountName(serviceAccountName); + return builder; + } - /** - *
    -         * Enables or disables the Workload Identity for the Kubernetes workload.
    -         * By default, Fractal Cloud Agent sets this to true.
    - * - * @param workloadIdentityEnabled A boolean flag to enable or disable Workload Identity. - * @return The builder instance. - */ - public KubernetesWorkloadBuilder withWorkloadIdentityEnabled(boolean workloadIdentityEnabled) { - component.setWorkloadIdentityEnabled(workloadIdentityEnabled); - return builder; - } + /** + *
    +     * Enables or disables the Workload Identity for the Kubernetes workload.
    +     * By default, Fractal Cloud Agent sets this to true.
    + * + * @param workloadIdentityEnabled A boolean flag to enable or disable Workload Identity. + * @return The builder instance. + */ + public KubernetesWorkloadBuilder withWorkloadIdentityEnabled(boolean workloadIdentityEnabled) { + component.setWorkloadIdentityEnabled(workloadIdentityEnabled); + return builder; + } - @Override - public CaaSKubernetesWorkload build() { - component.setType(CAAS_K8S_WORKLOAD); - return super.build(); - } + @Override + public CaaSKubernetesWorkload build() { + component.setType(CAAS_K8S_WORKLOAD); + return super.build(); } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSLoggingImpl.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSLoggingImpl.java index e2dde304..318ea269 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSLoggingImpl.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSLoggingImpl.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSLogging; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSLogging; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.AccessLevel; @@ -17,28 +17,28 @@ @ToString(callSuper = true) public abstract class CaaSLoggingImpl extends CaaSLogging implements LiveSystemComponent { - private String storage; - private String storageClassName; - private int memory; - private int cpu; + private String storage; + private String storageClassName; + private int memory; + private int cpu; - @Override - public ProviderType getProvider(){ - return ProviderType.CAAS; - } - - @Override - public Collection validate() { - Collection errors = super.validate(); + @Override + public ProviderType getProvider() { + return ProviderType.CAAS; + } - if (isBlank(storage)) { - errors.add(getStorageIsBlankErrorMessage()); - } + @Override + public Collection validate() { + Collection errors = super.validate(); - return errors; + if (isBlank(storage)) { + errors.add(getStorageIsBlankErrorMessage()); } - private String getStorageIsBlankErrorMessage() { - return String.format("[%s Validation] Storage has not been defined and it is required", this.getClass().getName()); - } + return errors; + } + + private String getStorageIsBlankErrorMessage() { + return String.format("[%s Validation] Storage has not been defined and it is required", this.getClass().getName()); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSMonitoringImpl.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSMonitoringImpl.java index 5dfdd45a..22a5a3a0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSMonitoringImpl.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSMonitoringImpl.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSMonitoring; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSMonitoring; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.ToString; @@ -10,13 +10,13 @@ @ToString(callSuper = true) public abstract class CaaSMonitoringImpl extends CaaSMonitoring implements LiveSystemComponent { - @Override - public ProviderType getProvider(){ - return ProviderType.CAAS; - } + @Override + public ProviderType getProvider() { + return ProviderType.CAAS; + } - @Override - public Collection validate() { - return super.validate(); - } + @Override + public Collection validate() { + return super.validate(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheus.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheus.java index 56f4bfef..2c9d7f0a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheus.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheus.java @@ -63,7 +63,8 @@ public PrometheusBuilder withContainerPlatform(String containerPlatform) { } /** - * If specified, Prometheus will be made available at the URL specified below. For example, if the parameter is set to + * If specified, Prometheus will be made available at the URL specified below. For example, if the parameter is + * set to * api.yourdomain.com, then Prometheus can be accessed at api.yourdomain.com/prometheus. *

    * This applies for all components available (Kibana, Grafana, Alert Manager) @@ -84,6 +85,6 @@ public CaaSPrometheus build() { @Override public Collection validate() { - return super.validate(); + return super.validate(); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSSearchImpl.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSSearchImpl.java index 50da69d9..6339ee4b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSSearchImpl.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSSearchImpl.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSSearch; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSSearch; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.AccessLevel; @@ -16,28 +16,28 @@ @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public abstract class CaaSSearchImpl extends CaaSSearch implements LiveSystemComponent { - private String storage; - private String storageClassName; - private Integer memory; - private Integer cpu; - - @Override - public ProviderType getProvider(){ - return ProviderType.CAAS; + private String storage; + private String storageClassName; + private Integer memory; + private Integer cpu; + + @Override + public ProviderType getProvider() { + return ProviderType.CAAS; + } + + @Override + public Collection validate() { + Collection errors = super.validate(); + + if (isBlank(storage)) { + errors.add(getStorageIsBlankErrorMessage()); } - @Override - public Collection validate() { - Collection errors = super.validate(); + return errors; + } - if (isBlank(storage)) { - errors.add(getStorageIsBlankErrorMessage()); - } - - return errors; - } - - private String getStorageIsBlankErrorMessage() { - return String.format("[%s Validation] Storage has not been defined and it is required", this.getClass().getName()); - } + private String getStorageIsBlankErrorMessage() { + return String.format("[%s Validation] Storage has not been defined and it is required", this.getClass().getName()); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSServiceMeshSecurityImpl.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSServiceMeshSecurityImpl.java index 04fb367f..4c3c746b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSServiceMeshSecurityImpl.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSServiceMeshSecurityImpl.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.caas.CaaSServiceMeshSecurity; +import com.yanchware.fractal.sdk.domain.fractal.caas.CaaSServiceMeshSecurity; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.AccessLevel; @@ -17,36 +17,39 @@ @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public abstract class CaaSServiceMeshSecurityImpl extends CaaSServiceMeshSecurity implements LiveSystemComponent { - private final static String HOST_IS_NULL_OR_EMPTY = "[CaaSServiceMeshSecurity Validation] Host has not been defined and it is required"; - private final static String HOST_OWNER_EMAIL_IS_NULL_OR_EMPTY = "[CaaSServiceMeshSecurity Validation] Host Owner Email has not been defined and it is required"; - private final static String COOKIE_MAX_AGE_IS_NULL_OR_EMPTY = "[CaaSServiceMeshSecurity Validation] Cookie max age has not been defined or is less than or equal to 0 and must be a positive number (in seconds)"; - - private String host; - private String hostOwnerEmail; - private List corsOrigins; - private int cookieMaxAgeSec; - private String pathPrefix; - - @Override - public ProviderType getProvider(){ - return ProviderType.CAAS; + private final static String HOST_IS_NULL_OR_EMPTY = "[CaaSServiceMeshSecurity Validation] Host has not been defined" + + " and it is required"; + private final static String HOST_OWNER_EMAIL_IS_NULL_OR_EMPTY = "[CaaSServiceMeshSecurity Validation] Host Owner " + + "Email has not been defined and it is required"; + private final static String COOKIE_MAX_AGE_IS_NULL_OR_EMPTY = "[CaaSServiceMeshSecurity Validation] Cookie max age " + + "has not been defined or is less than or equal to 0 and must be a positive number (in seconds)"; + + private String host; + private String hostOwnerEmail; + private List corsOrigins; + private int cookieMaxAgeSec; + private String pathPrefix; + + @Override + public ProviderType getProvider() { + return ProviderType.CAAS; + } + + @Override + public Collection validate() { + Collection errors = super.validate(); + + if (isBlank(host)) { + errors.add(HOST_IS_NULL_OR_EMPTY); } - @Override - public Collection validate() { - Collection errors = super.validate(); - - if (isBlank(host)) { - errors.add(HOST_IS_NULL_OR_EMPTY); - } - - if (isBlank(hostOwnerEmail)) { - errors.add(HOST_OWNER_EMAIL_IS_NULL_OR_EMPTY); - } + if (isBlank(hostOwnerEmail)) { + errors.add(HOST_OWNER_EMAIL_IS_NULL_OR_EMPTY); + } - if (cookieMaxAgeSec <= 0) { - errors.add(COOKIE_MAX_AGE_IS_NULL_OR_EMPTY); - } - return errors; + if (cookieMaxAgeSec <= 0) { + errors.add(COOKIE_MAX_AGE_IS_NULL_OR_EMPTY); } + return errors; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefik.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefik.java index 4666931e..b7c3639f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefik.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefik.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.caas; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsRecord; import com.yanchware.fractal.sdk.utils.CollectionUtils; import com.yanchware.fractal.sdk.utils.SerializationUtils; import lombok.AccessLevel; @@ -17,7 +17,8 @@ @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) public class CaaSTraefik extends CaaSAPIGatewayImpl { - private final static String OIDC_IS_PARTIAL = "[CaaSTraefik Validation] OIDC has been partially configured. You must provide all required values or none of them"; + private final static String OIDC_IS_PARTIAL = "[CaaSTraefik Validation] OIDC has been partially configured. You " + + "must provide all required values or none of them"; private final static String NO_ENTRY_POINTS = "[CaaSTraefik Validation] Traefik should have at least one entrypoint"; private final static String NO_HOSTNAME = "[CaaSTraefik Validation] Traefik should have a hostname"; @@ -138,7 +139,8 @@ public TraefikBuilder withEntryPoint(TraefikEntryPoint entryPoint) { /** * Configures Traefik's forward authentication settings. - * For more details check Traefik documentation + * For more details check + * Traefik documentation * * @param forwardAuthSettings settings for forward authentication. * @return the current builder instance @@ -248,16 +250,16 @@ public Collection validate() { private boolean allBlank() { return isBlank(oidcIssuerUrl) - && isBlank(oidcClientId) - && isBlank(oidcClientSecretId) - && isBlank(forwardAuthSecretId); + && isBlank(oidcClientId) + && isBlank(oidcClientSecretId) + && isBlank(forwardAuthSecretId); } private boolean allDefined() { return !isBlank(oidcIssuerUrl) - && !isBlank(oidcClientId) - && !isBlank(oidcClientSecretId) - && !isBlank(forwardAuthSecretId); + && !isBlank(oidcClientId) + && !isBlank(oidcClientSecretId) + && !isBlank(forwardAuthSecretId); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResources.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResources.java index 4e956815..f124c9d7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResources.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResources.java @@ -20,11 +20,11 @@ public class ContainerResources implements Validatable { protected ContainerResources() { } - + public static ContainerResourcesBuilder builder() { return new ContainerResourcesBuilder(); } - + public static class ContainerResourcesBuilder { private final ContainerResources resources; private final ContainerResourcesBuilder builder; @@ -38,8 +38,9 @@ public ContainerResourcesBuilder() { *

          * Sets the CPU resource request or limit for the container.
          * This value can be specified in CPU units, where 1000m represents 1 CPU core.
    -     * 
    +     *
          * For example, "250m" represents a quarter of a CPU core.
    + * * @param cpu The amount of CPU to request or limit */ public ContainerResourcesBuilder withCpu(String cpu) { @@ -50,19 +51,20 @@ public ContainerResourcesBuilder withCpu(String cpu) { /** *
          * Sets the memory resource request or limit for the container. Memory can be specified in bytes or using
    -     * suffixes to denote fixed-point numbers. Supported decimal unit suffixes include E, P, T, G, M, k, and 
    +     * suffixes to denote fixed-point numbers. Supported decimal unit suffixes include E, P, T, G, M, k, and
          * their power-of-two equivalents are Ei, Pi, Ti, Gi, Mi, Ki. It's crucial to use the correct suffix to accurately
          * specify memory requirements.
          *
    -     * For example, "64Mi" (64 Mebibytes) and "1Gi" (1 Gibibyte) use binary suffixes, while "500M" (500 Megabytes) 
    -     * uses a decimal suffix. The case of the suffix is significant and directly impacts the allocated resources. 
    -     * For instance, specifying "400m" would request 0.4 bytes, likely a mistake for "400Mi" (400 Mebibytes) or 
    +     * For example, "64Mi" (64 Mebibytes) and "1Gi" (1 Gibibyte) use binary suffixes, while "500M" (500 Megabytes)
    +     * uses a decimal suffix. The case of the suffix is significant and directly impacts the allocated resources.
    +     * For instance, specifying "400m" would request 0.4 bytes, likely a mistake for "400Mi" (400 Mebibytes) or
          * "400M" (400 Megabytes). This distinction is vital to ensure resources are requested as intended.
          *
    -     * Be mindful of the suffix case to avoid common pitfalls: 'M' denotes Megabytes, while 'Mi' denotes Mebibytes. 
    +     * Be mindful of the suffix case to avoid common pitfalls: 'M' denotes Megabytes, while 'Mi' denotes Mebibytes.
          * A lowercase 'm' is not valid for memory specifications and could lead to configuration errors.
    + * * @param memory The amount of memory to request or limit, specified as a plain integer or as a fixed-point - * number with one of the supported suffixes. + * number with one of the supported suffixes. */ public ContainerResourcesBuilder withMemory(String memory) { resources.setMemory(memory); @@ -74,9 +76,9 @@ public ContainerResources build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("ContainerResources validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } - + return resources; } } @@ -89,7 +91,7 @@ public Collection validate() { if (!cpu.matches("\\d+[A-Za-z]|\\d+\\.\\d+|\\d+")) { errors.add("CPU quantity is not in a valid format"); } - + if (cpu.endsWith("m")) { int value = Integer.parseInt(cpu.substring(0, cpu.length() - 1)); if (value < 1) { @@ -102,18 +104,19 @@ public Collection validate() { } } } - - if(isNotBlank(memory)) { + + if (isNotBlank(memory)) { if (!memory.matches("\\d+(\\.\\d+)?[EPTGMk]?i?|\\d+")) { errors.add("Memory quantity is not in a valid format"); } // Specific check for the incorrect 'm' suffix usage if (memory.toLowerCase().endsWith("m")) { - errors.add("The 'm' suffix is not valid for memory quantities. Did you mean 'Mi' for mebibytes or 'M' for megabytes?"); + errors.add("The 'm' suffix is not valid for memory quantities. Did you mean 'Mi' for mebibytes or 'M' for " + + "megabytes?"); } } - + return errors; } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/JaegerTracing.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/JaegerTracing.java index 25c48c16..081b164b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/JaegerTracing.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/JaegerTracing.java @@ -32,7 +32,7 @@ public JaegerTracingBuilder withCollectorEndpoint(String collectorEndpoint) { jaeger.collectorEndpoint = collectorEndpoint; return builder; } - + public JaegerTracingBuilder withLocalAgentPort(Integer localAgentPort) { jaeger.localAgentPort = localAgentPort; @@ -49,7 +49,7 @@ public JaegerTracing build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("JaegerTracingBuilder validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return jaeger; @@ -71,7 +71,7 @@ public Collection validate() { if (localAgentUrlPath == null || localAgentUrlPath.isEmpty()) { errors.add("localAgentUrlPath must be defined"); } - + if (localAgentPort == null) { errors.add("localAgentPort must be defined"); } else if (localAgentPort < 1 || localAgentPort > 65535) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/PriorityClass.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/PriorityClass.java index 3a338512..6c19a8d1 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/PriorityClass.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/PriorityClass.java @@ -12,7 +12,8 @@ @Getter @Setter(AccessLevel.PRIVATE) public class PriorityClass implements Validatable { - private final static String VALUE_IS_NOT_ALLOWED = "[PriorityClass Validation] Value must be between 1 and 1_000_000_000"; + private final static String VALUE_IS_NOT_ALLOWED = "[PriorityClass Validation] Value must be between 1 and " + + "1_000_000_000"; private String name; private String description; @@ -57,7 +58,7 @@ public PriorityClass build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("PriorityClass validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return priorityClass; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagement.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagement.java index b19cfff7..47474595 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagement.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagement.java @@ -31,12 +31,12 @@ public ResourceManagementBuilder() { *
          * Specifies the resource requests for a container.
    * - * @important.note If you choose to customize these values, please be aware that Fractal Cloud cannot guarantee the functionality of the deployment. - *
    You bear full responsibility for ensuring the correctness of your configuration. - *
    Misconfiguration can lead to application failures or resource allocation issues. - *
    Be mindful of the suffix case and the units of measurement to avoid common pitfalls.
    - * * @param requests The desired resource requests for the container, including CPU and memory specifications. + * @important.note If you choose to customize these values, please be aware that Fractal Cloud cannot + * guarantee the functionality of the deployment. + *
    You bear full responsibility for ensuring the correctness of your configuration. + *
    Misconfiguration can lead to application failures or resource allocation issues. + *
    Be mindful of the suffix case and the units of measurement to avoid common pitfalls.
    */ public ResourceManagementBuilder withRequests(ContainerResources requests) { resourceManagement.setRequests(requests); @@ -46,13 +46,13 @@ public ResourceManagementBuilder withRequests(ContainerResources requests) { /** *
          * Specifies the resource limits for a container.
    - * - * @important.note If you choose to customize these values, please be aware that Fractal Cloud cannot guarantee the functionality of the deployment. - *
    You bear full responsibility for ensuring the correctness of your configuration. - *
    Misconfiguration can lead to application failures or resource allocation issues. - *
    Be mindful of the suffix case and the units of measurement to avoid common pitfalls.
    - * + * * @param limits The desired resource limits for the container, including CPU and memory specifications. + * @important.note If you choose to customize these values, please be aware that Fractal Cloud cannot + * guarantee the functionality of the deployment. + *
    You bear full responsibility for ensuring the correctness of your configuration. + *
    Misconfiguration can lead to application failures or resource allocation issues. + *
    Be mindful of the suffix case and the units of measurement to avoid common pitfalls.
    */ public ResourceManagementBuilder withLimits(ContainerResources limits) { resourceManagement.setLimits(limits); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TaintEffect.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TaintEffect.java index d556fb23..b9e14e01 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TaintEffect.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TaintEffect.java @@ -12,12 +12,12 @@ * Taints are a mechanism in Kubernetes used to evict pods from nodes. If a pod does not tolerate a taint, * the effect of the taint determines what happens to the pod on that node. * - * + * * The effects include: * - NoSchedule: Pods that do not tolerate this effect are not scheduled on the node. * - PreferNoSchedule: The scheduler tries to avoid scheduling pods that do not tolerate this effect on the node, * but it is not a strict requirement. - * - NoExecute: Pods that are already running on the node and do not tolerate this effect are evicted. + * - NoExecute: Pods that are already running on the node and do not tolerate this effect are evicted. * New pods that do not tolerate this effect are not scheduled on the node. *
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/Toleration.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/Toleration.java index fb0c6716..5e99d361 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/Toleration.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/Toleration.java @@ -34,7 +34,7 @@ public Collection validate() { if (isBlank(key)) { errors.add("The key must be provided for a toleration"); } - + if (effect == null) { errors.add("The effect must be provided for a toleration"); } @@ -42,13 +42,13 @@ public Collection validate() { if (operator == null) { errors.add("The operator must be provided for a toleration"); } - - if(operator != null) { + + if (operator != null) { if (TolerationOperator.EQUAL.equals(operator) && isBlank(value)) { errors.add("A value must be provided when the operator is 'Equal'"); } } - + return errors; } @@ -63,7 +63,7 @@ public TolerationBuilder() { /** *
    -     * Sets the key for the toleration. 
    +     * Sets the key for the toleration.
          * The key corresponds to the taint key that this toleration is meant to match.
    * * @param key The label key of the taint to tolerate. @@ -75,7 +75,7 @@ public TolerationBuilder withKey(String key) { /** *
    -     * Sets the operator for the toleration. 
    +     * Sets the operator for the toleration.
          * The operator defines how to match the taint's value.
          * Use TolerationOperator.EQUAL for exact matches or TolerationOperator.EXISTS to ignore the taint's value.
    * @@ -88,7 +88,7 @@ public TolerationBuilder withOperator(TolerationOperator operator) { /** *
    -     * Sets the value for the toleration. 
    +     * Sets the value for the toleration.
          * This is the value that the taint must have if the operator is TolerationOperator.EQUAL.
    * * @param value The value that must match the taint's value. @@ -100,8 +100,8 @@ public TolerationBuilder withValue(String value) { /** *
    -     * Sets the effect for the toleration. 
    -     * The effect specifies what happens to a pod if it does not tolerate the taint. 
    +     * Sets the effect for the toleration.
    +     * The effect specifies what happens to a pod if it does not tolerate the taint.
          * Common effects include NoSchedule, PreferNoSchedule, and NoExecute.
    * * @param effect The effect of the taint that the pod should tolerate. @@ -110,14 +110,14 @@ public TolerationBuilder withEffect(TaintEffect effect) { toleration.setEffect(effect); return builder; } - + public Toleration build() { var errors = toleration.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("Toleration validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return toleration; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationOperator.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationOperator.java index 886055db..dd3ed6c7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationOperator.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationOperator.java @@ -7,7 +7,7 @@ /** *
    - * Represents the set of valid operators used in Kubernetes tolerations. 
    + * Represents the set of valid operators used in Kubernetes tolerations.
      * A toleration operator determines how the toleration matches taints on nodes.
      *
      * - EQUAL: Specifies that the toleration matches taints with the same key and effect, and exactly the same value.
    @@ -17,7 +17,7 @@
     public final class TolerationOperator extends ExtendableEnum {
       public static final TolerationOperator EQUAL = fromString("Equal");
       public static final TolerationOperator EXISTS = fromString("Exists");
    -  
    +
     
       /**
        * Creates or finds a TolerationOperator from its string representation.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TraefikTracing.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TraefikTracing.java
    index 88729955..e463eb2a 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TraefikTracing.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TraefikTracing.java
    @@ -34,7 +34,7 @@ public TraefikTracing build() {
     
           if (!errors.isEmpty()) {
             throw new IllegalArgumentException(String.format("TraefikTracingBuilder validation failed. Errors: %s",
    -            Arrays.toString(errors.toArray())));
    +          Arrays.toString(errors.toArray())));
           }
     
           return tracing;
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Blackout.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Blackout.java
    index 0bee3cf9..0689bbb3 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Blackout.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Blackout.java
    @@ -9,14 +9,17 @@
      * The start time is inclusive, while the end time is exclusive.
      *
      * @param start the start time of the blackout period, inclusive; must not be {@code null}
    - * @param end the end time of the blackout period, exclusive; must not be {@code null};
    - *            must be strictly after {@code start}
    + * @param end   the end time of the blackout period, exclusive; must not be {@code null};
    + *              must be strictly after {@code start}
      * @throws IllegalArgumentException if {@code end} is not after {@code start}
      */
     public record Blackout(ZonedDateTime start, ZonedDateTime end) {
       public Blackout {
    -    if (!end.isAfter(start)) throw new IllegalArgumentException("Blackout end must be after start");
    +    if (!end.isAfter(start)) {
    +      throw new IllegalArgumentException("Blackout end must be after start");
    +    }
       }
    +
       boolean overlaps(Window w) {
         return !(w.end().isBefore(start) || w.start().isAfter(end));
       }
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OneOffRule.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OneOffRule.java
    index 2e0ee533..dda49c92 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OneOffRule.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OneOffRule.java
    @@ -27,10 +27,10 @@ public class OneOffRule implements Rule {
        * Constructs a new instance of {@code OneOffRule} that defines a single operational
        * service window for a specific date and time range.
        *
    -   * @param date the specific date for the one-off rule; must not be {@code null}
    +   * @param date  the specific date for the one-off rule; must not be {@code null}
        * @param start the start time of the service window on the specified date; must not be {@code null}
    -   * @param end the end time of the service window on the specified date; must not be {@code null}
    -   *            (if {@code end} is earlier than or equal to {@code start}, the window rolls over into the next day)
    +   * @param end   the end time of the service window on the specified date; must not be {@code null}
    +   *              (if {@code end} is earlier than or equal to {@code start}, the window rolls over into the next day)
        */
       public OneOffRule(LocalDate date, LocalTime start, LocalTime end) {
         this.date = Objects.requireNonNull(date);
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OperationalServiceWindow.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OperationalServiceWindow.java
    index d6f42d26..7fe9bcbd 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OperationalServiceWindow.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/OperationalServiceWindow.java
    @@ -113,7 +113,8 @@ public Optional currentWindow(ZonedDateTime zonedDateTime) {
       }
     
       /**
    -   * Searches for the next available operational service window starting after the given instant and within the specified search horizon.
    +   * Searches for the next available operational service window starting after the given instant and within the
    +   * specified search horizon.
        * 

    * The search is conducted in the configured time zone of the service window, considering any applicable blackouts, * active periods, and exclusions defined in the rules of the operational service window. @@ -162,7 +163,8 @@ public Stream windowsBetween(Instant fromIncl, Instant toExcl) { * * @param fromIncl the inclusive start of the time range to evaluate, represented as a {@code ZonedDateTime} * @param toExcl the exclusive end of the time range to evaluate, represented as a {@code ZonedDateTime} - * @return a {@code Stream} containing the resulting operational service windows that match the specified criteria + * @return a {@code Stream} containing the resulting operational service windows that match the specified + * criteria */ public Stream windowsBetween(ZonedDateTime fromIncl, ZonedDateTime toExcl) { // Respect active range diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Rule.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Rule.java index 213ed31f..c7a2de51 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Rule.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/Rule.java @@ -25,10 +25,10 @@ public interface Rule { * the given range, adhering to the scheduling logic of the implemented rule. * * @param fromIncl the start of the range, inclusive; must not be {@code null} - * @param toExcl the end of the range, exclusive; must not be {@code null} - * @param zone the time zone in which the windows should be calculated; must not be {@code null} + * @param toExcl the end of the range, exclusive; must not be {@code null} + * @param zone the time zone in which the windows should be calculated; must not be {@code null} * @return a stream of {@code Window} objects representing the enumerated time intervals - * within the specified range; an empty stream is returned if no intervals match + * within the specified range; an empty stream is returned if no intervals match */ Stream enumerate(ZonedDateTime fromIncl, ZonedDateTime toExcl, ZoneId zone); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/WeeklyRule.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/WeeklyRule.java index d81fa349..c2d6c01d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/WeeklyRule.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/operationalservicewindow/WeeklyRule.java @@ -34,11 +34,11 @@ public class WeeklyRule implements Rule { * the duration of each interval. The end time can roll over into the next day if it is earlier than or equal * to the start time. * - * @param days the days of the week when the rule applies; must not be empty + * @param days the days of the week when the rule applies; must not be empty * @param start the start time of the interval; must not be {@code null} - * @param end the end time of the interval; must not be {@code null} + * @param end the end time of the interval; must not be {@code null} * @throws IllegalArgumentException if {@code days} is empty - * @throws NullPointerException if {@code start} or {@code end} is {@code null} + * @throws NullPointerException if {@code start} or {@code end} is {@code null} */ public WeeklyRule(EnumSet days, LocalTime start, LocalTime end) { if (days.isEmpty()) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/KubernetesCluster.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/KubernetesCluster.java index 1fd6d519..d5921b35 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/KubernetesCluster.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/KubernetesCluster.java @@ -1,8 +1,8 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.caas.*; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSContainerPlatform; +import com.yanchware.fractal.sdk.domain.fractal.caas.*; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSContainerPlatform; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.caas.*; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; @@ -21,20 +21,22 @@ /** *

    - * Builder class to represent a Kubernetes cluster. + * Builder class to represent a Kubernetes cluster. *

    *
    *

    - * For more details about creating a Kubernetes cluster using Fractal Cloud check out - * our documentation page + * For more details about creating a Kubernetes cluster using Fractal Cloud check out + * our documentation page *

    */ @Getter @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public abstract class KubernetesCluster extends PaaSContainerPlatform implements LiveSystemComponent { - private final static String SERVICE_IP_RANGE_NOT_VALID = "[KubernetesCluster Validation] Service IP Range does not contain a valid ip with mask"; - private final static String POD_RANGE_NOT_VALID = "[KubernetesCluster Validation] Pod IP Range does not contain a valid ip with mask"; + private final static String SERVICE_IP_RANGE_NOT_VALID = "[KubernetesCluster Validation] Service IP Range does not " + + "contain a valid ip with mask"; + private final static String POD_RANGE_NOT_VALID = "[KubernetesCluster Validation] Pod IP Range does not contain a " + + "valid ip with mask"; private String serviceIpRange; private String podIpRange; @@ -233,7 +235,7 @@ public B withWorkloadIdentityEnabled(boolean workloadIdentityEnabled) { @Override public T build() { component.setType(PAAS_KUBERNETES); - + return super.build(); } @@ -247,37 +249,41 @@ public Collection validate() { isPresentAndValidIpRange(podIpRange, errors, POD_RANGE_NOT_VALID); priorityClasses.stream() - .map(PriorityClass::validate) - .forEach(errors::addAll); + .map(PriorityClass::validate) + .forEach(errors::addAll); k8sWorkloadInstances.stream() - .map(CaaSWorkload::validate) - .forEach(errors::addAll); + .map(CaaSWorkload::validate) + .forEach(errors::addAll); monitoringInstances.stream() - .map(CaaSMonitoring::validate) - .forEach(errors::addAll); + .map(CaaSMonitoring::validate) + .forEach(errors::addAll); apiGatewayInstances.stream() - .map(CaaSAPIGateway::validate) - .forEach(errors::addAll); + .map(CaaSAPIGateway::validate) + .forEach(errors::addAll); serviceMeshSecurityInstances.stream() - .map(CaaSServiceMeshSecurity::validate) - .forEach(errors::addAll); + .map(CaaSServiceMeshSecurity::validate) + .forEach(errors::addAll); loggingInstances.stream() - .map(CaaSLogging::validate) - .forEach(errors::addAll); + .map(CaaSLogging::validate) + .forEach(errors::addAll); documentDBInstances.stream() - .map(CaaSSearch::validate) - .forEach(errors::addAll); + .map(CaaSSearch::validate) + .forEach(errors::addAll); - if(podManagedIdentity != null) { + if (podManagedIdentity != null) { errors.addAll(podManagedIdentity.validate()); } //FRA-684 - Add error until we implement in GCP - if(this.getProvider().equals(ProviderType.GCP)) { - if(podManagedIdentity != null) errors.add("Pod Managed Identity is not fully supported yet for GCP"); - if(!priorityClasses.isEmpty()) errors.add("Priority classes are not fully supported yet for GCP"); + if (this.getProvider().equals(ProviderType.GCP)) { + if (podManagedIdentity != null) { + errors.add("Pod Managed Identity is not fully supported yet for GCP"); + } + if (!priorityClasses.isEmpty()) { + errors.add("Priority classes are not fully supported yet for GCP"); + } } - + return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSCassandra.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSCassandra.java index 863e8053..bcf862df 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSCassandra.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSCassandra.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSColumnOrientedDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSColumnOrientedDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import lombok.AccessLevel; import lombok.Getter; @@ -16,18 +16,20 @@ @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public abstract class PaaSCassandra extends PaaSColumnOrientedDbms implements LiveSystemComponent { - public static final String TYPE = PAAS_CASANDRA_DBMS.getId(); - public static abstract class Builder> extends Component.Builder { + public static final String TYPE = PAAS_CASANDRA_DBMS.getId(); - @Override - public T build() { - component.setType(PAAS_CASANDRA_DBMS); - return super.build(); - } - } + public static abstract class Builder> extends Component.Builder { @Override - public Collection validate() { - return super.validate(); + public T build() { + component.setType(PAAS_CASANDRA_DBMS); + return super.build(); } + } + + @Override + public Collection validate() { + return super.validate(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSDataStorage.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSDataStorage.java index 9f8521d5..50cba824 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSDataStorage.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSDataStorage.java @@ -12,23 +12,24 @@ @Getter @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) -public abstract class PaaSDataStorage extends com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSDataStorage - implements LiveSystemComponent { +public abstract class PaaSDataStorage extends com.yanchware.fractal.sdk.domain.fractal.paas.PaaSDataStorage + implements LiveSystemComponent +{ - protected PaaSDataStorage() { - } - - public static abstract class Builder> extends Component.Builder { + protected PaaSDataStorage() { + } - @Override - public T build() { - return super.build(); - } - } + public static abstract class Builder> extends Component.Builder { @Override - public Collection validate() { - Collection errors = super.validate(); - return errors; + public T build() { + return super.build(); } + } + + @Override + public Collection validate() { + Collection errors = super.validate(); + return errors; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDatabase.java index 4382c131..d0f34e44 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDatabase.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDatabase; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDatabase; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import lombok.AccessLevel; import lombok.Getter; @@ -17,75 +17,82 @@ @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public abstract class PaaSPostgreSqlDatabase extends PaaSRelationalDatabase implements LiveSystemComponent { - private final static String COLLATION_IS_BLANK = "PostgreSQLDB collation defined was either empty or blank and it is required"; - private final static String SCHEMA_IS_BLANK = "PostgreSQLDB schema defined was either empty or blank and it is required"; - - private String name; - private PostgreSqlCharset charset; - private String collation; - private String schema; + private final static String COLLATION_IS_BLANK = "PostgreSQLDB collation defined was either empty or blank and it " + + "is required"; + private final static String SCHEMA_IS_BLANK = "PostgreSQLDB schema defined was either empty or blank and it is " + + "required"; + + private String name; + private PostgreSqlCharset charset; + private String collation; + private String schema; + + protected PaaSPostgreSqlDatabase() { + } + + + public static abstract class Builder> extends Component.Builder { + + /** + * Name of the database + * + * @param name + */ + public B withName(String name) { + component.setName(name); + return builder; + } - protected PaaSPostgreSqlDatabase() { + /** + * Charset of the database + * + * @param charset + */ + public B withCharset(PostgreSqlCharset charset) { + component.setCharset(charset); + return builder; } + /** + * Collation of the database + * + * @param collation + */ + public B withCollation(String collation) { + component.setCollation(collation); + return builder; + } - public static abstract class Builder> extends Component.Builder { - - /** - * Name of the database - * @param name - */ - public B withName(String name) { - component.setName(name); - return builder; - } - - /** - * Charset of the database - * @param charset - */ - public B withCharset(PostgreSqlCharset charset) { - component.setCharset(charset); - return builder; - } - - /** - * Collation of the database - * @param collation - */ - public B withCollation(String collation) { - component.setCollation(collation); - return builder; - } - - /** - * Schema of the database - * @param schema - */ - public B withSchema(String schema) { - component.setSchema(schema); - return builder; - } - - @Override - public T build() { - component.setType(PAAS_POSTGRESQL_DATABASE); - return super.build(); - } + /** + * Schema of the database + * + * @param schema + */ + public B withSchema(String schema) { + component.setSchema(schema); + return builder; } @Override - public Collection validate() { - Collection errors = super.validate(); + public T build() { + component.setType(PAAS_POSTGRESQL_DATABASE); + return super.build(); + } + } - if(collation != null && isBlank(collation)) { - errors.add(COLLATION_IS_BLANK); - } + @Override + public Collection validate() { + Collection errors = super.validate(); - if(schema != null && isBlank(schema)) { - errors.add(SCHEMA_IS_BLANK); - } + if (collation != null && isBlank(collation)) { + errors.add(COLLATION_IS_BLANK); + } - return errors; + if (schema != null && isBlank(schema)) { + errors.add(SCHEMA_IS_BLANK); } + + return errors; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDbms.java index 1a3b32f7..6ec32476 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PaaSPostgreSqlDbms.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import lombok.AccessLevel; import lombok.Getter; @@ -17,29 +17,29 @@ @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public abstract class PaaSPostgreSqlDbms extends PaaSRelationalDbms implements LiveSystemComponent { - private Collection databases; + private Collection databases; - protected PaaSPostgreSqlDbms() { - databases = new ArrayList<>(); - } + protected PaaSPostgreSqlDbms() { + databases = new ArrayList<>(); + } - public static abstract class Builder> extends Component.Builder { + public static abstract class Builder> extends Component.Builder { - @Override - public T build() { - component.setType(PAAS_POSTGRESQL_DBMS); - return super.build(); - } + @Override + public T build() { + component.setType(PAAS_POSTGRESQL_DBMS); + return super.build(); } + } - @Override - public Collection validate() { - Collection errors = super.validate(); + @Override + public Collection validate() { + Collection errors = super.validate(); - databases.stream() - .map(PaaSPostgreSqlDatabase::validate) - .forEach(errors::addAll); + databases.stream() + .map(PaaSPostgreSqlDatabase::validate) + .forEach(errors::addAll); - return errors; - } + return errors; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PodManagedIdentity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PodManagedIdentity.java index 71621788..5e7cb07f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PodManagedIdentity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/PodManagedIdentity.java @@ -16,11 +16,16 @@ @Setter(AccessLevel.PRIVATE) @Builder(setterPrefix = "with") public class PodManagedIdentity implements Validatable { - private final static String NAME_IS_BLANK = "[PodManagedIdentity Validation] Name has not been defined and it is required"; - private final static String NAMESPACE_IS_BLANK = "[PodManagedIdentity Validation] Namespace has not been defined and it is required"; - private final static String ENABLE_IS_BLANK = "[PodManagedIdentity Validation] Enable has not been defined and it is required"; - private final static String EXCEPTION_POD_LABELS_IS_BLANK = "[PodManagedIdentity Validation] Exception pod labels has not been defined and it is required"; - private final static String ALLOW_NETWORK_PLUGIN_KUBE_NET_IS_BLANK = "[PodManagedIdentity Validation] AllowNetworkPluginKubeNet has not been defined and it is required"; + private final static String NAME_IS_BLANK = "[PodManagedIdentity Validation] Name has not been defined and it is " + + "required"; + private final static String NAMESPACE_IS_BLANK = "[PodManagedIdentity Validation] Namespace has not been defined " + + "and it is required"; + private final static String ENABLE_IS_BLANK = "[PodManagedIdentity Validation] Enable has not been defined and it " + + "is required"; + private final static String EXCEPTION_POD_LABELS_IS_BLANK = "[PodManagedIdentity Validation] Exception pod labels " + + "has not been defined and it is required"; + private final static String ALLOW_NETWORK_PLUGIN_KUBE_NET_IS_BLANK = "[PodManagedIdentity Validation] " + + "AllowNetworkPluginKubeNet has not been defined and it is required"; private String name; private String namespace; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/ResourceEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/ResourceEntity.java index acb33686..4ba77b80 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/ResourceEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/ResourceEntity.java @@ -3,9 +3,11 @@ import java.util.Map; public interface ResourceEntity { - Map getTags(); - void setTags(Map tags); + Map getTags(); - String getName(); - void setName(String Name); + void setTags(Map tags); + + String getName(); + + void setName(String Name); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesService.java index 6f7ac314..6a536f53 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesService.java @@ -18,221 +18,232 @@ @Getter @Setter public class AwsElasticKubernetesService extends KubernetesCluster implements AwsResourceEntity { - private final static String REGION_IS_NULL = "[AwsElasticKuernetesService Validation] Region is not specified and it is required"; - private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and 63 characters long"; - - private AwsRegion awsRegion; - private Map tags; - private String name; - private String vpcCidrBlock; - private List privateSubnetCidrs; - private Integer desiredAvailabilityZoneCount; + private final static String REGION_IS_NULL = "[AwsElasticKuernetesService Validation] Region is not specified and " + + "it is required"; + private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, " + + "numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and" + + " 63 characters long"; + + private AwsRegion awsRegion; + private Map tags; + private String name; + private String vpcCidrBlock; + private List privateSubnetCidrs; + private Integer desiredAvailabilityZoneCount; + + @Override + public ProviderType getProvider() { + return ProviderType.AWS; + } + + public static AwsElasticKubernetesServiceBuilder builder() { + return new AwsElasticKubernetesServiceBuilder(); + } + + public static class AwsElasticKubernetesServiceBuilder extends Builder { + @Override + protected AwsElasticKubernetesService createComponent() { + return new AwsElasticKubernetesService(); + } @Override - public ProviderType getProvider() { - return ProviderType.AWS; + protected AwsElasticKubernetesServiceBuilder getBuilder() { + return this; } - public static AwsElasticKubernetesServiceBuilder builder() { - return new AwsElasticKubernetesServiceBuilder(); + public AwsElasticKubernetesServiceBuilder withRegion(AwsRegion region) { + component.setAwsRegion(region); + return builder; } - public static class AwsElasticKubernetesServiceBuilder extends Builder { - @Override - protected AwsElasticKubernetesService createComponent() { - return new AwsElasticKubernetesService(); - } + public AwsElasticKubernetesServiceBuilder withName(String name) { + component.setName(name); + return builder; + } - @Override - protected AwsElasticKubernetesServiceBuilder getBuilder() { - return this; - } + public AwsElasticKubernetesServiceBuilder withTags(Map tags) { + component.setTags(tags); + return builder; + } - public AwsElasticKubernetesServiceBuilder withRegion(AwsRegion region) { - component.setAwsRegion(region); - return builder; - } + public AwsElasticKubernetesServiceBuilder withTag(String key, String value) { + if (component.getTags() == null) { + withTags(new HashMap<>()); + } - public AwsElasticKubernetesServiceBuilder withName(String name) { - component.setName(name); - return builder; - } + component.getTags().put(key, value); + return builder; + } - public AwsElasticKubernetesServiceBuilder withTags(Map tags) { - component.setTags(tags); - return builder; - } + /** + * Sets the VPC CIDR block for the EKS cluster. + *

    + * Must be a valid CIDR block between /16 and /24 (inclusive). + * If not set, the default {@code 172.33.0.0/16} will be used. + * + * @param cidrBlock the VPC CIDR block (e.g., {@code "10.0.0.0/16"}) + * @return the builder instance + */ + public AwsElasticKubernetesServiceBuilder withVpcCidrBlock(String cidrBlock) { + component.setVpcCidrBlock(cidrBlock); + return builder; + } - public AwsElasticKubernetesServiceBuilder withTag(String key, String value) { - if (component.getTags() == null) { - withTags(new HashMap<>()); - } + /** + * Sets the private subnet CIDRs for the EKS cluster. + *

    + * Each CIDR must: + *

      + *
    • Be within the configured VPC CIDR block
    • + *
    • Have a longer prefix than the VPC CIDR (e.g., /20 if VPC is /16)
    • + *
    • Not overlap with other subnets
    • + *
    + *
    + * Default (if not explicitly set): + * Derived from the VPC CIDR prefix: + *
      + *
    • {@code .128.0/20}
    • + *
    • {@code .144.0/20}
    • + *
    • {@code .160.0/20}
    • + *
    + * + * @param cidrs list of private subnet CIDRs + * @return the builder instance + */ + public AwsElasticKubernetesServiceBuilder withPrivateSubnetCidrs(List cidrs) { + component.setPrivateSubnetCidrs(cidrs); + return builder; + } - component.getTags().put(key, value); - return builder; - } + /** + * Sets how many availability zones the EKS cluster should span. + *

    + * Must be a value between 1 and 3 (inclusive), in accordance with AWS best practices. + * If set, the number of private subnets provided must match this count. + *
    + * Default: 3 availability zones + * + * @param count number of desired availability zones + * @return the builder instance + */ + public AwsElasticKubernetesServiceBuilder withDesiredAvailabilityZoneCount(int count) { + component.setDesiredAvailabilityZoneCount(count); + return builder; + } + } - /** - * Sets the VPC CIDR block for the EKS cluster. - *

    - * Must be a valid CIDR block between /16 and /24 (inclusive). - * If not set, the default {@code 172.33.0.0/16} will be used. - * - * @param cidrBlock the VPC CIDR block (e.g., {@code "10.0.0.0/16"}) - * @return the builder instance - */ - public AwsElasticKubernetesServiceBuilder withVpcCidrBlock(String cidrBlock) { - component.setVpcCidrBlock(cidrBlock); - return builder; - } + @Override + public Collection validate() { - /** - * Sets the private subnet CIDRs for the EKS cluster. - *

    - * Each CIDR must: - *

      - *
    • Be within the configured VPC CIDR block
    • - *
    • Have a longer prefix than the VPC CIDR (e.g., /20 if VPC is /16)
    • - *
    • Not overlap with other subnets
    • - *
    - *
    - * Default (if not explicitly set): - * Derived from the VPC CIDR prefix: - *
      - *
    • {@code .128.0/20}
    • - *
    • {@code .144.0/20}
    • - *
    • {@code .160.0/20}
    • - *
    - * - * @param cidrs list of private subnet CIDRs - * @return the builder instance - */ - public AwsElasticKubernetesServiceBuilder withPrivateSubnetCidrs(List cidrs) { - component.setPrivateSubnetCidrs(cidrs); - return builder; - } + Collection errors = super.validate(); + errors.addAll(AwsResourceEntity.validateAwsResourceEntity(this, "Kubernetes Service")); - /** - * Sets how many availability zones the EKS cluster should span. - *

    - * Must be a value between 1 and 3 (inclusive), in accordance with AWS best practices. - * If set, the number of private subnets provided must match this count. - *
    - * Default: 3 availability zones - * - * @param count number of desired availability zones - * @return the builder instance - */ - public AwsElasticKubernetesServiceBuilder withDesiredAvailabilityZoneCount(int count) { - component.setDesiredAvailabilityZoneCount(count); - return builder; - } + if (StringUtils.isNotBlank(name)) { + var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); + var hasValidLengths = isValidStringLength(name, 1, 63); + if (!isAlphaNumerics || !hasValidLengths) { + errors.add(NAME_NOT_VALID); + } } - @Override - public Collection validate() { + if (awsRegion == null) { + errors.add(REGION_IS_NULL); + } - Collection errors = super.validate(); - errors.addAll(AwsResourceEntity.validateAwsResourceEntity(this, "Kubernetes Service")); + if (StringUtils.isNotBlank(vpcCidrBlock)) { + try { + var vpcUtils = new SubnetUtils(vpcCidrBlock); + int vpcPrefix = Integer.parseInt(vpcCidrBlock.split("/")[1]); - if(StringUtils.isNotBlank(name)) { - var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); - var hasValidLengths = isValidStringLength(name, 1, 63); - if(!isAlphaNumerics || !hasValidLengths) { - errors.add(NAME_NOT_VALID); - } + if (vpcPrefix < 16 || vpcPrefix > 24) { + errors.add("[AwsElasticKubernetesService Validation] vpcCidrBlock mask must be between /16 and /24"); } - if (awsRegion == null) { - errors.add(REGION_IS_NULL); - } - - if (StringUtils.isNotBlank(vpcCidrBlock)) { + if (privateSubnetCidrs != null) { + for (String subnet : privateSubnetCidrs) { try { - var vpcUtils = new SubnetUtils(vpcCidrBlock); - int vpcPrefix = Integer.parseInt(vpcCidrBlock.split("/")[1]); - - if (vpcPrefix < 16 || vpcPrefix > 24) { - errors.add("[AwsElasticKubernetesService Validation] vpcCidrBlock mask must be between /16 and /24"); - } - - if (privateSubnetCidrs != null) { - for (String subnet : privateSubnetCidrs) { - try { - var subnetUtils = new SubnetUtils(subnet); - int subnetPrefix = Integer.parseInt(subnet.split("/")[1]); - - if (subnetPrefix <= vpcPrefix) { - errors.add(String.format( - "[AwsElasticKubernetesService Validation] Subnet %s mask must be greater than VPC's (%s)", subnet, vpcCidrBlock)); - } - - if (!vpcUtils.getInfo().isInRange(subnetUtils.getInfo().getAddress())) { - errors.add(String.format( - "[AwsElasticKubernetesService Validation] Subnet %s is not within the VPC CIDR range %s", - subnet, vpcCidrBlock)); - } - } catch (IllegalArgumentException e) { - errors.add(String.format("[AwsElasticKubernetesService Validation] Invalid CIDR format: %s", subnet)); - } - } - - // Optional: check subnet CIDRs do not overlap - for (int i = 0; i < privateSubnetCidrs.size(); i++) { - for (int j = i + 1; j < privateSubnetCidrs.size(); j++) { - if (cidrOverlaps(privateSubnetCidrs.get(i), privateSubnetCidrs.get(j))) { - errors.add(String.format( - "[AwsElasticKubernetesService Validation] Subnet CIDRs %s and %s overlap", - privateSubnetCidrs.get(i), privateSubnetCidrs.get(j))); - } - } - } - } - } catch (IllegalArgumentException e) { - errors.add("[AwsElasticKubernetesService Validation] vpcCidrBlock is not a valid CIDR"); - } - } + var subnetUtils = new SubnetUtils(subnet); + int subnetPrefix = Integer.parseInt(subnet.split("/")[1]); - if (desiredAvailabilityZoneCount != null) { - if (desiredAvailabilityZoneCount <= 0) { - errors.add("[AwsElasticKubernetesService Validation] desiredAvailabilityZoneCount must be greater than 0"); - } + if (subnetPrefix <= vpcPrefix) { + errors.add(String.format( + "[AwsElasticKubernetesService Validation] Subnet %s mask must be greater than VPC's (%s)", subnet, + vpcCidrBlock)); + } - if (desiredAvailabilityZoneCount > 3) { - errors.add("[AwsElasticKubernetesService Validation] desiredAvailabilityZoneCount cannot be greater than 3 (AWS best practice)"); + if (!vpcUtils.getInfo().isInRange(subnetUtils.getInfo().getAddress())) { + errors.add(String.format( + "[AwsElasticKubernetesService Validation] Subnet %s is not within the VPC CIDR range %s", + subnet, vpcCidrBlock)); + } + } catch (IllegalArgumentException e) { + errors.add(String.format("[AwsElasticKubernetesService Validation] Invalid CIDR format: %s", subnet)); } + } - if (privateSubnetCidrs != null && privateSubnetCidrs.size() != desiredAvailabilityZoneCount) { + // Optional: check subnet CIDRs do not overlap + for (int i = 0; i < privateSubnetCidrs.size(); i++) { + for (int j = i + 1; j < privateSubnetCidrs.size(); j++) { + if (cidrOverlaps(privateSubnetCidrs.get(i), privateSubnetCidrs.get(j))) { errors.add(String.format( - "[AwsElasticKubernetesService Validation] privateSubnetCidrs size (%d) must match desiredAvailabilityZoneCount (%d)", - privateSubnetCidrs.size(), desiredAvailabilityZoneCount - )); + "[AwsElasticKubernetesService Validation] Subnet CIDRs %s and %s overlap", + privateSubnetCidrs.get(i), privateSubnetCidrs.get(j))); + } } + } } + } catch (IllegalArgumentException e) { + errors.add("[AwsElasticKubernetesService Validation] vpcCidrBlock is not a valid CIDR"); + } + } - return errors; + if (desiredAvailabilityZoneCount != null) { + if (desiredAvailabilityZoneCount <= 0) { + errors.add("[AwsElasticKubernetesService Validation] desiredAvailabilityZoneCount must be greater than 0"); + } + + if (desiredAvailabilityZoneCount > 3) { + errors.add("[AwsElasticKubernetesService Validation] desiredAvailabilityZoneCount cannot be greater than 3 " + + "(AWS best practice)"); + } + + if (privateSubnetCidrs != null && privateSubnetCidrs.size() != desiredAvailabilityZoneCount) { + errors.add(String.format( + "[AwsElasticKubernetesService Validation] privateSubnetCidrs size (%d) must match " + + "desiredAvailabilityZoneCount (%d)", + privateSubnetCidrs.size(), desiredAvailabilityZoneCount + )); + } } - private boolean cidrOverlaps(String cidr1, String cidr2) { - SubnetUtils subnet1 = new SubnetUtils(cidr1); - SubnetUtils subnet2 = new SubnetUtils(cidr2); + return errors; + } - var info1 = subnet1.getInfo(); - var info2 = subnet2.getInfo(); + private boolean cidrOverlaps(String cidr1, String cidr2) { + SubnetUtils subnet1 = new SubnetUtils(cidr1); + SubnetUtils subnet2 = new SubnetUtils(cidr2); - return !(ipLessThan(info1.getHighAddress(), info2.getLowAddress()) - || ipLessThan(info2.getHighAddress(), info1.getLowAddress())); - } + var info1 = subnet1.getInfo(); + var info2 = subnet2.getInfo(); - private boolean ipLessThan(String ip1, String ip2) { - String[] a = ip1.split("\\."); - String[] b = ip2.split("\\."); + return !(ipLessThan(info1.getHighAddress(), info2.getLowAddress()) + || ipLessThan(info2.getHighAddress(), info1.getLowAddress())); + } - for (int i = 0; i < 4; i++) { - int diff = Integer.parseInt(a[i]) - Integer.parseInt(b[i]); - if (diff < 0) return true; - if (diff > 0) return false; - } - return false; // equal IPs means not less than + private boolean ipLessThan(String ip1, String ip2) { + String[] a = ip1.split("\\."); + String[] b = ip2.split("\\."); + + for (int i = 0; i < 4; i++) { + int diff = Integer.parseInt(a[i]) - Integer.parseInt(b[i]); + if (diff < 0) { + return true; + } + if (diff > 0) { + return false; + } } + return false; // equal IPs means not less than + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegion.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegion.java index b892a5eb..4536fc89 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegion.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegion.java @@ -9,57 +9,57 @@ * Choose the AWS region that's right for you and your customers */ public class AwsRegion extends ExtendableEnum { - public static final AwsRegion US_EAST_1 = fromString("us-east-1"); - public static final AwsRegion US_EAST_2 = fromString("us-east-2"); - public static final AwsRegion US_WEST_1 = fromString("us-west-1"); - public static final AwsRegion US_WEST_2 = fromString("us-west-2"); - public static final AwsRegion AF_SOUTH_1 = fromString("af-south-1"); - public static final AwsRegion AP_EAST_1 = fromString("ap-east-1"); - public static final AwsRegion AP_SOUTH_2 = fromString("ap-south-2"); - public static final AwsRegion AP_SOUTHEAST_3 = fromString("ap-southeast-3"); - public static final AwsRegion AP_SOUTHEAST_5 = fromString("ap-southeast-5"); - public static final AwsRegion AP_SOUTHEAST_4 = fromString("ap-southeast-4"); - public static final AwsRegion AP_SOUTH_1 = fromString("ap-south-1"); - public static final AwsRegion AP_NORTHEAST_3 = fromString("ap-northeast-3"); - public static final AwsRegion AP_NORTHEAST_2 = fromString("ap-northeast-2"); - public static final AwsRegion AP_SOUTHEAST_1 = fromString("ap-southeast-1"); - public static final AwsRegion AP_SOUTHEAST_2 = fromString("ap-southeast-2"); - public static final AwsRegion AP_NORTHEAST_1 = fromString("ap-northeast-1"); - public static final AwsRegion CA_CENTRAL_1 = fromString("ca-central-1"); - public static final AwsRegion CA_WEST_1 = fromString("ca-west-1"); - public static final AwsRegion CN_NORTH_1 = fromString("cn-north-1"); - public static final AwsRegion CN_NORTHWEST_1 = fromString("cn-northwest-1"); - public static final AwsRegion EU_CENTRAL_1 = fromString("eu-central-1"); - public static final AwsRegion EU_WEST_1 = fromString("eu-west-1"); - public static final AwsRegion EU_WEST_2 = fromString("eu-west-2"); - public static final AwsRegion EU_SOUTH_1 = fromString("eu-south-1"); - public static final AwsRegion EU_WEST_3 = fromString("eu-west-3"); - public static final AwsRegion EU_SOUTH_2 = fromString("eu-south-2"); - public static final AwsRegion EU_NORTH_1 = fromString("eu-north-1"); - public static final AwsRegion EU_CENTRAL_2 = fromString("eu-central-2"); - public static final AwsRegion IL_CENTRAL_1 = fromString("il-central-1"); - public static final AwsRegion ME_SOUTH_1 = fromString("me-south-1"); - public static final AwsRegion ME_CENTRAL_1 = fromString("me-central-1"); - public static final AwsRegion SA_EAST_1 = fromString("sa-east-1"); + public static final AwsRegion US_EAST_1 = fromString("us-east-1"); + public static final AwsRegion US_EAST_2 = fromString("us-east-2"); + public static final AwsRegion US_WEST_1 = fromString("us-west-1"); + public static final AwsRegion US_WEST_2 = fromString("us-west-2"); + public static final AwsRegion AF_SOUTH_1 = fromString("af-south-1"); + public static final AwsRegion AP_EAST_1 = fromString("ap-east-1"); + public static final AwsRegion AP_SOUTH_2 = fromString("ap-south-2"); + public static final AwsRegion AP_SOUTHEAST_3 = fromString("ap-southeast-3"); + public static final AwsRegion AP_SOUTHEAST_5 = fromString("ap-southeast-5"); + public static final AwsRegion AP_SOUTHEAST_4 = fromString("ap-southeast-4"); + public static final AwsRegion AP_SOUTH_1 = fromString("ap-south-1"); + public static final AwsRegion AP_NORTHEAST_3 = fromString("ap-northeast-3"); + public static final AwsRegion AP_NORTHEAST_2 = fromString("ap-northeast-2"); + public static final AwsRegion AP_SOUTHEAST_1 = fromString("ap-southeast-1"); + public static final AwsRegion AP_SOUTHEAST_2 = fromString("ap-southeast-2"); + public static final AwsRegion AP_NORTHEAST_1 = fromString("ap-northeast-1"); + public static final AwsRegion CA_CENTRAL_1 = fromString("ca-central-1"); + public static final AwsRegion CA_WEST_1 = fromString("ca-west-1"); + public static final AwsRegion CN_NORTH_1 = fromString("cn-north-1"); + public static final AwsRegion CN_NORTHWEST_1 = fromString("cn-northwest-1"); + public static final AwsRegion EU_CENTRAL_1 = fromString("eu-central-1"); + public static final AwsRegion EU_WEST_1 = fromString("eu-west-1"); + public static final AwsRegion EU_WEST_2 = fromString("eu-west-2"); + public static final AwsRegion EU_SOUTH_1 = fromString("eu-south-1"); + public static final AwsRegion EU_WEST_3 = fromString("eu-west-3"); + public static final AwsRegion EU_SOUTH_2 = fromString("eu-south-2"); + public static final AwsRegion EU_NORTH_1 = fromString("eu-north-1"); + public static final AwsRegion EU_CENTRAL_2 = fromString("eu-central-2"); + public static final AwsRegion IL_CENTRAL_1 = fromString("il-central-1"); + public static final AwsRegion ME_SOUTH_1 = fromString("me-south-1"); + public static final AwsRegion ME_CENTRAL_1 = fromString("me-central-1"); + public static final AwsRegion SA_EAST_1 = fromString("sa-east-1"); - /** - * Creates or finds a AwsRegion from its string representation. - * - * @param name a name to look for. - * @return the corresponding AwsRegion. - */ - @JsonCreator - public static AwsRegion fromString(String name) { - return fromString(name, AwsRegion.class); - } + /** + * Creates or finds a AwsRegion from its string representation. + * + * @param name a name to look for. + * @return the corresponding AwsRegion. + */ + @JsonCreator + public static AwsRegion fromString(String name) { + return fromString(name, AwsRegion.class); + } - /** - * Gets known AwsRegion values. - * - * @return known AwsRegion values. - */ - public static Collection values() { - return values(AwsRegion.class); - } + /** + * Gets known AwsRegion values. + * + * @return known AwsRegion values. + */ + public static Collection values() { + return values(AwsRegion.class); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsResourceEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsResourceEntity.java index a756d76f..e800f4e0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsResourceEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsResourceEntity.java @@ -7,6 +7,7 @@ public interface AwsResourceEntity extends ResourceEntity { AwsRegion getAwsRegion(); + void setAwsRegion(AwsRegion region); static Collection validateAwsResourceEntity(AwsResourceEntity resourceEntity, String entityName) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureIdentityType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureIdentityType.java index 16c6540a..60d3c937 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureIdentityType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureIdentityType.java @@ -13,7 +13,7 @@ public final class AzureIdentityType extends ExtendableEnum { public static final AzureIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); public static final AzureIdentityType USER_ASSIGNED = fromString("UserAssigned"); public static final AzureIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED = fromString("SystemAssigned,UserAssigned"); - + @JsonCreator public static AzureIdentityType fromString(String name) { return fromString(name, AzureIdentityType.class); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineType.java index 3c2340b5..70cfbb97 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineType.java @@ -824,7 +824,7 @@ public final class AzureMachineType extends ExtendableEnum { public static final AzureMachineType STANDARD_NV6_PROMO = fromString("Standard_NV6_Promo"); public static final AzureMachineType STANDARD_NV72ADS_A10_V5 = fromString("Standard_NV72ads_A10_v5"); public static final AzureMachineType STANDARD_NV8AS_V4 = fromString("Standard_NV8as_v4"); - public static final AzureMachineType STANDARD_PB6S= fromString("Standard_PB6s"); + public static final AzureMachineType STANDARD_PB6S = fromString("Standard_PB6s"); public AzureMachineType() { } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSku.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSku.java index 9841d8ec..92d9dc49 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSku.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSku.java @@ -7,16 +7,16 @@ /** *

    - * Specifies the OS SKU used by the agent pool. 
    - * The default is Ubuntu if OSType is Linux. 
    - * The default is Windows2019 when Kubernetes <= 1.24 or 
    + * Specifies the OS SKU used by the agent pool.
    + * The default is Ubuntu if OSType is Linux.
    + * The default is Windows2019 when Kubernetes <= 1.24 or
      * Windows2022 when Kubernetes >= 1.25 if OSType is Windows.
      * 
    */ public class AzureOsSku extends ExtendableEnum { /** - * Use AzureLinux as the OS for node images. + * Use AzureLinux as the OS for node images. * Azure Linux is a container-optimized Linux distro built by Microsoft. * For more information, visit https://aka.ms/azurelinux. */ @@ -34,15 +34,15 @@ public class AzureOsSku extends ExtendableEnum { public static final AzureOsSku UBUNTU = fromString("Ubuntu"); /** - * Use Windows2019 as the OS for node images. - * Unsupported for system node pools. + * Use Windows2019 as the OS for node images. + * Unsupported for system node pools. * Windows2019 only supports Windows2019 containers; it cannot run Windows2022 containers and vice versa. */ public static final AzureOsSku WINDOWS2019 = fromString("Windows2019"); /** - * Use Windows2022 as the OS for node images. - * Unsupported for system node pools. + * Use Windows2022 as the OS for node images. + * Unsupported for system node pools. * Windows2022 only supports Windows2022 containers; it cannot run Windows2019 containers and vice versa. */ public static final AzureOsSku WINDOWS2022 = fromString("Windows2022"); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsType.java index 49d3ec3d..d140d925 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsType.java @@ -3,23 +3,23 @@ import com.fasterxml.jackson.annotation.JsonValue; public enum AzureOsType { - LINUX("Linux"), - WINDOWS("Windows"); + LINUX("Linux"), + WINDOWS("Windows"); - private final String id; + private final String id; - AzureOsType(final String id) { - this.id = id; - } + AzureOsType(final String id) { + this.id = id; + } - @JsonValue - public String getId() { - return id; - } + @JsonValue + public String getId() { + return id; + } - @Override - public String toString() { - return id; - } + @Override + public String toString() { + return id; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDatabase.java index 76c8ca35..eef5eabd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDatabase.java @@ -15,11 +15,13 @@ public class AzurePostgreSqlDatabase extends PaaSPostgreSqlDatabase implements A public static AzurePostgreSqlDbBuilder builder() { return new AzurePostgreSqlDbBuilder(); } - private final static String NAME_IS_BLANK = "[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"; + + private final static String NAME_IS_BLANK = "[AzurePostgreSqlDatabase Validation] name has not been defined and it " + + "is required"; private String name; - - + + @Override public ProviderType getProvider() { return ProviderType.AZURE; @@ -29,25 +31,26 @@ public ProviderType getProvider() { private AzureResourceGroup azureResourceGroup; private Map tags; - public static class AzurePostgreSqlDbBuilder extends PaaSPostgreSqlDatabase.Builder { + public static class AzurePostgreSqlDbBuilder extends PaaSPostgreSqlDatabase.Builder { - @Override - protected AzurePostgreSqlDbBuilder getBuilder() { - return this; - } + @Override + protected AzurePostgreSqlDbBuilder getBuilder() { + return this; + } - @Override - protected AzurePostgreSqlDatabase createComponent() { - return new AzurePostgreSqlDatabase(); - } + @Override + protected AzurePostgreSqlDatabase createComponent() { + return new AzurePostgreSqlDatabase(); } + } @Override public Collection validate() { Collection errors = super.validate(); - if(StringUtils.isBlank(name)) { - errors.add(NAME_IS_BLANK); + if (StringUtils.isBlank(name)) { + errors.add(NAME_IS_BLANK); } return errors; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDbms.java index 00c0f2dd..71bbb089 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlDbms.java @@ -21,13 +21,17 @@ @ToString(callSuper = true) public class AzurePostgreSqlDbms extends PaaSPostgreSqlDbms implements AzureResourceEntity, LiveSystemComponent { - private final static String REGION_IS_NULL = "[AzurePostgreSQL Validation] Region has not been defined and it is required"; + private final static String REGION_IS_NULL = "[AzurePostgreSQL Validation] Region has not been defined and it is " + + "required"; - private final static String INVALID_STORAGE_GB = "[AzurePostgreSQL Validation] Storage GB is less than minimum requirement of 5 GB"; + private final static String INVALID_STORAGE_GB = "[AzurePostgreSQL Validation] Storage GB is less than minimum " + + "requirement of 5 GB"; - private final static String INVALID_BACKUP_RETENTION_DAYS = "[AzurePostgreSQL Validation] Backup Retention Days must be between 7 and 35 days"; + private final static String INVALID_BACKUP_RETENTION_DAYS = "[AzurePostgreSQL Validation] Backup Retention Days " + + "must be between 7 and 35 days"; - private final static String NAME_NOT_VALID = "[AzurePostgreSQL Validation] The name must only contain lowercase letters, numbers, and hyphens. It must not start or end in a hyphen and must be between 3 and 63 characters long"; + private final static String NAME_NOT_VALID = "[AzurePostgreSQL Validation] The name must only contain lowercase " + + "letters, numbers, and hyphens. It must not start or end in a hyphen and must be between 3 and 63 characters long"; private String rootUser; @@ -73,6 +77,7 @@ protected AzurePostgreSqlBuilder getBuilder() { /** * Database definition to be created part of this DBMS + * * @param db */ public AzurePostgreSqlBuilder withDatabase(AzurePostgreSqlDatabase db) { @@ -81,6 +86,7 @@ public AzurePostgreSqlBuilder withDatabase(AzurePostgreSqlDatabase db) { /** * List of databases to be created part of this DBMS + * * @param dbs */ public AzurePostgreSqlBuilder withDatabases(Collection dbs) { @@ -103,6 +109,7 @@ public AzurePostgreSqlBuilder withDatabases(Collection validate() { } getDatabases().stream() - .map(x -> AzureResourceEntity.validateAzureResourceEntity((AzureResourceEntity) x, "PostgreSql Database")) - .forEach(errors::addAll); - + .map(x -> AzureResourceEntity.validateAzureResourceEntity((AzureResourceEntity) x, "PostgreSql Database")) + .forEach(errors::addAll); + return errors; } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegion.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegion.java index 973c5543..2d2f2a30 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegion.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegion.java @@ -9,7 +9,7 @@ * Choose the Azure region that's right for you and your customers */ public final class AzureRegion extends ExtendableEnum { - + public static final AzureRegion EAST_US = fromString("eastus"); public static final AzureRegion SOUTH_CENTRAL_US = fromString("southcentralus"); public static final AzureRegion WEST_US2 = fromString("westus2"); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResource.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResource.java index bc8e683e..6faf93d7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResource.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResource.java @@ -11,10 +11,12 @@ public class AzureResource extends AzureProxyResource { private AzureResourceGroup azureResourceGroup; - public AzureResource(String name, - AzureRegion region, - Map tags, - AzureResourceGroup azureResourceGroup) { + public AzureResource( + String name, + AzureRegion region, + Map tags, + AzureResourceGroup azureResourceGroup) + { super(name, region, tags); this.azureResourceGroup = azureResourceGroup; @@ -23,16 +25,18 @@ public AzureResource(String name, public static Builder> builder() { return new Builder<>(); } - + public static class Builder> extends AzureProxyResource.Builder { protected AzureResourceGroup azureResourceGroup; - public Builder() {} + public Builder() { + } /** * A resource group is a collection of resources that share the same lifecycle, permissions, and policies. - * The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. + * The resource group can include all the resources for the solution, or only those resources that you want to + * manage as a group. */ public Builder withAzureResourceGroup(AzureResourceGroup resourceGroup) { this.azureResourceGroup = resourceGroup; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceEntity.java index c44b1ef9..9e0f8f4f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceEntity.java @@ -7,8 +7,11 @@ public interface AzureResourceEntity extends ResourceEntity { AzureResourceGroup getAzureResourceGroup(); + void setAzureResourceGroup(AzureResourceGroup azureResourceGroup); + AzureRegion getAzureRegion(); + void setAzureRegion(AzureRegion region); static Collection validateAzureResourceEntity(AzureResourceEntity resourceEntity, String entityName) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroup.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroup.java index 71a0bbb1..015617c3 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroup.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroup.java @@ -11,8 +11,9 @@ import java.util.regex.Pattern; /** - * A container that holds related resources for an Azure solution. - * The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. + * A container that holds related resources for an Azure solution. + * The resource group can include all the resources for the solution, or only those resources that you want to manage + * as a group. * You decide how you want to allocate resources to resource groups based on what makes the most sense for you . */ public class AzureResourceGroup extends AzureProxyResource implements Validatable { @@ -21,13 +22,16 @@ public class AzureResourceGroup extends AzureProxyResource implements Validatabl private static final String NAME_EXCEEDS_LENGTH_LIMIT = "[AzureResourceGroup Validation] Name exceeds 90 characters"; @JsonIgnore - public static final String NAME_IS_NOT_VALID = "[AzureResourceGroup Validation] Name can only include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters that match the allowed characters"; + public static final String NAME_IS_NOT_VALID = "[AzureResourceGroup Validation] Name can only include alphanumeric," + + " underscore, parentheses, hyphen, period (except at end), and Unicode characters that match the allowed " + + "characters"; @JsonIgnore - public final static String REGION_IS_BLANK = "[AzureResourceGroup Validation] Region has not been defined and it is required"; + public final static String REGION_IS_BLANK = "[AzureResourceGroup Validation] Region has not been defined and it is" + + " required"; private static final Pattern RESOURCE_GROUP_NAME_PATTERN = Pattern.compile("^[\\w()-.]+[\\w()-]$"); - + public AzureResourceGroup() { } @@ -49,8 +53,8 @@ public AzureResourceGroup build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureResourceGroup validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureResourceGroup validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return azureResourceGroup; @@ -61,7 +65,7 @@ public AzureResourceGroup build() { public Collection validate() { Collection errors = new ArrayList<>(); var name = this.getName(); - + if (StringUtils.isBlank(name)) { errors.add(NAME_IS_NULL_OR_EMPTY); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersion.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersion.java index 4648ba6f..8ee42b20 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersion.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersion.java @@ -10,11 +10,11 @@ */ public final class AzureTlsVersion extends ExtendableEnum { public static final AzureTlsVersion TLS1_0 = fromString("TLS1_0"); - + public static final AzureTlsVersion TLS1_1 = fromString("TLS1_1"); - + public static final AzureTlsVersion TLS1_2 = fromString("TLS1_2"); - + /** * Creates or finds a AzureTlsVersion from its string representation. diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/BackupStorageRedundancy.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/BackupStorageRedundancy.java index 7b224708..0c5e81d1 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/BackupStorageRedundancy.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/BackupStorageRedundancy.java @@ -27,8 +27,8 @@ public String toString() { public static BackupStorageRedundancy fromString(String redundancy) { return Arrays.stream(values()) - .filter(r -> r.value.equalsIgnoreCase(redundancy)) - .findFirst() - .orElse(null); + .filter(r -> r.value.equalsIgnoreCase(redundancy)) + .findFirst() + .orElse(null); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureActiveDirectoryProfile.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureActiveDirectoryProfile.java index 3815ace2..49a1799f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureActiveDirectoryProfile.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureActiveDirectoryProfile.java @@ -14,7 +14,8 @@ @Getter @Setter(AccessLevel.PRIVATE) public class AzureActiveDirectoryProfile implements Validatable { - private static final String ADMIN_GROUP_OBJECT_IDS_IS_EMPTY = "[AzureActiveDirectoryProfile Validation] adminGroupObjectIDs is empty but it is required"; + private static final String ADMIN_GROUP_OBJECT_IDS_IS_EMPTY = "[AzureActiveDirectoryProfile Validation] " + + "adminGroupObjectIDs is empty but it is required"; @JsonProperty("managed") private Boolean managed; @JsonProperty("enableAzureRBAC") @@ -26,16 +27,16 @@ public class AzureActiveDirectoryProfile implements Validatable { public static AzureActiveDirectoryProfileBuilder builder() { return new AzureActiveDirectoryProfileBuilder(); } - + private AzureActiveDirectoryProfile() { } //Builder Class - public static class AzureActiveDirectoryProfileBuilder{ + public static class AzureActiveDirectoryProfileBuilder { private final AzureActiveDirectoryProfile aadProfile; private final AzureActiveDirectoryProfileBuilder builder; - public AzureActiveDirectoryProfileBuilder () { + public AzureActiveDirectoryProfileBuilder() { aadProfile = createComponent(); builder = getBuilder(); } @@ -71,15 +72,15 @@ public AzureActiveDirectoryProfileBuilder withAdminGroupObjectId(String adminGro return withAdminGroupObjectIDs(List.of(adminGroupObjectId)); } - public AzureActiveDirectoryProfile build(){ + public AzureActiveDirectoryProfile build() { Collection errors = aadProfile.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureActiveDirectoryProfile validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureActiveDirectoryProfile validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } - + return aadProfile; } @@ -92,7 +93,7 @@ public Collection validate() { if (adminGroupObjectIDs != null && adminGroupObjectIDs.size() == 0) { errors.add(ADMIN_GROUP_OBJECT_IDS_IS_EMPTY); } - + return errors; } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddon.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddon.java index 9a913bc0..744bc33d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddon.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddon.java @@ -5,10 +5,10 @@ import java.util.Collection; -public final class AzureKubernetesAddon extends ExtendableEnum { +public final class AzureKubernetesAddon extends ExtendableEnum { /** * Configure ingress with automatic public DNS name creation - * + * */ public static final AzureKubernetesAddon HTTP_APPLICATION_ROUTING = fromString("httpApplicationRouting"); @@ -23,8 +23,9 @@ public final class AzureKubernetesAddon extends ExtendableEnum config; - + private AzureKubernetesAddonProfile() { } @@ -31,7 +32,7 @@ public static class AzureKubernetesAddonProfileBuilder { private final AzureKubernetesAddonProfile component; private final AzureKubernetesAddonProfileBuilder builder; - public AzureKubernetesAddonProfileBuilder () { + public AzureKubernetesAddonProfileBuilder() { component = createComponent(); builder = getBuilder(); } @@ -48,19 +49,19 @@ public AzureKubernetesAddonProfileBuilder withAddonToEnable(AzureKubernetesAddon component.setAddonToEnable(azureKubernetesAddon); return builder; } - + public AzureKubernetesAddonProfileBuilder withConfig(Map config) { component.setConfig(config); return builder; } - public AzureKubernetesAddonProfile build(){ + public AzureKubernetesAddonProfile build() { Collection errors = component.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureKubernetesAddonProfile validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureKubernetesAddonProfile validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return component; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesService.java index 2dd55b12..1943858a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesService.java @@ -24,11 +24,17 @@ @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) public class AzureKubernetesService extends KubernetesCluster implements AzureResourceEntity, LiveSystemComponent { - private final static String EMPTY_NODE_POOL = "[AzureKubernetesService Validation] Node pool list is null or empty and at least one node pool is required"; - private final static String REGION_IS_NULL = "[AzureKubernetesService Validation] Region is not specified and it is required"; - private final static String VNET_ADDRESS_SPACE_RANGE_NOT_VALID = "[KubernetesCluster Validation] VNet Address Space IP Range does not contain a valid ip with mask"; - private final static String VNET_SUBNET_ADDRESS_IP_RANGE_NOT_VALID = "[KubernetesCluster Validation] VNet Subnet Address IP Range does not contain a valid ip with mask"; - private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and 63 characters long"; + private final static String EMPTY_NODE_POOL = "[AzureKubernetesService Validation] Node pool list is null or empty " + + "and at least one node pool is required"; + private final static String REGION_IS_NULL = "[AzureKubernetesService Validation] Region is not specified and it is" + + " required"; + private final static String VNET_ADDRESS_SPACE_RANGE_NOT_VALID = "[KubernetesCluster Validation] VNet Address Space" + + " IP Range does not contain a valid ip with mask"; + private final static String VNET_SUBNET_ADDRESS_IP_RANGE_NOT_VALID = "[KubernetesCluster Validation] VNet Subnet " + + "Address IP Range does not contain a valid ip with mask"; + private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, " + + "numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and" + + " 63 characters long"; private String vnetAddressSpaceIpRange; private String vnetSubnetAddressIpRange; @Setter @@ -68,7 +74,8 @@ public static AzureKubernetesServiceBuilder builder() { return new AzureKubernetesServiceBuilder(); } - public static class AzureKubernetesServiceBuilder extends Builder { + public static class AzureKubernetesServiceBuilder extends Builder { @Override protected AzureKubernetesService createComponent() { @@ -133,12 +140,12 @@ public AzureKubernetesServiceBuilder withOutboundIps(List outbo public AzureKubernetesServiceBuilder withOutboundIp(AzureOutboundIp outboundIp) { return withOutboundIps(List.of(outboundIp)); } - + public AzureKubernetesServiceBuilder withExternalWorkspaceResourceId(String externalWorkspaceResourceId) { component.setExternalWorkspaceResourceId(externalWorkspaceResourceId); return builder; } - + public AzureKubernetesServiceBuilder withAddonProfile(AzureKubernetesAddonProfile addonProfile) { return withAddonProfiles(List.of(addonProfile)); } @@ -185,11 +192,11 @@ public AzureKubernetesServiceBuilder withTag(String key, String value) { if (component.getTags() == null) { withTags(new HashMap<>()); } - + component.getTags().put(key, value); return builder; } - + public AzureKubernetesServiceBuilder withActiveDirectoryProfile(AzureActiveDirectoryProfile aadProfile) { component.setAzureActiveDirectoryProfile(aadProfile); return builder; @@ -217,18 +224,18 @@ public Collection validate() { Collection errors = super.validate(); errors.addAll(AzureResourceEntity.validateAzureResourceEntity(this, "Kubernetes Service")); - if(StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(name)) { var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); var hasValidLengths = isValidStringLength(name, 1, 63); - if(!isAlphaNumerics || !hasValidLengths) { + if (!isAlphaNumerics || !hasValidLengths) { errors.add(NAME_NOT_VALID); } } - + if (azureRegion == null) { errors.add(REGION_IS_NULL); } - + if (nodePools.isEmpty()) { errors.add(EMPTY_NODE_POOL); } @@ -237,12 +244,12 @@ public Collection validate() { isPresentAndValidIpRange(vnetSubnetAddressIpRange, errors, VNET_SUBNET_ADDRESS_IP_RANGE_NOT_VALID); nodePools.stream() - .map(AzureNodePool::validate) - .forEach(errors::addAll); - + .map(AzureNodePool::validate) + .forEach(errors::addAll); + outboundIps.stream() - .map(AzureOutboundIp::validate) - .forEach(errors::addAll); + .map(AzureOutboundIp::validate) + .forEach(errors::addAll); return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureNodePool.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureNodePool.java index ce9039f1..79d73a80 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureNodePool.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureNodePool.java @@ -20,15 +20,23 @@ public class AzureNodePool implements Validatable { private final static String NAME_REGEX = "^[a-z\\d]+$"; private final static String NAME_IS_BLANK = "[AzureNodePool Validation] Name has not been defined and it is required"; - private final static String NAME_ONLY_LOWERCASE_ALPHANUMERIC = "[AzureNodePool Validation] Name should only contain lowercase alphanumeric characters"; - private final static String LINUX_NAME_IS_TOO_LONG = "[AzureNodePool Validation] Name for node with Linux OS Type should be between 1 and 12 characters"; - private final static String WINDOWS_NAME_IS_TOO_LONG = "[AzureNodePool Validation] Name for node with Windows OS Type should be between 1 and 6 characters"; + private final static String NAME_ONLY_LOWERCASE_ALPHANUMERIC = "[AzureNodePool Validation] Name should only contain" + + " lowercase alphanumeric characters"; + private final static String LINUX_NAME_IS_TOO_LONG = "[AzureNodePool Validation] Name for node with Linux OS Type " + + "should be between 1 and 12 characters"; + private final static String WINDOWS_NAME_IS_TOO_LONG = "[AzureNodePool Validation] Name for node with Windows OS " + + "Type should be between 1 and 6 characters"; private final static String DISK_SIZE_UNDER_30GB = "[AzureNodePool Validation] Disk size must be at least 30GB"; - private final static String SYSTEM_POOL_MODE_WINDOWS = "[AzureNodePool Validation] Pool Mode is set to SYSTEM but that is not supported for a Windows node pool"; - private final static String MAX_NODE_COUNT = "[AzureNodePool Validation] Max node count must be a positive integer (> 0)"; - private final static String MIN_NODE_COUNT_IS_NULL = "[AzureNodePool Validation] MinNodeCount has not been defined and it is required when autoscaling is enabled"; - private final static String MAX_NODE_COUNT_IS_NULL = "[AzureNodePool Validation] MaxNodeCount has not been defined and it is required when autoscaling is enabled"; - private final static String MACHINE_TYPE_IS_NULL = "[AzureNodePool Validation] Machine Type has not been defined and it is required"; + private final static String SYSTEM_POOL_MODE_WINDOWS = "[AzureNodePool Validation] Pool Mode is set to SYSTEM but " + + "that is not supported for a Windows node pool"; + private final static String MAX_NODE_COUNT = "[AzureNodePool Validation] Max node count must be a positive integer " + + "(> 0)"; + private final static String MIN_NODE_COUNT_IS_NULL = "[AzureNodePool Validation] MinNodeCount has not been defined " + + "and it is required when autoscaling is enabled"; + private final static String MAX_NODE_COUNT_IS_NULL = "[AzureNodePool Validation] MaxNodeCount has not been defined " + + "and it is required when autoscaling is enabled"; + private final static String MACHINE_TYPE_IS_NULL = "[AzureNodePool Validation] Machine Type has not been defined " + + "and it is required"; private final static Integer MIN_NUMBER_OF_USER_NODE_POOLS = 0; private final static Integer MIN_NUMBER_OF_SYSTEM_NODE_POOLS = 1; private final static Integer MAX_NUMBER_OF_NODE_POOLS = 1000; @@ -89,7 +97,7 @@ public AzureNodePoolBuilder withMaxNodeCount(Integer maxNodeCount) { nodePool.setMaxNodeCount(maxNodeCount); return builder; } - + public AzureNodePoolBuilder withMaxSurge(Integer maxSurge) { nodePool.setMaxSurge(maxSurge); return builder; @@ -98,14 +106,15 @@ public AzureNodePoolBuilder withMaxSurge(Integer maxSurge) { /** *
          * Sets the drain timeout for nodes in the node pool.
    -     * 
    -     * This method configures the amount of time, in minutes, to wait for the eviction of pods and their graceful 
    -     * termination on each node during an upgrade process. The specified timeout period respects the constraints 
    +     *
    +     * This method configures the amount of time, in minutes, to wait for the eviction of pods and their graceful
    +     * termination on each node during an upgrade process. The specified timeout period respects the constraints
          * imposed by pod disruption budgets. If the operation exceeds this timeout, the upgrade is considered to have failed.
    -     * 
    +     *
          * If this parameter is not explicitly set, a default timeout of 30 minutes is applied.
    * - * @param drainTimeoutInMinutes the drain timeout in minutes to be set for the node pool; if null, the default timeout is applied + * @param drainTimeoutInMinutes the drain timeout in minutes to be set for the node pool; if null, the default + * timeout is applied * @return this {@code AzureNodePoolBuilder} instance with the updated drain timeout setting */ public AzureNodePoolBuilder withDrainTimeoutInMinutes(Integer drainTimeoutInMinutes) { @@ -157,7 +166,7 @@ public AzureNodePoolBuilder withNodeTaints(List nodeTaints) { } nodeTaints.forEach(nodeTaint -> nodePool.getNodeTaints() - .add(nodeTaint.toString())); + .add(nodeTaint.toString())); return builder; } @@ -191,7 +200,7 @@ public AzureNodePool build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("AzureNodePool validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return nodePool; @@ -232,31 +241,38 @@ public Collection validate() { } if (this.initialNodeCount != null && this.agentPoolMode == AzureAgentPoolMode.USER) { - validateIntegerInRange("InitialNodeCount", this.initialNodeCount, MIN_NUMBER_OF_USER_NODE_POOLS, MAX_NUMBER_OF_NODE_POOLS, errors); + validateIntegerInRange("InitialNodeCount", this.initialNodeCount, MIN_NUMBER_OF_USER_NODE_POOLS, + MAX_NUMBER_OF_NODE_POOLS, errors); } if (this.initialNodeCount != null && this.agentPoolMode == AzureAgentPoolMode.SYSTEM) { - validateIntegerInRange("InitialNodeCount", this.initialNodeCount, MIN_NUMBER_OF_SYSTEM_NODE_POOLS, MAX_NUMBER_OF_NODE_POOLS, errors); + validateIntegerInRange("InitialNodeCount", this.initialNodeCount, MIN_NUMBER_OF_SYSTEM_NODE_POOLS, + MAX_NUMBER_OF_NODE_POOLS, errors); } if (this.maxNodeCount != null && this.agentPoolMode == AzureAgentPoolMode.USER) { - validateIntegerInRange("MaxNodeCount", this.maxNodeCount, MIN_NUMBER_OF_USER_NODE_POOLS, MAX_NUMBER_OF_NODE_POOLS, errors); + validateIntegerInRange("MaxNodeCount", this.maxNodeCount, MIN_NUMBER_OF_USER_NODE_POOLS, + MAX_NUMBER_OF_NODE_POOLS, errors); } if (this.maxNodeCount != null && this.agentPoolMode == AzureAgentPoolMode.SYSTEM) { - validateIntegerInRange("MaxNodeCount", this.maxNodeCount, MIN_NUMBER_OF_SYSTEM_NODE_POOLS, MAX_NUMBER_OF_NODE_POOLS, errors); + validateIntegerInRange("MaxNodeCount", this.maxNodeCount, MIN_NUMBER_OF_SYSTEM_NODE_POOLS, + MAX_NUMBER_OF_NODE_POOLS, errors); } if (this.minNodeCount != null && this.agentPoolMode == AzureAgentPoolMode.USER) { - validateIntegerInRange("MinNodeCount", this.minNodeCount, MIN_NUMBER_OF_USER_NODE_POOLS, MAX_NUMBER_OF_NODE_POOLS, errors); + validateIntegerInRange("MinNodeCount", this.minNodeCount, MIN_NUMBER_OF_USER_NODE_POOLS, + MAX_NUMBER_OF_NODE_POOLS, errors); } if (this.minNodeCount != null && this.agentPoolMode == AzureAgentPoolMode.SYSTEM) { - validateIntegerInRange("MinNodeCount", this.minNodeCount, MIN_NUMBER_OF_SYSTEM_NODE_POOLS, MAX_NUMBER_OF_NODE_POOLS, errors); + validateIntegerInRange("MinNodeCount", this.minNodeCount, MIN_NUMBER_OF_SYSTEM_NODE_POOLS, + MAX_NUMBER_OF_NODE_POOLS, errors); } if (this.maxPodsPerNode != null) { - validateIntegerInRange("MaxPodsPerNode", this.maxPodsPerNode, MIN_NUMBER_OF_PODS_PER_NODE, MAX_NUMBER_OF_PODS_PER_NODE, errors); + validateIntegerInRange("MaxPodsPerNode", this.maxPodsPerNode, MIN_NUMBER_OF_PODS_PER_NODE, + MAX_NUMBER_OF_PODS_PER_NODE, errors); } if (this.autoscalingEnabled) { @@ -270,17 +286,19 @@ public Collection validate() { } if (this.osType == AzureOsType.LINUX && - this.osSku != null && ( - this.osSku.equals(AzureOsSku.WINDOWS2019) || - this.osSku.equals(AzureOsSku.WINDOWS2022))) { + this.osSku != null && ( + this.osSku.equals(AzureOsSku.WINDOWS2019) || + this.osSku.equals(AzureOsSku.WINDOWS2022))) + { errors.add("Windows OS SKU cannot be used with Linux OS Type"); } if (this.osType == AzureOsType.WINDOWS && - this.osSku != null && - (this.osSku.equals(AzureOsSku.UBUNTU) || - this.osSku.equals(AzureOsSku.AZURE_LINUX) || - this.osSku.equals(AzureOsSku.CBLMARINER))) { + this.osSku != null && + (this.osSku.equals(AzureOsSku.UBUNTU) || + this.osSku.equals(AzureOsSku.AZURE_LINUX) || + this.osSku.equals(AzureOsSku.CBLMARINER))) + { errors.add("Linux OS SKU cannot be used with Windows OS Type"); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIp.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIp.java index ad768b0a..aea18e70 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIp.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIp.java @@ -16,10 +16,11 @@ @Setter(AccessLevel.PRIVATE) @Builder(setterPrefix = "with") public class AzureOutboundIp implements Validatable { - private static final String NAME_IS_EMPTY_OR_TOO_LONG = "[AzureOutboundIp Validation] name is empty or it exceeds 80 characters"; + private static final String NAME_IS_EMPTY_OR_TOO_LONG = "[AzureOutboundIp Validation] name is empty or it exceeds " + + "80 characters"; private String name; private AzureResourceGroup azureResourceGroup; - + private AzureOutboundIp() { } @@ -31,7 +32,7 @@ public static class AzureOutboundIpBuilder { private final AzureOutboundIp component; private final AzureOutboundIpBuilder builder; - public AzureOutboundIpBuilder () { + public AzureOutboundIpBuilder() { component = createComponent(); builder = getBuilder(); } @@ -48,19 +49,19 @@ public AzureOutboundIpBuilder withName(String outboundIpName) { component.setName(outboundIpName); return builder; } - + public AzureOutboundIpBuilder withAzureResourceGroup(AzureResourceGroup azureResourceGroup) { component.setAzureResourceGroup(azureResourceGroup); return builder; } - public AzureOutboundIp build(){ + public AzureOutboundIp build() { Collection errors = component.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureOutboundIp validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureOutboundIp validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return component; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTier.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTier.java index 5b68890e..f1b71c22 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTier.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTier.java @@ -9,7 +9,7 @@ public final class ManagedClusterSkuTier extends ExtendableEnum tags, - AzureResourceGroup azureResourceGroup, - AzureOsType operatingSystem, - AzurePricingPlan pricingPlan, - Boolean zoneRedundancyEnabled, - Integer numberOfWorkers) { + public AzureAppServicePlan( + String name, + AzureRegion region, + Map tags, + AzureResourceGroup azureResourceGroup, + AzureOsType operatingSystem, + AzurePricingPlan pricingPlan, + Boolean zoneRedundancyEnabled, + Integer numberOfWorkers) + { super(name, region, tags, azureResourceGroup); - + this.operatingSystem = operatingSystem; this.pricingPlan = pricingPlan; this.zoneRedundancyEnabled = zoneRedundancyEnabled; @@ -49,15 +52,15 @@ public AzureAppServicePlan(String name, public static AzureAppServicePlanBuilder builder() { return new AzureAppServicePlanBuilder(); } - + public static class AzureAppServicePlanBuilder extends AzureResource.Builder { - + protected AzureResourceGroup azureResourceGroup; protected AzureOsType operatingSystem; protected AzurePricingPlan pricingPlan; protected Boolean zoneRedundancyEnabled; protected Integer numberOfWorkers; - + /** * A resource group is a collection of resources that share the same lifecycle, permissions, and policies. @@ -69,6 +72,7 @@ public AzureAppServicePlanBuilder withAzureResourceGroup(AzureResourceGroup reso /** * App Service Plan operating system, either Windows or Linux + * * @param operatingSystem */ public AzureAppServicePlanBuilder withOperatingSystem(AzureOsType operatingSystem) { @@ -77,7 +81,8 @@ public AzureAppServicePlanBuilder withOperatingSystem(AzureOsType operatingSyste } /** - * App Service plan pricing tier determines the location, features, cost and compute resources associated with your app. + * App Service plan pricing tier determines the location, features, cost and compute resources associated with + * your app. */ public AzureAppServicePlanBuilder withPricingPlan(AzurePricingPlan pricingPlan) { this.pricingPlan = pricingPlan; @@ -85,8 +90,8 @@ public AzureAppServicePlanBuilder withPricingPlan(AzurePricingPlan pricingPlan) } /** - * An App Service plan can be deployed as a zone redundant service in the regions that support it. - * This is a deployment time only decision. You can't make an App Service plan zone redundant after + * An App Service plan can be deployed as a zone redundant service in the regions that support it. + * This is a deployment time only decision. You can't make an App Service plan zone redundant after * it has been deployed */ public AzureAppServicePlanBuilder withZoneRedundancyEnabled() { @@ -102,27 +107,27 @@ public AzureAppServicePlanBuilder withNumberOfWorkers(Integer numberOfWorkers) { return this; } - public AzureAppServicePlan build(){ + public AzureAppServicePlan build() { var appServicePlan = new AzureAppServicePlan(name, - region, - tags, - azureResourceGroup, - operatingSystem, - pricingPlan, - zoneRedundancyEnabled, - numberOfWorkers); - + region, + tags, + azureResourceGroup, + operatingSystem, + pricingPlan, + zoneRedundancyEnabled, + numberOfWorkers); + var errors = appServicePlan.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureAppServicePlan validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureAppServicePlan validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return appServicePlan; } - + } @Override @@ -130,7 +135,7 @@ public Collection validate() { Collection errors = new ArrayList<>(); var name = getName(); - if(StringUtils.isBlank(name)) { + if (StringUtils.isBlank(name)) { errors.add(NAME_NOT_VALID); } else { var hasValidCharacters = isValidAlphanumericsHyphens(name); @@ -139,7 +144,7 @@ public Collection validate() { errors.add(NAME_NOT_VALID); } } - + return errors; } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringType.java index 6f43fbcb..2a848f0c 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringType.java @@ -27,7 +27,7 @@ public static AzureConnectionStringType fromString(String name) { } public static Collection values() { - + return values(AzureConnectionStringType.class); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificate.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificate.java index e3ed5e4a..c54c9880 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificate.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificate.java @@ -14,24 +14,29 @@ import static org.apache.commons.lang3.StringUtils.isBlank; /* - Private key certificates (.pfx) can be used for TLS/SSL bindings and can be loaded to the certificate store for your app to consume. + Private key certificates (.pfx) can be used for TLS/SSL bindings and can be loaded to the certificate store for + your app to consume. */ @Getter @NoArgsConstructor public class AzureKeyVaultCertificate extends AzureProxyResource implements Validatable { - private final static String KEY_VAULT_ID_IS_BLANK = "[AzureKeyVaultCertificate Validation] KeyVaultId has not been defined and it is required"; - private final static String NAME_IS_BLANK = "[AzureKeyVaultCertificate Validation] Name has not been defined and it is required"; - + private final static String KEY_VAULT_ID_IS_BLANK = "[AzureKeyVaultCertificate Validation] KeyVaultId has not been " + + "defined and it is required"; + private final static String NAME_IS_BLANK = "[AzureKeyVaultCertificate Validation] Name has not been defined and it" + + " is required"; + private String keyVaultId; private String password; - public AzureKeyVaultCertificate(String name, - AzureRegion region, - Map tags, - String keyVaultId, - String password) { + public AzureKeyVaultCertificate( + String name, + AzureRegion region, + Map tags, + String keyVaultId, + String password) + { super(name, region, tags); - + this.keyVaultId = keyVaultId; this.password = password; } @@ -55,14 +60,14 @@ public Builder withPassword(String password) { } @Override - public AzureKeyVaultCertificate build(){ + public AzureKeyVaultCertificate build() { var certificate = new AzureKeyVaultCertificate(name, region, tags, keyVaultId, password); Collection errors = certificate.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureKeyVaultCertificate validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureKeyVaultCertificate validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return certificate; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancing.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancing.java index 2d808f2d..baf2cf48 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancing.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancing.java @@ -6,7 +6,7 @@ import java.util.Collection; -public final class AzureSiteLoadBalancing extends ExtendableEnum { +public final class AzureSiteLoadBalancing extends ExtendableEnum { public static final AzureSiteLoadBalancing LEAST_REQUESTS = fromString("LeastRequests"); public static final AzureSiteLoadBalancing LEAST_RESPONSE_TIME = fromString("LeastResponseTime"); public static final AzureSiteLoadBalancing PER_SITE_ROUND_ROBIN = fromString("PerSiteRoundRobin"); @@ -26,5 +26,5 @@ public static Collection values() { return values(AzureSiteLoadBalancing.class); } - + } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebApp.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebApp.java index 24c36fa8..b2167c5b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebApp.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebApp.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.appservice; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsRecord; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSWorkload; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsRecord; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSWorkload; import com.yanchware.fractal.sdk.domain.livesystem.CustomWorkload; import com.yanchware.fractal.sdk.domain.livesystem.CustomWorkloadBuilder; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; @@ -41,11 +41,17 @@ @Setter @ToString(callSuper = true) public class AzureWebApp extends PaaSWorkload implements AzureResourceEntity, LiveSystemComponent, CustomWorkload { - private final static String RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN = "[AzureWebApp Validation] The Runtime Stack and Operating System mismatches. Please choose %s or change Operating System to %s"; - private final static String NAME_NOT_VALID = "[AzureWebApp Validation] The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be between 2 and 60 characters"; - private final static String CUSTOM_DOMAIN_NOT_VALID = "[AzureWebApp Validation] The CustomDomain must contain at least one period, cannot start or end with a period. CustomDomain are made up of letters, numbers, periods, and dashes."; - private final static String RUNTIME_STACK_IS_EMPTY = "[AzureWebApp Validation] The Runtime Stack is either empty or blank and it is required"; - private final static String OPERATING_SYSTEM_IS_EMPTY = "[AzureWebApp Validation] The Operating System is either empty or blank and it is required"; + private final static String RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN = "[AzureWebApp Validation] The " + + "Runtime Stack and Operating System mismatches. Please choose %s or change Operating System to %s"; + private final static String NAME_NOT_VALID = "[AzureWebApp Validation] The name only allow alphanumeric characters " + + "and hyphens, cannot start or end in a hyphen, and must be between 2 and 60 characters"; + private final static String CUSTOM_DOMAIN_NOT_VALID = "[AzureWebApp Validation] The CustomDomain must contain at " + + "least one period, cannot start or end with a period. CustomDomain are made up of letters, numbers, periods, and " + + "dashes."; + private final static String RUNTIME_STACK_IS_EMPTY = "[AzureWebApp Validation] The Runtime Stack is either empty or" + + " blank and it is required"; + private final static String OPERATING_SYSTEM_IS_EMPTY = "[AzureWebApp Validation] The Operating System is either " + + "empty or blank and it is required"; private String name; private String privateSSHKeyPassphraseEnvironmentSecretShortName; @@ -119,15 +125,16 @@ public Collection validate() { } if (configuration != null - && StringUtils.isBlank(configuration.getDotnetVersion()) - && StringUtils.isBlank(configuration.getJavaVersion()) - && StringUtils.isBlank(configuration.getJavaContainerVersion()) - && StringUtils.isBlank(configuration.getLinuxFxVersion()) - && StringUtils.isBlank(configuration.getNodeVersion()) - && StringUtils.isBlank(configuration.getPhpVersion()) - && StringUtils.isBlank(configuration.getPythonVersion()) - && StringUtils.isBlank(configuration.getWindowsFxVersion())) { - + && StringUtils.isBlank(configuration.getDotnetVersion()) + && StringUtils.isBlank(configuration.getJavaVersion()) + && StringUtils.isBlank(configuration.getJavaContainerVersion()) + && StringUtils.isBlank(configuration.getLinuxFxVersion()) + && StringUtils.isBlank(configuration.getNodeVersion()) + && StringUtils.isBlank(configuration.getPhpVersion()) + && StringUtils.isBlank(configuration.getPythonVersion()) + && StringUtils.isBlank(configuration.getWindowsFxVersion())) + { + if (operatingSystem == null) { errors.add(OPERATING_SYSTEM_IS_EMPTY); } @@ -138,13 +145,17 @@ public Collection validate() { } if (operatingSystem == AzureOsType.LINUX - && runtimeStack instanceof AzureWebAppWindowsRuntimeStack) { - errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppLinuxRuntimeStack", "WINDOWS")); + && runtimeStack instanceof AzureWebAppWindowsRuntimeStack) + { + errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppLinuxRuntimeStack", + "WINDOWS")); } if (operatingSystem == AzureOsType.WINDOWS - && runtimeStack instanceof AzureWebAppLinuxRuntimeStack) { - errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppWindowsRuntimeStack", "LINUX")); + && runtimeStack instanceof AzureWebAppLinuxRuntimeStack) + { + errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppWindowsRuntimeStack", + "LINUX")); } @@ -203,17 +214,18 @@ public AzureWebApp build() { * latency, availability, and compliance. Utilizing the {@link AzureRegion} ExtendableEnum * allows for flexibility in specifying regions, accommodating cases where specific regions might * not be explicitly listed in the enum. - * + * * In scenarios where automation scripts or tools require dynamic region specification or if a * particular region is known to exist but is not present in the AzureRegion enum, * AzureRegion.fromString(String name) can be used to extend the enum dynamically. * This approach ensures that the builder remains compatible with future Azure regions without * needing constant updates. - * + * * Usage example: * builder.withRegion(AzureRegion.EAST_US); // Using a predefined region * builder.withRegion(AzureRegion.fromString("custom_region_name")); // Extending the enum for a custom or future region *
    + * * @param region the Azure region as an {@link AzureRegion} where the Web App will be deployed. * This can either be one of the predefined regions or an extended enum value * created through AzureRegion.fromString(String name). @@ -229,13 +241,13 @@ public AzureWebAppBuilder withRegion(AzureRegion region) { * Sets the Azure resource group for the Web App. The resource group name must adhere to Azure's * naming conventions, specifically matching the regex pattern ^[-\w\._\(\)]+[^\.]$, which * ensures the name is valid and conforms to Azure's standards for resource naming. - * + * * The resource group is a crucial organizational unit within Azure that holds related resources for * an Azure solution. Specifying the correct resource group is essential for resource management and * billing. This method enables setting the resource group to which the Web App belongs. - * + * * Example usage: - * + * * {@code AzureResourceGroup.builder() * .withName("rg-sample-group") * .withRegion(AzureRegion.WEST_EUROPE) @@ -256,7 +268,7 @@ public AzureWebAppBuilder withResourceGroup(AzureResourceGroup resourceGroup) { * Sets the configuration for the Azure Web App using an {@link AzureWebAppConfiguration} instance. * This configuration encompasses a wide range of settings applicable to the web app, including * runtime versions, app settings, connection strings, scaling options, security settings, and more. - * + * * The {@link AzureWebAppConfiguration} object should be prepared in advance, with all necessary * configurations set via its builder pattern. This approach allows for a flexible, detailed * specification of the web app's behavior and properties. @@ -290,6 +302,7 @@ public AzureWebAppBuilder withConfiguration(AzureWebAppConfiguration configurati *
          * Sets the unique name for the Azure Web App to be created or updated
          * 
    + * * @param name the unique name for the Azure Web App. This name must be unique across the Azure * environment and adhere to Azure's naming conventions and restrictions. */ @@ -300,17 +313,17 @@ public AzureWebAppBuilder withName(String name) { /** *
    -     * Assigns a set of tags to the Azure Web App as name/value pairs. Tags are instrumental in organizing 
    -     * Azure resources, enabling you to categorize resources across your subscription. By applying consistent tags 
    -     * to resources and resource groups, you can streamline management tasks such as monitoring and automation. 
    -     * Additionally, tags facilitate more effective cost tracking and analysis, allowing for consolidated billing 
    +     * Assigns a set of tags to the Azure Web App as name/value pairs. Tags are instrumental in organizing
    +     * Azure resources, enabling you to categorize resources across your subscription. By applying consistent tags
    +     * to resources and resource groups, you can streamline management tasks such as monitoring and automation.
    +     * Additionally, tags facilitate more effective cost tracking and analysis, allowing for consolidated billing
          * reports by tag.
    -     * 
    -     * This method allows for the specification of multiple tags at once. 
    -     * Each tag consists of a unique key and a value pair, both of which are strings. 
    -     * If a resource already has tags assigned, calling this method will overwrite existing tags with 
    +     *
    +     * This method allows for the specification of multiple tags at once.
    +     * Each tag consists of a unique key and a value pair, both of which are strings.
    +     * If a resource already has tags assigned, calling this method will overwrite existing tags with
          * the new set provided.
    -     * 
    +     *
          * Example usage:
          * {@code Map tags = new HashMap<>();
          * tags.put("Environment", "Production");
    @@ -321,7 +334,8 @@ public AzureWebAppBuilder withName(String name) {
          *
          * @param tags a {@link Map} containing the tags to be assigned to the Azure Web App, where each key is the tag name
          *             and each value is the tag value.
    -     * @return the AzureWebAppBuilder instance, allowing for chaining of multiple configuration methods in a fluent manner.
    +     * @return the AzureWebAppBuilder instance, allowing for chaining of multiple configuration methods
    +     * in a fluent manner.
          */
         public AzureWebAppBuilder withTags(Map tags) {
           component.setTags(tags);
    @@ -334,11 +348,11 @@ public AzureWebAppBuilder withTags(Map tags) {
          * allowing for categorization across your subscription. This can simplify management tasks like monitoring
          * and automation and aid in creating more accurate billing reports by grouping resources and resource groups
          * with common tags.
    -     * 
    +     *
          * This method facilitates the addition of tags incrementally. If no tags are currently assigned to the Web App,
          * a new tag collection is initiated. Otherwise, the provided tag is added to the existing collection. If a tag
          * with the given key already exists, its value will be updated with the provided value.
    -     * 
    +     *
          * Example usage:
          * {@code builder.withTag("Environment", "Production")
          *        .withTag("Project", "ProjectName");}  
    @@ -362,12 +376,12 @@ public AzureWebAppBuilder withTag(String key, String value) { * defines a set of compute resources for a web app to run. It specifies the region, operating system, * pricing tier, and the capacity of the infrastructure. This method is crucial for aligning the web * app's performance and cost-efficiency with business requirements. - * + * * The {@link AzureAppServicePlan} encapsulates various configurations such as the operating system * (Windows or Linux), pricing plan, whether zone redundancy is enabled, and the number of workers. * It is validated to ensure that the plan's name and other properties comply with Azure's constraints, * such as naming rules and resource limitations. - * + * * Usage example: * {@code AzureAppServicePlan appServicePlan = AzureAppServicePlan.builder() * .withName("myAppServicePlan") @@ -391,16 +405,16 @@ public AzureWebAppBuilder withAppServicePlan(AzureAppServicePlan appServicePlan) /** *
    -     * Configures the Azure Web App to use a specified Azure Key Vault certificate for SSL/TLS. 
    -     * Azure Key Vault certificates are utilized to secure communications to and from the web app, 
    -     * enabling encrypted connections via HTTPS. This method allows for the specification of a single 
    +     * Configures the Azure Web App to use a specified Azure Key Vault certificate for SSL/TLS.
    +     * Azure Key Vault certificates are utilized to secure communications to and from the web app,
    +     * enabling encrypted connections via HTTPS. This method allows for the specification of a single
          * certificate, identified by its Key Vault reference, to be applied to the web app.
    -     * 
    -     * The certificate must be a private key certificate (.pfx) and already stored in Azure Key Vault. 
    -     * It is identified by the Key Vault's ID and optionally protected by a password. The web app will 
    -     * use this certificate for its TLS/SSL bindings, ensuring that all data transmitted to and from the 
    +     *
    +     * The certificate must be a private key certificate (.pfx) and already stored in Azure Key Vault.
    +     * It is identified by the Key Vault's ID and optionally protected by a password. The web app will
    +     * use this certificate for its TLS/SSL bindings, ensuring that all data transmitted to and from the
          * web app is encrypted.
    -     * 
    +     *
          * Example usage:
          * {@code AzureKeyVaultCertificate certificate = AzureKeyVaultCertificate.builder()
          *     .withName("myCertificateName")
    @@ -421,19 +435,19 @@ public AzureWebAppBuilder withCertificate(AzureKeyVaultCertificate certificate)
     
         /**
          * 
    -     * Configures the Azure Web App to use a collection of Azure Key Vault certificates for SSL/TLS. 
    -     * This method enables the web app to establish encrypted connections via HTTPS by utilizing one or more 
    -     * certificates stored in Azure Key Vault. Using multiple certificates can be useful for supporting different 
    +     * Configures the Azure Web App to use a collection of Azure Key Vault certificates for SSL/TLS.
    +     * This method enables the web app to establish encrypted connections via HTTPS by utilizing one or more
    +     * certificates stored in Azure Key Vault. Using multiple certificates can be useful for supporting different
          * domains or subdomains, or for rotating certificates without downtime.
    -     * 
    -     * Each certificate in the collection must be a private key certificate (.pfx) already stored in Azure Key Vault. 
    -     * These certificates are identified by their Key Vault IDs and can be optionally protected by passwords. The web app 
    +     *
    +     * Each certificate in the collection must be a private key certificate (.pfx) already stored in Azure Key Vault.
    +     * These certificates are identified by their Key Vault IDs and can be optionally protected by passwords. The web app
          * will use these certificates for its TLS/SSL bindings, securing data transmission.
    -     * 
    -     * If no certificates are currently assigned to the web app, a new collection will be initialized. Otherwise, the 
    -     * provided certificates will be added to the existing collection. This allows for incremental updates to the web app's 
    +     *
    +     * If no certificates are currently assigned to the web app, a new collection will be initialized. Otherwise, the
    +     * provided certificates will be added to the existing collection. This allows for incremental updates to the web app's
          * certificate configuration.
    -     * 
    +     *
          * Example usage:
          * {@code List certificates = Arrays.asList(
          *     AzureKeyVaultCertificate.builder()
    @@ -451,7 +465,8 @@ public AzureWebAppBuilder withCertificate(AzureKeyVaultCertificate certificate)
          *
          * builder.withCertificates(certificates);}
    * - * @param certificates a collection of {@link AzureKeyVaultCertificate} instances to be used by the web app for SSL/TLS. + * @param certificates a collection of {@link AzureKeyVaultCertificate} instances to be used by the web app for + * SSL/TLS. * @return the AzureWebAppBuilder instance, allowing for fluent chaining of configuration methods. * @throws IllegalArgumentException if any of the provided certificates are invalid or if validation fails. */ @@ -470,14 +485,14 @@ public AzureWebAppBuilder withCertificates(Collection - * Configures the Azure Web App to use a specific custom domain. Custom domains enhance the branding - * and visibility of your web app. The specified domain must adhere to specific formatting rules: it - * must contain at least one period ('.') to denote a subdomain or TLD, cannot start or end with a + * Configures the Azure Web App to use a specific custom domain. Custom domains enhance the branding + * and visibility of your web app. The specified domain must adhere to specific formatting rules: it + * must contain at least one period ('.') to denote a subdomain or TLD, cannot start or end with a * period, and can only include letters, numbers, periods, and dashes. - * - * This method supports configuring a single custom domain. For applications requiring multiple custom + * + * This method supports configuring a single custom domain. For applications requiring multiple custom * domains, consider using {@link #withCustomDomains(Collection)}. - * + * * Example usage: * {@code builder.withCustomDomain("example.mydomain.com");}
    * @@ -491,22 +506,22 @@ public AzureWebAppBuilder withCustomDomain(String customDomain) { /** *
    -     * Configures the Azure Web App to use a collection of custom domains. Assigning custom domains 
    -     * enhances the branding and accessibility of your web app. Each domain in the collection must 
    -     * adhere to specific formatting rules: it must contain at least one period ('.') to denote 
    -     * subdomains or top-level domains (TLDs), cannot start or end with a period, and can only include 
    +     * Configures the Azure Web App to use a collection of custom domains. Assigning custom domains
    +     * enhances the branding and accessibility of your web app. Each domain in the collection must
    +     * adhere to specific formatting rules: it must contain at least one period ('.') to denote
    +     * subdomains or top-level domains (TLDs), cannot start or end with a period, and can only include
          * letters, numbers, periods, and dashes.
    -     * 
    -     * This method enables the configuration of multiple custom domains at once, providing flexibility 
    -     * for applications requiring several domain names. If specific formatting rules are not met, the 
    +     *
    +     * This method enables the configuration of multiple custom domains at once, providing flexibility
    +     * for applications requiring several domain names. If specific formatting rules are not met, the
          * method may throw an IllegalArgumentException.
    -     * 
    +     *
          * Example usage:
          * {@code Collection customDomains = List.of("www.example.com", "api.example.com");
          * builder.withCustomDomains(customDomains);}
    * - * @param customDomains a collection of custom domain names to associate with the Azure Web App, - * adhering to the defined formatting rules. + * @param customDomains a collection of custom domain names to associate with the Azure Web App, + * adhering to the defined formatting rules. * @return the AzureWebAppBuilder instance, allowing for fluent chaining of configuration methods. * @throws IllegalArgumentException if any provided custom domain is invalid based on the defined rules. */ @@ -529,20 +544,21 @@ public AzureWebAppBuilder withCustomDomains(Collection customD * server instance, thereby improving user experience by maintaining session state across requests. * This is achieved by sending session affinity cookies to clients, which route requests from the * same session to the same instance. - * + * * Enabling client affinity is beneficial for applications where maintaining user session state * on the server side is crucial. Disabling client affinity can be useful for stateless applications * where load distribution is more important than session stickiness. - * + * * The default behavior is to enable client affinity, ensuring session stickiness. - * + * * Example usage: * {@code builder.withClientAffinityEnabled(true); // To enable client affinity * builder.withClientAffinityEnabled(false); // To disable client affinity} * * @param clientAffinityEnabled true to enable client affinity, ensuring that requests from the same - * session are routed to the same instance. False to disable client affinity, allowing requests - * to be distributed across all instances without session stickiness. + * session are routed to the same instance. False to disable client affinity, + * allowing requests + * to be distributed across all instances without session stickiness. * @return the AzureWebAppBuilder instance, allowing for fluent chaining of configuration methods. */ public AzureWebAppBuilder withClientAffinityEnabled(Boolean clientAffinityEnabled) { @@ -556,18 +572,18 @@ public AzureWebAppBuilder withClientAffinityEnabled(Boolean clientAffinityEnable * authentication, also known as TLS mutual authentication, requires clients to present a certificate * when making requests to the server. This method of authentication adds an extra layer of security * by ensuring that only clients with a valid certificate can access the web app. - * + * * This feature is particularly useful for scenarios where you need to secure sensitive operations or * enforce stricter access controls. Enabling client certificate authentication can help prevent unauthorized * access and ensure that only trusted clients can communicate with the web app. - * + * * Example usage: * {@code builder.withClientCertEnabled(true); // To enable client certificate authentication * builder.withClientCertEnabled(false); // To keep client certificate authentication disabled} * * @param clientCertEnabled true to enable client certificate authentication, requiring clients to - * present a valid certificate for access. False to disable this feature, allowing access - * without client certificates. + * present a valid certificate for access. False to disable this feature, allowing access + * without client certificates. * @return the AzureWebAppBuilder instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withClientCertEnabled(Boolean clientCertEnabled) { @@ -579,20 +595,20 @@ public AzureWebAppBuilder withClientCertEnabled(Boolean clientCertEnabled) { *
          * Specifies paths that are excluded from client certificate authentication in a comma-separated list.
          * While client certificate authentication adds an extra layer of security, there may be specific paths
    -     * within your application that do not require, or should not enforce, this level of authentication. 
    +     * within your application that do not require, or should not enforce, this level of authentication.
          * These could include public resources, health check endpoints, or other paths intended for unauthenticated access.
    -     * 
    +     *
          * Setting exclusion paths allows these specific routes to bypass client certificate authentication, ensuring
          * they remain accessible without presenting a client certificate. This approach enables a more granular
          * control over security and access within your Azure Web App.
    -     * 
    +     *
          * Example usage:
          * {@code builder.withClientCertExclusionPaths("/public,/healthcheck,/api/public");}
          *
          * Note: Paths should be specified relative to the web app's root URL and separated by commas.
    * - * @param clientCertExclusionPaths a comma-separated list of paths to exclude from client certificate - * authentication. Each path should be specified relative to the web app's root. + * @param clientCertExclusionPaths a comma-separated list of paths to exclude from client certificate + * authentication. Each path should be specified relative to the web app's root. * @return the AzureWebAppBuilder instance, allowing for fluent chaining of configuration methods. */ public AzureWebAppBuilder withClientCertExclusionPaths(String clientCertExclusionPaths) { @@ -605,22 +621,23 @@ public AzureWebAppBuilder withClientCertExclusionPaths(String clientCertExclusio * Sets the mode for client certificate authentication in the Azure Web App, determining how client * certificates are handled. This setting works in conjunction with ClientCertEnabled to * define the behavior for client certificate authentication. - * + * * When ClientCertEnabled is set to false, the client certificate is ignored regardless * of the ClientCertMode setting. If ClientCertEnabled is true and * ClientCertMode is set to Required, client certificates are mandatory for accessing * the web app. When ClientCertEnabled is true and ClientCertMode is * Optional, client certificates, if provided, are accepted but not required for access. - * + * * This configuration allows for flexible handling of client certificates, accommodating scenarios * ranging from strict security requirements to more open access with the option of client certificate * authentication. - * + * * Example usage: * {@code builder.withClientCertMode(AzureAppServiceClientCertMode.Required); // Client certificates are required * builder.withClientCertMode(AzureAppServiceClientCertMode.Optional); // Client certificates are optional} * - * @param clientCertMode the {@link AzureAppServiceClientCertMode} value defining the handling of client certificates. + * @param clientCertMode the {@link AzureAppServiceClientCertMode} value defining the handling of client + * certificates. * @return the AzureWebAppBuilder instance, facilitating fluent chaining of configuration methods. */ public AzureWebAppBuilder withClientCertMode(AzureAppServiceClientCertMode clientCertMode) { @@ -636,12 +653,12 @@ public AzureWebAppBuilder withClientCertMode(AzureAppServiceClientCertMode clien * customization of the cloning process, including application setting overrides, whether to clone * custom hostnames and source control, and whether to configure load balancing between the source * and destination apps. - * + * * Cloning is particularly useful for creating staging environments, testing changes, or replicating * app configurations across different regions or environments. If specified during app creation, * the new app is cloned from the provided source app based on the {@link AzureWebAppCloningInfo} * configuration. - * + * * Example usage: * {@code AzureWebAppCloningInfo cloningInfo = AzureWebAppCloningInfo.builder() * .withSourceWebAppId("/subscriptions/{subId}/.../sites/{siteName}") @@ -665,11 +682,11 @@ public AzureWebAppBuilder withCloningInfo(AzureWebAppCloningInfo cloningInfo) { * Sets the size of the container for the Azure Web App, which directly impacts the amount of memory * and computational resources allocated to the app. This configuration is particularly important for * applications with specific performance and resource requirements. - * + * * The container size is specified in megabytes and should be selected based on the expected workload * and performance criteria of the application. Adjusting the container size can help manage the balance * between performance and cost-efficiency. - * + * * Example usage: * {@code builder.withContainerSize(1536); // Sets the container size to 1536 MB} * @@ -688,11 +705,11 @@ public AzureWebAppBuilder withContainerSize(Integer containerSize) { * part of the domain verification process. The presence of this TXT record with the correct * verification ID proves ownership of the domain and is a necessary step for assigning custom * domains to the web app. - * + * * Custom domain verification is an essential security measure to ensure that only domains owned by * the web app owner are associated with the app. This process prevents unauthorized use of domains * and helps maintain the integrity and trustworthiness of the web app. - * + * * Example usage: * {@code builder.withCustomDomainVerificationId("uniqueVerificationId");} * @@ -709,17 +726,17 @@ public AzureWebAppBuilder withCustomDomainVerificationId(String customDomainVeri * Sets the maximum allowed daily memory-time quota for the Azure Web App, applicable only to dynamic * app service plans. This quota is defined in terms of memory-time units (MTU), which are calculated * by multiplying the average memory usage in GB by the app's running time in hours, aggregated daily. - * + * * Setting a daily memory-time quota is useful for controlling the resource consumption of your app, * preventing unexpected charges, especially in dynamic hosting environments where scalability and * resource optimization are crucial. Once the daily quota is reached, the app will be stopped until * the quota is reset the following day. - * + * * Example usage: * {@code builder.withDailyMemoryTimeQuota(1024); // Sets the daily memory-time quota to 1024 MB-hours} * * @param dailyMemoryTimeQuota the daily memory-time quota in MB-hours. A null or zero value indicates - * no quota is applied. + * no quota is applied. * @return the AzureWebAppBuilder instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withDailyMemoryTimeQuota(Integer dailyMemoryTimeQuota) { @@ -732,18 +749,18 @@ public AzureWebAppBuilder withDailyMemoryTimeQuota(Integer dailyMemoryTimeQuota) * Enables or disables the Azure Web App. This setting determines whether the web app is available * and accessible. Setting the web app to disabled takes it offline, making it inaccessible to users * and potentially useful for maintenance periods or controlling access. - * + * * When the app is disabled, it will not serve any web pages or handle incoming traffic, effectively * taking the app offline without altering its configuration or removing deployed content. This can * be particularly useful for temporary outages or to prevent access while performing significant updates * or changes. - * + * * Example usage: * {@code builder.withEnabled(true); // Enables the web app, making it accessible * builder.withEnabled(false); // Disables the web app, taking it offline} * * @param enabled true to enable the web app, making it accessible to users; false to disable the web app, - * taking it offline. + * taking it offline. * @return the AzureWebAppBuilder instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withEnabled(Boolean enabled) { @@ -757,16 +774,16 @@ public AzureWebAppBuilder withEnabled(Boolean enabled) { * the public hostnames makes the app inaccessible through standard web browsers, restricting access * to APIs or backend processes only. This setting can be used for apps that should not be directly * accessed by users, serving instead as backend services or APIs. - * + * * When hostNamesDisabled is set to true, the app is only accessible through an API * management process, providing an additional layer of control over how the app is exposed. - * + * * Example usage: * {@code builder.withHostNamesDisabled(true); // Disables public hostnames, limiting access to APIs * builder.withHostNamesDisabled(false); // Enables public hostnames, allowing web access} * * @param hostNamesDisabled true to disable public hostnames and restrict access to the app; - * false to enable public hostnames and allow web access. + * false to enable public hostnames and allow web access. * @return the AzureWebAppBuilder instance, facilitating fluent chaining of configuration methods. */ public AzureWebAppBuilder withHostNamesDisabled(Boolean hostNamesDisabled) { @@ -782,11 +799,11 @@ public AzureWebAppBuilder withHostNamesDisabled(Boolean hostNamesDisabled) { * scale. Specifying an ASE is crucial for apps that require enhanced isolation, custom network * configurations, or are subject to compliance and security standards that cannot be met by the * multi-tenant public cloud environment. - * + * * Using an ASE can significantly impact the app's networking capabilities, access control, and * scalability options. This method associates the web app with the specified ASE using its unique * ID, which is typically obtained from the ASE's resource properties in Azure. - * + * * Example usage: * {@code builder.withHostingEnvironmentProfileId("your-ase-resource-id");} * @@ -805,15 +822,15 @@ public AzureWebAppBuilder withHostingEnvironmentProfileId(String hostingEnvironm * redirected to HTTPS, preventing unencrypted access to the app. If this option is not explicitly * set, Fractal Cloud configures the web app to use HTTPS-only mode by default, aligning with security * best practices. - * + * * Enabling HTTPS-only mode is strongly recommended to protect user data, prevent man-in-the-middle * attacks, and maintain the confidentiality and integrity of information exchanged between the user * and the web app. - * + * * Example usage: * {@code builder.withHttpsOnly(true); // Explicitly enforces HTTPS, redirecting HTTP requests to HTTPS * builder.withHttpsOnly(false); // Disables HTTPS-only mode, allowing both HTTP and HTTPS requests} - * + * * Note: In the absence of explicit configuration, Fractal Cloud sets HTTPS-only mode to true * by default, ensuring enhanced security for your web application. * @@ -833,10 +850,10 @@ public AzureWebAppBuilder withHttpsOnly(Boolean httpsOnly) { * an additional layer of isolation by running the app in a virtualized environment. This setting * is particularly useful for applications requiring enhanced security, compatibility with * specific Windows features, or isolation from other apps running on the same infrastructure. - * + * * Enabling the Hyper-V sandbox can impact the app's performance and resource consumption, * so it should be used judiciously based on the application's specific requirements. - * + * * Example usage: * {@code builder.withHyperV(true); // Enables the Hyper-V sandbox for enhanced isolation * builder.withHyperV(false); // Disables the Hyper-V sandbox} @@ -854,13 +871,13 @@ public AzureWebAppBuilder withHyperV(Boolean hyperV) { * Configures the redundancy mode for the Azure Web App, determining the strategy for high availability * and fault tolerance. This setting allows the selection of an appropriate redundancy mode based on the * application's requirements for uptime, data replication, and failover capabilities. - * + * * The available redundancy modes are: * - NONE No additional redundancy; the app is hosted in a single location. * - MANUAL Redundancy is managed manually by the user, allowing for custom failover processes. * - FAILOVER Automatic failover to a secondary location in case of failure in the primary location. * - ACTIVE_ACTIVE The app runs simultaneously in multiple locations, offering high availability. - * - GEO_REDUNDANT The app is hosted across multiple geographic regions for maximum availability + * - GEO_REDUNDANT The app is hosted across multiple geographic regions for maximum availability * and disaster recovery. * * Example usage: @@ -878,12 +895,12 @@ public AzureWebAppBuilder withRedundancyMode(AzureAppServiceRedundancyMode redun *
          * Specifies whether the Azure Web App is reserved for Linux-based hosting. Setting this to true
          * indicates that the web app is intended to run on Linux, while false typically indicates Windows-based hosting.
    -     * This distinction is crucial for ensuring that the app is deployed on the correct operating system, which can 
    +     * This distinction is crucial for ensuring that the app is deployed on the correct operating system, which can
          * affect compatibility, performance, and available features.
    -     * 
    -     * It's important to set this flag correctly according to the application's hosting requirements and the target 
    +     *
    +     * It's important to set this flag correctly according to the application's hosting requirements and the target
          * operating system environment. Incorrect settings may lead to deployment issues or runtime errors.
    -     * 
    +     *
          * Example usage:
          * {@code builder.withReserved(true); // Specifies that the web app is intended for Linux-based hosting
          * builder.withReserved(false); // Specifies that the web app is intended for Windows-based hosting}
    @@ -901,11 +918,11 @@ public AzureWebAppBuilder withReserved(Boolean reserved) { * Configures whether the SCM (KUDU) site associated with the Azure Web App is also stopped when * the web app is stopped. Stopping the SCM site along with the web app can help conserve resources * and reduce costs, especially for environments that do not require continuous SCM site availability. - * + * * By default, the SCM site remains operational even when the web app is stopped, allowing access to * SCM functions such as deployment and logging. Setting this option to true synchronizes the * operational state of the SCM site with the web app, ensuring both are stopped or started together. - * + * * Example usage: * {@code builder.withScmSiteAlsoStopped(true); // Stops the SCM site when the web app is stopped * builder.withScmSiteAlsoStopped(false); // Keeps the SCM site running when the web app is stopped} @@ -927,18 +944,20 @@ public AzureWebAppBuilder withScmSiteAlsoStopped(Boolean scmSiteAlsoStopped) { * session state, or logs outside the default web app environment. Enabling this option indicates * that the web app's functionality depends on access to a separate storage account, which must be * configured separately. - * + * * Setting this to {@code true} is necessary for apps that need to utilize custom storage capabilities * beyond what is provided by Azure Web Apps by default. It ensures that the app configuration includes * the necessary integrations with Azure Storage or other compatible storage services. - * + * * Example usage: * {@code builder.withStorageAccountRequired(true); // Indicates the app requires a customer-provided storage account - * builder.withStorageAccountRequired(false); // Indicates the app does not require a separate storage account} + * builder.withStorageAccountRequired(false); // Indicates the app does not require a separate storage account} + * * * @param storageAccountRequired {@code true} to indicate that the web app requires integration with a - * customer-provided storage account; {@code false} if the app can operate with the default - * storage provisions. + * customer-provided storage account; {@code false} if the app can operate with the + * default + * storage provisions. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withStorageAccountRequired(Boolean storageAccountRequired) { @@ -953,12 +972,12 @@ public AzureWebAppBuilder withStorageAccountRequired(Boolean storageAccountRequi * the Azure Resource Manager (ARM) ID of the virtual network subnet. Regional VNET Integration allows * the web app to securely access resources within a virtual network, facilitating scenarios such as * accessing Azure services or databases securely within a private network. - * + * * The ARM ID provided must follow the specific format for virtual networks and subnets: * {@code /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks * /{vnetName}/subnets/{subnetName}}. * This ensures that the web app is correctly associated with the intended virtual network and subnet. - * + * * Example usage: * {@code builder.withVirtualNetworkSubnetId("/subscriptions/your-subscription-id/resourceGroups/your-resource-group/providers/Microsoft.Network/virtualNetworks/your-vnet-name/subnets/your-subnet-name");} * @@ -977,18 +996,19 @@ public AzureWebAppBuilder withVirtualNetworkSubnetId(String virtualNetworkSubnet * virtual network, such as files, databases, or services that are not publicly accessible outside the * VNet. This is particularly useful for web apps that require secure access to resources within a * corporate network or a managed service environment. - * + * * Enabling VNet content share is recommended for applications that rely on secure, high-speed access * to content or services hosted within a VNet. This setting enhances the security posture by ensuring * that sensitive content is accessed over the protected network infrastructure. - * + * * Example usage: * {@code builder.withVnetContentShareEnabled(true); // Enables VNet content sharing * builder.withVnetContentShareEnabled(false); // Disables VNet content sharing} * * @param vnetContentShareEnabled {@code true} to enable accessing content over a virtual network; {@code false} to - * disable this capability. The default setting is typically {@code false}, requiring explicit - * enabling as needed. + * disable this capability. The default setting is typically {@code false}, + * requiring explicit + * enabling as needed. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withVnetContentShareEnabled(Boolean vnetContentShareEnabled) { @@ -1002,19 +1022,20 @@ public AzureWebAppBuilder withVnetContentShareEnabled(Boolean vnetContentShareEn * When enabled, this feature allows the web app to securely access and pull images from a container registry * or other image repositories hosted within a VNet. This is essential for applications that depend on custom * images stored in private networks or require enhanced security for accessing images. - * + * * Enabling VNet image pull is recommended for scenarios where the web app's container images are not hosted * on public registries or when there is a need to ensure secure, private access to images. This setting * facilitates the use of custom or proprietary images that are critical for the application's operation * without exposing them on public networks. - * + * * Example usage: * {@code builder.withVnetImagePullEnabled(true); // Enables pulling images over VNet * builder.withVnetImagePullEnabled(false); // Disables pulling images over VNet} * * @param vnetImagePullEnabled {@code true} to enable pulling images over a Virtual Network; {@code false} to - * disable this capability. The default setting is typically {@code false}, requiring explicit - * enabling as needed. + * disable this capability. The default setting is typically {@code false}, requiring + * explicit + * enabling as needed. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withVnetImagePullEnabled(Boolean vnetImagePullEnabled) { @@ -1028,12 +1049,12 @@ public AzureWebAppBuilder withVnetImagePullEnabled(Boolean vnetImagePullEnabled) * environment of the web app, affecting available features, deployment methods, and the overall * performance profile. The operating system can be set to either Linux or Windows, each offering * distinct advantages and capabilities. - * + * * Linux is often chosen for its performance, security, and support for container-based deployments, * while Windows is preferred for applications that require specific Windows-based technologies or * integrations. The choice should align with the application's requirements and the development * team's expertise. - * + * * Example usage: * {@code builder.withOperatingSystem(AzureOsType.LINUX); // Configures the web app to run on Linux * builder.withOperatingSystem(AzureOsType.WINDOWS); // Configures the web app to run on Windows} @@ -1051,12 +1072,12 @@ public AzureWebAppBuilder withOperatingSystem(AzureOsType operatingSystem) { * Configures the runtime stack for the Azure Web App, specifying the development framework and version * for the application's environment. This method supports both predefined runtime stacks and the ability * to specify newer runtime versions not listed, thanks to the {code ExtendableEnum} functionality. - * + * * Predefined runtime stacks include various versions of .NET, ASP.NET, Node.js, Java, Python, PHP, and more, * for both Windows and Linux operating systems. If a new runtime stack version is available in Azure and not * yet defined in this SDK, it can be specified using the {@code fromString} method of the respective runtime stack * class ({@link AzureWebAppWindowsRuntimeStack} or {@link AzureWebAppLinuxRuntimeStack}). - * + * * Example usage for a predefined Windows runtime stack: * {@code builder.withRuntimeStack(AzureWebAppWindowsRuntimeStack.DOTNET_8);} * @@ -1065,7 +1086,7 @@ public AzureWebAppBuilder withOperatingSystem(AzureOsType operatingSystem) { * * * @param runtimeStack the {@link AzureWebAppRuntimeStack} specifying the desired runtime environment, either - * a predefined option or a custom string for newer runtimes. + * a predefined option or a custom string for newer runtimes. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withRuntimeStack(AzureWebAppRuntimeStack runtimeStack) { @@ -1079,12 +1100,12 @@ public AzureWebAppBuilder withRuntimeStack(AzureWebAppRuntimeStack runtimeStack) * DNS zone name. This method allows for the addition of various types of DNS records (A, AAAA, CNAME, * MX, PTR, SRV, TXT, etc.) to support different DNS configurations necessary for the web app's * routing, mail delivery, and service discovery. - * + * * The DNS zone configuration is key to ensuring the web app is accessible under the desired domain * names and that other DNS-related services are correctly routed. Each record type supports different * configurations, such as target IP addresses for A records, canonical names for CNAME records, and * priority and weight for MX and SRV records. - * + * * Example usage: * {@code DnsRecord aRecord = new DnsARecord.builder() * .withName("www") @@ -1094,9 +1115,9 @@ public AzureWebAppBuilder withRuntimeStack(AzureWebAppRuntimeStack runtimeStack) * builder.withDnsZoneConfig("example.com", aRecord);} * * @param dnsZoneName the name of the DNS zone to which the records should be added. This should match - * the domain name configured in your DNS provider. - * @param dnsRecord an instance of {@link DnsRecord} representing the DNS record to be added to the zone. - * This can be any of the supported DNS record types. + * the domain name configured in your DNS provider. + * @param dnsRecord an instance of {@link DnsRecord} representing the DNS record to be added to the zone. + * This can be any of the supported DNS record types. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withDnsZoneConfig(String dnsZoneName, DnsRecord dnsRecord) { @@ -1118,12 +1139,12 @@ public AzureWebAppBuilder withDnsZoneConfig(String dnsZoneName, DnsRecord dnsRec * Configures multiple DNS records for a specified DNS zone associated with the Azure Web App. This * method allows for batch addition of various types of DNS records (A, AAAA, CNAME, MX, PTR, SRV, TXT, etc.), * supporting comprehensive DNS configurations for domain routing, service discovery, and mail delivery. - * - * Utilizing this method simplifies the process of adding multiple DNS records to a single DNS zone, + * + * Utilizing this method simplifies the process of adding multiple DNS records to a single DNS zone, * enhancing the efficiency of DNS setup tasks. Each type of DNS record supports configurations specific - * to its purpose, such as IP addresses for A and AAAA records, canonical names for CNAME records, and + * to its purpose, such as IP addresses for A and AAAA records, canonical names for CNAME records, and * priority and weight specifications for MX and SRV records. - * + * * Example usage: * {@code Collection dnsRecords = Arrays.asList( * new DnsARecord.builder() @@ -1139,9 +1160,9 @@ public AzureWebAppBuilder withDnsZoneConfig(String dnsZoneName, DnsRecord dnsRec * builder.withDnsZoneConfig("example.com", dnsRecords);} * * @param dnsZoneName the name of the DNS zone to which the records are to be added, matching the domain - * name configured with your DNS provider. - * @param dnsRecords a collection of {@link DnsRecord} instances representing the DNS records to be added - * to the zone. Supports a variety of DNS record types for flexible configuration. + * name configured with your DNS provider. + * @param dnsRecords a collection of {@link DnsRecord} instances representing the DNS records to be added + * to the zone. Supports a variety of DNS record types for flexible configuration. * @return the {@code AzureWebAppBuilder} instance, allowing for fluent chaining of configuration methods. */ public AzureWebAppBuilder withDnsZoneConfig(String dnsZoneName, Collection dnsRecords) { @@ -1154,11 +1175,11 @@ public AzureWebAppBuilder withDnsZoneConfig(String dnsZoneName, Collection> dnsRecordsMap = Map.of( * "example.com", Arrays.asList( @@ -1179,7 +1200,7 @@ public AzureWebAppBuilder withDnsZoneConfig(String dnsZoneName, Collection * * @param dnsRecordsMap a map where each key is a DNS zone name and each value is a collection of {@link DnsRecord} - * instances to be associated with that DNS zone. + * instances to be associated with that DNS zone. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withDnsZoneConfig(Map> dnsRecordsMap) { @@ -1203,12 +1224,12 @@ public AzureWebAppBuilder withDnsZoneConfig(Map deploymentSlots = Arrays.asList( * new AzureWebAppDeploymentSlot.builder() @@ -1218,11 +1239,11 @@ public AzureWebAppBuilder withDnsZoneConfig(Map * * @param deploymentSlots a collection of {@link AzureWebAppDeploymentSlot} instances to be added - * to the web app. Each slot is configured and linked to the parent web app. + * to the web app. Each slot is configured and linked to the parent web app. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withDeploymentSlots(Collection deploymentSlots) { @@ -1241,11 +1262,11 @@ public AzureWebAppBuilder withDeploymentSlots(Collection * * @param deploymentSlot an {@link AzureWebAppDeploymentSlot} instance to be added to the web app. - * The slot is set up to align with the web app's configuration while allowing for specific - * adjustments. + * The slot is set up to align with the web app's configuration while allowing for specific + * adjustments. * @return the {@code AzureWebAppBuilder} instance, enabling fluent chaining of configuration methods. */ public AzureWebAppBuilder withDeploymentSlot(AzureWebAppDeploymentSlot deploymentSlot) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppCloningInfo.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppCloningInfo.java index c2c2aaea..9ef042d9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppCloningInfo.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppCloningInfo.java @@ -11,8 +11,8 @@ @Builder(setterPrefix = "with") public class AzureWebAppCloningInfo { /** - * Application setting overrides for cloned app. - * If specified, these settings override the settings cloned from source app. + * Application setting overrides for cloned app. + * If specified, these settings override the settings cloned from source app. * Otherwise, application settings from source app are retained. */ private Map appSettingsOverrides; @@ -33,7 +33,7 @@ public class AzureWebAppCloningInfo { private Boolean configureLoadBalancing; /** - * Correlation ID of cloning operation. + * Correlation ID of cloning operation. * This ID ties multiple cloning operations together to use the same snapshot. */ private String correlationId; @@ -49,9 +49,11 @@ public class AzureWebAppCloningInfo { private Boolean overwrite; /** - * ARM resource ID of the source app. - * App resource ID is of the form /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName} for production slots - * and /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/slots/{slotName} for other slots. + * ARM resource ID of the source app. + * App resource ID is of the form /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft + * .Web/sites/{siteName} for production slots + * and /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/slots/{ + * slotName} for other slots. */ private String sourceWebAppId; @@ -61,15 +63,16 @@ public class AzureWebAppCloningInfo { private String sourceWebAppLocation; /** - * ARM resource ID of the Traffic Manager profile to use, if it exists. - * Traffic Manager resource ID is of the form /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{profileName}. + * ARM resource ID of the Traffic Manager profile to use, if it exists. + * Traffic Manager resource ID is of the form /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers + * /Microsoft.Network/trafficManagerProfiles/{profileName}. */ private String trafficManagerProfileId; /** - * Name of Traffic Manager profile to create. + * Name of Traffic Manager profile to create. * This is only needed if Traffic Manager profile does not already exist. */ private String trafficManagerProfileName; - + } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppConfiguration.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppConfiguration.java index 204bd559..1781601b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppConfiguration.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppConfiguration.java @@ -412,8 +412,8 @@ public AzureWebAppConfiguration build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureWebAppConfiguration validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureWebAppConfiguration validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return configuration; @@ -423,8 +423,10 @@ public AzureWebAppConfiguration build() { @Override public Collection validate() { - final var DUPLICATED_HOSTING_TYPES = "[AzureWebAppConfiguration Validation] Only one hosting configuration can be set. [%s] has already been set"; - final var INCOMPLETE_JAVA_CONTAINER = "[AzureWebAppConfiguration Validation] Incomplete hosting types definition. Both [javaContainer] and [javaContainerVersion] must be set"; + final var DUPLICATED_HOSTING_TYPES = "[AzureWebAppConfiguration Validation] Only one hosting configuration can be" + + " set. [%s] has already been set"; + final var INCOMPLETE_JAVA_CONTAINER = "[AzureWebAppConfiguration Validation] Incomplete hosting types definition." + + " Both [javaContainer] and [javaContainerVersion] must be set"; var errors = new ArrayList(); @@ -467,17 +469,20 @@ public Collection validate() { } if (getJavaContainer() != null && !StringUtils.isBlank(getJavaContainer()) && - getJavaContainerVersion() != null && !StringUtils.isBlank(getJavaContainerVersion())) { + getJavaContainerVersion() != null && !StringUtils.isBlank(getJavaContainerVersion())) + { if (isNotBlank(versionType)) { errors.add(String.format(DUPLICATED_HOSTING_TYPES, versionType)); return errors; } } else if ((getJavaContainer() == null || StringUtils.isBlank(getJavaContainer())) && - getJavaContainerVersion() != null && !StringUtils.isBlank(getJavaContainerVersion())) { + getJavaContainerVersion() != null && !StringUtils.isBlank(getJavaContainerVersion())) + { errors.add(INCOMPLETE_JAVA_CONTAINER); return errors; } else if (getJavaContainer() != null && !StringUtils.isBlank(getJavaContainer()) && - (getJavaContainerVersion() == null || StringUtils.isBlank(getJavaContainerVersion()))) { + (getJavaContainerVersion() == null || StringUtils.isBlank(getJavaContainerVersion()))) + { errors.add(INCOMPLETE_JAVA_CONTAINER); return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppDeploymentSlot.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppDeploymentSlot.java index c4b990d5..a224c058 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppDeploymentSlot.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppDeploymentSlot.java @@ -23,13 +23,18 @@ @Setter public class AzureWebAppDeploymentSlot implements Validatable { - private final static String RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN = "[AzureWebAppDeploymentSlot Validation] The Runtime Stack and Operating System mismatches. Please choose %s or change Operating System to %s"; - private final static String NAME_NOT_VALID = "[AzureWebAppDeploymentSlot Validation] The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be between 2 and 59 characters"; - private final static String CUSTOM_DOMAIN_NOT_VALID = "[AzureWebAppDeploymentSlot Validation] The CustomDomain must contain at least one period, cannot start or end with a period. CustomDomain are made up of letters, numbers, periods, and dashes."; - private final static String RUNTIME_STACK_IS_EMPTY = "[AzureWebAppDeploymentSlot Validation] The Runtime Stack is either empty or blank and it is required"; - private final static String OPERATING_SYSTEM_IS_EMPTY = "[AzureWebAppDeploymentSlot Validation] The Operating System is either empty or blank and it is required"; + private final static String RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN = "[AzureWebAppDeploymentSlot " + + "Validation] The Runtime Stack and Operating System mismatches. Please choose %s or change Operating System to %s"; + private final static String NAME_NOT_VALID = "[AzureWebAppDeploymentSlot Validation] The name only allow " + + "alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be between 2 and 59 characters"; + private final static String CUSTOM_DOMAIN_NOT_VALID = "[AzureWebAppDeploymentSlot Validation] The CustomDomain must" + + " contain at least one period, cannot start or end with a period. CustomDomain are made up of letters, numbers, " + + "periods, and dashes."; + private final static String RUNTIME_STACK_IS_EMPTY = "[AzureWebAppDeploymentSlot Validation] The Runtime Stack is " + + "either empty or blank and it is required"; + private final static String OPERATING_SYSTEM_IS_EMPTY = "[AzureWebAppDeploymentSlot Validation] The Operating " + + "System is either empty or blank and it is required"; - @JsonIgnore public static final String TAG_KEY_IS_BLANK = "Tag key cannot be null or empty"; @@ -64,7 +69,7 @@ public class AzureWebAppDeploymentSlot implements Validatable { private Collection customDomains; private AzureOsType operatingSystem; private AzureWebAppRuntimeStack runtimeStack; - + AzureWebAppDeploymentSlot() { cloneSettingsFromWebApp = true; @@ -78,7 +83,7 @@ public static DeploymentSlotBuilder builder() { public Collection validate() { Collection errors = new ArrayList<>(); - if(!this.cloneSettingsFromWebApp) { + if (!this.cloneSettingsFromWebApp) { if (configuration == null && operatingSystem == null) { @@ -91,14 +96,15 @@ public Collection validate() { } if (configuration != null - && StringUtils.isBlank(configuration.getDotnetVersion()) - && StringUtils.isBlank(configuration.getJavaVersion()) - && StringUtils.isBlank(configuration.getJavaContainerVersion()) - && StringUtils.isBlank(configuration.getLinuxFxVersion()) - && StringUtils.isBlank(configuration.getNodeVersion()) - && StringUtils.isBlank(configuration.getPhpVersion()) - && StringUtils.isBlank(configuration.getPythonVersion()) - && StringUtils.isBlank(configuration.getWindowsFxVersion())) { + && StringUtils.isBlank(configuration.getDotnetVersion()) + && StringUtils.isBlank(configuration.getJavaVersion()) + && StringUtils.isBlank(configuration.getJavaContainerVersion()) + && StringUtils.isBlank(configuration.getLinuxFxVersion()) + && StringUtils.isBlank(configuration.getNodeVersion()) + && StringUtils.isBlank(configuration.getPhpVersion()) + && StringUtils.isBlank(configuration.getPythonVersion()) + && StringUtils.isBlank(configuration.getWindowsFxVersion())) + { if (operatingSystem == null) { errors.add(OPERATING_SYSTEM_IS_EMPTY); @@ -110,13 +116,17 @@ public Collection validate() { } if (operatingSystem == AzureOsType.LINUX - && runtimeStack instanceof AzureWebAppWindowsRuntimeStack) { - errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppLinuxRuntimeStack", "WINDOWS")); + && runtimeStack instanceof AzureWebAppWindowsRuntimeStack) + { + errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppLinuxRuntimeStack", + "WINDOWS")); } if (operatingSystem == AzureOsType.WINDOWS - && runtimeStack instanceof AzureWebAppLinuxRuntimeStack) { - errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppWindowsRuntimeStack", "LINUX")); + && runtimeStack instanceof AzureWebAppLinuxRuntimeStack) + { + errors.add(String.format(RUNTIME_STACK_AND_OPERATING_SYSTEM_MISMATCH_PATTERN, "AzureWebAppWindowsRuntimeStack", + "LINUX")); } @@ -337,7 +347,7 @@ public DeploymentSlotBuilder withRuntimeStack(AzureWebAppRuntimeStack runtimeSta slot.setRuntimeStack(runtimeStack); return builder; } - + public AzureWebAppDeploymentSlot build() { return slot; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppIpSecurityRestriction.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppIpSecurityRestriction.java index 3ffc7afb..e65f920f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppIpSecurityRestriction.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppIpSecurityRestriction.java @@ -28,22 +28,23 @@ public class AzureWebAppIpSecurityRestriction { private Map> headers; /** - * IP address the security restriction is valid for. - * It can be in form of pure ipv4 address (required SubnetMask property) or CIDR notation such as ipv4/mask (leading bit match). + * IP address the security restriction is valid for. + * It can be in form of pure ipv4 address (required SubnetMask property) or CIDR notation such as ipv4/mask + * (leading bit match). * For CIDR, SubnetMask property must not be specified. */ private String ipAddress; - + /** * IP restriction rule name. */ private String name; - + /** * Priority of IP restriction rule. */ private Integer priority; - + /** * Subnet mask for the range of IP addresses the restriction is valid for. */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStack.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStack.java index ce83d237..820be0e2 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStack.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStack.java @@ -37,7 +37,7 @@ public final class AzureWebAppLinuxRuntimeStack extends ExtendableEnum { - public static final AzureFtpsState ALL_ALLOWED = fromString("AllAllowed"); - public static final AzureFtpsState DISABLED = fromString("Disabled"); - public static final AzureFtpsState FTPS_ONLY = fromString("FtpsOnly"); - - public AzureFtpsState() { - } + public static final AzureFtpsState ALL_ALLOWED = fromString("AllAllowed"); + public static final AzureFtpsState DISABLED = fromString("Disabled"); + public static final AzureFtpsState FTPS_ONLY = fromString("FtpsOnly"); - @JsonCreator - public static AzureFtpsState fromString(String name) { - return fromString(name, AzureFtpsState.class); - } + public AzureFtpsState() { + } - public static Collection values() { + @JsonCreator + public static AzureFtpsState fromString(String name) { + return fromString(name, AzureFtpsState.class); + } - return values(AzureFtpsState.class); - } + public static Collection values() { + + return values(AzureFtpsState.class); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnProfile.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnProfile.java index 18e1b8e7..77d244f7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnProfile.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnProfile.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cdn; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSNetworkCdnProfile; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSNetworkCdnProfile; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceEntity; @@ -68,6 +68,7 @@ protected AzureCdnProfileBuilder getBuilder() { *
          * Configures the identity for the CDN Profile, allowing for both system assigned and user assigned identities.
          * This identity is used for authentication within Azure to access or modify the CDN Profile.
    + * * @param identity The managed service identity configuration. * @return The builder instance for chaining. */ @@ -80,14 +81,15 @@ public AzureCdnProfileBuilder withIdentity(AzureManagedServiceIdentity identity) *
          * Sets the name for the Azure CDN Profile. The name must be unique within the resource group and must follow Azure's
          * naming conventions.
    -     * 
    +     *
          * Validation rules:
          *   - Name can contain letters, numbers, and hyphens.
          *   - The first and last characters must be a letter or a number.
          *   - Maximum length is 260 characters.
          *   - Minimum length is 1 character.
    -     * 
    +     *
          * Attempting to set a name that violates these rules will result in a validation error.
    + * * @param name The unique name of the CDN Profile. * @return The builder instance for chaining. */ @@ -100,15 +102,15 @@ public AzureCdnProfileBuilder withName(String name) { *
          * Configures the origin response timeout in seconds for forwarding requests to the CDN origin. This setting determines
          * how long the CDN waits for a response from the origin server before the request is considered failed.
    -     * 
    +     *
          * Setting an appropriate timeout is crucial for optimizing content delivery performance, balancing the need for content
          * freshness against minimizing user-perceived latency.
    -     * 
    +     *
          * Note on acceptable values:
          *   - The value must be an integer between 16 and 240, inclusive. Values outside this range will be rejected.
          *   - Choosing a value too close to the lower limit may lead to increased failed requests during intermittent
          *     network instability, while setting it too high could cause unnecessary delays for your users.
    - * + * * @param originResponseTimeoutSeconds The desired number of seconds to wait for a response from the origin server. * @return The builder instance for chaining further configuration calls. */ @@ -122,8 +124,8 @@ public AzureCdnProfileBuilder withOriginResponseTimeoutSeconds(Integer originRes * Specifies the SKU (Stock Keeping Unit) for the Azure CDN Profile, which determines the pricing tier, feature * set, and the provider of the CDN services. The SKU choice impacts various aspects of the CDN service, * including global distribution capabilities, content acceleration, security features, and cost. - * - * The AzureCdnSku is an extendable enum, allowing for future expansion. + * + * The AzureCdnSku is an extendable enum, allowing for future expansion. * Current predefined SKUs include: * - STANDARD_EDGIO Standard tier provided by Verizon. Suitable for general content delivery needs * with a balance of performance and cost. @@ -135,14 +137,15 @@ public AzureCdnProfileBuilder withOriginResponseTimeoutSeconds(Integer originRes * for global and dynamic content acceleration. * - PREMIUM_AZURE_FRONT_DOOR The premium version of Azure Front Door services, providing additional * security and optimization features for highly dynamic and secure applications. - * - * @important.note Direct SKU updates post-creation of the CDN profile are not supported through this SDK. Changing the SKU - * requires creating a new CDN profile with the desired SKU and, if necessary, deleting the old one. - * Selecting the correct SKU is crucial for aligning service capabilities with your application needs and - * budget. Review the detailed comparison of features and pricing in Azure CDN documentation to make an - * informed choice. + * * @param sku The desired SKU for the CDN Profile, selected from the predefined AzureCdnSku values. * @return The builder instance for chaining further configuration calls. + * @important.note Direct SKU updates post-creation of the CDN profile are not supported through this SDK. + * Changing the SKU + * requires creating a new CDN profile with the desired SKU and, if necessary, deleting the old one. + * Selecting the correct SKU is crucial for aligning service capabilities with your application needs and + * budget. Review the detailed comparison of features and pricing in Azure CDN documentation to make an + * informed choice. */ public AzureCdnProfileBuilder withSku(AzureCdnSku sku) { component.setSku(sku); @@ -153,7 +156,7 @@ public AzureCdnProfileBuilder withSku(AzureCdnSku sku) { *
          * Configures the Azure region where the CDN Profile will be deployed. The region is a critical
          * configuration that dictates the geographical location of the deployed resources, affecting
    -     * latency, availability, and compliance. Utilizing the {@link AzureRegion} allows for flexibility in specifying 
    +     * latency, availability, and compliance. Utilizing the {@link AzureRegion} allows for flexibility in specifying
          * regions, accommodating cases where specific regions might not be explicitly listed in the enum.
          *
          * In scenarios where automation scripts or tools require dynamic region specification or if a
    @@ -166,6 +169,7 @@ public AzureCdnProfileBuilder withSku(AzureCdnSku sku) {
          * builder.withRegion(AzureRegion.EAST_US); // Using a predefined region
          * builder.withRegion(AzureRegion.fromString("custom_region_name")); // Extending the enum for a custom or future region
          * 
    + * * @param region the Azure region as an {@link AzureRegion} where the Web App will be deployed. * This can either be one of the predefined regions or an extended enum value * created through AzureRegion.fromString(String name). @@ -203,11 +207,11 @@ public AzureCdnProfileBuilder withResourceGroup(AzureResourceGroup resourceGroup return builder; } - public AzureCdnProfile build(){ + public AzureCdnProfile build() { component.setType(PAAS_CDN_PROFILE); return super.build(); } - + } @Override @@ -218,29 +222,32 @@ public Collection validate() { } var nameToValidate = name != null ? name : getId().getValue(); - if (nameToValidate != null){ - if((nameToValidate.isEmpty() || nameToValidate.length() > 260)) { + if (nameToValidate != null) { + if ((nameToValidate.isEmpty() || nameToValidate.length() > 260)) { errors.add("[AzureCdnProfile Validation] The profile name must be between 1 and 260 characters long."); } if (!NAME_PATTERN.matcher(nameToValidate).matches()) { - errors.add("[AzureCdnProfile Validation] The profile name must start and end with a letter or number and can only contain letters, numbers, and hyphens."); + errors.add("[AzureCdnProfile Validation] The profile name must start and end with a letter or number and can " + + "only contain letters, numbers, and hyphens."); } } - + var isSkuAllowed = sku == AzureCdnSku.STANDARD_AZURE_FRONT_DOOR || sku == AzureCdnSku.PREMIUM_AZURE_FRONT_DOOR; if (originResponseTimeoutSeconds != null && !isSkuAllowed) { - errors.add("[AzureCdnProfile Validation] OriginResponseTimeoutSeconds can only be provided when sku is STANDARD_AZURE_FRONT_DOOR or PREMIUM_AZURE_FRONT_DOOR."); + errors.add("[AzureCdnProfile Validation] OriginResponseTimeoutSeconds can only be provided when sku is " + + "STANDARD_AZURE_FRONT_DOOR or PREMIUM_AZURE_FRONT_DOOR."); } if (originResponseTimeoutSeconds != null) { if (originResponseTimeoutSeconds < 16) { errors.add("[AzureCdnProfile Validation] Property 'OriginResponseTimeoutSeconds' must be 16 or greater."); } else if (originResponseTimeoutSeconds > 240) { - errors.add("[AzureCdnProfile Validation] Property 'OriginResponseTimeoutSeconds' exceeds the allowed limit of 240."); + errors.add("[AzureCdnProfile Validation] Property 'OriginResponseTimeoutSeconds' exceeds the allowed limit of" + + " 240."); } } - + return errors; } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureManagedServiceIdentity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureManagedServiceIdentity.java index 3d6f2745..776e34c6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureManagedServiceIdentity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureManagedServiceIdentity.java @@ -41,9 +41,10 @@ public AzureManagedServiceIdentityBuilder withType(AzureIdentityType type) { } /** - * The set of user assigned identity id's associated with the resource. It should be ARM + * The set of user assigned identity id's associated with the resource. It should be ARM * resource ids in the form: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.' + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft + * .ManagedIdentity/userAssignedIdentities/{identityName}.' */ public AzureManagedServiceIdentityBuilder withUserAssignedIdentities(Collection userAssignedIdentities) { instance.setUserAssignedIdentities(userAssignedIdentities); @@ -52,7 +53,8 @@ public AzureManagedServiceIdentityBuilder withUserAssignedIdentities(Collection< /** * User assigned identity associated with the resource. It should be ARM resource id in the form: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.' + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft + * .ManagedIdentity/userAssignedIdentities/{identityName}.' */ public AzureManagedServiceIdentityBuilder withUserAssignedIdentity(String userAssignedIdentityId) { if (instance.getUserAssignedIdentities() == null) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccount.java index e1d04563..d01c44f0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccount.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccount.java @@ -8,11 +8,15 @@ public interface AzureCosmosAccount extends AzureResourceEntity { Collection getCosmosEntities(); + Integer getMaxTotalThroughput(); + void setMaxTotalThroughput(Integer maxTotalThroughput); + AzureCosmosBackupPolicy getBackupPolicy(); + void setBackupPolicy(AzureCosmosBackupPolicy backupPolicy); - + void setPublicNetworkAccess(String publicNetworkAccessMode); static Collection validateCosmosAccount(AzureCosmosAccount cosmosAccount, String accountType) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccountBuilder.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccountBuilder.java index 0638eda1..f473fded 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccountBuilder.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosAccountBuilder.java @@ -12,7 +12,8 @@ import static com.yanchware.fractal.sdk.domain.values.ComponentType.PAAS_COSMOS_ACCOUNT; -public abstract class AzureCosmosAccountBuilder> extends Component.Builder { +public abstract class AzureCosmosAccountBuilder> extends Component.Builder { private static final String PUBLIC_NETWORK_ACCESS_ENABLED_MODE = "Enabled"; private static final String PUBLIC_NETWORK_ACCESS_DISABLED_MODE = "Disabled"; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicy.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicy.java index 921f8076..63537718 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicy.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicy.java @@ -15,8 +15,10 @@ @Getter @Setter(AccessLevel.PRIVATE) public class AzureCosmosBackupPolicy implements Validatable { - private final static String BACKUP_STORAGE_REDUNDANCY_IS_BLANK = "[AzureCosmosBackupPolicy Validation] BackupStorageRedundancy has not been defined and it is required"; - private final static String BACKUP_POLICY_TYPE_IS_BLANK = "[AzureCosmosBackupPolicy Validation] BackupPolicyType has not been defined and it is required"; + private final static String BACKUP_STORAGE_REDUNDANCY_IS_BLANK = "[AzureCosmosBackupPolicy Validation] " + + "BackupStorageRedundancy has not been defined and it is required"; + private final static String BACKUP_POLICY_TYPE_IS_BLANK = "[AzureCosmosBackupPolicy Validation] BackupPolicyType " + + "has not been defined and it is required"; private Integer backupIntervalInMinutes; private Integer backupRetentionIntervalInHours; private BackupStorageRedundancy backupStorageRedundancy; @@ -33,32 +35,34 @@ public AzureCosmosBackupPolicy() { public Collection validate() { Collection errors = new ArrayList<>(); - if(this.backupPolicyType == null) { + if (this.backupPolicyType == null) { errors.add(BACKUP_STORAGE_REDUNDANCY_IS_BLANK); } - - if(this.backupPolicyType == AzureCosmosBackupPolicyType.PERIODIC) { - if(this.backupIntervalInMinutes != null) { - validateIntegerInRange("[AzureCosmosPeriodicModeBackupPolicy Validation] BackupIntervalInMinutes", this.backupIntervalInMinutes, 60, 1440, errors); - if(this.backupStorageRedundancy == null) { + if (this.backupPolicyType == AzureCosmosBackupPolicyType.PERIODIC) { + if (this.backupIntervalInMinutes != null) { + validateIntegerInRange("[AzureCosmosPeriodicModeBackupPolicy Validation] BackupIntervalInMinutes", + this.backupIntervalInMinutes, 60, 1440, errors); + + if (this.backupStorageRedundancy == null) { errors.add(BACKUP_STORAGE_REDUNDANCY_IS_BLANK); } } - if(this.backupRetentionIntervalInHours != null) { - validateIntegerInRange("[AzureCosmosPeriodicModeBackupPolicy Validation] BackupRetentionIntervalInHours", this.backupRetentionIntervalInHours, 8, 720, errors); + if (this.backupRetentionIntervalInHours != null) { + validateIntegerInRange("[AzureCosmosPeriodicModeBackupPolicy Validation] BackupRetentionIntervalInHours", + this.backupRetentionIntervalInHours, 8, 720, errors); } } - + return errors; } - public static class AzureCosmosBackupPolicyBuilder{ + public static class AzureCosmosBackupPolicyBuilder { private final AzureCosmosBackupPolicy backupPolicy; private final AzureCosmosBackupPolicyBuilder builder; - public AzureCosmosBackupPolicyBuilder () { + public AzureCosmosBackupPolicyBuilder() { backupPolicy = createComponent(); builder = getBuilder(); } @@ -91,17 +95,17 @@ public AzureCosmosBackupPolicyBuilder withBackupPolicyType(AzureCosmosBackupPoli return builder; } - public AzureCosmosBackupPolicy build(){ + public AzureCosmosBackupPolicy build() { Collection errors = backupPolicy.validate(); if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format( - "AzureCosmosPeriodicModeBackupPolicy validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + "AzureCosmosPeriodicModeBackupPolicy validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); } return backupPolicy; } } - + } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicyType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicyType.java index caec5b08..2f2dbd45 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicyType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosBackupPolicyType.java @@ -26,9 +26,9 @@ public String toString() { public static AzureCosmosBackupPolicyType fromString(String redundancy) { return Arrays.stream(values()) - .filter(t -> t.value.equalsIgnoreCase(redundancy)) - .findFirst() - .orElse(null); + .filter(t -> t.value.equalsIgnoreCase(redundancy)) + .findFirst() + .orElse(null); } - + } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosCassandraCluster.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosCassandraCluster.java index d69c3e31..5b5ef285 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosCassandraCluster.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosCassandraCluster.java @@ -22,8 +22,11 @@ @Setter(AccessLevel.PROTECTED) @ToString(callSuper = true) public class AzureCosmosCassandraCluster extends PaaSCassandra implements AzureResourceEntity { - private final static String ILLEGAL_AMOUNT_OF_HOURS_BETWEEN_BACKUP = "Cosmos Cassandra Cluster periodic backup feature needs a value of hours between backups that is larger or equal to 1"; - private final static String NAME_NOT_VALID = "[AzureCosmosCassandraCluster Validation] The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be between 3 and 44 characters long"; + private final static String ILLEGAL_AMOUNT_OF_HOURS_BETWEEN_BACKUP = "Cosmos Cassandra Cluster periodic backup " + + "feature needs a value of hours between backups that is larger or equal to 1"; + private final static String NAME_NOT_VALID = "[AzureCosmosCassandraCluster Validation] The name only allow " + + "alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be between 3 and 44 characters " + + "long"; private String cassandraVersion; private boolean useCassandraAuthentication; @@ -53,7 +56,8 @@ public ProviderType getProvider() { return ProviderType.AZURE; } - public static class AzureCosmosCassandraClusterBuilder extends PaaSCassandra.Builder { + public static class AzureCosmosCassandraClusterBuilder extends PaaSCassandra.Builder { @Override protected AzureCosmosCassandraCluster createComponent() { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntity.java index fba6f3f1..e0f29c37 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntity.java @@ -5,18 +5,22 @@ import java.util.Collection; -public interface AzureCosmosEntity extends AzureResourceEntity { +public interface AzureCosmosEntity extends AzureResourceEntity { int getThroughput(); + void setThroughput(int throughput); int getMaxThroughput(); + void setMaxThroughput(int maxThroughput); String getEntityName(); static Collection validateCosmosEntity(AzureCosmosEntity cosmosEntity) { - final var MAX_THROUGHPUT_AND_THROUGHPUT_ARE_DEFINED_TEMPLATE = "[Cosmos %s Validation] Defined both throughput and max throughput. Only one of them can be defined and not both"; - final var NAME_IS_NOT_VALID_TEMPLATE = "[Cosmos %s Validation] The Name is invalid. Ensure to provide a unique non-empty string less than '255' characters"; + final var MAX_THROUGHPUT_AND_THROUGHPUT_ARE_DEFINED_TEMPLATE = "[Cosmos %s Validation] Defined both throughput " + + "and max throughput. Only one of them can be defined and not both"; + final var NAME_IS_NOT_VALID_TEMPLATE = "[Cosmos %s Validation] The Name is invalid. Ensure to provide a unique " + + "non-empty string less than '255' characters"; var errors = AzureResourceEntity.validateAzureResourceEntity(cosmosEntity, cosmosEntity.getEntityName()); @@ -25,9 +29,9 @@ static Collection validateCosmosEntity(AzureCosmosEntity cosmosEntity) { if (maxThroughput > 0 && throughput > 0) { errors.add(String.format(MAX_THROUGHPUT_AND_THROUGHPUT_ARE_DEFINED_TEMPLATE, cosmosEntity.getEntityName())); } - + var name = cosmosEntity.getName(); - if(StringUtils.isNotBlank(name) && name.length() > 254) { + if (StringUtils.isNotBlank(name) && name.length() > 254) { errors.add(String.format(NAME_IS_NOT_VALID_TEMPLATE, cosmosEntity.getEntityName())); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntityBuilder.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntityBuilder.java index 033fe1c9..5c6858d3 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntityBuilder.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosEntityBuilder.java @@ -3,10 +3,10 @@ import com.yanchware.fractal.sdk.domain.Component; import com.yanchware.fractal.sdk.domain.values.ComponentId; -public abstract class AzureCosmosEntityBuilder> extends Component.Builder{ +public abstract class AzureCosmosEntityBuilder> extends Component.Builder { public B withCosmosAccount(ComponentId cosmosAccount) { - if (component instanceof AzureCosmosEntity){ + if (component instanceof AzureCosmosEntity) { component.getDependencies().add(cosmosAccount); } @@ -14,7 +14,7 @@ public B withCosmosAccount(ComponentId cosmosAccount) { } public B withName(String name) { - if (component instanceof AzureCosmosEntity){ + if (component instanceof AzureCosmosEntity) { ((AzureCosmosEntity) component).setName(name); } @@ -22,7 +22,7 @@ public B withName(String name) { } public B withThroughput(int throughput) { - if (component instanceof AzureCosmosEntity){ + if (component instanceof AzureCosmosEntity) { ((AzureCosmosEntity) component).setThroughput(throughput); } @@ -30,7 +30,7 @@ public B withThroughput(int throughput) { } public B withMaxThroughput(int maxThroughput) { - if (component instanceof AzureCosmosEntity){ + if (component instanceof AzureCosmosEntity) { ((AzureCosmosEntity) component).setMaxThroughput(maxThroughput); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDatabase.java index 26d774d9..3d4db6d0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDatabase.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSGraphDatabase; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSGraphDatabase; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -20,50 +20,51 @@ @ToString(callSuper = true) public class AzureCosmosGremlinDatabase extends PaaSGraphDatabase implements LiveSystemComponent, AzureCosmosEntity { - public static final String TYPE = PAAS_COSMOS_GREMLIN_DATABASE.getId(); + public static final String TYPE = PAAS_COSMOS_GREMLIN_DATABASE.getId(); - public static AzureCosmosGremlinDatabaseBuilder builder() { - return new AzureCosmosGremlinDatabaseBuilder(); - } - - private String name; - private int throughput; - private int maxThroughput; - private AzureRegion azureRegion; - private AzureResourceGroup azureResourceGroup; - private Map tags; - - @Setter(AccessLevel.PRIVATE) - private String entityName = "Gremlin Database"; + public static AzureCosmosGremlinDatabaseBuilder builder() { + return new AzureCosmosGremlinDatabaseBuilder(); + } + private String name; + private int throughput; + private int maxThroughput; + private AzureRegion azureRegion; + private AzureResourceGroup azureResourceGroup; + private Map tags; - @Override - public ProviderType getProvider() { - return ProviderType.AZURE; - } + @Setter(AccessLevel.PRIVATE) + private String entityName = "Gremlin Database"; - public static class AzureCosmosGremlinDatabaseBuilder extends AzureCosmosEntityBuilder { - @Override - protected AzureCosmosGremlinDatabase createComponent() { - return new AzureCosmosGremlinDatabase(); - } + @Override + public ProviderType getProvider() { + return ProviderType.AZURE; + } - @Override - protected AzureCosmosGremlinDatabaseBuilder getBuilder() { - return this; - } - @Override - public AzureCosmosGremlinDatabase build() { - component.setType(PAAS_COSMOS_GREMLIN_DATABASE); - return super.build(); - } + public static class AzureCosmosGremlinDatabaseBuilder extends AzureCosmosEntityBuilder { + @Override + protected AzureCosmosGremlinDatabase createComponent() { + return new AzureCosmosGremlinDatabase(); + } + @Override + protected AzureCosmosGremlinDatabaseBuilder getBuilder() { + return this; } @Override - public Collection validate() { - return super.validate(); + public AzureCosmosGremlinDatabase build() { + component.setType(PAAS_COSMOS_GREMLIN_DATABASE); + return super.build(); } + + } + + @Override + public Collection validate() { + return super.validate(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDbms.java index 24a01b88..e6f5a9d3 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosGremlinDbms.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSGraphDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSGraphDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -25,7 +25,9 @@ public class AzureCosmosGremlinDbms extends PaaSGraphDbms implements LiveSystemC public static final String TYPE = PAAS_COSMOS_ACCOUNT.getId(); - private final static String NAME_NOT_VALID = "[AzureCosmosGremlinDbms Validation] The name must only contains lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44 characters long"; + private final static String NAME_NOT_VALID = "[AzureCosmosGremlinDbms Validation] The name must only contains " + + "lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44" + + " characters long"; private String name; private Integer maxTotalThroughput; @@ -51,7 +53,8 @@ public static AzureCosmosGremlinDbmsBuilder builder() { return new AzureCosmosGremlinDbmsBuilder(); } - public static class AzureCosmosGremlinDbmsBuilder extends AzureCosmosAccountBuilder { + public static class AzureCosmosGremlinDbmsBuilder extends AzureCosmosAccountBuilder { @Override protected AzureCosmosGremlinDbms createComponent() { @@ -68,14 +71,14 @@ public Collection validate() { Collection errors = super.validate(); errors.addAll(AzureCosmosAccount.validateCosmosAccount(this, "Gremlin DBMS")); - if(StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(name)) { var hasValidCharacters = isValidLowercaseLettersNumbersAndHyphens(name); var hasValidLengths = isValidStringLength(name, 3, 44); - if(!hasValidCharacters || !hasValidLengths) { + if (!hasValidCharacters || !hasValidLengths) { errors.add(NAME_NOT_VALID); } } - + return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDatabase.java index c37034cd..febfd43b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDatabase.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSDocumentDatabase; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSDocumentDatabase; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -20,50 +20,51 @@ @ToString(callSuper = true) public class AzureCosmosMongoDatabase extends PaaSDocumentDatabase implements LiveSystemComponent, AzureCosmosEntity { - public static final String TYPE = PAAS_COSMOS_MONGO_DATABASE.getId(); + public static final String TYPE = PAAS_COSMOS_MONGO_DATABASE.getId(); - public static AzureCosmosMongoDatabaseBuilder builder() { - return new AzureCosmosMongoDatabaseBuilder(); - } + public static AzureCosmosMongoDatabaseBuilder builder() { + return new AzureCosmosMongoDatabaseBuilder(); + } - private String name; - private int throughput; - private int maxThroughput; - private AzureRegion azureRegion; - private AzureResourceGroup azureResourceGroup; + private String name; + private int throughput; + private int maxThroughput; + private AzureRegion azureRegion; + private AzureResourceGroup azureResourceGroup; - @Setter(AccessLevel.PRIVATE) - private String entityName = "Mongo Database"; - - private Map tags; + @Setter(AccessLevel.PRIVATE) + private String entityName = "Mongo Database"; - @Override - public ProviderType getProvider() { - return ProviderType.AZURE; - } + private Map tags; + @Override + public ProviderType getProvider() { + return ProviderType.AZURE; + } - public static class AzureCosmosMongoDatabaseBuilder extends AzureCosmosEntityBuilder { - @Override - protected AzureCosmosMongoDatabase createComponent() { - return new AzureCosmosMongoDatabase(); - } - @Override - protected AzureCosmosMongoDatabaseBuilder getBuilder() { - return this; - } - - @Override - public AzureCosmosMongoDatabase build() { - component.setType(PAAS_COSMOS_MONGO_DATABASE); - return super.build(); - } + public static class AzureCosmosMongoDatabaseBuilder extends AzureCosmosEntityBuilder { + @Override + protected AzureCosmosMongoDatabase createComponent() { + return new AzureCosmosMongoDatabase(); + } + @Override + protected AzureCosmosMongoDatabaseBuilder getBuilder() { + return this; } @Override - public Collection validate() { - return super.validate(); + public AzureCosmosMongoDatabase build() { + component.setType(PAAS_COSMOS_MONGO_DATABASE); + return super.build(); } + + } + + @Override + public Collection validate() { + return super.validate(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDbms.java index c634fd46..e1d63e69 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosMongoDbms.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSDocumentDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSDocumentDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -25,7 +25,9 @@ public class AzureCosmosMongoDbms extends PaaSDocumentDbms implements LiveSystem public static final String TYPE = PAAS_COSMOS_ACCOUNT.getId(); - private final static String NAME_NOT_VALID = "[AzureCosmosMongoDbms Validation] The name must only contains lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44 characters long"; + private final static String NAME_NOT_VALID = "[AzureCosmosMongoDbms Validation] The name must only contains " + + "lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44" + + " characters long"; private String name; private Integer maxTotalThroughput; @@ -51,7 +53,8 @@ public static AzureCosmosMongoDbmsBuilder builder() { return new AzureCosmosMongoDbmsBuilder(); } - public static class AzureCosmosMongoDbmsBuilder extends AzureCosmosAccountBuilder { + public static class AzureCosmosMongoDbmsBuilder extends AzureCosmosAccountBuilder { @Override protected AzureCosmosMongoDbms createComponent() { @@ -68,14 +71,14 @@ public Collection validate() { Collection errors = super.validate(); errors.addAll(AzureCosmosAccount.validateCosmosAccount(this, "Mongo DBMS")); - if(StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(name)) { var hasValidCharacters = isValidLowercaseLettersNumbersAndHyphens(name); var hasValidLengths = isValidStringLength(name, 3, 44); - if(!hasValidCharacters || !hasValidLengths) { + if (!hasValidCharacters || !hasValidLengths) { errors.add(NAME_NOT_VALID); } } - + return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDatabase.java index 60621747..1c1fafb4 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDatabase.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSDocumentDatabase; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSDocumentDatabase; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -20,48 +20,49 @@ @ToString(callSuper = true) public class AzureCosmosNoSqlDatabase extends PaaSDocumentDatabase implements LiveSystemComponent, AzureCosmosEntity { - public static final String TYPE = PAAS_COSMOS_NOSQL_DATABASE.getId(); + public static final String TYPE = PAAS_COSMOS_NOSQL_DATABASE.getId(); - public static AzureCosmosNoSqlDatabaseBuilder builder() { - return new AzureCosmosNoSqlDatabaseBuilder(); - } - - private String name; - private int throughput; - private int maxThroughput; - private AzureRegion azureRegion; - private AzureResourceGroup azureResourceGroup; - private Map tags; + public static AzureCosmosNoSqlDatabaseBuilder builder() { + return new AzureCosmosNoSqlDatabaseBuilder(); + } - @Setter(AccessLevel.PRIVATE) - private String entityName = "NoSql Database"; + private String name; + private int throughput; + private int maxThroughput; + private AzureRegion azureRegion; + private AzureResourceGroup azureResourceGroup; + private Map tags; - @Override - public ProviderType getProvider() { - return ProviderType.AZURE; - } + @Setter(AccessLevel.PRIVATE) + private String entityName = "NoSql Database"; + @Override + public ProviderType getProvider() { + return ProviderType.AZURE; + } - public static class AzureCosmosNoSqlDatabaseBuilder extends AzureCosmosEntityBuilder { - @Override - protected AzureCosmosNoSqlDatabase createComponent() { - return new AzureCosmosNoSqlDatabase(); - } - @Override - protected AzureCosmosNoSqlDatabaseBuilder getBuilder() { - return this; - } + public static class AzureCosmosNoSqlDatabaseBuilder extends AzureCosmosEntityBuilder { + @Override + protected AzureCosmosNoSqlDatabase createComponent() { + return new AzureCosmosNoSqlDatabase(); + } - @Override - public AzureCosmosNoSqlDatabase build() { - component.setType(PAAS_COSMOS_NOSQL_DATABASE); - return super.build(); - } + @Override + protected AzureCosmosNoSqlDatabaseBuilder getBuilder() { + return this; } @Override - public Collection validate() { - return super.validate(); + public AzureCosmosNoSqlDatabase build() { + component.setType(PAAS_COSMOS_NOSQL_DATABASE); + return super.build(); } + } + + @Override + public Collection validate() { + return super.validate(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDbms.java index ea7fb419..e9fd2bd4 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosNoSqlDbms.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSDocumentDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSDocumentDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -25,7 +25,9 @@ public class AzureCosmosNoSqlDbms extends PaaSDocumentDbms implements LiveSystem public static final String TYPE = PAAS_COSMOS_ACCOUNT.getId(); - private final static String NAME_NOT_VALID = "[AzureCosmosNoSqlDbms Validation] The name must only contains lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44 characters long"; + private final static String NAME_NOT_VALID = "[AzureCosmosNoSqlDbms Validation] The name must only contains " + + "lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44" + + " characters long"; private String name; private Integer maxTotalThroughput; @@ -50,7 +52,8 @@ public static AzureCosmosNoSqlDbmsBuilder builder() { return new AzureCosmosNoSqlDbmsBuilder(); } - public static class AzureCosmosNoSqlDbmsBuilder extends AzureCosmosAccountBuilder { + public static class AzureCosmosNoSqlDbmsBuilder extends AzureCosmosAccountBuilder { @Override protected AzureCosmosNoSqlDbms createComponent() { @@ -67,14 +70,14 @@ public Collection validate() { Collection errors = super.validate(); errors.addAll(AzureCosmosAccount.validateCosmosAccount(this, "NoSql DBMS")); - if(StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(name)) { var hasValidCharacters = isValidLowercaseLettersNumbersAndHyphens(name); var hasValidLengths = isValidStringLength(name, 3, 44); - if(!hasValidCharacters || !hasValidLengths) { + if (!hasValidCharacters || !hasValidLengths) { errors.add(NAME_NOT_VALID); } } - + return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosPostgreSqlDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosPostgreSqlDbms.java index 84a1cadf..725aa290 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosPostgreSqlDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosPostgreSqlDbms.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.PaaSPostgreSqlDbms; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; @@ -27,7 +27,9 @@ public class AzureCosmosPostgreSqlDbms extends PaaSPostgreSqlDbms implements LiveSystemComponent, AzureResourceEntity { public static final String TYPE = PAAS_COSMOS_POSTGRESQL_CLUSTER.getId(); - private final static String NAME_NOT_VALID = "[AzureCosmosPostgreSqlDbms Validation] The name must only contains lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 40 characters long"; + private final static String NAME_NOT_VALID = "[AzureCosmosPostgreSqlDbms Validation] The name must only contains " + + "lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 40" + + " characters long"; private String name; private String rootUser; @@ -61,7 +63,8 @@ public static AzureCosmosPostgreSqlDbmsBuilder builder() { return new AzureCosmosPostgreSqlDbmsBuilder(); } - public static class AzureCosmosPostgreSqlDbmsBuilder extends PaaSRelationalDbms.Builder { + public static class AzureCosmosPostgreSqlDbmsBuilder extends PaaSRelationalDbms.Builder { @Override protected AzureCosmosPostgreSqlDbms createComponent() { @@ -75,6 +78,7 @@ protected AzureCosmosPostgreSqlDbmsBuilder getBuilder() { /** * Name of the root user to be set for the PostgreSql DBMS + * * @param rootUser */ public AzureCosmosPostgreSqlDbmsBuilder withRootUser(String rootUser) { @@ -94,6 +98,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withRegion(AzureRegion region) { /** * SKU name for PostgreSql DBMS + * * @param skuName */ public AzureCosmosPostgreSqlDbmsBuilder withSkuName(AzureCosmosPostgreSqlDbmsSkuName skuName) { @@ -103,6 +108,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withSkuName(AzureCosmosPostgreSqlDbmsSku /** * Enable/Disable storage auto grow + * * @param storageAutoGrow */ public AzureCosmosPostgreSqlDbmsBuilder withStorageAutoGrow(AzureStorageAutoGrow storageAutoGrow) { @@ -112,6 +118,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withStorageAutoGrow(AzureStorageAutoGrow /** * PostgreSql DBMS storage in GB + * * @param storageGb */ public AzureCosmosPostgreSqlDbmsBuilder withStorageGb(int storageGb) { @@ -121,6 +128,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withStorageGb(int storageGb) { /** * Setting for backup retention days + * * @param backupRetentionDays */ public AzureCosmosPostgreSqlDbmsBuilder withBackupRetentionDays(int backupRetentionDays) { @@ -130,6 +138,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withBackupRetentionDays(int backupRetent /** * PostgreSql DBMS high replication role + * * @param replicationRole */ public AzureCosmosPostgreSqlDbmsBuilder withReplicationRole(ReplicationRole replicationRole) { @@ -139,6 +148,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withReplicationRole(ReplicationRole repl /** * PostgreSql DBMS high availability mode + * * @param highAvailabilityMode */ public AzureCosmosPostgreSqlDbmsBuilder withHighAvailabilityMode(HighAvailabilityMode highAvailabilityMode) { @@ -148,6 +158,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withHighAvailabilityMode(HighAvailabilit /** * PostgreSql DBMS subnet address cidr + * * @param subnetAddressCidr */ public AzureCosmosPostgreSqlDbmsBuilder withSubnetAddressCidr(String subnetAddressCidr) { @@ -157,6 +168,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withSubnetAddressCidr(String subnetAddre /** * PostgreSql DBMS private cluster + * * @param isPrivate */ public AzureCosmosPostgreSqlDbmsBuilder withIsPrivate(boolean isPrivate) { @@ -166,6 +178,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withIsPrivate(boolean isPrivate) { /** * PostgreSql DBMS coordinator storage GB + * * @param coordinatorStorageGb */ public AzureCosmosPostgreSqlDbmsBuilder withCoordinatorStorageGb(Integer coordinatorStorageGb) { @@ -175,6 +188,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withCoordinatorStorageGb(Integer coordin /** * PostgreSql DBMS workers storage GB + * * @param workerStorageGb */ public AzureCosmosPostgreSqlDbmsBuilder withWorkerStorageGb(Integer workerStorageGb) { @@ -184,6 +198,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withWorkerStorageGb(Integer workerStorag /** * PostgreSql DBMS coordinator cores + * * @param coordinatorCores */ public AzureCosmosPostgreSqlDbmsBuilder withCoordinatorCores(Integer coordinatorCores) { @@ -193,6 +208,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withCoordinatorCores(Integer coordinator /** * PostgreSql DBMS workers cores + * * @param workerCores */ public AzureCosmosPostgreSqlDbmsBuilder withWorkerCores(Integer workerCores) { @@ -202,6 +218,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withWorkerCores(Integer workerCores) { /** * PostgreSql DBMS node count + * * @param nodeCount */ public AzureCosmosPostgreSqlDbmsBuilder withNodeCount(Integer nodeCount) { @@ -211,6 +228,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withNodeCount(Integer nodeCount) { /** * PostgreSql DBMS coordinator server edition + * * @param coordinatorServerEdition */ public AzureCosmosPostgreSqlDbmsBuilder withCoordinatorServerEdition(String coordinatorServerEdition) { @@ -220,6 +238,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withCoordinatorServerEdition(String coor /** * PostgreSql DBMS node server edition + * * @param nodeServerEdition */ public AzureCosmosPostgreSqlDbmsBuilder withNodeServerEdition(String nodeServerEdition) { @@ -229,6 +248,7 @@ public AzureCosmosPostgreSqlDbmsBuilder withNodeServerEdition(String nodeServerE /** * Name of the PostgreSql DBms + * * @param name */ public AzureCosmosPostgreSqlDbmsBuilder withName(String name) { @@ -273,14 +293,14 @@ public AzureCosmosPostgreSqlDbms build() { public Collection validate() { Collection errors = super.validate(); - if(StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(name)) { var hasValidCharacters = isValidLowercaseLettersNumbersAndHyphens(name); var hasValidLengths = isValidStringLength(name, 3, 40); - if(!hasValidCharacters || !hasValidLengths) { + if (!hasValidCharacters || !hasValidLengths) { errors.add(NAME_NOT_VALID); } } - + return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableDbms.java index 1a3d1900..4513e9ef 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableDbms.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDbms; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDbms; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -24,7 +24,9 @@ public class AzureCosmosTableDbms extends PaaSRelationalDbms implements LiveSystemComponent, AzureCosmosAccount { public static final String TYPE = PAAS_COSMOS_ACCOUNT.getId(); - private final static String NAME_NOT_VALID = "[AzureCosmosTableDbms Validation] The name must only contains lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44 characters long"; + private final static String NAME_NOT_VALID = "[AzureCosmosTableDbms Validation] The name must only contains " + + "lowercase letters, numbers, and hyphens. The name must not start or end in a hyphen and must be between 3 and 44" + + " characters long"; private String name; private Integer maxTotalThroughput; @@ -51,7 +53,8 @@ public static AzureCosmosTableDbmsBuilder builder() { return new AzureCosmosTableDbmsBuilder(); } - public static class AzureCosmosTableDbmsBuilder extends AzureCosmosAccountBuilder { + public static class AzureCosmosTableDbmsBuilder extends AzureCosmosAccountBuilder { @Override protected AzureCosmosTableDbms createComponent() { @@ -68,14 +71,14 @@ public Collection validate() { Collection errors = super.validate(); errors.addAll(AzureCosmosAccount.validateCosmosAccount(this, "Table DBMS")); - if(StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(name)) { var hasValidCharacters = isValidLowercaseLettersNumbersAndHyphens(name); var hasValidLengths = isValidStringLength(name, 3, 44); - if(!hasValidCharacters || !hasValidLengths) { + if (!hasValidCharacters || !hasValidLengths) { errors.add(NAME_NOT_VALID); } } - + return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableEntity.java index 17c16daa..d7344103 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cosmos/AzureCosmosTableEntity.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDatabase; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDatabase; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -20,49 +20,50 @@ @ToString(callSuper = true) public class AzureCosmosTableEntity extends PaaSRelationalDatabase implements LiveSystemComponent, AzureCosmosEntity { - public static final String TYPE = PAAS_COSMOS_TABLE.getId(); + public static final String TYPE = PAAS_COSMOS_TABLE.getId(); - public static AzureCosmosTableEntityBuilder builder() { - return new AzureCosmosTableEntityBuilder(); - } - - private String name; - private int throughput; + public static AzureCosmosTableEntityBuilder builder() { + return new AzureCosmosTableEntityBuilder(); + } - private int maxThroughput; - private AzureRegion azureRegion; - private AzureResourceGroup azureResourceGroup; - private Map tags; + private String name; + private int throughput; - @Setter(AccessLevel.PRIVATE) - private String entityName = "Table Entity"; + private int maxThroughput; + private AzureRegion azureRegion; + private AzureResourceGroup azureResourceGroup; + private Map tags; - @Override - public ProviderType getProvider() { - return ProviderType.AZURE; - } + @Setter(AccessLevel.PRIVATE) + private String entityName = "Table Entity"; + @Override + public ProviderType getProvider() { + return ProviderType.AZURE; + } - public static class AzureCosmosTableEntityBuilder extends AzureCosmosEntityBuilder { - @Override - protected AzureCosmosTableEntity createComponent() { - return new AzureCosmosTableEntity(); - } - @Override - protected AzureCosmosTableEntityBuilder getBuilder() { - return this; - } + public static class AzureCosmosTableEntityBuilder extends AzureCosmosEntityBuilder { + @Override + protected AzureCosmosTableEntity createComponent() { + return new AzureCosmosTableEntity(); + } - @Override - public AzureCosmosTableEntity build() { - component.setType(PAAS_COSMOS_TABLE); - return super.build(); - } + @Override + protected AzureCosmosTableEntityBuilder getBuilder() { + return this; } @Override - public Collection validate() { - return super.validate(); + public AzureCosmosTableEntity build() { + component.setType(PAAS_COSMOS_TABLE); + return super.build(); } + } + + @Override + public Collection validate() { + return super.validate(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelay.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelay.java index 8716138e..4c4d5443 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelay.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelay.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.servicebus; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSMessaging; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSMessaging; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceEntity; @@ -27,8 +27,8 @@ public class AzureRelay extends PaaSMessaging implements AzureResourceEntity, Li private static final Integer ID_MIN_LENGTH = 6; private static final Integer ID_MAX_LENGTH = 50; private final static String NAME_LENGTH_MISMATCH_TEMPLATE = - "[AzureRelay validation] Relay name is illegal. A valid Relay name must be between " + ID_MIN_LENGTH + - " and " + ID_MAX_LENGTH + " characters of length"; + "[AzureRelay validation] Relay name is illegal. A valid Relay name must be between " + ID_MIN_LENGTH + + " and " + ID_MAX_LENGTH + " characters of length"; private String name; private AzureRegion azureRegion; private AzureResourceGroup azureResourceGroup; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBus.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBus.java index 9b6a55f3..7ce339fa 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBus.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBus.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.servicebus; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSMessaging; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSMessaging; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureIdentityType; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; @@ -29,8 +29,8 @@ public class AzureServiceBus extends PaaSMessaging implements AzureResourceEntit private static final Integer ID_MIN_LENGTH = 6; private static final Integer ID_MAX_LENGTH = 50; private final static String NAME_LENGTH_MISMATCH_TEMPLATE = - "[AzureServiceBus validation] Service Bus name is illegal. A valid Service Bus name must be between " + ID_MIN_LENGTH + - " and " + ID_MAX_LENGTH + " characters of length"; + "[AzureServiceBus validation] Service Bus name is illegal. A valid Service Bus name must be between " + ID_MIN_LENGTH + + " and " + ID_MAX_LENGTH + " characters of length"; private String name; private AzureRegion azureRegion; private AzureResourceGroup azureResourceGroup; @@ -61,6 +61,7 @@ protected AzureServiceBusBuilder getBuilder() { /** * Name of the component * Must be between 6 and 50 characters + * * @param name */ public AzureServiceBusBuilder withName(String name) { @@ -112,6 +113,7 @@ public AzureServiceBusBuilder withTag(String key, String value) { /** * Service Bus SKU + * * @param sku */ public AzureServiceBusBuilder withSku(ServiceBusSku sku) { @@ -121,6 +123,7 @@ public AzureServiceBusBuilder withSku(ServiceBusSku sku) { /** * Identity of the Service Bus + * * @param identity */ public AzureServiceBusBuilder withIdentity(AzureIdentityType identity) { @@ -130,6 +133,7 @@ public AzureServiceBusBuilder withIdentity(AzureIdentityType identity) { /** * Encryption properties for the Service Bus + * * @param encryption */ public AzureServiceBusBuilder withEncryption(Encryption encryption) { @@ -139,6 +143,7 @@ public AzureServiceBusBuilder withEncryption(Encryption encryption) { /** * If enabled, creates a Zone Redundant Service Bus in regions supported availability zones + * * @param zoneRedundant */ public AzureServiceBusBuilder withZoneRedundant(Boolean zoneRedundant) { @@ -148,6 +153,7 @@ public AzureServiceBusBuilder withZoneRedundant(Boolean zoneRedundant) { /** * Disabling local auth for the Service Bus + * * @param disableLocalAuth */ public AzureServiceBusBuilder withDisableLocalAuth(Boolean disableLocalAuth) { @@ -157,6 +163,7 @@ public AzureServiceBusBuilder withDisableLocalAuth(Boolean disableLocalAuth) { /** * Queue that will be created part of the Service Bus + * * @param queue */ public AzureServiceBusBuilder withQueue(AzureServiceBusQueue queue) { @@ -165,6 +172,7 @@ public AzureServiceBusBuilder withQueue(AzureServiceBusQueue queue) { /** * List of queues that will be created part of the Service Bus + * * @param queues */ public AzureServiceBusBuilder withQueues(Collection queues) { @@ -183,6 +191,7 @@ public AzureServiceBusBuilder withQueues(Collection queues /** * Topic that will be created part of the Service Bus + * * @param topic */ public AzureServiceBusBuilder withTopic(AzureServiceBusTopic topic) { @@ -191,6 +200,7 @@ public AzureServiceBusBuilder withTopic(AzureServiceBusTopic topic) { /** * List of topics that will be created part of the Service Bus + * * @param topics */ public AzureServiceBusBuilder withTopics(Collection topics) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusQueue.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusQueue.java index b86b28a6..c273e743 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusQueue.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusQueue.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.servicebus; import com.yanchware.fractal.sdk.domain.Component; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSMessageEntity; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSMessageEntity; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.Getter; @@ -37,7 +37,8 @@ public class AzureServiceBusQueue extends PaaSMessageEntity implements LiveSyste protected AzureServiceBusQueue() { } - public static class AzureServiceBusQueueBuilder extends Component.Builder { + public static class AzureServiceBusQueueBuilder extends Component.Builder { @Override protected AzureServiceBusQueue createComponent() { @@ -51,6 +52,7 @@ protected AzureServiceBusQueueBuilder getBuilder() { /** * Idle after which the queue is automatically deleted + * * @param autoDeleteOnIdle */ public AzureServiceBusQueueBuilder withAutoDeleteOnIdle(Duration autoDeleteOnIdle) { @@ -60,6 +62,7 @@ public AzureServiceBusQueueBuilder withAutoDeleteOnIdle(Duration autoDeleteOnIdl /** * If enabled, dead letter support is available when a message expires + * * @param deadLetteringOnMessageExpiration */ public AzureServiceBusQueueBuilder withDeadLetteringOnMessageExpiration(Boolean deadLetteringOnMessageExpiration) { @@ -69,6 +72,7 @@ public AzureServiceBusQueueBuilder withDeadLetteringOnMessageExpiration(Boolean /** * Duration after which the message expires + * * @param defaultMessageTimeToLive */ public AzureServiceBusQueueBuilder withDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) { @@ -78,6 +82,7 @@ public AzureServiceBusQueueBuilder withDefaultMessageTimeToLive(Duration default /** * Duration of duplicate detection history + * * @param duplicateDetectionHistoryTimeWindow */ public AzureServiceBusQueueBuilder withDuplicateDetectionHistoryTimeWindow(Duration duplicateDetectionHistoryTimeWindow) { @@ -87,6 +92,7 @@ public AzureServiceBusQueueBuilder withDuplicateDetectionHistoryTimeWindow(Durat /** * Indicates if Express Entities are enabled + * * @param enableExpress */ public AzureServiceBusQueueBuilder withEnableExpress(Boolean enableExpress) { @@ -95,7 +101,8 @@ public AzureServiceBusQueueBuilder withEnableExpress(Boolean enableExpress) { } /** - * Indicates if batched operations are enabled + * Indicates if batched operations are enabled + * * @param enableBatchedOperations */ public AzureServiceBusQueueBuilder withEnableBatchedOperations(Boolean enableBatchedOperations) { @@ -105,6 +112,7 @@ public AzureServiceBusQueueBuilder withEnableBatchedOperations(Boolean enableBat /** * Indicates if the queue will be partitioned across multiple message brokers + * * @param enablePartitioning */ public AzureServiceBusQueueBuilder withEnablePartitioning(Boolean enablePartitioning) { @@ -114,6 +122,7 @@ public AzureServiceBusQueueBuilder withEnablePartitioning(Boolean enablePartitio /** * Name of the queue where to forward messages + * * @param forwardTo */ public AzureServiceBusQueueBuilder withForwardTo(String forwardTo) { @@ -123,6 +132,7 @@ public AzureServiceBusQueueBuilder withForwardTo(String forwardTo) { /** * Name of the queue where to forward dead letter messages + * * @param forwardDeadLetteredMessagesTo */ public AzureServiceBusQueueBuilder withForwardDeadLetteredMessagesTo(String forwardDeadLetteredMessagesTo) { @@ -132,6 +142,7 @@ public AzureServiceBusQueueBuilder withForwardDeadLetteredMessagesTo(String forw /** * Duration of a peek-lock (amount of time that a message is locked for other receivers) + * * @param lockDuration */ public AzureServiceBusQueueBuilder withLockDuration(Duration lockDuration) { @@ -141,6 +152,7 @@ public AzureServiceBusQueueBuilder withLockDuration(Duration lockDuration) { /** * Maximum delivery count + * * @param maxDeliveryCount */ public AzureServiceBusQueueBuilder withMaxDeliveryCount(Integer maxDeliveryCount) { @@ -150,6 +162,7 @@ public AzureServiceBusQueueBuilder withMaxDeliveryCount(Integer maxDeliveryCount /** * Maximum size of the queue in megabytes + * * @param maxSizeInMegabytes */ public AzureServiceBusQueueBuilder withMaxSizeInMegabytes(Integer maxSizeInMegabytes) { @@ -159,6 +172,7 @@ public AzureServiceBusQueueBuilder withMaxSizeInMegabytes(Integer maxSizeInMegab /** * Maximum size of message payload in kilobytes + * * @param maxMessageSizeInKilobytes */ public AzureServiceBusQueueBuilder withMaxMessageSizeInKilobytes(Long maxMessageSizeInKilobytes) { @@ -168,6 +182,7 @@ public AzureServiceBusQueueBuilder withMaxMessageSizeInKilobytes(Long maxMessage /** * Indicates if the queue supports the concept of sessions + * * @param requiresSession */ public AzureServiceBusQueueBuilder withRequiresSession(Boolean requiresSession) { @@ -177,6 +192,7 @@ public AzureServiceBusQueueBuilder withRequiresSession(Boolean requiresSession) /** * Indicates if the queue requires duplicate detection + * * @param requiresDuplicateDetection */ public AzureServiceBusQueueBuilder withRequiresDuplicateDetection(Boolean requiresDuplicateDetection) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTopic.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTopic.java index b45e5218..e37523b9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTopic.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTopic.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.servicebus; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSMessageEntity; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSMessageEntity; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.Getter; @@ -45,6 +45,7 @@ protected AzureServiceBusQueueBuilder getBuilder() { /** * Idle after which the topic is automatically deleted + * * @param autoDeleteOnIdle */ public AzureServiceBusQueueBuilder withAutoDeleteOnIdle(Duration autoDeleteOnIdle) { @@ -54,6 +55,7 @@ public AzureServiceBusQueueBuilder withAutoDeleteOnIdle(Duration autoDeleteOnIdl /** * Duration after which the message expires + * * @param defaultMessageTimeToLive */ public AzureServiceBusQueueBuilder withDefaultMessageTimeToLive(Duration defaultMessageTimeToLive) { @@ -63,6 +65,7 @@ public AzureServiceBusQueueBuilder withDefaultMessageTimeToLive(Duration default /** * Duration of duplicate detection history + * * @param duplicateDetectionHistoryTimeWindow */ public AzureServiceBusQueueBuilder withDuplicateDetectionHistoryTimeWindow(Duration duplicateDetectionHistoryTimeWindow) { @@ -72,6 +75,7 @@ public AzureServiceBusQueueBuilder withDuplicateDetectionHistoryTimeWindow(Durat /** * Indicates if Express Entities are enabled + * * @param enableExpress */ public AzureServiceBusQueueBuilder withEnableExpress(Boolean enableExpress) { @@ -81,6 +85,7 @@ public AzureServiceBusQueueBuilder withEnableExpress(Boolean enableExpress) { /** * Indicates if batched operations are enabled + * * @param enableBatchedOperations */ public AzureServiceBusQueueBuilder withEnableBatchedOperations(Boolean enableBatchedOperations) { @@ -90,6 +95,7 @@ public AzureServiceBusQueueBuilder withEnableBatchedOperations(Boolean enableBat /** * Indicates if the topic will be partitioned across multiple message brokers + * * @param enablePartitioning */ public AzureServiceBusQueueBuilder withEnablePartitioning(Boolean enablePartitioning) { @@ -99,6 +105,7 @@ public AzureServiceBusQueueBuilder withEnablePartitioning(Boolean enablePartitio /** * Maximum size of the topic in megabytes + * * @param maxSizeInMegabytes */ public AzureServiceBusQueueBuilder withMaxSizeInMegabytes(Integer maxSizeInMegabytes) { @@ -108,6 +115,7 @@ public AzureServiceBusQueueBuilder withMaxSizeInMegabytes(Integer maxSizeInMegab /** * Maximum size of message payload in kilobytes + * * @param maxMessageSizeInKilobytes */ public AzureServiceBusQueueBuilder withMaxMessageSizeInKilobytes(Long maxMessageSizeInKilobytes) { @@ -117,6 +125,7 @@ public AzureServiceBusQueueBuilder withMaxMessageSizeInKilobytes(Long maxMessage /** * Indicates if the topic requires duplicate detection + * * @param requiresDuplicateDetection */ public AzureServiceBusQueueBuilder withRequiresDuplicateDetection(Boolean requiresDuplicateDetection) { @@ -126,6 +135,7 @@ public AzureServiceBusQueueBuilder withRequiresDuplicateDetection(Boolean requir /** * Indicates if the topic supports ordering + * * @param supportOrdering */ public AzureServiceBusQueueBuilder withSupportOrdering(Boolean supportOrdering) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainer.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainer.java index ea753f7e..bf5a9833 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainer.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainer.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.storageaccount; import com.yanchware.fractal.sdk.domain.Validatable; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSStorageContainer; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSStorageContainer; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -21,8 +21,11 @@ @Getter @Setter(AccessLevel.PROTECTED) public class AzureBlobContainer extends PaaSStorageContainer implements LiveSystemComponent, Validatable { - private static final Pattern NAME_PATTERN = Pattern.compile("^[a-z0-9](?:[a-z0-9]|(?<=[a-z0-9])-(?=[a-z0-9])){1,61}[a-z0-9]$"); - private static final String INVALID_NAME_MESSAGE = "This name may only contain lowercase letters, numbers, and hyphens, and must begin with a letter or a number. Each hyphen must be preceded and followed by a non-hyphen character. The name must also be between 3 and 63 characters long"; + private static final Pattern NAME_PATTERN = Pattern.compile("^[a-z0-9](?:[a-z0-9]|(?<=[a-z0-9])-(?=[a-z0-9])){1," + + "61}[a-z0-9]$"); + private static final String INVALID_NAME_MESSAGE = "This name may only contain lowercase letters, numbers, and " + + "hyphens, and must begin with a letter or a number. Each hyphen must be preceded and followed by a non-hyphen " + + "character. The name must also be between 3 and 63 characters long"; private String name; @@ -91,13 +94,14 @@ public AzureBlobContainer build() { /** *
          * Sets the name for the Azure Blob Container.
    -     * 
    -     * The name must be a valid Azure Blob Container name, adhering to Azure naming requirements. 
    -     * It may only contain lowercase letters, numbers, and hyphens, and must begin and end with a letter or a number. 
    -     * Each hyphen must be preceded and followed by a non-hyphen character. 
    +     *
    +     * The name must be a valid Azure Blob Container name, adhering to Azure naming requirements.
    +     * It may only contain lowercase letters, numbers, and hyphens, and must begin and end with a letter or a number.
    +     * Each hyphen must be preceded and followed by a non-hyphen character.
          * The name must also be between 3 and 63 characters long.
    * - * @param name A String representing the name for the Azure Blob Container. Must follow Azure naming conventions. + * @param name A String representing the name for the Azure Blob Container. Must follow Azure naming + * conventions. * @return The builder instance for chaining. */ public AzureBlobContainerBuilder withName(String name) { @@ -108,9 +112,9 @@ public AzureBlobContainerBuilder withName(String name) { /** *
          * Sets the default encryption scope for the Azure Blob Container.
    -     * 
    -     * This defines the encryption mechanism used for the Blob Container. 
    -     * Setting a default encryption scope enables specifying the encryption key 
    +     *
    +     * This defines the encryption mechanism used for the Blob Container.
    +     * Setting a default encryption scope enables specifying the encryption key
          * to be used for storing the blobs in this container.
    * * @param defaultEncryptionScope A String representing the default encryption scope. @@ -124,8 +128,8 @@ public AzureBlobContainerBuilder withDefaultEncryptionScope(String defaultEncryp /** *
          * Specifies whether the encryption scope override should be denied for the Azure Blob Container.
    -     * 
    -     * When set to true, it prevents the clients from specifying an encryption scope other than the default 
    +     *
    +     * When set to true, it prevents the clients from specifying an encryption scope other than the default
          * for this container. This ensures that all blobs in the container are encrypted under the same scope.
    * * @param denyEncryptionScopeOverride A Boolean indicating whether to deny encryption scope override. @@ -139,8 +143,8 @@ public AzureBlobContainerBuilder withDenyEncryptionScopeOverride(Boolean denyEnc /** *
          * Enables or disables the NFSv3 'all squash' feature for the Azure Blob Container.
    -     * 
    -     * When enabled, all user access is mapped to anonymous access. 
    +     *
    +     * When enabled, all user access is mapped to anonymous access.
          * This can be useful in scenarios where you do not want to maintain user identities for access to the container.
    * * @param enableNfsV3AllSquash A Boolean indicating whether to enable NFSv3 all squash. @@ -154,9 +158,9 @@ public AzureBlobContainerBuilder withEnableNfsV3AllSquash(Boolean enableNfsV3All /** *
          * Enables or disables the NFSv3 'root squash' feature for the Azure Blob Container.
    -     * 
    -     * When enabled, it maps the root user access to an anonymous user access. 
    -     * This is a security feature to prevent a root user on the client machine from having root privileges 
    +     *
    +     * When enabled, it maps the root user access to an anonymous user access.
    +     * This is a security feature to prevent a root user on the client machine from having root privileges
          * on the container.
    * * @param enableNfsV3RootSquash A Boolean indicating whether to enable NFSv3 root squash. @@ -170,11 +174,12 @@ public AzureBlobContainerBuilder withEnableNfsV3RootSquash(Boolean enableNfsV3Ro /** *
          * Sets the immutable storage with versioning configuration for the Azure Blob Container.
    -     * 
    -     * Immutable storage with versioning helps protect your data from accidental or malicious modification and deletion. 
    +     *
    +     * Immutable storage with versioning helps protect your data from accidental or malicious modification and deletion.
          * It's useful for scenarios where data preservation is critical.
    * - * @param immutableStorageWithVersioning An instance of {@link AzureBlobContainerImmutableStorageWithVersioning} representing the configuration settings. + * @param immutableStorageWithVersioning An instance of {@link AzureBlobContainerImmutableStorageWithVersioning} + * representing the configuration settings. * @return The builder instance for chaining. */ public AzureBlobContainerBuilder withImmutableStorageWithVersioning(AzureBlobContainerImmutableStorageWithVersioning immutableStorageWithVersioning) { @@ -185,8 +190,8 @@ public AzureBlobContainerBuilder withImmutableStorageWithVersioning(AzureBlobCon /** *
          * Sets the metadata for the Azure Blob Container.
    -     * 
    -     * Metadata is represented as a collection of key-value pairs that can be used to store additional information 
    +     *
    +     * Metadata is represented as a collection of key-value pairs that can be used to store additional information
          * about the container. Each key and value must be a non-null and non-empty string.
    * * @param metadata A Map<String, String> containing the metadata key-value pairs. @@ -200,19 +205,20 @@ public AzureBlobContainerBuilder withMetadata(Map metadata) { /** *
          * Sets the level of public access allowed for the Azure Blob Container.
    -     * 
    -     * Determines the accessibility of the data within the container from the internet based on the specified level 
    +     *
    +     * Determines the accessibility of the data within the container from the internet based on the specified level
          * of public access:
          *   - {@link AzureBlobContainerPublicAccess#CONTAINER}: Full public read access for both container and blob data.
    -     *   - {@link AzureBlobContainerPublicAccess#BLOB}: Public read access for blob data only; container data is not 
    +     *   - {@link AzureBlobContainerPublicAccess#BLOB}: Public read access for blob data only; container data is not
          *     accessible publicly.
    -     *   - {@link AzureBlobContainerPublicAccess#NONE}: No public read access; data within the container can only be 
    +     *   - {@link AzureBlobContainerPublicAccess#NONE}: No public read access; data within the container can only be
          *     accessed with appropriate authorization.
          *
    -     * This setting is crucial for controlling the exposure of data stored in Azure Blob Containers to the public 
    +     * This setting is crucial for controlling the exposure of data stored in Azure Blob Containers to the public
          * internet.
    * - * @param publicAccess An instance of {@link AzureBlobContainerPublicAccess} representing the desired level of public access. + * @param publicAccess An instance of {@link AzureBlobContainerPublicAccess} representing the desired level of + * public access. * @return The builder instance for chaining, allowing for fluent configuration of the {@link AzureBlobContainer}. */ public AzureBlobContainerBuilder withPublicAccess(AzureBlobContainerPublicAccess publicAccess) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerImmutableStorageWithVersioning.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerImmutableStorageWithVersioning.java index f76642f0..f23b1457 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerImmutableStorageWithVersioning.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerImmutableStorageWithVersioning.java @@ -25,9 +25,9 @@ public AzureBlobContainerImmutableStorageWithVersioningBuilder() { /** *
          * Sets whether immutable storage with versioning is enabled for the Azure Blob Container.
    -     * 
    -     * Enabling immutable storage with versioning ensures that blobs cannot be modified 
    -     * or deleted once they are created, providing an additional layer of data protection. 
    +     *
    +     * Enabling immutable storage with versioning ensures that blobs cannot be modified
    +     * or deleted once they are created, providing an additional layer of data protection.
          * This setting is particularly useful for compliance and data retention scenarios.
    * * @param enabled A Boolean indicating whether immutable storage with versioning is enabled. @@ -41,9 +41,9 @@ public AzureBlobContainerImmutableStorageWithVersioningBuilder withEnabled(Boole /** *
          * Builds the configured {@link AzureBlobContainerImmutableStorageWithVersioning} instance.
    -     * 
    -     * This method finalizes the configuration of the 
    -     * {@link AzureBlobContainerImmutableStorageWithVersioning} instance and returns it, 
    +     *
    +     * This method finalizes the configuration of the
    +     * {@link AzureBlobContainerImmutableStorageWithVersioning} instance and returns it,
          * ready for use in configuring an Azure Blob Container.
    * * @return The configured {@link AzureBlobContainerImmutableStorageWithVersioning} instance. diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerPublicAccess.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerPublicAccess.java index 535215f6..d6bc411b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerPublicAccess.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobContainerPublicAccess.java @@ -6,31 +6,31 @@ /** *
      * Represents the level of public access granted to an Azure Blob Container.
    - * 
    + *
      * This enum specifies the accessibility of the data within the container from the internet:
    - * 
    + *
      *   ♦ CONTAINER Indicates full public read access for container and blob data.
    - *   ♦ BLOB Indicates public read access for blobs only. Container data is not 
    + *   ♦ BLOB Indicates public read access for blobs only. Container data is not
      *      available publicly.
    - *   ♦ NONE Indicates no public read access. Data within the container can only 
    + *   ♦ NONE Indicates no public read access. Data within the container can only
      *      be accessed with an appropriate authorization.
      * 
    */ public enum AzureBlobContainerPublicAccess { /** - * Full public read access for container and blob data. + * Full public read access for container and blob data. */ CONTAINER("Container"), /** - * Public read access for blobs only. + * Public read access for blobs only. * Container data is not available publicly. */ BLOB("Blob"), /** - * No public read access. + * No public read access. * Data within the container can only be accessed with appropriate authorization. */ NONE("None"); @@ -62,7 +62,9 @@ public static AzureBlobContainerPublicAccess fromString(String value) { return null; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @JsonValue @Override public String toString() { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccount.java index 44dd674b..1f34e73a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccount.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccount.java @@ -31,7 +31,8 @@ public static AzureBlobStorageAccountBuilder builder() { return new AzureBlobStorageAccountBuilder(); } - public static class AzureBlobStorageAccountBuilder extends Builder { + public static class AzureBlobStorageAccountBuilder extends Builder { @Override protected AzureBlobStorageAccount createComponent() { @@ -45,8 +46,8 @@ protected AzureBlobStorageAccountBuilder getBuilder() { /** *
    -     * Indicates whether the Hierarchical Namespace (HNS) is enabled on the storage account, 
    -     * enabling Azure Data Lake Storage Gen2 features. Enabling HNS allows for the organization of files 
    +     * Indicates whether the Hierarchical Namespace (HNS) is enabled on the storage account,
    +     * enabling Azure Data Lake Storage Gen2 features. Enabling HNS allows for the organization of files
          * into a hierarchy of directories for efficient data access.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccount.java index 4d977d0f..c5d49c67 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccount.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccount.java @@ -19,7 +19,7 @@ public class AzureBlockBlobStorageAccount extends BaseAzureStorageAccount { public AzureBlockBlobStorageAccount() { this.containers = new ArrayList<>(); } - + @Override public String getKind() { return "BlockBlobStorage"; @@ -29,7 +29,8 @@ public static AzureBlockBlobStorageAccountBuilder builder() { return new AzureBlockBlobStorageAccountBuilder(); } - public static class AzureBlockBlobStorageAccountBuilder extends Builder { + public static class AzureBlockBlobStorageAccountBuilder extends Builder { @Override protected AzureBlockBlobStorageAccount createComponent() { @@ -43,8 +44,8 @@ protected AzureBlockBlobStorageAccountBuilder getBuilder() { /** *
    -     * Indicates whether the Hierarchical Namespace (HNS) is enabled on the storage account, 
    -     * enabling Azure Data Lake Storage Gen2 features. Enabling HNS allows for the organization of files 
    +     * Indicates whether the Hierarchical Namespace (HNS) is enabled on the storage account,
    +     * enabling Azure Data Lake Storage Gen2 features. Enabling HNS allows for the organization of files
          * into a hierarchy of directories for efficient data access.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypass.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypass.java index 6133e887..0f2513ce 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypass.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypass.java @@ -7,9 +7,9 @@ /** *
    - * Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. 
    + * Specifies whether traffic is bypassed for Logging/Metrics/AzureServices.
      * Possible values are any combination of Logging|Metrics|AzureServices.
    - * 
    + *
      * For example:
      *  "Logging, Metrics"
      *  or None to bypass none of those traffics.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationAction.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationAction.java
    index 9e713847..72cc8a1f 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationAction.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationAction.java
    @@ -7,7 +7,7 @@
     
     /**
      * 
    - * The SAS expiration action. 
    + * The SAS expiration action.
      * Can only be Log.
      * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShare.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShare.java index c388aa51..858bbfb2 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShare.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShare.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.storageaccount; import com.yanchware.fractal.sdk.domain.Validatable; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSFileShare; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSFileShare; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; @@ -55,7 +55,8 @@ public Collection validate() { } else if (name.length() < 3 || name.length() > 63) { errors.add("Name must be between 3 and 63 characters in length"); } else if (!NAME_PATTERN.matcher(name).matches()) { - errors.add("Invalid name: '" + name + "'; Name must use numbers, lower-case letters, and dash (-) only. Every dash (-) must be immediately preceded and followed by a letter or number"); + errors.add("Invalid name: '" + name + "'; Name must use numbers, lower-case letters, and dash (-) only. Every " + + "dash (-) must be immediately preceded and followed by a letter or number"); } if (enabledProtocols == AzureFileShareEnabledProtocols.NFS) { @@ -82,8 +83,8 @@ public Collection validate() { if (signedIdentifiers != null) { signedIdentifiers.forEach(signedIdentifier -> errors.addAll(signedIdentifier.validate())); } - - if(shareQuota != null && shareQuota <=0) { + + if (shareQuota != null && shareQuota <= 0) { errors.add("Share quota must be greater than 0 for shares."); } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicy.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicy.java index 0996a148..0ed3e4b6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicy.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicy.java @@ -13,7 +13,7 @@ @Getter @Setter(AccessLevel.PRIVATE) public class AzureFileShareAccessPolicy implements Validatable { - + private OffsetDateTime expiryTime; private String permission; private OffsetDateTime startTime; @@ -25,17 +25,17 @@ public static AzureFileShareAccessPolicyBuilder builder() { @Override public Collection validate() { Collection errors = new ArrayList<>(); - + if (expiryTime == null) { errors.add("Expiry time cannot be null"); } else if (startTime != null && expiryTime.isBefore(startTime)) { errors.add("Expiry time must be after start time"); } - + if (permission == null || permission.trim().isEmpty()) { errors.add("Permission cannot be null or empty"); } - + if (startTime == null) { errors.add("Start time cannot be null"); } @@ -87,7 +87,7 @@ public AzureFileShareAccessPolicy build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("AzureFileShareAccessPolicy validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return accessPolicy; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTier.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTier.java index 6ed183d2..8cebf590 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTier.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTier.java @@ -6,8 +6,8 @@ import java.util.Collection; /** - * Access tier for specific share. - * GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. + * Access tier for specific share. + * GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. * FileStorage account can choose Premium. */ public final class AzureFileShareAccessTier extends ExtendableEnum { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocols.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocols.java index f6b3434b..d5299546 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocols.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocols.java @@ -8,7 +8,7 @@ public final class AzureFileShareEnabledProtocols extends ExtendableEnum { public static final AzureFileShareEnabledProtocols NFS = fromString("NFS"); public static final AzureFileShareEnabledProtocols SMB = fromString("SMB"); - + public AzureFileShareEnabledProtocols() { } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifier.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifier.java index dde01e0e..593fa3f0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifier.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifier.java @@ -14,7 +14,7 @@ @Setter(AccessLevel.PRIVATE) public class AzureFileShareSignedIdentifier implements Validatable { private String id; - + private AzureFileShareAccessPolicy accessPolicy; public static AzureFileShareSignedIdentifierBuilder builder() { @@ -24,11 +24,11 @@ public static AzureFileShareSignedIdentifierBuilder builder() { @Override public Collection validate() { Collection errors = new ArrayList<>(); - + if (StringUtils.isBlank(id)) { errors.add("ID cannot be null or empty."); } - + if (accessPolicy == null) { errors.add("Access policy cannot be null."); } else { @@ -70,7 +70,7 @@ public AzureFileShareSignedIdentifier build() { if (!errors.isEmpty()) { throw new IllegalArgumentException(String.format("AzureFileShareSignedIdentifier validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); + Arrays.toString(errors.toArray()))); } return signedIdentifier; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccount.java index 01e5d762..148e8464 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccount.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccount.java @@ -20,7 +20,7 @@ public class AzureFileStorageAccount extends BaseAzureStorageAccount { public AzureFileStorageAccount() { this.fileShares = new ArrayList<>(); } - + @Override public String getKind() { return "FileStorage"; @@ -30,7 +30,8 @@ public static AzureFileStorageAccountBuilder builder() { return new AzureFileStorageAccountBuilder(); } - public static class AzureFileStorageAccountBuilder extends Builder { + public static class AzureFileStorageAccountBuilder extends Builder { @Override protected AzureFileStorageAccount createComponent() { @@ -58,7 +59,7 @@ public AzureFileStorageAccountBuilder withFileShares(Collection f.setAzureRegion(component.getAzureRegion()); f.setAzureResourceGroup(component.getAzureResourceGroup()); }); - + this.component.fileShares.addAll(fileShares); return this; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFilesIdentityBasedAuthentication.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFilesIdentityBasedAuthentication.java index b1e17e08..5b7665c9 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFilesIdentityBasedAuthentication.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFilesIdentityBasedAuthentication.java @@ -34,7 +34,8 @@ public AzureFilesIdentityBasedAuthenticationBuilder() { *
    Required if directoryServiceOptions are AD, optional if they are AADKERB.
    */ public AzureFilesIdentityBasedAuthenticationBuilder withActiveDirectoryProperties( - AzureActiveDirectoryProperties activeDirectoryProperties) { + AzureActiveDirectoryProperties activeDirectoryProperties) + { azureFilesIdentityBasedAuthentication.setActiveDirectoryProperties(activeDirectoryProperties); return builder; } @@ -43,7 +44,8 @@ public AzureFilesIdentityBasedAuthenticationBuilder withActiveDirectoryPropertie *
    Default share permission for users using Kerberos authentication if RBAC role is not assigned.
    */ public AzureFilesIdentityBasedAuthenticationBuilder withDefaultSharePermission( - AzureDefaultSharePermission defaultSharePermission) { + AzureDefaultSharePermission defaultSharePermission) + { azureFilesIdentityBasedAuthentication.setDefaultSharePermission(defaultSharePermission); return builder; } @@ -52,7 +54,8 @@ public AzureFilesIdentityBasedAuthenticationBuilder withDefaultSharePermission( *
    Indicates the directory service used. Note that this enum may be extended in the future.
    */ public AzureFilesIdentityBasedAuthenticationBuilder withDirectoryServiceOptions( - AzureDirectoryServiceOptions directoryServiceOptions) { + AzureDirectoryServiceOptions directoryServiceOptions) + { azureFilesIdentityBasedAuthentication.setDirectoryServiceOptions(directoryServiceOptions); return builder; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureImmutableStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureImmutableStorageAccount.java index 50cb69d4..aadc2497 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureImmutableStorageAccount.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureImmutableStorageAccount.java @@ -26,7 +26,7 @@ public AzureImmutableStorageAccountBuilder() { /** *
    -     * A boolean flag which enables account-level immutability. 
    +     * A boolean flag which enables account-level immutability.
          * All the containers under such an account have object-level immutability enabled by default.
          * 
    */ @@ -34,12 +34,12 @@ public AzureImmutableStorageAccountBuilder withEnabled(Boolean enabled) { instance.setEnabled(enabled); return builder; } - + /** *
    -     * Specifies the default account-level immutability policy which is inherited and applied to objects 
    -     * that do not possess an explicit immutability policy at the object level. 
    -     * The object-level immutability policy has higher precedence than the container-level immutability policy, 
    +     * Specifies the default account-level immutability policy which is inherited and applied to objects
    +     * that do not possess an explicit immutability policy at the object level.
    +     * The object-level immutability policy has higher precedence than the container-level immutability policy,
          * which has a higher precedence than the account-level immutability policy.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRule.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRule.java index 59dfd2f0..41de0d04 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRule.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRule.java @@ -38,10 +38,10 @@ public AzureIpRuleBuilder withAction(AzureNetworkAction action) { instance.setAction(action); return builder; } - + /** *
    -     * Specifies the IP or IP range in CIDR format. 
    +     * Specifies the IP or IP range in CIDR format.
          * Only IPV4 address is allowed.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccount.java index add74c3a..5b55e8f1 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccount.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccount.java @@ -57,7 +57,7 @@ public AzureLegacyStorageAccountBuilder withFileShares(Collection { public static final AzureNetworkAction ALLOW = fromString("Allow"); + /** * Creates or finds an Azure Network Action from its string representation. * diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureNetworkRuleSet.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureNetworkRuleSet.java index c31793f0..1e9e4b5a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureNetworkRuleSet.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureNetworkRuleSet.java @@ -35,8 +35,8 @@ public AzureNetworkRuleSetBuilder() { /** *
    -     * Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. 
    -     * Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), 
    +     * Specifies whether traffic is bypassed for Logging/Metrics/AzureServices.
    +     * Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"),
          * or None to bypass none of those traffics.
          * 
    */ @@ -44,7 +44,7 @@ public AzureNetworkRuleSetBuilder withBypass(AzureBypass bypass) { instance.setBypass(bypass); return builder; } - + /** *
          * Specifies the default action of allow or deny when no other rules match.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureResourceAccessRule.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureResourceAccessRule.java
    index e1d6e7d3..ae72e339 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureResourceAccessRule.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureResourceAccessRule.java
    @@ -38,7 +38,7 @@ public AzureResourceAccessRuleBuilder withResourceId(String resourceId) {
           instance.setResourceId(resourceId);
           return builder;
         }
    -    
    +
         /**
          * 
          * Tenant Id
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoice.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoice.java
    index b652e784..0f04f09c 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoice.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoice.java
    @@ -13,7 +13,7 @@
     public final class AzureRoutingChoice extends ExtendableEnum {
       public static final AzureRoutingChoice MICROSOFT_ROUTING = fromString("MicrosoftRouting");
       public static final AzureRoutingChoice INTERNET_ROUTING = fromString("InternetRouting");
    -  
    +
     
       /**
        * Creates or finds a RoutingChoice from its string representation.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccount.java
    index ffafe9ac..16a181d5 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccount.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccount.java
    @@ -19,7 +19,7 @@ public class AzureStorageAccount extends BaseAzureStorageAccount {
       public AzureStorageAccount() {
         this.containers = new ArrayList<>();
       }
    -  
    +
       @Override
       public String getKind() {
         return "StorageV2";
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountBackup.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountBackup.java
    index 606fc741..24892638 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountBackup.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountBackup.java
    @@ -45,7 +45,7 @@ public AzureStorageAccountBackupBuilder withVaultName(String vaultName) {
     
         /**
          * 
    -     * Specifies the geographic location of the Recovery Services vault, ensuring data residency and compliance 
    +     * Specifies the geographic location of the Recovery Services vault, ensuring data residency and compliance
          * requirements are met.
          * 
    */ @@ -66,7 +66,7 @@ public AzureStorageAccountBackupBuilder withVaultResourceGroupName(String vaultR /** *
    -     * Specifies the SKU level for the Recovery Services vault, which determines the pricing and features available 
    +     * Specifies the SKU level for the Recovery Services vault, which determines the pricing and features available
          * for backup and recovery services.
          * 
    */ @@ -77,7 +77,7 @@ public AzureStorageAccountBackupBuilder withSku(AzureRecoveryServicesSkuName sku /** *
    -     * A unique identifier for a particular configuration version of the Recovery Services vault, used for optimistic 
    +     * A unique identifier for a particular configuration version of the Recovery Services vault, used for optimistic
          * concurrency during updates.
          * 
    */ @@ -88,7 +88,7 @@ public AzureStorageAccountBackupBuilder withEtag(String etag) { /** *
    -     * The name of the backup policy applied to the storage account. Backup policies define the schedule and retention 
    +     * The name of the backup policy applied to the storage account. Backup policies define the schedule and retention
          * rules for backups.
          * 
    */ @@ -119,7 +119,7 @@ public AzureStorageAccountBackupBuilder withPolicyLocation(String policyLocation /** *
    -     * Determines the type of Azure workload the backup policy is designed for, allowing for targeted backup strategies 
    +     * Determines the type of Azure workload the backup policy is designed for, allowing for targeted backup strategies
          * tailored to specific service types.
          * 
    */ @@ -130,7 +130,7 @@ public AzureStorageAccountBackupBuilder withPolicyType(AzureRecoveryServicesBack /** *
    -     * A JSON string representing the detailed configuration of the backup policy, including backup frequency, 
    +     * A JSON string representing the detailed configuration of the backup policy, including backup frequency,
          * retention duration, and other parameters.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountCustomDomain.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountCustomDomain.java index a49e3fff..b94efb1a 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountCustomDomain.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountCustomDomain.java @@ -29,7 +29,7 @@ public AzureStorageAccountCustomDomainBuilder() { /** *
    -     * Sets the custom domain name assigned to the storage account. 
    +     * Sets the custom domain name assigned to the storage account.
          * Name is the CNAME source.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryption.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryption.java index 0333d4e6..0dee695d 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryption.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryption.java @@ -40,7 +40,7 @@ public AzureStorageAccountEncryptionBuilder withIdentity(AzureStorageAccountEncr /** *
    -     * The encryption keySource (provider). 
    +     * The encryption keySource (provider).
          * Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault
          * 
    */ @@ -58,10 +58,10 @@ public AzureStorageAccountEncryptionBuilder withKeyVaultProperties(AzureStorageA encryption.setKeyVaultProperties(keyVaultProperties); return builder; } - + /** *
    -     * A boolean indicating whether the service applies a secondary layer of encryption 
    +     * A boolean indicating whether the service applies a secondary layer of encryption
          * with platform managed keys for data at rest.
          * 
    */ @@ -69,7 +69,7 @@ public AzureStorageAccountEncryptionBuilder withRequireInfrastructureEncryption( encryption.setRequireInfrastructureEncryption(requireInfrastructureEncryption); return builder; } - + /** *
          * List of services which support encryption.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionIdentity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionIdentity.java
    index b511ce40..45eea0fe 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionIdentity.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionIdentity.java
    @@ -27,7 +27,7 @@ public AzureStorageAccountEncryptionIdentityBuilder() {
     
         /**
          * 
    -     * ClientId of the multi-tenant application to be used in conjunction with the user-assigned identity 
    +     * ClientId of the multi-tenant application to be used in conjunction with the user-assigned identity
          * for cross-tenant customer-managed-keys server-side encryption on the storage account.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionService.java index ce0d7da1..c00300ef 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountEncryptionService.java @@ -27,7 +27,7 @@ public AzureStorageAccountEncryptionServiceBuilder() { /** *
    -     * A boolean indicating whether the service encrypts the data as it is stored. 
    +     * A boolean indicating whether the service encrypts the data as it is stored.
          * Encryption at rest is enabled by default today and cannot be disabled.
          * 
    */ @@ -35,11 +35,11 @@ public AzureStorageAccountEncryptionServiceBuilder withEnabled(Boolean enabled) instance.setEnabled(enabled); return builder; } - + /** *
    -     * Encryption key type to be used for the encryption service. 
    -     * 'Account' key type implies that an account-scoped encryption key will be used. 
    +     * Encryption key type to be used for the encryption service.
    +     * 'Account' key type implies that an account-scoped encryption key will be used.
          * 'Service' key type implies that a default service key is used.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountIdentity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountIdentity.java index d52a8d88..572914a6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountIdentity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountIdentity.java @@ -43,8 +43,8 @@ public AzureStorageAccountIdentityBuilder withIdentityType(AzureIdentityType ide /** *
    -     * Sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. 
    -     * The key is the ARM resource identifier of the identity. 
    +     * Sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account.
    +     * The key is the ARM resource identifier of the identity.
          * Only 1 User Assigned identity is permitted here.
          * 
    */ @@ -55,11 +55,14 @@ public AzureStorageAccountIdentityBuilder withUserAssignedIdentities(Map - * Key value pair that describe User Assigned identity that will be used with this storage account. - * The key is the ARM resource identifier of the identity. + * Key value pair that describe User Assigned identity that will be used with this storage account. + * The key is the ARM resource identifier of the identity. *
    */ - public AzureStorageAccountIdentityBuilder withUserAssignedIdentity(String key, AzureUserAssignedIdentity userAssignedIdentity) { + public AzureStorageAccountIdentityBuilder withUserAssignedIdentity( + String key, + AzureUserAssignedIdentity userAssignedIdentity) + { if (identity.getUserAssignedIdentities() == null) { withUserAssignedIdentities(new HashMap<>()); } @@ -73,5 +76,5 @@ public AzureStorageAccountIdentity build() { return identity; } } - + } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountImmutabilityPolicyProperties.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountImmutabilityPolicyProperties.java index 716d8e68..7986df13 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountImmutabilityPolicyProperties.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountImmutabilityPolicyProperties.java @@ -28,8 +28,8 @@ public AzureStorageAccountImmutabilityPolicyPropertiesBuilder() { /** *
    -     * This property can only be changed for disabled and unlocked time-based retention policies. 
    -     * When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance. 
    +     * This property can only be changed for disabled and unlocked time-based retention policies.
    +     * When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance.
          * Only new blocks can be added and any existing blocks cannot be modified or deleted.
          * 
    */ @@ -37,7 +37,7 @@ public AzureStorageAccountImmutabilityPolicyPropertiesBuilder withAllowProtected instance.setAllowProtectedAppendWrites(allowProtectedAppendWrites); return builder; } - + /** *
          * The immutability period for the blobs in the container since the policy creation, in days.
    @@ -47,14 +47,14 @@ public AzureStorageAccountImmutabilityPolicyPropertiesBuilder withImmutabilityPe
           instance.setImmutabilityPeriodSinceCreationInDays(immutabilityPeriodSinceCreationInDays);
           return builder;
         }
    -    
    +
         /**
          * 
    -     * The ImmutabilityPolicy state defines the mode of the policy. 
    -     * Disabled state disables the policy. 
    -     * Unlocked state allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites property. 
    -     * Locked state only allows the increase of the immutability retention time. 
    -     * A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. 
    +     * The ImmutabilityPolicy state defines the mode of the policy.
    +     * Disabled state disables the policy.
    +     * Unlocked state allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites property.
    +     * Locked state only allows the increase of the immutability retention time.
    +     * A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states.
          * Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted.
          * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeyVaultProperties.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeyVaultProperties.java index 1919f9fa..d2d5edc8 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeyVaultProperties.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeyVaultProperties.java @@ -24,7 +24,7 @@ public AzureStorageAccountKeyVaultPropertiesBuilder() { this.instance = new AzureStorageAccountKeyVaultProperties(); this.builder = this; } - + /** *
          * The name of KeyVault key.
    @@ -34,7 +34,7 @@ public AzureStorageAccountKeyVaultPropertiesBuilder withKeyName(String keyName)
           instance.setKeyName(keyName);
           return builder;
         }
    -    
    +
         /**
          * 
          * The Uri of KeyVault.
    @@ -44,7 +44,7 @@ public AzureStorageAccountKeyVaultPropertiesBuilder withKeyVaultUri(String keyVa
           instance.setKeyVaultUri(keyVaultUri);
           return builder;
         }
    -    
    +
         /**
          * 
          * The version of KeyVault key.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountRoutingPreference.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountRoutingPreference.java
    index 7e0c0d32..0833c1ea 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountRoutingPreference.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountRoutingPreference.java
    @@ -18,7 +18,7 @@ public class AzureStorageAccountRoutingPreference {
       private Boolean publishInternetEndpoints;
       private Boolean publishMicrosoftEndpoints;
       private AzureRoutingChoice routingChoice;
    -  
    +
     
       public static AzureStorageAccountRoutingPreferenceBuilder builder() {
         return new AzureStorageAccountRoutingPreferenceBuilder();
    @@ -42,7 +42,7 @@ public AzureStorageAccountRoutingPreferenceBuilder withPublishInternetEndpoints(
           instance.setPublishInternetEndpoints(publishInternetEndpoints);
           return builder;
         }
    -    
    +
         /**
          * 
          * A boolean flag which indicates whether microsoft routing storage endpoints are to be published
    @@ -52,7 +52,7 @@ public AzureStorageAccountRoutingPreferenceBuilder withPublishMicrosoftEndpoints
           instance.setPublishMicrosoftEndpoints(publishMicrosoftEndpoints);
           return builder;
         }
    -    
    +
         /**
          * 
          * Routing Choice defines the kind of network routing opted by the user.
    @@ -62,7 +62,7 @@ public AzureStorageAccountRoutingPreferenceBuilder withRoutingChoice(AzureRoutin
           instance.setRoutingChoice(routingChoice);
           return builder;
         }
    -    
    +
         public AzureStorageAccountRoutingPreference build() {
           return instance;
         }
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountSasPolicy.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountSasPolicy.java
    index a5db7cb4..2ebb3a53 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountSasPolicy.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountSasPolicy.java
    @@ -31,7 +31,7 @@ public AzureStorageAccountSasPolicyBuilder() {
     
         /**
          * 
    -     * The SAS expiration action. 
    +     * The SAS expiration action.
          * Can only be Log.
          * 
    */ @@ -39,7 +39,7 @@ public AzureStorageAccountSasPolicyBuilder withExpirationAction(AzureExpirationA instance.setExpirationAction(expirationAction); return builder; } - + /** *
          * The SAS expiration period, DD.HH:MM:SS
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureUserAssignedIdentity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureUserAssignedIdentity.java
    index 8311eb31..45986522 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureUserAssignedIdentity.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureUserAssignedIdentity.java
    @@ -6,7 +6,7 @@
     
     /**
      * 
    - * UserAssignedIdentity for the resource.  
    + * UserAssignedIdentity for the resource.
      * 
    */ @Getter @@ -28,7 +28,7 @@ public AzureUserAssignedIdentityBuilder() { this.instance = new AzureUserAssignedIdentity(); this.builder = this; } - + /** *
          * The client ID of the identity.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureVirtualNetworkRule.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureVirtualNetworkRule.java
    index bf5fdc36..489902a3 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureVirtualNetworkRule.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureVirtualNetworkRule.java
    @@ -40,11 +40,11 @@ public AzureVirtualNetworkRuleBuilder withAction(AzureNetworkAction action) {
           instance.setAction(action);
           return builder;
         }
    -    
    +
         /**
          * 
          * Resource ID of a subnet.
    -     * 
    +     *
          * For example:
          *  /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}.
          * 
    @@ -53,7 +53,7 @@ public AzureVirtualNetworkRuleBuilder withVirtualNetworkResourceId(String virtua instance.setVirtualNetworkResourceId(virtualNetworkResourceId); return builder; } - + /** *
          * Gets the state of virtual network rule.
    diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/BaseAzureStorageAccount.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/BaseAzureStorageAccount.java
    index 329f4b9a..1894695b 100644
    --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/BaseAzureStorageAccount.java
    +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/BaseAzureStorageAccount.java
    @@ -23,14 +23,17 @@
     
     @Getter
     @Setter
    -public abstract class BaseAzureStorageAccount extends PaaSDataStorage implements AzureResourceEntity, LiveSystemComponent {
    +public abstract class BaseAzureStorageAccount extends PaaSDataStorage implements AzureResourceEntity,
    +  LiveSystemComponent {
       private static final Pattern NAME_PATTERN = Pattern.compile("^[a-z0-9]{3,24}$");
     
       @JsonIgnore
    -  public static final String NAME_IS_NOT_VALID = "Name must be between 3 and 24 characters in length and use numbers and lower-case letters only";
    +  public static final String NAME_IS_NOT_VALID = "Name must be between 3 and 24 characters in length and use numbers " +
    +    "and lower-case letters only";
     
       @JsonIgnore
    -  public static final String AZURE_RESOURCE_GROUP_IS_BLANK = "Azure Resource group has not been defined and it is required";
    +  public static final String AZURE_RESOURCE_GROUP_IS_BLANK = "Azure Resource group has not been defined and it is " +
    +    "required";
     
       @JsonIgnore
       public static final String AZURE_REGION_IS_BLANK = "Region has not been defined and it is required";
    @@ -90,7 +93,7 @@ public T build() {
          * 
          * The name of the storage account within the specified resource group.
          * Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
    -     * 
    +     *
          * Regex pattern: ^[a-z0-9]+$
          * 
    */ @@ -136,7 +139,7 @@ public B withSku(AzureStorageAccountSkuName sku) { /** *
    -     * Set the extended location of the resource. 
    +     * Set the extended location of the resource.
          * If not set, the storage account will be created in Azure main region.
          * 
    */ @@ -159,7 +162,7 @@ public B withIdentity(AzureStorageAccountIdentity identity) { /** *
    -     * Required for Blob Storage accounts. 
    +     * Required for Blob Storage accounts.
          * The access tier is used for billing.
          * 
    */ @@ -182,8 +185,8 @@ public B withAllowBlobPublicAccess(Boolean allowBlobPublicAccess) { /** *
    -     * Allow or disallow cross AAD tenant object replication. 
    -     * Set this property to true for new or existing accounts only if object replication policies will involve 
    +     * Allow or disallow cross AAD tenant object replication.
    +     * Set this property to true for new or existing accounts only if object replication policies will involve
          * storage accounts in different AAD tenants.
          * 
    */ @@ -196,7 +199,7 @@ public B withAllowCrossTenantReplication(Boolean allowCrossTenantReplication) { /** *
          * Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key.
    -     * If false, then all requests, including shared access signatures, 
    +     * If false, then all requests, including shared access signatures,
          * must be authorized with Azure Active Directory (Azure AD).
          * 
    */ @@ -230,9 +233,9 @@ public B withAzureFilesIdentityBasedAuthentication(AzureFilesIdentityBasedAuthen /** *
    -     * User domain assigned to the storage account. 
    -     * Name is the CNAME source. 
    -     * Only one custom domain is supported per storage account at this time. 
    +     * User domain assigned to the storage account.
    +     * Name is the CNAME source.
    +     * Only one custom domain is supported per storage account at this time.
          * To clear the existing custom domain, use an empty string for the custom domain name property.
          * 
    */ @@ -255,8 +258,8 @@ public B withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication) /** *
    -     * Allows you to specify the type of endpoint. 
    -     * Set this to AzureDNSZone to create a large number of accounts in a single subscription, 
    +     * Allows you to specify the type of endpoint.
    +     * Set this to AzureDNSZone to create a large number of accounts in a single subscription,
          * which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier.
          * 
    */ @@ -279,7 +282,7 @@ public B withEncryption(AzureStorageAccountEncryption encryption) { /** *
    -     * This property enables and defines account-level immutability. 
    +     * This property enables and defines account-level immutability.
          * Enabling the feature auto-enables Blob Versioning.
          * 
    */ @@ -439,8 +442,8 @@ public B withTag(String key, String value) { } /** - * Specifies settings for the backup configuration of the Azure Storage Account, including details about - * the Recovery Services vault, backup policy, and other related settings. This configuration ensures data + * Specifies settings for the backup configuration of the Azure Storage Account, including details about + * the Recovery Services vault, backup policy, and other related settings. This configuration ensures data * protection and facilitates disaster recovery scenarios. */ public B withBackup(AzureStorageAccountBackup backup) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyState.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyState.java index 9166059f..2d0fe39b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyState.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyState.java @@ -7,13 +7,13 @@ /** *
    - * The ImmutabilityPolicy state defines the mode of the policy. 
    - * 
    - * Disabled state disables the policy. 
    - * 
    - * Unlocked state allows increase and decrease of immutability retention time 
    - * and also allows toggling allowProtectedAppendWrites property. 
    - * 
    + * The ImmutabilityPolicy state defines the mode of the policy.
    + *
    + * Disabled state disables the policy.
    + *
    + * Unlocked state allows increase and decrease of immutability retention time
    + * and also allows toggling allowProtectedAppendWrites property.
    + *
      * Locked state only allows the increase of the immutability retention time.
      * 
    */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountType.java index 63d641cb..bd09e8bf 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountType.java @@ -11,7 +11,7 @@ public final class AzureActiveDirectoryAccountType extends ExtendableEnum { public static final AzureActiveDirectoryAccountType USER = fromString("User"); public static final AzureActiveDirectoryAccountType COMPUTER = fromString("Computer"); - + @JsonCreator public static AzureActiveDirectoryAccountType fromString(String name) { return fromString(name, AzureActiveDirectoryAccountType.class); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermission.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermission.java index f8fd0237..51a9e9ee 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermission.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermission.java @@ -10,12 +10,12 @@ */ public final class AzureDefaultSharePermission extends ExtendableEnum { public static final AzureDefaultSharePermission NONE = fromString("None"); - public static final AzureDefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_READER = - fromString("StorageFileDataSmbShareReader"); - public static final AzureDefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = - fromString("StorageFileDataSmbShareContributor"); - public static final AzureDefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = - fromString("StorageFileDataSmbShareElevatedContributor"); + public static final AzureDefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_READER = + fromString("StorageFileDataSmbShareReader"); + public static final AzureDefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = + fromString("StorageFileDataSmbShareContributor"); + public static final AzureDefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = + fromString("StorageFileDataSmbShareElevatedContributor"); @JsonCreator public static AzureDefaultSharePermission fromString(String name) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointType.java index 9f7a9a71..bc5f7a3f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointType.java @@ -6,8 +6,8 @@ import java.util.Collection; /** - * Allows you to specify the type of endpoint. - * Set this to AzureDNSZone to create a large number of accounts in a single subscription, + * Allows you to specify the type of endpoint. + * Set this to AzureDNSZone to create a large number of accounts in a single subscription, * which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. */ public final class AzureDnsEndpointType extends ExtendableEnum { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesState.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesState.java index 3a678978..216d348f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesState.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesState.java @@ -12,7 +12,7 @@ */ public final class AzureLargeFileSharesState extends ExtendableEnum { public static final AzureLargeFileSharesState DISABLED = fromString("Disabled"); - + public static final AzureLargeFileSharesState ENABLED = fromString("Enabled"); /** diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccess.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccess.java index 040f4ec4..dd221052 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccess.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccess.java @@ -7,13 +7,13 @@ /** *
    - * Allow or disallow public network access to Storage Account. 
    + * Allow or disallow public network access to Storage Account.
      * Value is optional but if passed in, must be 'Enabled' or 'Disabled'.
      * 
    */ public final class AzurePublicNetworkAccess extends ExtendableEnum { public static final AzurePublicNetworkAccess ENABLED = fromString("Enabled"); - + public static final AzurePublicNetworkAccess DISABLED = fromString("Disabled"); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesBackupPolicyWorkloadType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesBackupPolicyWorkloadType.java index d01901e7..57d66d43 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesBackupPolicyWorkloadType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesBackupPolicyWorkloadType.java @@ -3,29 +3,29 @@ import com.fasterxml.jackson.annotation.JsonValue; - public enum AzureRecoveryServicesBackupPolicyWorkloadType { - AzureWorkload ("AzureWorkload"), - AzureStorage ("AzureStorage"), - AzureIaasVM ("AzureIaasVM"), - AzureSql ("AzureSql"), - GenericProtectionPolicy ("GenericProtectionPolicy"), - MAB ("MAB"); - - private final String id; - - AzureRecoveryServicesBackupPolicyWorkloadType(final String id) { - this.id = id; - } - - @JsonValue - public String getId() { - return id; - } - - @Override - public String toString() { - return id; - } +public enum AzureRecoveryServicesBackupPolicyWorkloadType { + AzureWorkload("AzureWorkload"), + AzureStorage("AzureStorage"), + AzureIaasVM("AzureIaasVM"), + AzureSql("AzureSql"), + GenericProtectionPolicy("GenericProtectionPolicy"), + MAB("MAB"); + + private final String id; + + AzureRecoveryServicesBackupPolicyWorkloadType(final String id) { + this.id = id; + } + + @JsonValue + public String getId() { + return id; + } + + @Override + public String toString() { + return id; } +} \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesSkuName.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesSkuName.java index 0b8f7d87..89fa3e50 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesSkuName.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureRecoveryServicesSkuName.java @@ -3,22 +3,22 @@ import com.fasterxml.jackson.annotation.JsonValue; public enum AzureRecoveryServicesSkuName { - STANDARD ("Standard"), - RS0 ("RS0"); - - private final String id; - - AzureRecoveryServicesSkuName(final String id) { - this.id = id; - } - - @JsonValue - public String getId() { - return id; - } - - @Override - public String toString() { - return id; - } + STANDARD("Standard"), + RS0("RS0"); + + private final String id; + + AzureRecoveryServicesSkuName(final String id) { + this.id = id; + } + + @JsonValue + public String getId() { + return id; + } + + @Override + public String toString() { + return id; } +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureState.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureState.java index 26f02308..bb5de5ee 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureState.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureState.java @@ -13,15 +13,15 @@ public final class AzureState extends ExtendableEnum { public static final AzureState PROVISIONING = fromString("Provisioning"); - + public static final AzureState DEPROVISIONING = fromString("Deprovisioning"); - + public static final AzureState SUCCEEDED = fromString("Succeeded"); - + public static final AzureState FAILED = fromString("Failed"); - + public static final AzureState NETWORK_SOURCE_DELETED = fromString("NetworkSourceDeleted"); - + /** * Creates or finds a State from its string representation. diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAccessTier.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAccessTier.java index 4d894577..96dcc5e0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAccessTier.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAccessTier.java @@ -7,7 +7,7 @@ public enum AzureStorageAccountAccessTier { HOT("Hot"), COOL("Cool"), PREMIUM("Premium"); - + private final String id; AzureStorageAccountAccessTier(final String id) { @@ -27,7 +27,7 @@ public static AzureStorageAccountAccessTier fromString(String value) { } return null; } - + @JsonValue public String getId() { return id; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountSkuName.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountSkuName.java index 38e9fac6..05a254d6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountSkuName.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountSkuName.java @@ -6,7 +6,7 @@ import java.util.Collection; /** - * The SKU name. + * The SKU name. * Required for account creation. */ public final class AzureStorageAccountSkuName extends ExtendableEnum { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDatabase.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDatabase.java index 59d40784..c5b14066 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDatabase.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDatabase.java @@ -4,10 +4,11 @@ import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; public class GcpPostgreSqlDatabase extends PaaSPostgreSqlDatabase { - private final static String SCHEMA_IS_BLANK = "[GcpPostgreSqlDatabase ] schema defined was either empty or blank and it is required"; + private final static String SCHEMA_IS_BLANK = "[GcpPostgreSqlDatabase ] schema defined was either empty or blank " + + "and it is required"; private String name; - + @Override public ProviderType getProvider() { return ProviderType.GCP; @@ -17,17 +18,18 @@ public static GcpPostgreSqlDbBuilder builder() { return new GcpPostgreSqlDbBuilder(); } - public static class GcpPostgreSqlDbBuilder extends Builder { + public static class GcpPostgreSqlDbBuilder extends Builder { - @Override - protected GcpPostgreSqlDbBuilder getBuilder() { - return this; - } + @Override + protected GcpPostgreSqlDbBuilder getBuilder() { + return this; + } - @Override - protected GcpPostgreSqlDatabase createComponent() { - return new GcpPostgreSqlDatabase(); - } + @Override + protected GcpPostgreSqlDatabase createComponent() { + return new GcpPostgreSqlDatabase(); } + } } \ No newline at end of file diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDbms.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDbms.java index 88ab9396..5cff52fc 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDbms.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpPostgreSqlDbms.java @@ -19,17 +19,22 @@ @ToString(callSuper = true) public class GcpPostgreSqlDbms extends PaaSPostgreSqlDbms { - private final static String REGION_IS_NULL = "[GcpProgreSQL Validation] Region has not been defined and it is required"; + private final static String REGION_IS_NULL = "[GcpProgreSQL Validation] Region has not been defined and it is " + + "required"; - private final static String NETWORK_IS_NULL_OR_EMPTY = "[GcpProgreSQL Validation] Network has not been defined and it is required"; + private final static String NETWORK_IS_NULL_OR_EMPTY = "[GcpProgreSQL Validation] Network has not been defined and " + + "it is required"; - private final static String PEERING_NETWORK_ADDRESS_IS_EMPTY = "[GcpProgreSQL Validation] Peering network address is empty"; + private final static String PEERING_NETWORK_ADDRESS_IS_EMPTY = "[GcpProgreSQL Validation] Peering network address " + + "is empty"; - private final static String PEERING_NETWORK_ADDRESS_DESCRIPTION_IS_EMPTY = "[GcpProgreSQL Validation] Peering network address description is empty"; + private final static String PEERING_NETWORK_ADDRESS_DESCRIPTION_IS_EMPTY = "[GcpProgreSQL Validation] Peering " + + "network address description is empty"; private final static String PEERING_NETWORK_NAME_IS_EMPTY = "[GcpProgreSQL Validation] Peering network name is empty"; - private final static String PEERING_NETWORK_PREFIX_IS_EMPTY = "[GcpProgreSQL Validation] Peering network prefix is empty"; + private final static String PEERING_NETWORK_PREFIX_IS_EMPTY = "[GcpProgreSQL Validation] Peering network prefix is " + + "empty"; private GcpRegion region; private String network; diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegion.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegion.java index 46e65936..277c8090 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegion.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegion.java @@ -10,65 +10,65 @@ */ public class GcpRegion extends ExtendableEnum { - public static final GcpRegion AFRICA_SOUTH1 = fromString("africa-south1"); - public static final GcpRegion ASIA_EAST1 = fromString("asia-east1"); - public static final GcpRegion ASIA_EAST2 = fromString("asia-east2"); - public static final GcpRegion ASIA_NORTHEAST1 = fromString("asia-northeast1-b"); - public static final GcpRegion ASIA_NORTHEAST2 = fromString("asia-northeast2"); - public static final GcpRegion ASIA_NORTHEAST3 = fromString("asia-northeast3"); - public static final GcpRegion ASIA_SOUTH1 = fromString("asia-south1"); - public static final GcpRegion ASIA_SOUTH2 = fromString("asia-south2"); - public static final GcpRegion ASIA_SOUTHEAST1 = fromString("asia-southeast1"); - public static final GcpRegion ASIA_SOUTHEAST2 = fromString("asia-southeast2"); - public static final GcpRegion AUSTRALIA_SOUTHEAST1 = fromString("australia-southeast1"); - public static final GcpRegion AUSTRALIA_SOUTHEAST2 = fromString("australia-southeast2"); - public static final GcpRegion EUROPE_CENTRAL2 = fromString("europe-central2"); - public static final GcpRegion EUROPE_NORTH1 = fromString("europe-north1"); - public static final GcpRegion EUROPE_SOUTHWEST1 = fromString("europe-southwest1"); - public static final GcpRegion EUROPE_WEST1 = fromString("europe-west1"); - public static final GcpRegion EUROPE_WEST10 = fromString("europe-west10"); - public static final GcpRegion EUROPE_WEST12 = fromString("europe-west12"); - public static final GcpRegion EUROPE_WEST2 = fromString("europe-west2"); - public static final GcpRegion EUROPE_WEST3 = fromString("europe-west3"); - public static final GcpRegion EUROPE_WEST4 = fromString("europe-west4"); - public static final GcpRegion EUROPE_WEST6 = fromString("europe-west6"); - public static final GcpRegion EUROPE_WEST8 = fromString("europe-west8"); - public static final GcpRegion EUROPE_WEST9 = fromString("europe-west9"); - public static final GcpRegion ME_CENTRAL1 = fromString("me-central1"); - public static final GcpRegion ME_CENTRAL2 = fromString("me-central2"); - public static final GcpRegion ME_WEST1 = fromString("me-west1"); - public static final GcpRegion NORTHAMERICA_NORTHEAST1 = fromString("northamerica-northeast1"); - public static final GcpRegion NORTHAMERICA_NORTHEAST2 = fromString("northamerica-northeast2"); - public static final GcpRegion NORTHAMERICA_SOUTH1 = fromString("northamerica-south1"); - public static final GcpRegion SOUTHAMERICA_EAST1 = fromString("southamerica-east1"); - public static final GcpRegion SOUTHAMERICA_WEST1 = fromString("southamerica-west1"); - public static final GcpRegion US_CENTRAL1 = fromString("us-central1"); - public static final GcpRegion US_EAST1 = fromString("us-east1"); - public static final GcpRegion US_EAST4 = fromString("us-east4"); - public static final GcpRegion US_EAST5 = fromString("us-east5"); - public static final GcpRegion US_SOUTH1 = fromString("us-south1"); - public static final GcpRegion US_WEST1 = fromString("us-west1"); - public static final GcpRegion US_WEST2 = fromString("us-west2"); - public static final GcpRegion US_WEST3 = fromString("us-west3"); - public static final GcpRegion US_WEST4 = fromString("us-west4"); + public static final GcpRegion AFRICA_SOUTH1 = fromString("africa-south1"); + public static final GcpRegion ASIA_EAST1 = fromString("asia-east1"); + public static final GcpRegion ASIA_EAST2 = fromString("asia-east2"); + public static final GcpRegion ASIA_NORTHEAST1 = fromString("asia-northeast1-b"); + public static final GcpRegion ASIA_NORTHEAST2 = fromString("asia-northeast2"); + public static final GcpRegion ASIA_NORTHEAST3 = fromString("asia-northeast3"); + public static final GcpRegion ASIA_SOUTH1 = fromString("asia-south1"); + public static final GcpRegion ASIA_SOUTH2 = fromString("asia-south2"); + public static final GcpRegion ASIA_SOUTHEAST1 = fromString("asia-southeast1"); + public static final GcpRegion ASIA_SOUTHEAST2 = fromString("asia-southeast2"); + public static final GcpRegion AUSTRALIA_SOUTHEAST1 = fromString("australia-southeast1"); + public static final GcpRegion AUSTRALIA_SOUTHEAST2 = fromString("australia-southeast2"); + public static final GcpRegion EUROPE_CENTRAL2 = fromString("europe-central2"); + public static final GcpRegion EUROPE_NORTH1 = fromString("europe-north1"); + public static final GcpRegion EUROPE_SOUTHWEST1 = fromString("europe-southwest1"); + public static final GcpRegion EUROPE_WEST1 = fromString("europe-west1"); + public static final GcpRegion EUROPE_WEST10 = fromString("europe-west10"); + public static final GcpRegion EUROPE_WEST12 = fromString("europe-west12"); + public static final GcpRegion EUROPE_WEST2 = fromString("europe-west2"); + public static final GcpRegion EUROPE_WEST3 = fromString("europe-west3"); + public static final GcpRegion EUROPE_WEST4 = fromString("europe-west4"); + public static final GcpRegion EUROPE_WEST6 = fromString("europe-west6"); + public static final GcpRegion EUROPE_WEST8 = fromString("europe-west8"); + public static final GcpRegion EUROPE_WEST9 = fromString("europe-west9"); + public static final GcpRegion ME_CENTRAL1 = fromString("me-central1"); + public static final GcpRegion ME_CENTRAL2 = fromString("me-central2"); + public static final GcpRegion ME_WEST1 = fromString("me-west1"); + public static final GcpRegion NORTHAMERICA_NORTHEAST1 = fromString("northamerica-northeast1"); + public static final GcpRegion NORTHAMERICA_NORTHEAST2 = fromString("northamerica-northeast2"); + public static final GcpRegion NORTHAMERICA_SOUTH1 = fromString("northamerica-south1"); + public static final GcpRegion SOUTHAMERICA_EAST1 = fromString("southamerica-east1"); + public static final GcpRegion SOUTHAMERICA_WEST1 = fromString("southamerica-west1"); + public static final GcpRegion US_CENTRAL1 = fromString("us-central1"); + public static final GcpRegion US_EAST1 = fromString("us-east1"); + public static final GcpRegion US_EAST4 = fromString("us-east4"); + public static final GcpRegion US_EAST5 = fromString("us-east5"); + public static final GcpRegion US_SOUTH1 = fromString("us-south1"); + public static final GcpRegion US_WEST1 = fromString("us-west1"); + public static final GcpRegion US_WEST2 = fromString("us-west2"); + public static final GcpRegion US_WEST3 = fromString("us-west3"); + public static final GcpRegion US_WEST4 = fromString("us-west4"); - /** - * Creates or finds a GcpRegion from its string representation. - * - * @param name a name to look for. - * @return the corresponding AwsRegion. - */ - @JsonCreator - public static GcpRegion fromString(String name) { - return fromString(name, GcpRegion.class); - } + /** + * Creates or finds a GcpRegion from its string representation. + * + * @param name a name to look for. + * @return the corresponding AwsRegion. + */ + @JsonCreator + public static GcpRegion fromString(String name) { + return fromString(name, GcpRegion.class); + } - /** - * Gets known GcpRegion values. - * - * @return known GcpRegion values. - */ - public static Collection values() { - return values(GcpRegion.class); - } + /** + * Gets known GcpRegion values. + * + * @return known GcpRegion values. + */ + public static Collection values() { + return values(GcpRegion.class); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngine.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngine.java index 1cc68c02..839a0a64 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngine.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngine.java @@ -16,7 +16,8 @@ @Getter @Setter(AccessLevel.PRIVATE) public class GoogleKubernetesEngine extends KubernetesCluster { - private final static String EMPTY_NODE_POOL = "[GoogleKubernetesEngine Validation] Node pool list is null or empty and at least one node pool is required"; + private final static String EMPTY_NODE_POOL = "[GoogleKubernetesEngine Validation] Node pool list is null or empty " + + "and at least one node pool is required"; private String networkName; private String subnetworkName; @@ -40,7 +41,8 @@ public static GoogleKubernetesEngineBuilder builder() { return new GoogleKubernetesEngineBuilder(); } - public static class GoogleKubernetesEngineBuilder extends Builder { + public static class GoogleKubernetesEngineBuilder extends Builder { @Override protected GoogleKubernetesEngine createComponent() { @@ -108,8 +110,8 @@ public Collection validate() { } nodePools.stream() - .map(GcpNodePool::validate) - .forEach(errors::addAll); + .map(GcpNodePool::validate) + .forEach(errors::addAll); return errors; } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerKubernetes.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerKubernetes.java index c687a83c..98f9f796 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerKubernetes.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerKubernetes.java @@ -16,76 +16,79 @@ @Getter @Setter public class HetznerKubernetes extends KubernetesCluster implements HetznerResourceEntity { - private final static String REGION_IS_NULL = "[HetznerKubernetes Validation] Region is not specified and it is required"; - private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and 63 characters long"; + private final static String REGION_IS_NULL = "[HetznerKubernetes Validation] Region is not specified and it is " + + "required"; + private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, " + + "numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and" + + " 63 characters long"; - private HetznerRegion hetznerRegion; - private Map tags; - private String name; + private HetznerRegion hetznerRegion; + private Map tags; + private String name; - public ProviderType getProvider() { - return ProviderType.HETZNER; + public ProviderType getProvider() { + return ProviderType.HETZNER; + } + + public static HetznerKubernetesBuilder builder() { + return new HetznerKubernetesBuilder(); + } + + public static class HetznerKubernetesBuilder extends Builder { + + @Override + protected HetznerKubernetes createComponent() { + return new HetznerKubernetes(); } - public static HetznerKubernetesBuilder builder() { - return new HetznerKubernetesBuilder(); + @Override + protected HetznerKubernetesBuilder getBuilder() { + return this; } - public static class HetznerKubernetesBuilder extends Builder { - - @Override - protected HetznerKubernetes createComponent() { - return new HetznerKubernetes(); - } - - @Override - protected HetznerKubernetesBuilder getBuilder() { - return this; - } - - public HetznerKubernetesBuilder withRegion(HetznerRegion region) { - component.setHetznerRegion(region); - return builder; - } - - public HetznerKubernetesBuilder withName(String name) { - component.setName(name); - return builder; - } - - public HetznerKubernetesBuilder withTags(Map tags) { - component.setTags(tags); - return builder; - } - - public HetznerKubernetesBuilder withTag(String key, String value) { - if (component.getTags() == null) { - withTags(new HashMap<>()); - } - - component.getTags().put(key, value); - return builder; - } + public HetznerKubernetesBuilder withRegion(HetznerRegion region) { + component.setHetznerRegion(region); + return builder; } - @Override - public Collection validate() { + public HetznerKubernetesBuilder withName(String name) { + component.setName(name); + return builder; + } - Collection errors = super.validate(); - errors.addAll(HetznerResourceEntity.validateHetznerResourceEntity(this, "Kubernetes Service")); + public HetznerKubernetesBuilder withTags(Map tags) { + component.setTags(tags); + return builder; + } + + public HetznerKubernetesBuilder withTag(String key, String value) { + if (component.getTags() == null) { + withTags(new HashMap<>()); + } + + component.getTags().put(key, value); + return builder; + } + } - if(StringUtils.isNotBlank(name)) { - var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); - var hasValidLengths = isValidStringLength(name, 1, 63); - if(!isAlphaNumerics || !hasValidLengths) { - errors.add(NAME_NOT_VALID); - } - } + @Override + public Collection validate() { - if (hetznerRegion == null) { - errors.add(REGION_IS_NULL); - } + Collection errors = super.validate(); + errors.addAll(HetznerResourceEntity.validateHetznerResourceEntity(this, "Kubernetes Service")); - return errors; + if (StringUtils.isNotBlank(name)) { + var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); + var hasValidLengths = isValidStringLength(name, 1, 63); + if (!isAlphaNumerics || !hasValidLengths) { + errors.add(NAME_NOT_VALID); + } } + + if (hetznerRegion == null) { + errors.add(REGION_IS_NULL); + } + + return errors; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerResourceEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerResourceEntity.java index 0af1445d..25de46c7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerResourceEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/hetzner/HetznerResourceEntity.java @@ -7,6 +7,7 @@ public interface HetznerResourceEntity extends ResourceEntity { HetznerRegion getHetznerRegion(); + void setHetznerRegion(HetznerRegion region); static Collection validateHetznerResourceEntity(HetznerResourceEntity resourceEntity, String entityName) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/Compartment.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/Compartment.java index 091f4920..05bf7eb7 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/Compartment.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/Compartment.java @@ -10,106 +10,108 @@ /** * A container that holds related resources for an OCI solution. - * The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. + * The resource group can include all the resources for the solution, or only those resources that you want to manage + * as a group. * You decide how you want to allocate resources to resource groups based on what makes the most sense for you . */ @Getter public class Compartment implements Validatable { - @JsonIgnore - public static final String NAME_IS_NULL_OR_EMPTY = "[OCI Compartment Validation] Name cannot be null or empty"; - @JsonIgnore - public static final String NAME_IS_NOT_VALID = "[OCI Compartment Validation] Name can only include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters that match the allowed characters"; - private static final String NAME_EXCEEDS_LENGTH_LIMIT = "[OCI Compartment Validation] Name exceeds 90 characters"; - private static final Pattern COMPARTMENT_NAME_PATTERN = Pattern.compile("^[\\w()-.]+[\\w()-]$"); - - private String name; - private String parentId; - private Map tags; - - public Compartment() { + @JsonIgnore + public static final String NAME_IS_NULL_OR_EMPTY = "[OCI Compartment Validation] Name cannot be null or empty"; + @JsonIgnore + public static final String NAME_IS_NOT_VALID = "[OCI Compartment Validation] Name can only include alphanumeric, " + + "underscore, parentheses, hyphen, period (except at end), and Unicode characters that match the allowed characters"; + private static final String NAME_EXCEEDS_LENGTH_LIMIT = "[OCI Compartment Validation] Name exceeds 90 characters"; + private static final Pattern COMPARTMENT_NAME_PATTERN = Pattern.compile("^[\\w()-.]+[\\w()-]$"); + + private String name; + private String parentId; + private Map tags; + + public Compartment() { + } + + public Compartment(String name, String parentId, Map tags) { + this.name = name; + this.parentId = parentId; + this.tags = tags; + } + + public static CompartmentBuilder builder() { + return new CompartmentBuilder(); + } + + @Override + public Collection validate() { + Collection errors = new ArrayList<>(); + var name = this.getName(); + + if (StringUtils.isBlank(name)) { + errors.add(NAME_IS_NULL_OR_EMPTY); } - public Compartment(String name, String parentId, Map tags) { - this.name = name; - this.parentId = parentId; - this.tags = tags; + if (StringUtils.isNotBlank(name) && !COMPARTMENT_NAME_PATTERN.matcher(name).matches()) { + errors.add(NAME_IS_NOT_VALID); } - public static CompartmentBuilder builder() { - return new CompartmentBuilder(); + if (StringUtils.isNotBlank(name) && name.length() > 90) { + errors.add(NAME_EXCEEDS_LENGTH_LIMIT); } - @Override - public Collection validate() { - Collection errors = new ArrayList<>(); - var name = this.getName(); + return errors; + } - if (StringUtils.isBlank(name)) { - errors.add(NAME_IS_NULL_OR_EMPTY); - } + public static class CompartmentBuilder { - if (StringUtils.isNotBlank(name) && !COMPARTMENT_NAME_PATTERN.matcher(name).matches()) { - errors.add(NAME_IS_NOT_VALID); - } + protected String name; + protected String parentId; + protected Map tags; - if (StringUtils.isNotBlank(name) && name.length() > 90) { - errors.add(NAME_EXCEEDS_LENGTH_LIMIT); - } + public CompartmentBuilder() { + } + + public CompartmentBuilder withName(String name) { + this.name = name; + return this; + } + + /** + * Tags are name/value pairs that enable you to categorize resources and view consolidated billing by + * applying the same tag to multiple resources and resource groups. + */ + public CompartmentBuilder withTags(Map tags) { + if (this.tags == null) { + this.tags = new HashMap<>(); + } + this.tags.putAll(tags); + return this; + } - return errors; + /** + * Tag is name/value pairs that enable you to categorize resources and view consolidated billing by + * applying the same tag to multiple resources and resource groups. + */ + public CompartmentBuilder withTag(String key, String value) { + if (this.tags == null) { + withTags(new HashMap<>()); + } + + this.tags.put(key, value); + return this; } - public static class CompartmentBuilder { - - protected String name; - protected String parentId; - protected Map tags; - - public CompartmentBuilder() { - } - - public CompartmentBuilder withName(String name) { - this.name = name; - return this; - } - - /** - * Tags are name/value pairs that enable you to categorize resources and view consolidated billing by - * applying the same tag to multiple resources and resource groups. - */ - public CompartmentBuilder withTags(Map tags) { - if (this.tags == null) { - this.tags = new HashMap<>(); - } - this.tags.putAll(tags); - return this; - } - - /** - * Tag is name/value pairs that enable you to categorize resources and view consolidated billing by - * applying the same tag to multiple resources and resource groups. - */ - public CompartmentBuilder withTag(String key, String value) { - if (this.tags == null) { - withTags(new HashMap<>()); - } - - this.tags.put(key, value); - return this; - } - - public Compartment build() { - var compartment = new Compartment(name, parentId, tags); - - var errors = compartment.validate(); - - if (!errors.isEmpty()) { - throw new IllegalArgumentException(String.format( - "Oci compartmenr validation failed. Errors: %s", - Arrays.toString(errors.toArray()))); - } - - return compartment; - } + public Compartment build() { + var compartment = new Compartment(name, parentId, tags); + + var errors = compartment.validate(); + + if (!errors.isEmpty()) { + throw new IllegalArgumentException(String.format( + "Oci compartmenr validation failed. Errors: %s", + Arrays.toString(errors.toArray()))); + } + + return compartment; } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciContainerEngineForKubernetes.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciContainerEngineForKubernetes.java index ba818053..3475b42b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciContainerEngineForKubernetes.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciContainerEngineForKubernetes.java @@ -16,83 +16,87 @@ @Getter @Setter public class OciContainerEngineForKubernetes extends KubernetesCluster implements OciResourceEntity { - private final static String REGION_IS_NULL = "[OciContainerEngineForKubernetes Validation] Region is not specified and it is required"; - private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and 63 characters long"; + private final static String REGION_IS_NULL = "[OciContainerEngineForKubernetes Validation] Region is not specified " + + "and it is required"; + private final static String NAME_NOT_VALID = "[KubernetesCluster Validation] The name can contain only letters, " + + "numbers, underscores, and hyphens. The name must start and end with a letter or number and must be between 1 and" + + " 63 characters long"; - private OciRegion ociRegion; - private Compartment compartment; - private Map tags; - private String name; + private OciRegion ociRegion; + private Compartment compartment; + private Map tags; + private String name; - public ProviderType getProvider() { - return ProviderType.OCI; - } + public ProviderType getProvider() { + return ProviderType.OCI; + } - public static OciContainerEngineForKubernetesBuilder builder() { - return new OciContainerEngineForKubernetesBuilder(); - } + public static OciContainerEngineForKubernetesBuilder builder() { + return new OciContainerEngineForKubernetesBuilder(); + } - public static class OciContainerEngineForKubernetesBuilder extends Builder { + public static class OciContainerEngineForKubernetesBuilder extends Builder { - @Override - protected OciContainerEngineForKubernetes createComponent() { - return new OciContainerEngineForKubernetes(); - } + @Override + protected OciContainerEngineForKubernetes createComponent() { + return new OciContainerEngineForKubernetes(); + } - @Override - protected OciContainerEngineForKubernetesBuilder getBuilder() { - return this; - } + @Override + protected OciContainerEngineForKubernetesBuilder getBuilder() { + return this; + } - public OciContainerEngineForKubernetesBuilder withRegion(OciRegion region) { - component.setOciRegion(region); - return builder; - } + public OciContainerEngineForKubernetesBuilder withRegion(OciRegion region) { + component.setOciRegion(region); + return builder; + } - public OciContainerEngineForKubernetesBuilder withCompartment(Compartment compartment) { - component.setCompartment(compartment); - return builder; - } + public OciContainerEngineForKubernetesBuilder withCompartment(Compartment compartment) { + component.setCompartment(compartment); + return builder; + } - public OciContainerEngineForKubernetesBuilder withName(String name) { - component.setName(name); - return builder; - } + public OciContainerEngineForKubernetesBuilder withName(String name) { + component.setName(name); + return builder; + } - public OciContainerEngineForKubernetesBuilder withTags(Map tags) { - component.setTags(tags); - return builder; - } + public OciContainerEngineForKubernetesBuilder withTags(Map tags) { + component.setTags(tags); + return builder; + } - public OciContainerEngineForKubernetesBuilder withTag(String key, String value) { - if (component.getTags() == null) { - withTags(new HashMap<>()); - } + public OciContainerEngineForKubernetesBuilder withTag(String key, String value) { + if (component.getTags() == null) { + withTags(new HashMap<>()); + } - component.getTags().put(key, value); - return builder; - } + component.getTags().put(key, value); + return builder; } + } - @Override - public Collection validate() { + @Override + public Collection validate() { - Collection errors = super.validate(); - errors.addAll(OciResourceEntity.validateOciResourceEntity(this, "Kubernetes Service")); + Collection errors = super.validate(); + errors.addAll(OciResourceEntity.validateOciResourceEntity(this, "Kubernetes Service")); - if(StringUtils.isNotBlank(name)) { - var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); - var hasValidLengths = isValidStringLength(name, 1, 63); - if(!isAlphaNumerics || !hasValidLengths) { - errors.add(NAME_NOT_VALID); - } - } - - if (ociRegion == null) { - errors.add(REGION_IS_NULL); - } + if (StringUtils.isNotBlank(name)) { + var isAlphaNumerics = isValidAlphanumericsUnderscoresHyphens(name); + var hasValidLengths = isValidStringLength(name, 1, 63); + if (!isAlphaNumerics || !hasValidLengths) { + errors.add(NAME_NOT_VALID); + } + } - return errors; + if (ociRegion == null) { + errors.add(REGION_IS_NULL); } + + return errors; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciResourceEntity.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciResourceEntity.java index 7879eb8f..c3341e69 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciResourceEntity.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciResourceEntity.java @@ -7,8 +7,11 @@ public interface OciResourceEntity extends ResourceEntity { Compartment getCompartment(); + void setCompartment(Compartment compartment); + OciRegion getOciRegion(); + void setOciRegion(OciRegion region); static Collection validateOciResourceEntity(OciResourceEntity resourceEntity, String entityName) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedBrokerComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedBrokerComponent.java index ddf2730e..07391728 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedBrokerComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedBrokerComponent.java @@ -15,8 +15,9 @@ @Getter @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) -public class UnmanagedBrokerComponent extends com.yanchware.fractal.sdk.domain.blueprint.saas.UnmanagedBrokerComponent implements LiveSystemComponent { - private final static String SECRET_VALUE_IS_BLANK = "[SaaSUnmanagedBrokerComponent Validation] Secret Value has not been defined and it is required"; +public class UnmanagedBrokerComponent extends com.yanchware.fractal.sdk.domain.fractal.saas.UnmanagedBrokerComponent implements LiveSystemComponent { + private final static String SECRET_VALUE_IS_BLANK = "[SaaSUnmanagedBrokerComponent Validation] Secret Value has not" + + " been defined and it is required"; private String secretName; private String secretValue; @@ -30,7 +31,8 @@ public static UnmanagedStorageComponentBuilder builder() { return new UnmanagedStorageComponentBuilder(); } - public static class UnmanagedStorageComponentBuilder extends Builder { + public static class UnmanagedStorageComponentBuilder extends Builder { @Override protected UnmanagedBrokerComponent createComponent() { @@ -44,6 +46,7 @@ protected UnmanagedStorageComponentBuilder getBuilder() { /** * Name of the secret + * * @param secretName */ public UnmanagedStorageComponentBuilder withSecretName(String secretName) { @@ -53,6 +56,7 @@ public UnmanagedStorageComponentBuilder withSecretName(String secretName) { /** * Value of the secret + * * @param secretValue */ public UnmanagedStorageComponentBuilder withSecretValue(String secretValue) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponent.java index 0fd68ebd..8449ac6e 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponent.java @@ -15,8 +15,9 @@ @Getter @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) -public class UnmanagedSecurityComponent extends com.yanchware.fractal.sdk.domain.blueprint.saas.UnmanagedSecurityComponent implements LiveSystemComponent { - private final static String SECRET_VALUE_IS_BLANK = "[SaaSUnmanagedSecurityComponent Validation] Secret Value has not been defined and it is required"; +public class UnmanagedSecurityComponent extends com.yanchware.fractal.sdk.domain.fractal.saas.UnmanagedSecurityComponent implements LiveSystemComponent { + private final static String SECRET_VALUE_IS_BLANK = "[SaaSUnmanagedSecurityComponent Validation] Secret Value has " + + "not been defined and it is required"; private String secretName; private String secretValue; @@ -30,7 +31,8 @@ public static ExternalSecurityComponentBuilder builder() { return new ExternalSecurityComponentBuilder(); } - public static class ExternalSecurityComponentBuilder extends Builder { + public static class ExternalSecurityComponentBuilder extends Builder { @Override protected UnmanagedSecurityComponent createComponent() { @@ -44,7 +46,7 @@ protected ExternalSecurityComponentBuilder getBuilder() { /** * Sets the name of the secret. - * + * * @param secretName The name of the secret. * @return The builder instance for method chaining. */ @@ -55,7 +57,7 @@ public ExternalSecurityComponentBuilder withSecretName(String secretName) { /** * Sets the value of the secret. - * + * * @param secretValue The value of the secret. * @return The builder instance for method chaining. */ diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageComponent.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageComponent.java index 8ef41c82..2abff373 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageComponent.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageComponent.java @@ -16,8 +16,9 @@ @Getter @Setter(AccessLevel.PRIVATE) @ToString(callSuper = true) -public class UnmanagedStorageComponent extends com.yanchware.fractal.sdk.domain.blueprint.saas.UnmanagedStorageComponent implements LiveSystemComponent { - private final static String SECRET_VALUE_IS_BLANK = "[SaaSUnmanagedStorageComponent Validation] Secret Value has not been defined and it is required"; +public class UnmanagedStorageComponent extends com.yanchware.fractal.sdk.domain.fractal.saas.UnmanagedStorageComponent implements LiveSystemComponent { + private final static String SECRET_VALUE_IS_BLANK = "[SaaSUnmanagedStorageComponent Validation] Secret Value has " + + "not been defined and it is required"; private String secretName; private String secretValue; @@ -31,7 +32,8 @@ public static UnmanagedStorageComponentBuilder builder() { return new UnmanagedStorageComponentBuilder(); } - public static class UnmanagedStorageComponentBuilder extends Component.Builder { + public static class UnmanagedStorageComponentBuilder extends Component.Builder { @Override protected UnmanagedStorageComponent createComponent() { @@ -42,18 +44,20 @@ protected UnmanagedStorageComponent createComponent() { protected UnmanagedStorageComponentBuilder getBuilder() { return this; } - + /** * Name of the secret + * * @param secretName */ public UnmanagedStorageComponentBuilder withSecretName(String secretName) { component.setSecretName(secretName); return builder; } - + /** * Value of the secret + * * @param secretValue */ public UnmanagedStorageComponentBuilder withSecretValue(String secretValue) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/LiveSystemService.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/LiveSystemService.java index c251caa2..e13133a6 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/LiveSystemService.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/LiveSystemService.java @@ -3,10 +3,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.yanchware.fractal.sdk.configuration.SdkConfiguration; import com.yanchware.fractal.sdk.domain.Service; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; import com.yanchware.fractal.sdk.domain.exceptions.ComponentInstantiationException; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; import com.yanchware.fractal.sdk.domain.exceptions.ProviderException; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; import com.yanchware.fractal.sdk.domain.livesystem.EnvironmentReference; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemIdValue; import com.yanchware.fractal.sdk.domain.livesystem.service.commands.InstantiateLiveSystemCommandRequest; @@ -41,82 +41,87 @@ public class LiveSystemService extends Service { protected static final Duration RETRIES_DELAY = Duration.ofMinutes(1L); public LiveSystemService( - HttpClient client, - SdkConfiguration sdkConfiguration, - RetryRegistry retryRegistry) { + HttpClient client, + SdkConfiguration sdkConfiguration, + RetryRegistry retryRegistry) + { super(client, sdkConfiguration, retryRegistry); } public void checkLiveSystemMutationStatus( - LiveSystemIdValue liveSystemId, - String liveSystemMutationId) throws InstantiatorException { + LiveSystemIdValue liveSystemId, + String liveSystemMutationId) throws InstantiatorException + { log.info("Checking Live System mutation status [Live System id: '{}', mutation id: '{}']", - liveSystemId.toString(), liveSystemMutationId); + liveSystemId.toString(), liveSystemMutationId); var requestName = "checkLiveSystemMutationStatus"; var acceptedResponses = new int[]{200, 404}; var request = HttpUtils.buildGetRequest( - getLiveSystemMutationUri(liveSystemId.toString(), liveSystemMutationId), - sdkConfiguration); + getLiveSystemMutationUri(liveSystemId.toString(), liveSystemMutationId), + sdkConfiguration); var retryConfig = RetryConfig.custom() - .retryExceptions(InstantiatorException.class) - .maxAttempts(CHECK_LIVE_SYSTEM_MUTATION_STATUS_MAX_ATTEMPTS) - .waitDuration(RETRIES_DELAY) - .build(); + .retryExceptions(InstantiatorException.class) + .maxAttempts(CHECK_LIVE_SYSTEM_MUTATION_STATUS_MAX_ATTEMPTS) + .waitDuration(RETRIES_DELAY) + .build(); var retry = RetryRegistry.of(retryConfig).retry(requestName); try { Retry.decorateCheckedSupplier(retry, () -> - checkLiveSystemMutationStatus( - liveSystemId, - liveSystemMutationId, - requestName, - acceptedResponses, - request)).get(); + checkLiveSystemMutationStatus( + liveSystemId, + liveSystemMutationId, + requestName, + acceptedResponses, + request)).get(); } catch (Throwable ex) { throw new InstantiatorException(ex.getLocalizedMessage()); } } private LiveSystemMutationDto checkLiveSystemMutationStatus( - LiveSystemIdValue liveSystemId, - String liveSystemMutationId, - String requestName, - int[] acceptedResponses, - HttpRequest request) throws IOException, InterruptedException, InstantiatorException, ProviderException { + LiveSystemIdValue liveSystemId, + String liveSystemMutationId, + String requestName, + int[] acceptedResponses, + HttpRequest request) throws IOException, InterruptedException, InstantiatorException, ProviderException + { var liveSystemIdStr = liveSystemId.toString(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); ensureAcceptableResponse(response, requestName, acceptedResponses); if (response.statusCode() == 404) { throw new InstantiatorException( - String.format("Attempted %s has come up with a 404 Not Found. Will attempt to create it", requestName)); + String.format("Attempted %s has come up with a 404 Not Found. Will attempt to create it", requestName)); } String bodyContents = response.body(); if (isBlank(bodyContents)) { throw new InstantiatorException( - String.format("Attempted %s has come up with empty or null body contents", requestName)); + String.format("Attempted %s has come up with empty or null body contents", requestName)); } var liveSystemMutationResponse = getLiveSystemMutationResponse(requestName, bodyContents); if (liveSystemMutationResponse == null) { - String message = String.format("The LiveSystem [%s] exists, but the LiveSystem's provider LiveSystem is still empty or not fully updated for mutation [%s]", - liveSystemIdStr, liveSystemMutationId); + String message = String.format("The LiveSystem [%s] exists, but the LiveSystem's provider LiveSystem is still " + + "empty or not fully updated for mutation [%s]", + liveSystemIdStr, liveSystemMutationId); log.info(message); throw new InstantiatorException(message); } var liveSystemMutationResponseComponents = liveSystemMutationResponse.componentsById(); if (liveSystemMutationResponseComponents == null) { - throw new ProviderException(String.format("Live System [%s] instantiation failed for mutation [%s] as component list is null", - liveSystemIdStr, - liveSystemMutationId)); + throw new ProviderException(String.format("Live System [%s] instantiation failed for mutation [%s] as component" + + " list is null", + liveSystemIdStr, + liveSystemMutationId)); } switch (liveSystemMutationResponse.status()) { @@ -126,28 +131,32 @@ private LiveSystemMutationDto checkLiveSystemMutationStatus( } case FAILED -> { var messageToThrow = getFailedComponentsMessageToThrow(liveSystemIdStr, - liveSystemMutationId, - liveSystemMutationResponseComponents); + liveSystemMutationId, + liveSystemMutationResponseComponents); if (StringUtils.isBlank(messageToThrow)) { - log.warn("Live System [id: '{}'] instantiation failed but erorrMessage is not visible yet, retrying: {}", liveSystemId, getStatusFromComponents(liveSystemMutationResponseComponents)); + log.warn("Live System [id: '{}'] instantiation failed but erorrMessage is not visible yet, retrying: {}", + liveSystemId, getStatusFromComponents(liveSystemMutationResponseComponents)); String timeoutExceptionMessage = String.format( - "Live System [%s] instantiation wait timeout. Response is %s", - liveSystemIdStr, - response.body()); + "Live System [%s] instantiation wait timeout. Response is %s", + liveSystemIdStr, + response.body()); throw new InstantiatorException(timeoutExceptionMessage); } else { - log.warn("Live System [id: '{}'] instantiation failed: {}", liveSystemId, getStatusFromComponents(liveSystemMutationResponseComponents)); + log.warn("Live System [id: '{}'] instantiation failed: {}", liveSystemId, + getStatusFromComponents(liveSystemMutationResponseComponents)); throw new ProviderException(messageToThrow); } } case CANCELLED -> { - log.warn("Live System [id: '{}'] instantiation cancelled: {}", liveSystemId, getStatusFromComponents(liveSystemMutationResponseComponents)); + log.warn("Live System [id: '{}'] instantiation cancelled: {}", liveSystemId, + getStatusFromComponents(liveSystemMutationResponseComponents)); var cancelledInstantiationMessage = String.format( - "Live System [%s] instantiation did not complete for mutation [%s] as the latter has been cancelled by an operator", - liveSystemId, - liveSystemMutationId); + "Live System [%s] instantiation did not complete for mutation [%s] as the latter has been cancelled by an " + + "operator", + liveSystemId, + liveSystemMutationId); throw new ProviderException(cancelledInstantiationMessage); } case INPROGRESS -> { @@ -157,60 +166,65 @@ private LiveSystemMutationDto checkLiveSystemMutationStatus( logInstantiationCompleted(liveSystemId, liveSystemMutationResponseComponents); return liveSystemMutationResponse; } else { - log.info("Live System [id: '{}'] instantiation is in progress: {}. Next check in {} seconds ...", - liveSystemId, getStatusFromComponents(liveSystemMutationResponseComponents), RETRIES_DELAY.toSeconds()); + log.info("Live System [id: '{}'] instantiation is in progress: {}. Next check in {} seconds ...", + liveSystemId, getStatusFromComponents(liveSystemMutationResponseComponents), RETRIES_DELAY.toSeconds()); String timeoutExceptionMessage = String.format( - "Live System [%s] instantiation wait timeout. Response is %s", - liveSystemIdStr, - response.body()); + "Live System [%s] instantiation wait timeout. Response is %s", + liveSystemIdStr, + response.body()); throw new InstantiatorException(timeoutExceptionMessage); } } default -> - throw new ProviderException(String.format("Live System [%s] instantiation has an unknown state for mutation [%s]: [%s]", - liveSystemIdStr, - liveSystemMutationId, - liveSystemMutationResponse.status())); + throw new ProviderException(String.format("Live System [%s] instantiation has an unknown state for mutation " + + "[%s]: [%s]", + liveSystemIdStr, + liveSystemMutationId, + liveSystemMutationResponse.status())); } } - private void logInstantiationCompleted(LiveSystemIdValue liveSystemId, - Map liveSystemMutationResponseComponents) { + private void logInstantiationCompleted( + LiveSystemIdValue liveSystemId, + Map liveSystemMutationResponseComponents) + { log.info("Live System [id: '{}'] instantiation completed: {}", - liveSystemId, - getStatusFromComponents(liveSystemMutationResponseComponents)); + liveSystemId, + getStatusFromComponents(liveSystemMutationResponseComponents)); } private boolean allComponentsProcessed(String uniqueStatuses) { return uniqueStatuses.equals("Active") - || uniqueStatuses.equals("Active,Deleted") - || uniqueStatuses.equals("Deleted"); + || uniqueStatuses.equals("Active,Deleted") + || uniqueStatuses.equals("Deleted"); } private String getUniqueStatusesFromComponents(Map mutationComponents) { return mutationComponents.values() - .stream() - .map(c -> c.getStatus().toString()) - .distinct() - .collect(Collectors.joining(",")); + .stream() + .map(c -> c.getStatus().toString()) + .distinct() + .collect(Collectors.joining(",")); } - private String getFailedComponentsMessageToThrow(String liveSystemId, - String liveSystemMutationId, - Map mutation) { + private String getFailedComponentsMessageToThrow( + String liveSystemId, + String liveSystemMutationId, + Map mutation) + { var failedComponents = mutation.values() - .stream() - .filter(c -> c.getStatus() == LiveSystemComponentStatusDto.Failed) - .toList(); + .stream() + .filter(c -> c.getStatus() == LiveSystemComponentStatusDto.Failed) + .toList(); if (failedComponents.isEmpty()) { return ""; } else { var messageToThrow = new StringBuilder(); messageToThrow.append( - String.format("Live System [id: '%s'] instantiation failed for mutation [id: '%s']. " + - "Failed components -> ", - liveSystemId, liveSystemMutationId)); + String.format("Live System [id: '%s'] instantiation failed for mutation [id: '%s']. " + + "Failed components -> ", + liveSystemId, liveSystemMutationId)); for (var component : failedComponents) { var errorMessage = component.getLastOperationStatusMessage(); @@ -219,9 +233,9 @@ private String getFailedComponentsMessageToThrow(String liveSystemId, } messageToThrow.append(String.format("id: '%s', status: '%s', errorMessage: '%s' - ", - component.getId(), - component.getStatus(), - errorMessage)); + component.getId(), + component.getStatus(), + errorMessage)); } return messageToThrow.substring(0, messageToThrow.length() - 3); @@ -238,7 +252,10 @@ private String getStatusFromComponents(Map liveS return status.substring(0, status.length() - 3); } - private static LiveSystemMutationDto getLiveSystemMutationResponse(String requestName, String bodyContents) throws ProviderException { + private static LiveSystemMutationDto getLiveSystemMutationResponse( + String requestName, + String bodyContents) throws ProviderException + { try { return deserialize(bodyContents, LiveSystemMutationDto.class); } catch (JsonProcessingException e) { @@ -248,7 +265,10 @@ private static LiveSystemMutationDto getLiveSystemMutationResponse(String reques } } - private static LiveSystemComponentMutationDto getLiveSystemComponentMutationResponse(String requestName, String bodyContents) throws ProviderException { + private static LiveSystemComponentMutationDto getLiveSystemComponentMutationResponse( + String requestName, + String bodyContents) throws ProviderException + { try { return deserialize(bodyContents, LiveSystemComponentMutationDto.class); } catch (JsonProcessingException e) { @@ -262,8 +282,8 @@ public LiveSystemDto retrieveLiveSystem(LiveSystemIdValue liveSystemId) throws I HttpResponse response; try { response = client.send( - HttpUtils.buildGetRequest(getLiveSystemUri(liveSystemId.toString()), sdkConfiguration), - HttpResponse.BodyHandlers.ofString() + HttpUtils.buildGetRequest(getLiveSystemUri(liveSystemId.toString()), sdkConfiguration), + HttpResponse.BodyHandlers.ofString() ); } catch (IOException | InterruptedException e) { throw new InstantiatorException("Attempted Retrieve LiveSystem failed", e); @@ -276,99 +296,104 @@ public LiveSystemDto retrieveLiveSystem(LiveSystemIdValue liveSystemId) throws I if (response.statusCode() != 200) { throw new InstantiatorException( - String.format( - "Attempted Retrieve Live System with response code: %s and body %s ", - response.statusCode(), - response.body())); + String.format( + "Attempted Retrieve Live System with response code: %s and body %s ", + response.statusCode(), + response.body())); } return getDeserializedResponseBody(response.body()); } public LiveSystemComponentMutationDto instantiateComponent(LiveSystemIdValue liveSystemId, String componentId) - throws InstantiatorException { + throws InstantiatorException + { log.info("Instantiating component [id: '{}'] in LiveSystem [id: '{}']", - componentId, liveSystemId); + componentId, liveSystemId); HttpRequest request = HttpUtils.buildPostRequest( - getInstantiateComponentUri(liveSystemId, componentId), - sdkConfiguration, null); // Assuming no request body needed for instantiation + getInstantiateComponentUri(liveSystemId, componentId), + sdkConfiguration, null); // Assuming no request body needed for instantiation return executeRequestWithRetries( - "instantiateComponent", - liveSystemId.toString(), - client, - retryRegistry, - request, - new int[]{200, 404}, // Accepted status code - LiveSystemComponentMutationDto.class); + "instantiateComponent", + liveSystemId.toString(), + client, + retryRegistry, + request, + new int[]{200, 404}, // Accepted status code + LiveSystemComponentMutationDto.class); } public LiveSystemComponentMutationDto getComponentMutationStatus( - String liveSystemId, - String componentId, - String mutationId) throws InstantiatorException { + String liveSystemId, + String componentId, + String mutationId) throws InstantiatorException + { var requestName = "getComponentMutationStatus"; var acceptedResponses = new int[]{200, 404}; var request = HttpUtils.buildGetRequest( - getComponentStateUri(liveSystemId, componentId, mutationId), - sdkConfiguration); + getComponentStateUri(liveSystemId, componentId, mutationId), + sdkConfiguration); var retryConfig = RetryConfig.custom() - .retryExceptions(InstantiatorException.class) - .maxAttempts(CHECK_LIVE_SYSTEM_MUTATION_STATUS_MAX_ATTEMPTS) - .waitDuration(Duration.ofSeconds(30L)) - .build(); + .retryExceptions(InstantiatorException.class) + .maxAttempts(CHECK_LIVE_SYSTEM_MUTATION_STATUS_MAX_ATTEMPTS) + .waitDuration(Duration.ofSeconds(30L)) + .build(); var retry = RetryRegistry.of(retryConfig).retry(requestName); try { return Retry.decorateCheckedSupplier(retry, () -> - getComponentMutationStatus( - liveSystemId, - componentId, - mutationId, - requestName, - acceptedResponses, - request)).get(); + getComponentMutationStatus( + liveSystemId, + componentId, + mutationId, + requestName, + acceptedResponses, + request)).get(); } catch (Throwable ex) { throw new InstantiatorException(ex.getLocalizedMessage()); } } private LiveSystemComponentMutationDto getComponentMutationStatus( - String liveSystemId, - String componentId, - String mutationId, - String requestName, - int[] acceptedResponses, - HttpRequest request) throws IOException, InterruptedException, InstantiatorException, ProviderException, ComponentInstantiationException { + String liveSystemId, + String componentId, + String mutationId, + String requestName, + int[] acceptedResponses, + HttpRequest request) throws IOException, InterruptedException, InstantiatorException, ProviderException, + ComponentInstantiationException + { var response = client.send(request, HttpResponse.BodyHandlers.ofString()); ensureAcceptableResponse(response, requestName, acceptedResponses); if (response.statusCode() == 404) { throw new ComponentInstantiationException( - String.format( - "Component [id: '%s'] not found [LiveSystemId: '%s', MutationId: '%s']", - componentId, liveSystemId, mutationId)); + String.format( + "Component [id: '%s'] not found [LiveSystemId: '%s', MutationId: '%s']", + componentId, liveSystemId, mutationId)); } String bodyContents = response.body(); if (isBlank(bodyContents)) { throw new ComponentInstantiationException( - String.format( - "Unexpected empty or null response body for component [id: '%s'] in LiveSystem [id: '%s']. Status code: %d.", - componentId, liveSystemId, response.statusCode())); + String.format( + "Unexpected empty or null response body for component [id: '%s'] in LiveSystem [id: '%s']. Status code: %d.", + componentId, liveSystemId, response.statusCode())); } var componentMutationDto = getLiveSystemComponentMutationResponse(requestName, bodyContents); if (componentMutationDto == null) { - String message = String.format("The LiveSystem [%s] exists, but the LiveSystem's provider LiveSystem is still empty or not fully updated for mutation [%s]", - liveSystemId, mutationId); + String message = String.format("The LiveSystem [%s] exists, but the LiveSystem's provider LiveSystem is still " + + "empty or not fully updated for mutation [%s]", + liveSystemId, mutationId); log.info(message); throw new InstantiatorException(message); } @@ -389,31 +414,32 @@ private LiveSystemComponentMutationDto getComponentMutationStatus( case Instantiating -> { log.info("Instantiation is in progress [LiveSystemId: '{}', ComponentId: '{}']", liveSystemId, componentId); String timeoutExceptionMessage = String.format( - "Instantiation wait timeout [LiveSystemId: '%s', ComponentId: '%s']. Response is %s", - liveSystemId, - componentId, - response.body()); + "Instantiation wait timeout [LiveSystemId: '%s', ComponentId: '%s']. Response is %s", + liveSystemId, + componentId, + response.body()); throw new InstantiatorException(timeoutExceptionMessage); } default -> - throw new ProviderException(String.format("Instantiation has an unknown state '%s' [LiveSystemId: '%s', ComponentId: '%s', MutationId: '%s']", - component.getStatus(), - liveSystemId, - componentId, - mutationId)); + throw new ProviderException(String.format("Instantiation has an unknown state '%s' [LiveSystemId: '%s', " + + "ComponentId: '%s', MutationId: '%s']", + component.getStatus(), + liveSystemId, + componentId, + mutationId)); } } private URI getInstantiateComponentUri(LiveSystemIdValue liveSystemId, String componentId) { return URI.create(String.format( - "%s/%s/%s/component/%s/instantiate", - getLiveSystemUri(), liveSystemId.resourceGroupId().toString(), liveSystemId.name(), componentId)); + "%s/%s/%s/component/%s/instantiate", + getLiveSystemUri(), liveSystemId.resourceGroupId().toString(), liveSystemId.name(), componentId)); } private URI getComponentStateUri(String liveSystemId, String componentId, String mutationId) { return URI.create(String.format( - "%s/%s/component/%s/state/%s", - getLiveSystemUri(), liveSystemId, componentId, mutationId)); + "%s/%s/component/%s/state/%s", + getLiveSystemUri(), liveSystemId, componentId, mutationId)); } private static LiveSystemDto getDeserializedResponseBody(String bodyContents) throws InstantiatorException { @@ -421,36 +447,37 @@ private static LiveSystemDto getDeserializedResponseBody(String bodyContents) th return deserialize(bodyContents, LiveSystemDto.class); } catch (JsonProcessingException e) { throw new InstantiatorException( - String.format("Attempted Retrieve LiveSystem failed. Deserialization of %s failed.", bodyContents), - e); + String.format("Attempted Retrieve LiveSystem failed. Deserialization of %s failed.", bodyContents), + e); } } public LiveSystemMutationDto updateLiveSystem( - String liveSystemId, - FractalIdValue fractalId, - String description, - String provider, - Map blueprintMap, - EnvironmentReference environmentReference - ) throws InstantiatorException { + String liveSystemId, + FractalIdValue fractalId, + String description, + String provider, + Map blueprintMap, + EnvironmentReference environmentReference + ) throws InstantiatorException + { var command = new UpdateLiveSystemCommandRequest( - liveSystemId, - fractalId.toString(), - description, - provider, - blueprintMap, - environmentReference); + liveSystemId, + fractalId.toString(), + description, + provider, + blueprintMap, + environmentReference); HttpRequest request; try { String serializedCommand = serialize(command); logLiveSystemInstantiation(liveSystemId); - + request = HttpUtils.buildPutRequest( - getLiveSystemUri(liveSystemId), sdkConfiguration, serializedCommand); + getLiveSystemUri(liveSystemId), sdkConfiguration, serializedCommand); } catch (JsonProcessingException e) { throw new InstantiatorException("Error processing UpdateLiveSystemCommandRequest because of JsonProcessing", e); } @@ -464,10 +491,10 @@ public LiveSystemMutationDto updateLiveSystem( if (response.statusCode() != 202) { throw new InstantiatorException( - String.format( - "Attempted UpdateLiveSystemCommandRequest failed [response code: '%s', message: '%s']", - response.statusCode(), - response.body())); + String.format( + "Attempted UpdateLiveSystemCommandRequest failed [response code: '%s', message: '%s']", + response.statusCode(), + response.body())); } try { @@ -479,19 +506,20 @@ public LiveSystemMutationDto updateLiveSystem( } public LiveSystemMutationDto instantiateLiveSystem( - String liveSystemId, - FractalIdValue fractalId, - String description, - String provider, - Map blueprintMap, - EnvironmentReference environmentReference) throws InstantiatorException { + String liveSystemId, + FractalIdValue fractalId, + String description, + String provider, + Map blueprintMap, + EnvironmentReference environmentReference) throws InstantiatorException + { var command = new InstantiateLiveSystemCommandRequest( - liveSystemId, - fractalId.toString(), - description, - provider, - blueprintMap, - environmentReference); + liveSystemId, + fractalId.toString(), + description, + provider, + blueprintMap, + environmentReference); HttpRequest request; try { @@ -501,17 +529,18 @@ public LiveSystemMutationDto instantiateLiveSystem( var liveSystemUri = URI.create(String.format("%s/", getLiveSystemUri())); request = HttpUtils.buildPostRequest(liveSystemUri, sdkConfiguration, serializedCommand); } catch (JsonProcessingException e) { - throw new InstantiatorException("Error processing InstantiateLiveSystemCommandRequest because of JsonProcessing", e); + throw new InstantiatorException("Error processing InstantiateLiveSystemCommandRequest because of " + + "JsonProcessing", e); } return executeRequestWithRetries( - "instantiateLiveSystem", - liveSystemId, - client, - retryRegistry, - request, - new int[]{200}, - LiveSystemMutationDto.class); + "instantiateLiveSystem", + liveSystemId, + client, + retryRegistry, + request, + new int[]{200}, + LiveSystemMutationDto.class); } private void logLiveSystemInstantiation(String liveSystemId) { @@ -534,8 +563,8 @@ public void deleteLiveSystem(String liveSystemId) throws InstantiatorException { HttpResponse response; try { response = client.send( - HttpUtils.buildDeleteRequest(getLiveSystemUri(liveSystemId), sdkConfiguration), - HttpResponse.BodyHandlers.ofString() + HttpUtils.buildDeleteRequest(getLiveSystemUri(liveSystemId), sdkConfiguration), + HttpResponse.BodyHandlers.ofString() ); } catch (IOException | InterruptedException e) { throw new InstantiatorException("Attempted deletion of LiveSystem failed", e); @@ -548,10 +577,10 @@ public void deleteLiveSystem(String liveSystemId) throws InstantiatorException { if (response.statusCode() != 200) { throw new InstantiatorException( - String.format( - "Attempted deletion of Live System failed with response code: %s and body %s ", - response.statusCode(), - response.body())); + String.format( + "Attempted deletion of Live System failed with response code: %s and body %s ", + response.statusCode(), + response.body())); } log.info("Live System with id [id: '{}'] has been marked for deletion", liveSystemId); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/InstantiateLiveSystemCommandRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/InstantiateLiveSystemCommandRequest.java index 5acf3bb6..5339fbbb 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/InstantiateLiveSystemCommandRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/InstantiateLiveSystemCommandRequest.java @@ -6,10 +6,11 @@ import java.util.Map; public record InstantiateLiveSystemCommandRequest( - String liveSystemId, - String fractalId, - String description, - String provider, - Map blueprintMap, - EnvironmentReference environment){ + String liveSystemId, + String fractalId, + String description, + String provider, + Map blueprintMap, + EnvironmentReference environment) +{ } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/UpdateLiveSystemCommandRequest.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/UpdateLiveSystemCommandRequest.java index c73c6b59..7289ebb8 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/UpdateLiveSystemCommandRequest.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/commands/UpdateLiveSystemCommandRequest.java @@ -5,10 +5,13 @@ import java.util.Map; -public record UpdateLiveSystemCommandRequest ( - String liveSystemId, - String fractalId, - String description, - String provider, //not set, here just to match the request in liveSystem. We will have provider at LiveSystemComponent level - Map blueprintMap, - EnvironmentReference environment){ } +public record UpdateLiveSystemCommandRequest( + String liveSystemId, + String fractalId, + String description, + String provider, + //not set, here just to match the request in liveSystem. We will have provider at LiveSystemComponent level + Map blueprintMap, + EnvironmentReference environment) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentDto.java index c12cecee..9636e8c0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentDto.java @@ -4,5 +4,7 @@ public record EnvironmentDto( EnvironmentIdDto id, - Map parameters) { } + Map parameters) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentIdDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentIdDto.java index 78ec4649..6aa53393 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentIdDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/EnvironmentIdDto.java @@ -2,10 +2,11 @@ import java.util.UUID; -public record EnvironmentIdDto ( - EnvironmentTypeDto type, - UUID ownerId, - String shortName){ +public record EnvironmentIdDto( + EnvironmentTypeDto type, + UUID ownerId, + String shortName) +{ @Override public String toString() { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentDto.java index 8cb7217f..21119314 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentDto.java @@ -15,51 +15,52 @@ @ToString(callSuper = true) @NoArgsConstructor public class LiveSystemComponentDto extends ComponentDto { - private LiveSystemComponentStatusDto status; - private Map outputFields; - private Date lastUpdated; - private ProviderType provider; - private String lastOperationStatusMessage; + private LiveSystemComponentStatusDto status; + private Map outputFields; + private Date lastUpdated; + private ProviderType provider; + private String lastOperationStatusMessage; - public static LiveSystemComponentDtoBuilder builder() { - return new LiveSystemComponentDtoBuilder(); - } + public static LiveSystemComponentDtoBuilder builder() { + return new LiveSystemComponentDtoBuilder(); + } - public static class LiveSystemComponentDtoBuilder extends Builder { + public static class LiveSystemComponentDtoBuilder extends Builder { - @Override - protected LiveSystemComponentDto createComponent() { - return new LiveSystemComponentDto(); - } + @Override + protected LiveSystemComponentDto createComponent() { + return new LiveSystemComponentDto(); + } - @Override - protected LiveSystemComponentDtoBuilder getBuilder() { - return this; - } + @Override + protected LiveSystemComponentDtoBuilder getBuilder() { + return this; + } - public LiveSystemComponentDtoBuilder withStatus(LiveSystemComponentStatusDto status) { - componentDto.setStatus(status); - return builder; - } + public LiveSystemComponentDtoBuilder withStatus(LiveSystemComponentStatusDto status) { + componentDto.setStatus(status); + return builder; + } - public LiveSystemComponentDtoBuilder withOutputFields(Map outputFields) { - if (componentDto.getOutputFields() == null) { - componentDto.setOutputFields(new HashMap<>()); - } + public LiveSystemComponentDtoBuilder withOutputFields(Map outputFields) { + if (componentDto.getOutputFields() == null) { + componentDto.setOutputFields(new HashMap<>()); + } - componentDto.getOutputFields().putAll(outputFields); + componentDto.getOutputFields().putAll(outputFields); - return builder; - } + return builder; + } - public LiveSystemComponentDtoBuilder withLastUpdated(Date lastUpdated) { - componentDto.setLastUpdated(lastUpdated); - return builder; - } + public LiveSystemComponentDtoBuilder withLastUpdated(Date lastUpdated) { + componentDto.setLastUpdated(lastUpdated); + return builder; + } - public LiveSystemComponentDtoBuilder withProvider(ProviderType provider) { - componentDto.setProvider(provider); - return builder; - } + public LiveSystemComponentDtoBuilder withProvider(ProviderType provider) { + componentDto.setProvider(provider); + return builder; } + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentMutationDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentMutationDto.java index c7a8fc76..f702ec59 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentMutationDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentMutationDto.java @@ -2,10 +2,12 @@ import java.util.Date; -public record LiveSystemComponentMutationDto ( +public record LiveSystemComponentMutationDto( String liveSystemId, String id, LiveSystemMutationStatusDto status, LiveSystemComponentDto component, Date created, - Date lastUpdated){ } + Date lastUpdated) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentStatusDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentStatusDto.java index 003f6e0b..df20744f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentStatusDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemComponentStatusDto.java @@ -1,10 +1,10 @@ package com.yanchware.fractal.sdk.domain.livesystem.service.dtos; public enum LiveSystemComponentStatusDto { - Instantiating, - Active, - Failed, - Mutating, - Deleting, - Deleted + Instantiating, + Active, + Failed, + Mutating, + Deleting, + Deleted } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemDto.java index 5f1285fd..c52d68dd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemDto.java @@ -1,16 +1,18 @@ package com.yanchware.fractal.sdk.domain.livesystem.service.dtos; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintDto; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintDto; import java.util.Date; -public record LiveSystemDto ( - String liveSystemId, - String fractalId, - String requesterId, - BlueprintDto blueprint, - Date created, - Date lastUpdated, - LiveSystemStatusDto status, - String statusMessage, - EnvironmentDto environment){ } +public record LiveSystemDto( + String liveSystemId, + String fractalId, + String requesterId, + BlueprintDto blueprint, + Date created, + Date lastUpdated, + LiveSystemStatusDto status, + String statusMessage, + EnvironmentDto environment) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemMutationDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemMutationDto.java index ec912530..4a9851dd 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemMutationDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemMutationDto.java @@ -3,7 +3,7 @@ import java.util.Map; import java.util.Set; -public record LiveSystemMutationDto ( +public record LiveSystemMutationDto( String liveSystemId, String id, LiveSystemMutationStatusDto status, @@ -11,5 +11,7 @@ public record LiveSystemMutationDto ( Set componentsCompletedIds, Set componentsFailedIds, Map componentsById, - Map> componentsBlocked){} + Map> componentsBlocked) +{ +} diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/ProviderType.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/ProviderType.java index 8cc7a196..845636e0 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/ProviderType.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/ProviderType.java @@ -1,11 +1,11 @@ package com.yanchware.fractal.sdk.domain.livesystem.service.dtos; public enum ProviderType { - AWS, - GCP, - AZURE, - CAAS, - SAAS, - OCI, - HETZNER + AWS, + GCP, + AZURE, + CAAS, + SAAS, + OCI, + HETZNER } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/services/contracts/ComponentDto.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/services/contracts/ComponentDto.java index e482e8a0..b0eeb700 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/services/contracts/ComponentDto.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/services/contracts/ComponentDto.java @@ -113,10 +113,10 @@ public B withFields(Map allFields) { withDisplayName(String.valueOf(allFields.get(DISPLAY_NAME_KEY))); withDescription(String.valueOf(allFields.get(DESCRIPTION_KEY))); withVersion(String.valueOf(allFields.get(VERSION_KEY))); - if ((Boolean)allFields.get(LOCKED_KEY)) { + if ((Boolean) allFields.get(LOCKED_KEY)) { lock(); } - withRecreateOnFailure((Boolean)allFields.get(RECREATE_ON_FAILURE_KEY)); + withRecreateOnFailure((Boolean) allFields.get(RECREATE_ON_FAILURE_KEY)); withParameters((Map) allFields.get(PARAMETERS_KEY)); withDependencies(componentIds.stream().map(ComponentId::getValue).collect(toSet())); withLinks((Set) allFields.get(Constants.LINKS_KEY)); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ComponentId.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ComponentId.java index 13214482..eae689bb 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ComponentId.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ComponentId.java @@ -14,49 +14,51 @@ @Data @NoArgsConstructor public class ComponentId { - - protected final static Integer MIN_LENGTH = 3; - protected final static Integer MAX_LENGTH = 63; - - private final static Pattern valueValidation = Pattern.compile("^(?!\\d)[a-z\\d]+((?:-[a-z\\d]+)*)+$"); - protected final static String ID_NULL_OR_EMPTY_TEMPLATE = "Component id '%s' is illegal. A valid component id cannot be null, empty or contain spaces"; - protected final static String ILLEGAL_ID_TEMPLATE = "Component id '%s' is illegal. A valid component id must start with a lowercase character and it can only contain lowercase characters, digits and hyphens"; - protected final static String ID_LENGTH_MISMATCH_TEMPLATE = - "Component id '%s' is illegal. A valid component Id must be between " + MIN_LENGTH + - " and " + MAX_LENGTH + " characters of length"; - - private String value; - - protected ComponentId(String value) { - Collection validationErrors = validate(value); - if (!validationErrors.isEmpty()) { - throw new IllegalArgumentException(String.format( - "Component Id is illegal. Errors: %s", - Arrays.toString(validationErrors.toArray()))); - } - this.value = value; - } - public static ComponentId from(String value) { - return new ComponentId(value); + protected final static Integer MIN_LENGTH = 3; + protected final static Integer MAX_LENGTH = 63; + + private final static Pattern valueValidation = Pattern.compile("^(?!\\d)[a-z\\d]+((?:-[a-z\\d]+)*)+$"); + protected final static String ID_NULL_OR_EMPTY_TEMPLATE = "Component id '%s' is illegal. A valid component id " + + "cannot be null, empty or contain spaces"; + protected final static String ILLEGAL_ID_TEMPLATE = "Component id '%s' is illegal. A valid component id must start " + + "with a lowercase character and it can only contain lowercase characters, digits and hyphens"; + protected final static String ID_LENGTH_MISMATCH_TEMPLATE = + "Component id '%s' is illegal. A valid component Id must be between " + MIN_LENGTH + + " and " + MAX_LENGTH + " characters of length"; + + private String value; + + protected ComponentId(String value) { + Collection validationErrors = validate(value); + if (!validationErrors.isEmpty()) { + throw new IllegalArgumentException(String.format( + "Component Id is illegal. Errors: %s", + Arrays.toString(validationErrors.toArray()))); } + this.value = value; + } - public static Collection validate(String value) { - List ret = new ArrayList<>(); - if (isBlank(value)) { - ret.add(String.format(ID_NULL_OR_EMPTY_TEMPLATE, value)); - return ret; - } + public static ComponentId from(String value) { + return new ComponentId(value); + } - if (!valueValidation.matcher(value).matches()) { - ret.add(String.format(ILLEGAL_ID_TEMPLATE, value)); - } + public static Collection validate(String value) { + List ret = new ArrayList<>(); + if (isBlank(value)) { + ret.add(String.format(ID_NULL_OR_EMPTY_TEMPLATE, value)); + return ret; + } - var length = value.length(); - if (length < MIN_LENGTH || length > MAX_LENGTH) { - ret.add(String.format(ID_LENGTH_MISMATCH_TEMPLATE, value)); - } + if (!valueValidation.matcher(value).matches()) { + ret.add(String.format(ILLEGAL_ID_TEMPLATE, value)); + } - return ret; + var length = value.length(); + if (length < MIN_LENGTH || length > MAX_LENGTH) { + ret.add(String.format(ID_LENGTH_MISMATCH_TEMPLATE, value)); } + + return ret; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ResourceGroupId.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ResourceGroupId.java index 039dbb07..520ceb7f 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ResourceGroupId.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/domain/values/ResourceGroupId.java @@ -17,7 +17,8 @@ public static ResourceGroupId fromString(String s) { throw new IllegalArgumentException("Invalid resource group id"); } - return new ResourceGroupId(ResourceGroupType.valueOf(rdIdArr[0].toUpperCase()), UUID.fromString(rdIdArr[1]), rdIdArr[2]); + return new ResourceGroupId(ResourceGroupType.valueOf(rdIdArr[0].toUpperCase()), UUID.fromString(rdIdArr[1]), + rdIdArr[2]); } @NotNull @@ -29,7 +30,7 @@ public String toString() { @Override public boolean equals(Object o) { - if (o == this){ + if (o == this) { return true; } if (!(o instanceof ResourceGroupId(ResourceGroupType groupType, UUID id, String name))) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/CollectionUtils.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/CollectionUtils.java index 9405a994..b01bde9e 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/CollectionUtils.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/CollectionUtils.java @@ -4,7 +4,7 @@ public class CollectionUtils { - public static boolean isBlank(Collection collection) { - return collection == null || collection.isEmpty(); - } + public static boolean isBlank(Collection collection) { + return collection == null || collection.isEmpty(); + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ExtendableEnum.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ExtendableEnum.java index dd9807c6..12605a1b 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ExtendableEnum.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ExtendableEnum.java @@ -13,10 +13,11 @@ @Getter public abstract class ExtendableEnum> { - private static final Map, ConcurrentHashMap>> VALUES = new ConcurrentHashMap<>(); + private static final Map, ConcurrentHashMap>> VALUES = + new ConcurrentHashMap<>(); private String name; - + @JsonIgnore private Class clazz; @@ -25,16 +26,17 @@ protected static > T fromString(String name, Class new ConcurrentHashMap()); + (key) -> new ConcurrentHashMap()); var value = (ExtendableEnum) clazzValues.get(name); if (value != null) { - return (T)value; + return (T) value; } else { try { value = clazz.getDeclaredConstructor().newInstance(); - return (T)value.nameAndAddValue(name, value, clazz); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException var5) { + return (T) value.nameAndAddValue(name, value, clazz); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | + InvocationTargetException var5) { return null; } } @@ -45,7 +47,7 @@ T nameAndAddValue(String name, T value, Class clazz) { this.name = name; this.clazz = clazz; ((ConcurrentHashMap) VALUES.get(clazz)).put(name, value); - return (T)this; + return (T) this; } protected static > Collection values(Class clazz) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/HttpUtils.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/HttpUtils.java index ec66e422..9e8ed012 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/HttpUtils.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/HttpUtils.java @@ -22,54 +22,62 @@ public class HttpUtils { public static HttpRequest buildGetRequest(URI uri, SdkConfiguration sdkConfiguration) { return getHttpRequestBuilder(uri, sdkConfiguration) - .GET() - .build(); + .GET() + .build(); } public static HttpRequest buildPutRequest(URI uri, SdkConfiguration sdkConfiguration, String payload) { return getHttpRequestBuilder(uri, sdkConfiguration) - .PUT(ofString(payload)) - .build(); + .PUT(ofString(payload)) + .build(); } public static HttpRequest buildPostRequest(URI uri, SdkConfiguration sdkConfiguration, String payload) { return buildPostRequest(uri, sdkConfiguration, payload, null); } - public static HttpRequest buildPostRequest(URI uri, SdkConfiguration sdkConfiguration, - String payload, - Map additionalHeaders) { + public static HttpRequest buildPostRequest( + URI uri, SdkConfiguration sdkConfiguration, + String payload, + Map additionalHeaders) + { return getHttpRequestBuilder(uri, sdkConfiguration, additionalHeaders) - .POST(StringUtils.isBlank(payload) ? noBody() : ofString(payload)) - .build(); + .POST(StringUtils.isBlank(payload) ? noBody() : ofString(payload)) + .build(); } - public static HttpRequest buildDeleteRequest(URI uri, - SdkConfiguration sdkConfiguration) { + public static HttpRequest buildDeleteRequest( + URI uri, + SdkConfiguration sdkConfiguration) + { return buildDeleteRequest(uri, sdkConfiguration, null); } - public static HttpRequest buildDeleteRequest(URI uri, - SdkConfiguration sdkConfiguration, - Map additionalHeaders) { + public static HttpRequest buildDeleteRequest( + URI uri, + SdkConfiguration sdkConfiguration, + Map additionalHeaders) + { return getHttpRequestBuilder(uri, sdkConfiguration, additionalHeaders) - .DELETE() - .build(); + .DELETE() + .build(); } public static HttpRequest.Builder getHttpRequestBuilder(URI uri, SdkConfiguration sdkConfiguration) { return getHttpRequestBuilder(uri, sdkConfiguration, null); } - public static HttpRequest.Builder getHttpRequestBuilder(URI uri, - SdkConfiguration sdkConfiguration, - Map additionalHeaders) { + public static HttpRequest.Builder getHttpRequestBuilder( + URI uri, + SdkConfiguration sdkConfiguration, + Map additionalHeaders) + { var builder = HttpRequest.newBuilder() - .uri(uri) - .header(X_CLIENT_ID_HEADER, sdkConfiguration.getClientId()) - .header(X_CLIENT_SECRET_HEADER, sdkConfiguration.getClientSecret()) - .header("Content-Type", "application/json"); + .uri(uri) + .header(X_CLIENT_ID_HEADER, sdkConfiguration.getClientId()) + .header(X_CLIENT_SECRET_HEADER, sdkConfiguration.getClientSecret()) + .header("Content-Type", "application/json"); if (additionalHeaders != null) { additionalHeaders.forEach(builder::header); @@ -78,26 +86,30 @@ public static HttpRequest.Builder getHttpRequestBuilder(URI uri, return builder; } - public static void ensureAcceptableResponse(HttpResponse response, - String requestName, - int[] acceptedResponses) throws InstantiatorException { + public static void ensureAcceptableResponse( + HttpResponse response, + String requestName, + int[] acceptedResponses) throws InstantiatorException + { ensureAcceptableResponse(response, requestName, null, acceptedResponses); } - public static void ensureAcceptableResponse(HttpResponse response, - String requestName, - String entityId, - int[] acceptedResponses) throws InstantiatorException { + public static void ensureAcceptableResponse( + HttpResponse response, + String requestName, + String entityId, + int[] acceptedResponses) throws InstantiatorException + { if (Arrays.stream(acceptedResponses).noneMatch((x) -> x == response.statusCode())) { var requestNameWords = StringHelper.toWords(requestName); handleStructuredError(response, requestNameWords, entityId); - + var responseBody = response.body(); - + if (responseBody.contains("Token validation failed")) { String errorMessage = formatErrorMessage(requestName, "Token validation failed", entityId); @@ -106,9 +118,9 @@ public static void ensureAcceptableResponse(HttpResponse response, throw new InstantiatorException(errorMessage); } else if (response.statusCode() == 401) { String errorMessage = formatErrorMessage(requestName, - "Invalid credentials provided. Please check your credentials or contact Fractal Cloud support " + - "if you do not have credentials or suspect a password issue.", - entityId); + "Invalid credentials provided. Please check your credentials or contact Fractal Cloud support " + + "if you do not have credentials or suspect a password issue.", + entityId); log.error(errorMessage); @@ -121,9 +133,11 @@ public static void ensureAcceptableResponse(HttpResponse response, } } - private static void handleStructuredError(HttpResponse response, - String requestName, - String entityId) throws InstantiatorException { + private static void handleStructuredError( + HttpResponse response, + String requestName, + String entityId) throws InstantiatorException + { try { var jsonNode = SerializationUtils.deserialize(response.body(), JsonNode.class); if (jsonNode.has("reasonCode") && jsonNode.has("message")) { @@ -131,9 +145,9 @@ private static void handleStructuredError(HttpResponse response, var message = jsonNode.get("message").asText(); String errorMessage = formatErrorMessage(requestName, - String.format("Reason: %s, Message: %s", reasonCode, message), - entityId); - + String.format("Reason: %s, Message: %s", reasonCode, message), + entityId); + log.error(errorMessage); throw new InstantiatorException(errorMessage); } @@ -144,8 +158,8 @@ private static void handleStructuredError(HttpResponse response, public static String formatErrorMessage(String requestName, String errorMessage, String entityId) { return String.format("Failed to %s%s.%s", - StringHelper.toWords(requestName), - StringUtils.isBlank(entityId) ? "" : String.format(" [id: '%s']", entityId), - StringUtils.isBlank(errorMessage) ? "" : String.format(" %s", errorMessage)); + StringHelper.toWords(requestName), + StringUtils.isBlank(entityId) ? "" : String.format(" [id: '%s']", entityId), + StringUtils.isBlank(errorMessage) ? "" : String.format(" %s", errorMessage)); } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionClassUnder.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionClassUnder.java index 4469dc8b..198fe198 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionClassUnder.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionClassUnder.java @@ -6,11 +6,11 @@ @Data @Builder public class ReflectionClassUnder { - private boolean isBlueprintComponent; - private boolean isLiveSystemComponent; - private boolean isValidatable; + private boolean isBlueprintComponent; + private boolean isLiveSystemComponent; + private boolean isValidatable; - public boolean isAnyComponent() { - return isBlueprintComponent || isLiveSystemComponent; - } + public boolean isAnyComponent() { + return isBlueprintComponent || isLiveSystemComponent; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionUtils.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionUtils.java index 19d81a7e..8a1fa4e8 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionUtils.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ReflectionUtils.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.yanchware.fractal.sdk.domain.Validatable; -import com.yanchware.fractal.sdk.domain.blueprint.BlueprintComponent; +import com.yanchware.fractal.sdk.domain.fractal.BlueprintComponent; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemComponent; import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.ProviderType; import lombok.extern.slf4j.Slf4j; @@ -15,250 +15,269 @@ @Slf4j public class ReflectionUtils { - /** - * Build component list together with dependencies - * #1 run "dependencyId" is null because we start at the top level of components (in most cases, a ContainerPlatform) - * @param component component to build from - can result in multiple components, depending on hierarchy - * @return a list of all components mapped as key-value - */ + /** + * Build component list together with dependencies + * #1 run "dependencyId" is null because we start at the top level of components (in most cases, a ContainerPlatform) + * + * @param component component to build from - can result in multiple components, depending on hierarchy + * @return a list of all components mapped as key-value + */ - public static List> buildComponents(LiveSystemComponent component) { - List> listOfComponentJson = new ArrayList<>(); + public static List> buildComponents(LiveSystemComponent component) { + List> listOfComponentJson = new ArrayList<>(); - //get fields of current component - Map allFields = getAllFields(component); - listOfComponentJson.add(allFields); + //get fields of current component + Map allFields = getAllFields(component); + listOfComponentJson.add(allFields); - //start looping through all the fields of all classes in the hierarchy - Class clazz = component.getClass(); - while (clazz.getSuperclass() != null) { - for (Field f : clazz.getDeclaredFields()) { - if (!isFieldTypeComponent(f)) { - continue; - } - f.setAccessible(true); - if (isFieldCollection(f)) { - ParameterizedType ptype = (ParameterizedType) f.getGenericType(); - Class typeArgClazz = (Class) ptype.getActualTypeArguments()[0]; - var fieldClazzUnder = determineClassType(typeArgClazz); + //start looping through all the fields of all classes in the hierarchy + Class clazz = component.getClass(); + while (clazz.getSuperclass() != null) { + for (Field f : clazz.getDeclaredFields()) { + if (!isFieldTypeComponent(f)) { + continue; + } + f.setAccessible(true); + if (isFieldCollection(f)) { + ParameterizedType ptype = (ParameterizedType) f.getGenericType(); + Class typeArgClazz = (Class) ptype.getActualTypeArguments()[0]; + var fieldClazzUnder = determineClassType(typeArgClazz); - if (fieldClazzUnder.isLiveSystemComponent()) { - try { - Object o = f.get(component); - if (o == null) { - log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), component.getClass().getSimpleName()); - continue; - } - List listOfComp = (List) o; - for (LiveSystemComponent comp : listOfComp) { - log.trace("Component to map: {}, with SuperComp: {}", comp.getClass().getSimpleName(), component.getClass().getSimpleName()); - listOfComponentJson.addAll(buildComponents(comp)); - } - } catch (IllegalAccessException e) { - log.error("Error when trying to map field '{}' for class '{}", f.getName(), clazz.getSimpleName(), e); - } - } - } else { - var fieldClazzUnder = determineClassType(f.getType()); - if (fieldClazzUnder.isLiveSystemComponent()) { - try { - Object o = f.get(component); - if (o == null) { - log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), component.getClass().getSimpleName()); - continue; - } - LiveSystemComponent comp = (LiveSystemComponent) o; - log.trace("Component to map: {}, with SuperComp: {}", comp.getClass().getSimpleName(), component.getClass().getSimpleName()); - listOfComponentJson.addAll(buildComponents(comp)); - } catch (IllegalAccessException e) { - log.error("Error when trying to map field '{}' for class '{}", f.getName(), clazz.getSimpleName(), e); - } - } - } + if (fieldClazzUnder.isLiveSystemComponent()) { + try { + Object o = f.get(component); + if (o == null) { + log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), + component.getClass().getSimpleName()); + continue; + } + List listOfComp = (List) o; + for (LiveSystemComponent comp : listOfComp) { + log.trace("Component to map: {}, with SuperComp: {}", comp.getClass().getSimpleName(), + component.getClass().getSimpleName()); + listOfComponentJson.addAll(buildComponents(comp)); + } + } catch (IllegalAccessException e) { + log.error("Error when trying to map field '{}' for class '{}", f.getName(), clazz.getSimpleName(), e); + } + } + } else { + var fieldClazzUnder = determineClassType(f.getType()); + if (fieldClazzUnder.isLiveSystemComponent()) { + try { + Object o = f.get(component); + if (o == null) { + log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), + component.getClass().getSimpleName()); + continue; + } + LiveSystemComponent comp = (LiveSystemComponent) o; + log.trace("Component to map: {}, with SuperComp: {}", comp.getClass().getSimpleName(), + component.getClass().getSimpleName()); + listOfComponentJson.addAll(buildComponents(comp)); + } catch (IllegalAccessException e) { + log.error("Error when trying to map field '{}' for class '{}", f.getName(), clazz.getSimpleName(), e); } - clazz = clazz.getSuperclass(); + } } - return listOfComponentJson; + } + clazz = clazz.getSuperclass(); } + return listOfComponentJson; + } - /** - * Takes in a component and generates a map with generic component fields and parameters. - * Loop through all fields of a class and skips constants. - * @param component component to be mapped - * @return map of all fields and parameters of component - */ - public static Map getAllFields(LiveSystemComponent component) { - Map fieldValueMap = new HashMap<>(); - Map parametersMap = new HashMap<>(); - Class clazz = component.getClass(); - while (clazz.getSuperclass() != null) { - log.trace("Mapping class: {}", clazz.getSimpleName()); - var classUnder = determineClassType(clazz); + /** + * Takes in a component and generates a map with generic component fields and parameters. + * Loop through all fields of a class and skips constants. + * + * @param component component to be mapped + * @return map of all fields and parameters of component + */ + public static Map getAllFields(LiveSystemComponent component) { + Map fieldValueMap = new HashMap<>(); + Map parametersMap = new HashMap<>(); + Class clazz = component.getClass(); + while (clazz.getSuperclass() != null) { + log.trace("Mapping class: {}", clazz.getSimpleName()); + var classUnder = determineClassType(clazz); - for (Field f : clazz.getDeclaredFields()) { - f.setAccessible(true); - if (isFieldTypeComponent(f)) { - log.trace("Field '{}' is a component. Skipped.", f.getName()); - continue; - } - try { - // New logic to handle specific methods - handleMethodInvocation(component, parametersMap, "getKind", "kind"); - if (classUnder.isBlueprintComponent()) { - handleParams(component, fieldValueMap, parametersMap, f, classUnder); - } else if (classUnder.isLiveSystemComponent()) { - handleParams(component, fieldValueMap, parametersMap, f, classUnder); - } else if (classUnder.isValidatable() && !isFieldPrivateStaticFinal(f)) { - Object componentObj = f.get(component); - if (componentObj == null) { - log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), component.getClass().getSimpleName()); - continue; - } - if (componentObj.getClass().isEnum()) { - fieldValueMap.put(f.getName(), componentObj.toString()); - } else { - fieldValueMap.put(f.getName(), componentObj); - } - } else { - //for now, we don't have a "TYPE" in other classes except ones that implement BlueprintComponent or LiveSystemComponent - handleParams(component, fieldValueMap, parametersMap, f, classUnder); - } - } catch (IllegalAccessException e) { - log.error("Error trying to access field: {}", f.getName(), e); - } + for (Field f : clazz.getDeclaredFields()) { + f.setAccessible(true); + if (isFieldTypeComponent(f)) { + log.trace("Field '{}' is a component. Skipped.", f.getName()); + continue; + } + try { + // New logic to handle specific methods + handleMethodInvocation(component, parametersMap, "getKind", "kind"); + if (classUnder.isBlueprintComponent()) { + handleParams(component, fieldValueMap, parametersMap, f, classUnder); + } else if (classUnder.isLiveSystemComponent()) { + handleParams(component, fieldValueMap, parametersMap, f, classUnder); + } else if (classUnder.isValidatable() && !isFieldPrivateStaticFinal(f)) { + Object componentObj = f.get(component); + if (componentObj == null) { + log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), + component.getClass().getSimpleName()); + continue; } - clazz = clazz.getSuperclass(); + if (componentObj.getClass().isEnum()) { + fieldValueMap.put(f.getName(), componentObj.toString()); + } else { + fieldValueMap.put(f.getName(), componentObj); + } + } else { + //for now, we don't have a "TYPE" in other classes except ones that implement BlueprintComponent or + // LiveSystemComponent + handleParams(component, fieldValueMap, parametersMap, f, classUnder); + } + } catch (IllegalAccessException e) { + log.error("Error trying to access field: {}", f.getName(), e); } - fieldValueMap.put("parameters", parametersMap); - return fieldValueMap; + } + clazz = clazz.getSuperclass(); } + fieldValueMap.put("parameters", parametersMap); + return fieldValueMap; + } - /** - * Method that will take a field in and determine how to handle it based on the type of the field - * @param component that holds the field we are mapping - * @param fieldValueMap map that holds generic component fields - * @param parametersMap map that holds parameters of a component - * @param f field we are handling - * @throws IllegalAccessException Illegal Access Exception - */ - private static void handleParams(LiveSystemComponent component, Map fieldValueMap, Map parametersMap, Field f, ReflectionClassUnder classUnder) throws IllegalAccessException { - if (f.isAnnotationPresent(JsonIgnore.class)) { - log.trace("Field '{}' is annotated with @JsonIgnore, so will be ignored.", f.getName()); - return; - } - - if (f.getType() == ProviderType.class) { - log.trace("Found a provider type for component: {}", component.getClass().getSimpleName()); - return; - } - - Object componentObject = f.get(component); - if (componentObject == null) { - log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), component.getClass().getSimpleName()); - return; - } - - if (classUnder.isBlueprintComponent() && isFieldTypeConstant(f)) { - fieldValueMap.put(BLUEPRINT_TYPE, componentObject); - return; - } - - if (isFieldPrivateStaticFinal(f)) { - log.trace("Field '{}' is private-static-final, so will be ignored.", f.getName()); - return; - } + /** + * Method that will take a field in and determine how to handle it based on the type of the field + * + * @param component that holds the field we are mapping + * @param fieldValueMap map that holds generic component fields + * @param parametersMap map that holds parameters of a component + * @param f field we are handling + * @throws IllegalAccessException Illegal Access Exception + */ + private static void handleParams( + LiveSystemComponent component, + Map fieldValueMap, + Map parametersMap, + Field f, + ReflectionClassUnder classUnder) throws IllegalAccessException + { + if (f.isAnnotationPresent(JsonIgnore.class)) { + log.trace("Field '{}' is annotated with @JsonIgnore, so will be ignored.", f.getName()); + return; + } - if (componentObject.getClass().isEnum()) { - parametersMap.put(f.getName(), componentObject.toString()); - return; - } + if (f.getType() == ProviderType.class) { + log.trace("Found a provider type for component: {}", component.getClass().getSimpleName()); + return; + } - parametersMap.put(f.getName(), componentObject); + Object componentObject = f.get(component); + if (componentObject == null) { + log.trace("Field '{}' of component '{}' is null. Will skip.", f.getName(), component.getClass().getSimpleName()); + return; } - // New method to handle invocation of specific methods like getKind - private static void handleMethodInvocation(LiveSystemComponent component, - Map parametersMap, - String methodName, - String paramKey) { - try { - Method method = component.getClass().getMethod(methodName); - if (method != null) { - Object result = method.invoke(component); - if (result != null) { - parametersMap.put(paramKey, result); - } - } - } catch (NoSuchMethodException e) { - log.trace("Method '{}' not found in component: {}", methodName, component.getClass().getSimpleName()); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - log.error("Error invoking method '{}' on component: {}", methodName, component.getClass().getSimpleName(), e); - } + if (classUnder.isBlueprintComponent() && isFieldTypeConstant(f)) { + fieldValueMap.put(BLUEPRINT_TYPE, componentObject); + return; } - /** - * Determine if a field is private static final (private constant) or not. - * @param f field to be determined - * @return true if it is a private static final, false otherwise - */ - private static boolean isFieldPrivateStaticFinal(Field f) { - int fieldModifiers = f.getModifiers(); - return Modifier.isPrivate(fieldModifiers) && Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers); + if (isFieldPrivateStaticFinal(f)) { + log.trace("Field '{}' is private-static-final, so will be ignored.", f.getName()); + return; } - private static boolean isFieldTypeConstant(Field f) { - int fieldModifiers = f.getModifiers(); - return Modifier.isPublic(fieldModifiers) && Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers) && f.getName().equals("TYPE"); + if (componentObject.getClass().isEnum()) { + parametersMap.put(f.getName(), componentObject.toString()); + return; } - /** - * Loops through all the interface of the class and returns an object that holds said information. - * @param clazz class to be determined - * @return a {@link ReflectionClassUnder} object that holds information about what type of class it is - */ - private static ReflectionClassUnder determineClassType(Class clazz) { - for (Class aClass : clazz.getInterfaces()) { - if (aClass.isAssignableFrom(BlueprintComponent.class)) { - return ReflectionClassUnder.builder().isBlueprintComponent(true).build(); - } - if (aClass.isAssignableFrom(LiveSystemComponent.class)) { - return ReflectionClassUnder.builder().isLiveSystemComponent(true).build(); - } - if (aClass.isAssignableFrom(Validatable.class)) { - return ReflectionClassUnder.builder().isValidatable(true).build(); - } + parametersMap.put(f.getName(), componentObject); + } + + // New method to handle invocation of specific methods like getKind + private static void handleMethodInvocation( + LiveSystemComponent component, + Map parametersMap, + String methodName, + String paramKey) + { + try { + Method method = component.getClass().getMethod(methodName); + if (method != null) { + Object result = method.invoke(component); + if (result != null) { + parametersMap.put(paramKey, result); } - return ReflectionClassUnder.builder().build(); + } + } catch (NoSuchMethodException e) { + log.trace("Method '{}' not found in component: {}", methodName, component.getClass().getSimpleName()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + log.error("Error invoking method '{}' on component: {}", methodName, component.getClass().getSimpleName(), e); } + } - private static boolean isClassSimpleType(Class clazz) { - return clazz.isPrimitive() || clazz.isEnum() || clazz.isAssignableFrom(String.class); - } + /** + * Determine if a field is private static final (private constant) or not. + * + * @param f field to be determined + * @return true if it is a private static final, false otherwise + */ + private static boolean isFieldPrivateStaticFinal(Field f) { + int fieldModifiers = f.getModifiers(); + return Modifier.isPrivate(fieldModifiers) && Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers); + } - private static boolean isFieldCollection(Field f) { - return Collection.class.isAssignableFrom(f.getType()); + private static boolean isFieldTypeConstant(Field f) { + int fieldModifiers = f.getModifiers(); + return Modifier.isPublic(fieldModifiers) && Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers) && f.getName().equals("TYPE"); + } + + /** + * Loops through all the interface of the class and returns an object that holds said information. + * + * @param clazz class to be determined + * @return a {@link ReflectionClassUnder} object that holds information about what type of class it is + */ + private static ReflectionClassUnder determineClassType(Class clazz) { + for (Class aClass : clazz.getInterfaces()) { + if (aClass.isAssignableFrom(BlueprintComponent.class)) { + return ReflectionClassUnder.builder().isBlueprintComponent(true).build(); + } + if (aClass.isAssignableFrom(LiveSystemComponent.class)) { + return ReflectionClassUnder.builder().isLiveSystemComponent(true).build(); + } + if (aClass.isAssignableFrom(Validatable.class)) { + return ReflectionClassUnder.builder().isValidatable(true).build(); + } } + return ReflectionClassUnder.builder().build(); + } - private static boolean isFieldTypeComponent(Field f) { - Class fieldClass = f.getType(); - if (isFieldCollection(f)) { - ParameterizedType ptype = (ParameterizedType) f.getGenericType(); - fieldClass = (Class) ptype.getActualTypeArguments()[0]; - } - if (isClassSimpleType(fieldClass)) { - return false; - } - var clazzUnder = determineClassType(fieldClass); - if (clazzUnder.isAnyComponent()) { - return true; - } - while (fieldClass.getSuperclass() != null) { - var checkClazz = fieldClass.getSuperclass(); - if (determineClassType(checkClazz).isAnyComponent()) { - return true; - } - fieldClass = fieldClass.getSuperclass(); - } - return false; + private static boolean isClassSimpleType(Class clazz) { + return clazz.isPrimitive() || clazz.isEnum() || clazz.isAssignableFrom(String.class); + } + + private static boolean isFieldCollection(Field f) { + return Collection.class.isAssignableFrom(f.getType()); + } + + private static boolean isFieldTypeComponent(Field f) { + Class fieldClass = f.getType(); + if (isFieldCollection(f)) { + ParameterizedType ptype = (ParameterizedType) f.getGenericType(); + fieldClass = (Class) ptype.getActualTypeArguments()[0]; + } + if (isClassSimpleType(fieldClass)) { + return false; + } + var clazzUnder = determineClassType(fieldClass); + if (clazzUnder.isAnyComponent()) { + return true; + } + while (fieldClass.getSuperclass() != null) { + var checkClazz = fieldClass.getSuperclass(); + if (determineClassType(checkClazz).isAnyComponent()) { + return true; + } + fieldClass = fieldClass.getSuperclass(); } + return false; + } } diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/RegexValidationUtils.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/RegexValidationUtils.java index 6303d8b1..a53978e1 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/RegexValidationUtils.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/RegexValidationUtils.java @@ -1,16 +1,28 @@ package com.yanchware.fractal.sdk.utils; public class RegexValidationUtils { - private static final String IP_MASK_REGEX = "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\.(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])){3}(?/(?:\\d|1\\d|2\\d|3[0-2]))$"; - private static final String ALPHANUMERICS_UNDERSCORES_HYPHENS_REGEX_PATTERN = "(^[a-zA-Z0-9])([a-zA-Z0-9\\-_]+)([a-zA-Z0-9])$"; + private static final String IP_MASK_REGEX = "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\.(?:\\d{1," + + "2}|1\\d{2}|2[0-4]\\d|25[0-5])){3}(?/(?:\\d|1\\d|2\\d|3[0-2]))$"; + private static final String ALPHANUMERICS_UNDERSCORES_HYPHENS_REGEX_PATTERN = "(^[a-zA-Z0-9])([a-zA-Z0-9\\-_]+)" + + "([a-zA-Z0-9])$"; private static final String ALPHANUMERICS_HYPHENS_REGEX_PATTERN = "^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$"; - private static final String LOWERCASE_LETTERS_NUMBERS_AND_HYPHENS_REGEX_PATTERN = "(^[a-z0-9])([a-z0-9\\-]+)([a-z0-9])$"; - private static final String LETTERS_NUMBERS_PERIODS_AND_HYPHENS_REGEX_PATTERN = "^(?=.*[.])([a-zA-Z0-9_.\\-]+)([a-z0-9])$"; - private static final String LETTERS_NUMBERS_UNDERSCORES_DASHES_PERIODS_REGEX_PATTERN = "^(?=.*[.])([a-zA-Z0-9_.\\-]+)$"; - private static final String LETTERS_NUMBERS_UNDERSCORES_DASHES_PERIODS_PERIOD_NOT_REQUIRED_REGEX_PATTERN = "^([a-zA-Z0-9_.\\-*]+)$"; + private static final String LOWERCASE_LETTERS_NUMBERS_AND_HYPHENS_REGEX_PATTERN = "(^[a-z0-9])([a-z0-9\\-]+)" + + "([a-z0-9])$"; + private static final String LETTERS_NUMBERS_PERIODS_AND_HYPHENS_REGEX_PATTERN = "^(?=.*[.])([a-zA-Z0-9_.\\-]+)" + + "([a-z0-9])$"; + private static final String LETTERS_NUMBERS_UNDERSCORES_DASHES_PERIODS_REGEX_PATTERN = "^(?=.*[.])([a-zA-Z0-9_" + + ".\\-]+)$"; + private static final String LETTERS_NUMBERS_UNDERSCORES_DASHES_PERIODS_PERIOD_NOT_REQUIRED_REGEX_PATTERN = "^([a-zA" + + "-Z0-9_.\\-*]+)$"; private static final String LOWERCASE_LETTERS_AND_NUMBERS_REGEX_PATTERN = "^[a-z0-9]+$"; private static final String LETTERS_AND_NUMBERS_REGEX_PATTERN = "^[a-zA-Z0-9]+$"; - private static final String IP_V6_REGEX_PATTERN = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]+|::(ffff(:0{1,4})?:)?((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\\.){3}(25[0-5]|(2[0-4]|1?[0-9])?[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\\.){3}(25[0-5]|(2[0-4]|1?[0-9])?[0-9]))"; + private static final String IP_V6_REGEX_PATTERN = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1," + + "7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1," + + "4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}" + + "(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:" + + "(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]+|::(ffff(:0{1,4})?:)?((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\\.){3}(25[0-5]|" + + "(2[0-4]|1?[0-9])?[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1?[0-9])?[0-9])\\.){3}(25[0-5]|" + + "(2[0-4]|1?[0-9])?[0-9]))"; private static final String IP_V4_REGEX_PATTERN = "^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$"; public static boolean isValidIpMask(String input) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/SerializationUtils.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/SerializationUtils.java index 421dcf93..b806b226 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/SerializationUtils.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/SerializationUtils.java @@ -19,8 +19,8 @@ public class SerializationUtils { private static ObjectMapper objectMapper; private static final ObjectMapper orderedMapper = new ObjectMapper() - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS) - .setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL); + .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS) + .setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL); public static String serializeSortedJson(Object value) throws JsonProcessingException { return orderedMapper.writeValueAsString(value); @@ -70,7 +70,7 @@ public static Map convertValueToMap(Object obj) { private static void initializeObjectMapper() { objectMapper = new ObjectMapper() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.registerModule(new JavaTimeModule()); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/StringHelper.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/StringHelper.java index b7e00d9b..2e88e0c8 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/StringHelper.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/StringHelper.java @@ -10,20 +10,20 @@ public class StringHelper { private static final String WORD_SEPARATOR = " "; private static final Pattern WORD_FINDER = Pattern.compile("(([A-Z]?[a-z]+)|([A-Z]))"); - + public static String convertToTitleCase(String text) { if (text == null || text.isEmpty()) { return text; } return Arrays - .stream(text.split(WORD_SEPARATOR)) - .map(word -> word.isEmpty() - ? word - : Character.toTitleCase(text.charAt(0)) + word - .substring(1) - .toLowerCase()) - .collect(Collectors.joining(WORD_SEPARATOR)); + .stream(text.split(WORD_SEPARATOR)) + .map(word -> word.isEmpty() + ? word + : Character.toTitleCase(text.charAt(0)) + word + .substring(1) + .toLowerCase()) + .collect(Collectors.joining(WORD_SEPARATOR)); } public static String toWords(String text) { diff --git a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ValidationUtils.java b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ValidationUtils.java index 8ff8d09d..2aa6c1e8 100644 --- a/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ValidationUtils.java +++ b/fractal.sdk/src/main/java/com/yanchware/fractal/sdk/utils/ValidationUtils.java @@ -6,13 +6,20 @@ public class ValidationUtils { - private final static String ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE_PATTERN = "%s must be between %d and %d, the value entered is: %d"; + private final static String ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE_PATTERN = "%s must be between %d and %d, the value " + + "entered is: %d"; private final static String ENTERED_NULL_MESSAGE_PATTERN = "%s cannot be set to null"; - public static void validateIntegerInRange(String fieldName, Integer entered, Integer min, Integer max, Collection errors) { - if(entered == null) { + public static void validateIntegerInRange( + String fieldName, + Integer entered, + Integer min, + Integer max, + Collection errors) + { + if (entered == null) { errors.add(String.format(ENTERED_NULL_MESSAGE_PATTERN, fieldName)); - } else if(entered < min || entered > max) { + } else if (entered < min || entered > max) { errors.add(String.format(ILLEGAL_ARGUMENT_EXCEPTION_MESSAGE_PATTERN, fieldName, min, max, entered)); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/AutomatonTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/AutomatonTest.java index 84a85bf0..9b5aafcf 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/AutomatonTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/AutomatonTest.java @@ -16,15 +16,13 @@ import java.net.http.HttpClient; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; @WireMockTest public class AutomatonTest extends TestWithFixture { @Test - public void success_when_deleteLiveSystem(WireMockRuntimeInfo wmRuntimeInfo) throws URISyntaxException, InstantiatorException, JsonProcessingException { + public void success_when_deleteLiveSystem(WireMockRuntimeInfo wmRuntimeInfo) throws URISyntaxException, + InstantiatorException, JsonProcessingException { var httpClient = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_2) .build(); @@ -36,7 +34,8 @@ public void success_when_deleteLiveSystem(WireMockRuntimeInfo wmRuntimeInfo) thr var environmentResponse = a(EnvironmentResponse.class); var environmentId = environmentResponse.id(); - stubFor(get(urlPathMatching(String.format("/environments/%s/%s/%s", environmentId.type(), environmentId.ownerId(), environmentId.shortName()))) + stubFor(get(urlPathMatching(String.format("/environments/%s/%s/%s", environmentId.type(), environmentId.ownerId() + , environmentId.shortName()))) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") @@ -50,8 +49,8 @@ public void success_when_deleteLiveSystem(WireMockRuntimeInfo wmRuntimeInfo) thr sut.delete(EnvironmentIdValue.fromDto(environmentResponse.id()), liveSystemIds); - for(var liveSystemId : liveSystemIds) { - verify(deleteRequestedFor(urlPathEqualTo(String.format("/livesystems/%s", liveSystemId)))); + for (var liveSystemId : liveSystemIds) { + verify(deleteRequestedFor(urlPathEqualTo(String.format("/livesystems/%s", liveSystemId)))); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/TestWithFixture.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/TestWithFixture.java index 3cdacd49..6d66b529 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/TestWithFixture.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/TestWithFixture.java @@ -1,9 +1,6 @@ package com.yanchware.fractal.sdk; import com.flextrade.jfixture.JFixture; -import com.yanchware.fractal.sdk.domain.environment.service.dtos.EnvironmentResponse; -import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.EnvironmentIdDto; -import com.yanchware.fractal.sdk.domain.livesystem.service.dtos.EnvironmentTypeDto; import com.yanchware.fractal.sdk.utils.EnvironmentIdDtoBuilder; import com.yanchware.fractal.sdk.utils.ExtendableEnum; import org.junit.jupiter.api.BeforeEach; @@ -30,7 +27,7 @@ protected T a(Class classToInstantiate) { if (ExtendableEnum.class.isAssignableFrom(classToInstantiate)) { return createExtendableEnumInstance(classToInstantiate); } - + return fixture.create(classToInstantiate); } @@ -43,11 +40,12 @@ protected List aListOf(Class elementsClass) { } protected String aLowerCaseAlphanumericString(int length) { - return aAlphanumericString(length, true, false,null); + return aAlphanumericString(length, true, false, null); } /** * Generates a positive integer less than or equal to 999 + * * @return A random positive integer less than or equal to 999 */ protected int aPositiveInteger() { @@ -79,7 +77,7 @@ protected String aLowerCaseAlphanumericString(int length, boolean mustStartWithL protected String aAlphanumericString(int length) { - return aAlphanumericString(length, false, false,null); + return aAlphanumericString(length, false, false, null); } protected String aAlphanumericString(int length, boolean mustStartWithLetter) { @@ -87,15 +85,22 @@ protected String aAlphanumericString(int length, boolean mustStartWithLetter) { return aAlphanumericString(length, false, mustStartWithLetter, null); } - protected String aAlphanumericString(int length, boolean lowercaseOnly, boolean mustStartWithLetter, String additionalChars) { + protected String aAlphanumericString( + int length, + boolean lowercaseOnly, + boolean mustStartWithLetter, + String additionalChars) + { String lowercaseChars = "abcdefghijklmnopqrstuvwxyz"; String uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String numberChars = "0123456789"; - String characters = lowercaseChars + (lowercaseOnly ? "" : uppercaseChars) + numberChars + (additionalChars != null ? additionalChars : ""); + String characters = + lowercaseChars + (lowercaseOnly ? "" : uppercaseChars) + numberChars + (additionalChars != null ? + additionalChars : ""); StringBuilder sb = new StringBuilder(); - char lastChar = '\0'; - + char lastChar = '\0'; + for (int i = 0; i < length; i++) { char nextChar; do { @@ -107,11 +112,11 @@ protected String aAlphanumericString(int length, boolean lowercaseOnly, boolean } } } while (nextChar == lastChar); - + sb.append(nextChar); lastChar = nextChar; } - + if (mustStartWithLetter && !Character.isLetter(sb.charAt(0))) { char startChar = lowercaseChars.charAt(random.nextInt(lowercaseChars.length())); sb.setCharAt(0, startChar); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/aggregates/LiveSystemTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/aggregates/LiveSystemTest.java index a200a653..42cb7cda 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/aggregates/LiveSystemTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/aggregates/LiveSystemTest.java @@ -21,7 +21,8 @@ public class LiveSystemTest { - private static ResourceGroupId validResourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"); + private static ResourceGroupId validResourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, + UUID.randomUUID(), "rg"); LiveSystemsFactory factory; @BeforeEach diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfigurationTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfigurationTest.java index cb77c146..0e40d96a 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfigurationTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/configuration/instantiation/InstantiationWaitConfigurationTest.java @@ -18,8 +18,8 @@ void testDefaultConfiguration() { @Test void testWaitForInstantiation() { InstantiationWaitConfiguration config = InstantiationWaitConfiguration.builder() - .withWaitForInstantiation(true) - .build(); + .withWaitForInstantiation(true) + .build(); assertThat(config.isWaitForInstantiation()).isTrue(); assertThat(config.getTimeoutMinutes()).isEqualTo(DEFAULT_LIVE_SYSTEM_INSTANTIATION_WAIT_TIMEOUT_MINUTES); @@ -28,9 +28,9 @@ void testWaitForInstantiation() { @Test void testCustomTimeout() { InstantiationWaitConfiguration config = InstantiationWaitConfiguration.builder() - .withWaitForInstantiation(true) - .withTimeoutMinutes(30) - .build(); + .withWaitForInstantiation(true) + .withTimeoutMinutes(30) + .build(); assertThat(config.isWaitForInstantiation()).isTrue(); assertThat(config.getTimeoutMinutes()).isEqualTo(30); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/ComponentLinkTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/ComponentLinkTest.java index 6193c826..8976c8f2 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/ComponentLinkTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/ComponentLinkTest.java @@ -11,80 +11,80 @@ class ComponentLinkTest { - @Test - public void componentLinkValid_when_IdPassedFromComponent() { - var aks = TestUtils.getAksExample(); - ComponentLink componentLink = ComponentLink.builder().withComponentId(aks).build(); - assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); - } - - @Test - public void componentLinkValid_when_IdPassedFromComponentId() { - var aks = TestUtils.getAksExample(); - Map settings = Map.of("keySetting", "valueSetting"); - ComponentLink componentLink = ComponentLink.builder().withComponentId(aks.getId()).withSettings(settings).build(); - assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); - assertThat(componentLink.getSettings()).isEqualTo(settings); - } - - @Test - public void componentLinkValid_when_SettingsAndRoleNameProvided() { - var aks = TestUtils.getAksExample(); - Map settings = Map.of("keySetting", "valueSetting"); - String roleName = "Owner"; - - ComponentLink componentLink = ComponentLink.builder() - .withComponentId(aks.getId()) - .withSettings(settings) - .withRoleName(roleName) - .build(); - - Map expectedSettings = new HashMap<>(settings); - expectedSettings.put("roleName", roleName); - - assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); - assertThat(componentLink.getSettings()).isEqualTo(expectedSettings); - } - - @Test - public void componentLinkValid_when_RoleNameProvided() { - var aks = TestUtils.getAksExample(); - String roleName = "Owner"; - - ComponentLink componentLink = ComponentLink.builder() - .withComponentId(aks.getId()) - .withRoleName(roleName) - .build(); - - Map expectedSettings = new HashMap<>(); - expectedSettings.put("roleName", roleName); - - assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); - assertThat(componentLink.getSettings()).isEqualTo(expectedSettings); - } - - @Test - public void lastRoleNameUsed_when_MultipleRoleNameProvided() { - var aks = TestUtils.getAksExample(); - String roleName1 = "Owner"; - String roleName2 = "Contributor"; - - ComponentLink componentLink = ComponentLink.builder() - .withComponentId(aks.getId()) - .withRoleName(roleName1) - .withRoleName(roleName2) - .build(); - - Map expectedSettings = new HashMap<>(); - expectedSettings.put("roleName", roleName2); - - assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); - assertThat(componentLink.getSettings()).isEqualTo(expectedSettings); - } - - @Test - public void componentLinkValidationErrors_when_ComponentIdNotValid() { - assertThatThrownBy(() -> ComponentLink.builder().withComponentId("A").build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("A valid component id must start with a lowercase character"); - } + @Test + public void componentLinkValid_when_IdPassedFromComponent() { + var aks = TestUtils.getAksExample(); + ComponentLink componentLink = ComponentLink.builder().withComponentId(aks).build(); + assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); + } + + @Test + public void componentLinkValid_when_IdPassedFromComponentId() { + var aks = TestUtils.getAksExample(); + Map settings = Map.of("keySetting", "valueSetting"); + ComponentLink componentLink = ComponentLink.builder().withComponentId(aks.getId()).withSettings(settings).build(); + assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); + assertThat(componentLink.getSettings()).isEqualTo(settings); + } + + @Test + public void componentLinkValid_when_SettingsAndRoleNameProvided() { + var aks = TestUtils.getAksExample(); + Map settings = Map.of("keySetting", "valueSetting"); + String roleName = "Owner"; + + ComponentLink componentLink = ComponentLink.builder() + .withComponentId(aks.getId()) + .withSettings(settings) + .withRoleName(roleName) + .build(); + + Map expectedSettings = new HashMap<>(settings); + expectedSettings.put("roleName", roleName); + + assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); + assertThat(componentLink.getSettings()).isEqualTo(expectedSettings); + } + + @Test + public void componentLinkValid_when_RoleNameProvided() { + var aks = TestUtils.getAksExample(); + String roleName = "Owner"; + + ComponentLink componentLink = ComponentLink.builder() + .withComponentId(aks.getId()) + .withRoleName(roleName) + .build(); + + Map expectedSettings = new HashMap<>(); + expectedSettings.put("roleName", roleName); + + assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); + assertThat(componentLink.getSettings()).isEqualTo(expectedSettings); + } + + @Test + public void lastRoleNameUsed_when_MultipleRoleNameProvided() { + var aks = TestUtils.getAksExample(); + String roleName1 = "Owner"; + String roleName2 = "Contributor"; + + ComponentLink componentLink = ComponentLink.builder() + .withComponentId(aks.getId()) + .withRoleName(roleName1) + .withRoleName(roleName2) + .build(); + + Map expectedSettings = new HashMap<>(); + expectedSettings.put("roleName", roleName2); + + assertThat(componentLink.getComponentId()).isEqualTo(aks.getId().getValue()); + assertThat(componentLink.getSettings()).isEqualTo(expectedSettings); + } + + @Test + public void componentLinkValidationErrors_when_ComponentIdNotValid() { + assertThatThrownBy(() -> ComponentLink.builder().withComponentId("A").build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("A valid component id must start with a lowercase character"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintServiceTest.java deleted file mode 100644 index 771d8033..00000000 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/BlueprintServiceTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service; - -import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; -import com.github.tomakehurst.wiremock.junit5.WireMockTest; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; -import com.yanchware.fractal.sdk.domain.blueprint.service.commands.CreateBlueprintCommandRequest; -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; -import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; -import com.yanchware.fractal.sdk.domain.values.ResourceGroupId; -import com.yanchware.fractal.sdk.domain.values.ResourceGroupType; -import com.yanchware.fractal.sdk.utils.LocalSdkConfiguration; -import com.yanchware.fractal.sdk.utils.StringHandler; -import io.github.resilience4j.retry.RetryRegistry; -import org.junit.jupiter.api.Test; - -import java.net.http.HttpClient; -import java.util.List; -import java.util.UUID; - -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; -import static org.assertj.core.api.Assertions.assertThat; - -@WireMockTest -public class BlueprintServiceTest { - - @Test - public void urlPathMatching_when_postRequestToBlueprint(WireMockRuntimeInfo wmRuntimeInfo) throws InstantiatorException { - var httpClient = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); - var sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); - var blueprintService = new BlueprintService(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); - - var inputStream = getClass().getClassLoader() - .getResourceAsStream("test-resources/postRequestToBlueprintBody.json"); - - assertThat(inputStream).isNotNull(); - - var resourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"); - var postRequestToBlueprintBody = StringHandler.getStringFromInputStream(inputStream); - var url = String.format("/blueprints/%s/fr/fr", resourceGroupId); - - stubFor(post(urlPathMatching(url)) - .withRequestBody(equalToJson(postRequestToBlueprintBody)) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json"))); - - blueprintService.create( - buildBlueprintRequest(), - new FractalIdValue(resourceGroupId, "fr", "fr")); - - verify(postRequestedFor(urlPathEqualTo(url))); - } - - private CreateBlueprintCommandRequest buildBlueprintRequest() { - return new CreateBlueprintCommandRequest( - "desc", - true, - List.of(buildBlueprintComponent())); - } - - private BlueprintComponentDto buildBlueprintComponent() { - return BlueprintComponentDto.builder() - .withId("0001") - .withDisplayName("blueprint basic") - .withDescription("blueprint basic desc") - .withType("type") - .withVersion("V0.1") - .withParameters(emptyMap()) - .withDependencies(emptySet()) - .withLinks(emptySet()) - .withOutputFields(emptySet()) - .build(); - } -} \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequestTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequestTest.java deleted file mode 100644 index b02cb9ae..00000000 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/commands/CreateBlueprintCommandRequestTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.commands; - -import com.yanchware.fractal.sdk.domain.blueprint.service.dtos.BlueprintComponentDto; -import com.yanchware.fractal.sdk.utils.TestUtils; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class CreateBlueprintCommandRequestTest { - - @Test - public void createBlueprintCommandRequestValid_when_liveSystemValid() { - var ls = TestUtils.getLiveSystemExample(); - String fractalId = "fractalId"; - var commandRequest = new CreateBlueprintCommandRequest(ls.getDescription(), true, BlueprintComponentDto.fromLiveSystemComponents(ls.getComponents())); - assertThat(commandRequest.description()).contains(ls.getDescription()); - assertThat(commandRequest.isPrivate()).isTrue(); - assertThat(commandRequest.components()).isNotEmpty(); - } -} \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfileTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfileTest.java index 9a7cd494..34783561 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfileTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/CiCdProfileTest.java @@ -7,123 +7,129 @@ class CiCdProfileTest { - private static final String VALID_SHORT_NAME = "my-profile"; - private static final String VALID_DISPLAY_NAME = "My Profile"; - private static final String VALID_SSH_KEY_DATA = "ssh-key-data"; - private static final String VALID_PASSPHRASE = "passphrase"; - - @Test - void exceptionThrown_when_shortNameIsEmpty() { - assertThatThrownBy(() -> new CiCdProfile("", "My Profile", "","ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); - } - - @Test - void exceptionThrown_when_shortNameIsNull() { - assertThatThrownBy(() -> new CiCdProfile(null, "My Profile", "ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); - } - - @Test - void exceptionThrown_when_shortNameStartsWithHyphen() { - assertThatThrownBy(() -> new CiCdProfile("-my-profile", "My Profile", "ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); - } - - @Test - void exceptionThrown_when_shortNameEndsWithHyphen() { - assertThatThrownBy(() -> new CiCdProfile("my-profile-", "My Profile", "ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); - } - - @Test - void exceptionThrown_when_shortNameContainsInvalidCharacters() { - assertThatThrownBy(() -> new CiCdProfile("my_profile%", "My Profile", "ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); - } - - @Test - void exceptionThrown_when_displayNameIsEmpty() { - assertThatThrownBy(() -> new CiCdProfile("my-profile", "", "ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Display Name cannot be empty or null"); - } - - @Test - void exceptionThrown_when_displayNameIsNull() { - assertThatThrownBy(() -> new CiCdProfile("my-profile", null, "ssh-key-data", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Display Name cannot be empty or null"); - } - - @Test - void exceptionThrown_when_sshPrivateKeyDataIsEmpty() { - assertThatThrownBy(() -> new CiCdProfile("my-profile", "My Profile", "", "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The SSH Private Key Data cannot be empty or null"); - } - - @Test - void exceptionThrown_when_sshPrivateKeyDataIsNull() { - assertThatThrownBy(() -> new CiCdProfile("my-profile", "My Profile", null, "passphrase")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The SSH Private Key Data cannot be empty or null"); - } - - @Test - void noValidationErrors_when_ciCdProfileIsValid() { - CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); - assertThat(profile).isNotNull(); - assertThat(profile.shortName()).isEqualTo(VALID_SHORT_NAME); - assertThat(profile.displayName()).isEqualTo(VALID_DISPLAY_NAME); - assertThat(profile.sshPrivateKeyData()).isEqualTo(VALID_SSH_KEY_DATA); - assertThat(profile.sshPrivateKeyPassphrase()).isEqualTo(VALID_PASSPHRASE); - } - - @Test - void noValidationErrors_when_shortNameIsMinimumLength() { - // Short name with 1 character (minimum length) - var shortName = "a"; - CiCdProfile profile = new CiCdProfile(shortName, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); - assertThat(profile).isNotNull(); - assertThat(profile.shortName()).isEqualTo(shortName); - } - - @Test - void noValidationErrors_when_shortNameIsMaximumLength() { - // Short name with 127 characters (maximum length) - String shortName = "a".repeat(127); - CiCdProfile profile = new CiCdProfile(shortName, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); - assertThat(profile).isNotNull(); - assertThat(profile.shortName()).isEqualTo(shortName); - } - - @Test - void noValidationErrors_when_descriptionIsNotNull() { - String description = "This is a test description."; - CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, description, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); - assertThat(profile).isNotNull(); - assertThat(profile.description()).isEqualTo(description); - } - - @Test - void noValidationErrors_when_passphraseIsNull() { - // Passphrase can be null - CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, null); - assertThat(profile).isNotNull(); - assertThat(profile.sshPrivateKeyPassphrase()).isNull(); - } - - @Test - void noValidationErrors_when_passphraseIsEmpty() { - // Passphrase can be empty - CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, ""); - assertThat(profile).isNotNull(); - assertThat(profile.sshPrivateKeyPassphrase()).isEmpty(); - } + private static final String VALID_SHORT_NAME = "my-profile"; + private static final String VALID_DISPLAY_NAME = "My Profile"; + private static final String VALID_SSH_KEY_DATA = "ssh-key-data"; + private static final String VALID_PASSPHRASE = "passphrase"; + + @Test + void exceptionThrown_when_shortNameIsEmpty() { + assertThatThrownBy(() -> new CiCdProfile("", "My Profile", "", "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); + } + + @Test + void exceptionThrown_when_shortNameIsNull() { + assertThatThrownBy(() -> new CiCdProfile(null, "My Profile", "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); + } + + @Test + void exceptionThrown_when_shortNameStartsWithHyphen() { + assertThatThrownBy(() -> new CiCdProfile("-my-profile", "My Profile", "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); + } + + @Test + void exceptionThrown_when_shortNameEndsWithHyphen() { + assertThatThrownBy(() -> new CiCdProfile("my-profile-", "My Profile", "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); + } + + @Test + void exceptionThrown_when_shortNameContainsInvalidCharacters() { + assertThatThrownBy(() -> new CiCdProfile("my_profile%", "My Profile", "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); + } + + @Test + void exceptionThrown_when_displayNameIsEmpty() { + assertThatThrownBy(() -> new CiCdProfile("my-profile", "", "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Display Name cannot be empty or null"); + } + + @Test + void exceptionThrown_when_displayNameIsNull() { + assertThatThrownBy(() -> new CiCdProfile("my-profile", null, "ssh-key-data", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Display Name cannot be empty or null"); + } + + @Test + void exceptionThrown_when_sshPrivateKeyDataIsEmpty() { + assertThatThrownBy(() -> new CiCdProfile("my-profile", "My Profile", "", "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The SSH Private Key Data cannot be empty or null"); + } + + @Test + void exceptionThrown_when_sshPrivateKeyDataIsNull() { + assertThatThrownBy(() -> new CiCdProfile("my-profile", "My Profile", null, "passphrase")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The SSH Private Key Data cannot be empty or null"); + } + + @Test + void noValidationErrors_when_ciCdProfileIsValid() { + CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); + assertThat(profile).isNotNull(); + assertThat(profile.shortName()).isEqualTo(VALID_SHORT_NAME); + assertThat(profile.displayName()).isEqualTo(VALID_DISPLAY_NAME); + assertThat(profile.sshPrivateKeyData()).isEqualTo(VALID_SSH_KEY_DATA); + assertThat(profile.sshPrivateKeyPassphrase()).isEqualTo(VALID_PASSPHRASE); + } + + @Test + void noValidationErrors_when_shortNameIsMinimumLength() { + // Short name with 1 character (minimum length) + var shortName = "a"; + CiCdProfile profile = new CiCdProfile(shortName, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); + assertThat(profile).isNotNull(); + assertThat(profile.shortName()).isEqualTo(shortName); + } + + @Test + void noValidationErrors_when_shortNameIsMaximumLength() { + // Short name with 127 characters (maximum length) + String shortName = "a".repeat(127); + CiCdProfile profile = new CiCdProfile(shortName, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, VALID_PASSPHRASE); + assertThat(profile).isNotNull(); + assertThat(profile.shortName()).isEqualTo(shortName); + } + + @Test + void noValidationErrors_when_descriptionIsNotNull() { + String description = "This is a test description."; + CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, description, VALID_SSH_KEY_DATA, + VALID_PASSPHRASE); + assertThat(profile).isNotNull(); + assertThat(profile.description()).isEqualTo(description); + } + + @Test + void noValidationErrors_when_passphraseIsNull() { + // Passphrase can be null + CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, null); + assertThat(profile).isNotNull(); + assertThat(profile.sshPrivateKeyPassphrase()).isNull(); + } + + @Test + void noValidationErrors_when_passphraseIsEmpty() { + // Passphrase can be empty + CiCdProfile profile = new CiCdProfile(VALID_SHORT_NAME, VALID_DISPLAY_NAME, VALID_SSH_KEY_DATA, ""); + assertThat(profile).isNotNull(); + assertThat(profile.sshPrivateKeyPassphrase()).isEmpty(); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsARecordTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsARecordTest.java index de96c87b..de32fb47 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsARecordTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsARecordTest.java @@ -1,12 +1,12 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsARecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsARecord; import com.yanchware.fractal.sdk.utils.TestUtils; import org.junit.jupiter.api.Test; import java.time.Duration; -import static com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsARecord.A_DNS_RECORD_TYPE; +import static com.yanchware.fractal.sdk.domain.fractal.iaas.DnsARecord.A_DNS_RECORD_TYPE; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -16,8 +16,8 @@ class DnsARecordTest { @Test public void validationError_when_NameIsNull() { assertThatThrownBy(() -> DnsARecord.builder().withName(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[DnsARecord Validation] The Name must contain between 1 and 63 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[DnsARecord Validation] The Name must contain between 1 and 63 characters"); } @Test @@ -28,24 +28,24 @@ public void dnsARecordWithAtSign() { var ipV4Address2 = "2.2.2.2"; var record = DnsARecord.builder() - .withName(recordName) - .withTtl(duration) - .withIpV4Address(ipV4Address) - .withIpV4Address(ipV4Address2) - .build(); + .withName(recordName) + .withTtl(duration) + .withIpV4Address(ipV4Address) + .withIpV4Address(ipV4Address2) + .build(); assertThat(record.getName()).isEqualTo(recordName); assertThat(record.getTtl()).isEqualTo(duration); assertThat(record.getIpV4Addresses().size()).isEqualTo(2); assertThat(record.getIpV4Addresses()) - .containsExactly(ipV4Address, ipV4Address2); + .containsExactly(ipV4Address, ipV4Address2); var jsonRecord = TestUtils.getJsonNodeRepresentation(record); assertThat(jsonRecord).isNotNull(); assertThat(jsonRecord.has("@type")).isNotNull(); assertEquals(A_DNS_RECORD_TYPE, jsonRecord.get("@type").textValue()); } - + @Test public void dnsARecordHasAllFields() { var recordName = "ARecord"; @@ -54,17 +54,17 @@ public void dnsARecordHasAllFields() { var ipV4Address2 = "2.2.2.2"; var record = DnsARecord.builder() - .withName(recordName) - .withTtl(duration) - .withIpV4Address(ipV4Address) - .withIpV4Address(ipV4Address2) - .build(); + .withName(recordName) + .withTtl(duration) + .withIpV4Address(ipV4Address) + .withIpV4Address(ipV4Address2) + .build(); assertThat(record.getName()).isEqualTo(recordName); assertThat(record.getTtl()).isEqualTo(duration); assertThat(record.getIpV4Addresses().size()).isEqualTo(2); assertThat(record.getIpV4Addresses()) - .containsExactly(ipV4Address, ipV4Address2); + .containsExactly(ipV4Address, ipV4Address2); var jsonRecord = TestUtils.getJsonNodeRepresentation(record); assertThat(jsonRecord).isNotNull(); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsAaaaRecordTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsAaaaRecordTest.java index 5e73b54c..78cd84cf 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsAaaaRecordTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsAaaaRecordTest.java @@ -1,12 +1,12 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsAaaaRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsAaaaRecord; import com.yanchware.fractal.sdk.utils.TestUtils; import org.junit.jupiter.api.Test; import java.time.Duration; -import static com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsAaaaRecord.AAAA_DNS_RECORD_TYPE; +import static com.yanchware.fractal.sdk.domain.fractal.iaas.DnsAaaaRecord.AAAA_DNS_RECORD_TYPE; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -16,8 +16,8 @@ class DnsAaaaRecordTest { @Test public void validationError_when_NameIsNull() { assertThatThrownBy(() -> DnsAaaaRecord.builder().withName(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[DnsAaaaRecord Validation] The Name must contain between 1 and 63 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[DnsAaaaRecord Validation] The Name must contain between 1 and 63 characters"); } @Test @@ -27,10 +27,10 @@ public void dnsAaaaRecordHasAllFields() { var ipV6Address = "2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF"; var record = DnsAaaaRecord.builder() - .withName(recordName) - .withTtl(duration) - .withIpV6Address(ipV6Address) - .build(); + .withName(recordName) + .withTtl(duration) + .withIpV6Address(ipV6Address) + .build(); assertThat(record.getName()).isEqualTo(recordName); assertThat(record.getTtl()).isEqualTo(duration); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordDataTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordDataTest.java index c66f4fbb..4a58749b 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordDataTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordDataTest.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsCaaRecordData; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsCaaRecordData; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -9,35 +9,35 @@ class DnsCaaRecordDataTest { @Test public void validationError_when_FlagsToSmall() { assertThatThrownBy(() -> DnsCaaRecordData.builder().withFlags(-1).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Flags value must be between 0 and 255"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Flags value must be between 0 and 255"); } - + @Test public void validationError_when_FlagsToBig() { assertThatThrownBy(() -> DnsCaaRecordData.builder().withFlags(256).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Flags value must be between 0 and 255"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Flags value must be between 0 and 255"); } @Test public void validationError_when_TagIsNull() { assertThatThrownBy(() -> DnsCaaRecordData.builder() - .withFlags(255) - .withTag(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The tag has not been defined and it is required"); + .withFlags(255) + .withTag(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The tag has not been defined and it is required"); } @Test public void validationError_when_ValueIsNull() { assertThatThrownBy(() -> DnsCaaRecordData.builder() - .withFlags(255) - .withTag("tag") - .withValue(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The value has not been defined and it is required"); + .withFlags(255) + .withTag("tag") + .withValue(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The value has not been defined and it is required"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordTest.java index fc6499a8..f33550f8 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsCaaRecordTest.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsCaaRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsCaaRecord; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -9,7 +9,7 @@ class DnsCaaRecordTest { @Test public void validationError_when_NameIsNull() { assertThatThrownBy(() -> DnsCaaRecord.builder().withName(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[DnsCaaRecord Validation] The Name must contain between 1 and 63 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[DnsCaaRecord Validation] The Name must contain between 1 and 63 characters"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsMxRecordDataTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsMxRecordDataTest.java index 3f51d195..6d2dcdb5 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsMxRecordDataTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsMxRecordDataTest.java @@ -1,7 +1,7 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsCaaRecordData; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsMxRecordData; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsCaaRecordData; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsMxRecordData; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -10,35 +10,35 @@ class DnsMxRecordDataTest { @Test public void validationError_when_PriorityToSmall() { assertThatThrownBy(() -> DnsMxRecordData.builder().withPriority(-1).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Priority value must be between 0 and 65535"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Priority value must be between 0 and 65535"); } @Test public void validationError_when_PriorityToBig() { assertThatThrownBy(() -> DnsMxRecordData.builder().withPriority(65536).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Priority value must be between 0 and 65535"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Priority value must be between 0 and 65535"); } @Test public void validationError_whenMailExchangeNull() { assertThatThrownBy(() -> DnsMxRecordData.builder() - .withPriority(1) - .withMailExchange(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The mailExchange has not been defined and it is required"); + .withPriority(1) + .withMailExchange(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The mailExchange has not been defined and it is required"); } @Test public void validationError_when_ValueIsNull() { assertThatThrownBy(() -> DnsCaaRecordData.builder() - .withFlags(255) - .withTag("tag") - .withValue(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The value has not been defined and it is required"); + .withFlags(255) + .withTag("tag") + .withValue(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The value has not been defined and it is required"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordDataTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordDataTest.java index 330357bd..33621645 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordDataTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordDataTest.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsSrvRecordData; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsSrvRecordData; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -9,68 +9,68 @@ class DnsSrvRecordDataTest { @Test public void validationError_when_PriorityToSmall() { assertThatThrownBy(() -> DnsSrvRecordData.builder().withPriority(-1).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The priority value must be less than or equal to 65535"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The priority value must be less than or equal to 65535"); } @Test public void validationError_when_PriorityToBig() { assertThatThrownBy(() -> DnsSrvRecordData.builder().withPriority(65536).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The priority value must be less than or equal to 65535"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The priority value must be less than or equal to 65535"); } @Test public void validationError_when_WeightToSmall() { assertThatThrownBy(() -> DnsSrvRecordData.builder() - .withPriority(1) - .withWeight(-1) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The weight value must be less than or equal to 65535"); + .withPriority(1) + .withWeight(-1) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The weight value must be less than or equal to 65535"); } @Test public void validationError_when_PortToBig() { assertThatThrownBy(() -> DnsSrvRecordData.builder() - .withPriority(65535) - .withWeight(65535) - .withPort(65536) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The port value must be less than or equal to 65535"); + .withPriority(65535) + .withWeight(65535) + .withPort(65536) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The port value must be less than or equal to 65535"); } @Test public void validationError_when_PortToSmall() { assertThatThrownBy(() -> DnsSrvRecordData.builder() - .withPriority(1) - .withWeight(1) - .withPort(-1) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The port value must be less than or equal to 65535"); + .withPriority(1) + .withWeight(1) + .withPort(-1) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The port value must be less than or equal to 65535"); } @Test public void validationError_when_WeightToBig() { assertThatThrownBy(() -> DnsSrvRecordData.builder() - .withPriority(65535) - .withWeight(65536) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The weight value must be less than or equal to 65535"); + .withPriority(65535) + .withWeight(65536) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The weight value must be less than or equal to 65535"); } @Test public void validationError_when_TargetIsNull() { assertThatThrownBy(() -> DnsSrvRecordData.builder() - .withPriority(1) - .withWeight(1) - .withPort(1) - .withTarget(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Target has not been defined and it is required"); + .withPriority(1) + .withWeight(1) + .withPort(1) + .withTarget(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Target has not been defined and it is required"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordTest.java index ce050372..c1ad2003 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsSrvRecordTest.java @@ -1,6 +1,6 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsSrvRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsSrvRecord; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -10,41 +10,41 @@ class DnsSrvRecordTest { @Test public void properName_when_NameIsNull() { var record = DnsSrvRecord.builder() - .withProtocolName("_tls") - .withService("_sip") - .withName(null) - .build(); - + .withProtocolName("_tls") + .withService("_sip") + .withName(null) + .build(); + assertThat(record.getName()).isEqualTo("_sip._tls"); } @Test public void properName_when_NameIsSet() { var record = DnsSrvRecord.builder() - .withProtocolName("_tls") - .withService("_sip") - .withName("name") - .build(); + .withProtocolName("_tls") + .withService("_sip") + .withName("name") + .build(); assertThat(record.getName()).isEqualTo("_sip._tls.name"); } - + @Test public void validationError_when_ServiceIsNull() { assertThatThrownBy(() -> DnsSrvRecord.builder() - .withService(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Service has not been defined and it is required"); + .withService(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Service has not been defined and it is required"); } @Test public void validationError_when_ProtocolNameIsNull() { assertThatThrownBy(() -> DnsSrvRecord.builder() - .withService("service") - .withProtocolName(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("ProtocolName has not been defined and it is required"); + .withService("service") + .withProtocolName(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("ProtocolName has not been defined and it is required"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsZoneTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsZoneTest.java index c660b063..2ebd86b4 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsZoneTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/DnsZoneTest.java @@ -1,8 +1,8 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsAaaaRecord; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsPtrRecord; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsZone; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsAaaaRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsPtrRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsZone; import com.yanchware.fractal.sdk.utils.TestUtils; import org.junit.jupiter.api.Test; @@ -18,40 +18,44 @@ class DnsZoneTest { @Test public void validationError_when_NameIsNull() { assertThatThrownBy(() -> DnsZone.builder().withName(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[DnsZone Validation] The name must contain no more than 253 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[DnsZone Validation] The name must contain no more than 253 characters"); } @Test public void validationError_when_NameWithoutPeriod() { assertThatThrownBy(() -> DnsZone.builder().withName("NameWithoutPeriod").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[DnsZone Validation] The name must contain no more than 253 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[DnsZone Validation] The name must contain no more than 253 characters"); } @Test public void validationError_when_NameTooLong() { assertThatThrownBy(() -> DnsZone.builder() - .withName("NameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong") - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[DnsZone Validation] The name must contain no more than 253 characters"); + .withName("NameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong" + + ".NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong" + + ".NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong") + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[DnsZone Validation] The name must contain no more than 253 characters"); } @Test public void noValidationErrors_when_NameIs254CharsWithTrailingPeriod() { assertThat(DnsZone.builder() - .withName("NameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLong.") - .build() - .validate()).isEmpty(); + .withName("NameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong" + + ".NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong" + + ".NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLongNameTooLong.NameTooLong.") + .build() + .validate()).isEmpty(); } @Test public void noValidationErrors_when_NameEndsWithPeriod() { assertThat(DnsZone.builder() - .withName("fractal.cloud.") - .build() - .validate()).isEmpty(); + .withName("fractal.cloud.") + .build() + .validate()).isEmpty(); } @Test @@ -61,16 +65,16 @@ public void dnsZoneHasAllFields() { var isDnsZonePrivate = true; var dnsRecords = Map.of("componentId", List.of( - DnsAaaaRecord.builder() - .withName("aaaaRecord") - .withIpV6Address("2001:db8:3333:4444:5555:6666:7777:8888") - .withTtl(Duration.ofMinutes(1)) - .build(), - DnsPtrRecord.builder() - .withName("name") - .withDomainNames(List.of("")) - .withTtl(Duration.ofMinutes(1)) - .build() + DnsAaaaRecord.builder() + .withName("aaaaRecord") + .withIpV6Address("2001:db8:3333:4444:5555:6666:7777:8888") + .withTtl(Duration.ofMinutes(1)) + .build(), + DnsPtrRecord.builder() + .withName("name") + .withDomainNames(List.of("")) + .withTtl(Duration.ofMinutes(1)) + .build() )); var parametersMap = new HashMap(); @@ -78,12 +82,12 @@ public void dnsZoneHasAllFields() { parametersMap.put("subscriptionId", "/subscription/id"); var dnsZone = DnsZone - .builder() - .withName(dnsZoneName) - .withRecords(dnsRecords) - .withParameters(parametersMap) - .isPrivate(isDnsZonePrivate) - .build(); + .builder() + .withName(dnsZoneName) + .withRecords(dnsRecords) + .withParameters(parametersMap) + .isPrivate(isDnsZonePrivate) + .build(); assertThat(dnsZone.getName()).isEqualTo(dnsZoneName); assertThat(dnsZone.isPrivate()).isEqualTo(isDnsZonePrivate); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregateTest.java index 282177ad..2fec8c02 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentAggregateTest.java @@ -22,26 +22,26 @@ public void noErrors_When_ManagingSecrets() throws InstantiatorException { var aggregate = new EnvironmentAggregate(mockedEnvironmentService); var ownerId = UUID.randomUUID(); var envId = new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001"); + EnvironmentType.PERSONAL, + ownerId, + "production-001"); var managementEnvironment = ManagementEnvironment.builder() - .withId(envId) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .build(); + .withId(envId) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .build(); aggregate.setManagementEnvironment(managementEnvironment); var secrets = new SecretResponse[]{ - new SecretResponse( - UUID.randomUUID(), - new EnvironmentIdDto(EnvironmentTypeDto.PERSONAL, envId.ownerId(), envId.shortName()), - "Secret-1", - null, - new Date(), - "Whoever", - new Date(), - "Whoever") + new SecretResponse( + UUID.randomUUID(), + new EnvironmentIdDto(EnvironmentTypeDto.PERSONAL, envId.ownerId(), envId.shortName()), + "Secret-1", + null, + new Date(), + "Whoever", + new Date(), + "Whoever") }; when(mockedEnvironmentService.manageSecrets(envId, managementEnvironment.getSecrets())).thenReturn(secrets); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentServiceTest.java index e20c3345..7f5628c9 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentServiceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentServiceTest.java @@ -38,21 +38,21 @@ class EnvironmentServiceTest { @BeforeEach void setUp(WireMockRuntimeInfo wmRuntimeInfo) { var httpClient = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); + .version(HttpClient.Version.HTTP_2) + .build(); var sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); var ownerId = UUID.randomUUID(); mockEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "test-env" - )) - .withName("Test Environment") - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .build(); - + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "test-env" + )) + .withName("Test Environment") + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .build(); + environmentService = new RestEnvironmentService(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); } @@ -65,33 +65,33 @@ void fetchEnvironment_should_ReturnEnvironmentIdDto() throws Exception { String parametersJson = serialize(mockEnvironment.toDto().parameters()); var jsonResponse = String.format(""" - { - "id": { - "type": "%s", - "ownerId": "%s", - "shortName": "%s" - }, - "name": "%s", - "resourceGroups": %s, - "parameters": %s, - "status": "Active", - "createdAt": "2024-05-20T21:30:27.045813+00:00", - "createdBy": "tests@yanchware.com", - "updatedAt": "2024-05-20T21:30:27.045813+00:00", - "updatedBy": "tests@yanchware.com" - } - """, mockEnvironment.getId().type(), - mockEnvironment.getId().ownerId(), - mockEnvironment.getId().shortName(), - mockEnvironment.getName(), - resourceGroupsJson, - parametersJson); + { + "id": { + "type": "%s", + "ownerId": "%s", + "shortName": "%s" + }, + "name": "%s", + "resourceGroups": %s, + "parameters": %s, + "status": "Active", + "createdAt": "2024-05-20T21:30:27.045813+00:00", + "createdBy": "tests@yanchware.com", + "updatedAt": "2024-05-20T21:30:27.045813+00:00", + "updatedBy": "tests@yanchware.com" + } + """, mockEnvironment.getId().type(), + mockEnvironment.getId().ownerId(), + mockEnvironment.getId().shortName(), + mockEnvironment.getName(), + resourceGroupsJson, + parametersJson); stubFor(get(urlPattern) - .willReturn(aResponse() - .withStatus(200) - .withBody(jsonResponse) - .withHeader("Content-Type", "application/json"))); + .willReturn(aResponse() + .withStatus(200) + .withBody(jsonResponse) + .withHeader("Content-Type", "application/json"))); // When var response = environmentService.fetch(mockEnvironment.getId()); @@ -115,46 +115,46 @@ void createOrUpdateEnvironment_whenEnvironmentExists_shouldUpdateEnvironment() t var urlPattern = urlPathMatching("/environments/.*/.*/.*"); var jsonResponse = String.format(""" - { - "id": { - "type": "%s", - "ownerId": "%s", - "shortName": "%s" - }, - "name": "%s", - "resourceGroups": [ - "ebc34d36-532c-45b4-aed9-94c2596d3840" - ], - "parameters": null, - "status": "Active", - "createdAt": "2024-05-20T21:30:27.045813+00:00", - "createdBy": "tests@yanchware.com", - "updatedAt": "2024-05-20T21:30:27.045813+00:00", - "updatedBy": "tests@yanchware.com" - } - """, mockEnvironment.getId().type(), - mockEnvironment.getId().ownerId(), - mockEnvironment.getId().shortName(), - mockEnvironment.getName()); + { + "id": { + "type": "%s", + "ownerId": "%s", + "shortName": "%s" + }, + "name": "%s", + "resourceGroups": [ + "ebc34d36-532c-45b4-aed9-94c2596d3840" + ], + "parameters": null, + "status": "Active", + "createdAt": "2024-05-20T21:30:27.045813+00:00", + "createdBy": "tests@yanchware.com", + "updatedAt": "2024-05-20T21:30:27.045813+00:00", + "updatedBy": "tests@yanchware.com" + } + """, mockEnvironment.getId().type(), + mockEnvironment.getId().ownerId(), + mockEnvironment.getId().shortName(), + mockEnvironment.getName()); stubFor(get(urlPattern) - .willReturn(aResponse() - .withStatus(200) - .withBody(jsonResponse) - .withHeader("Content-Type", "application/json"))); + .willReturn(aResponse() + .withStatus(200) + .withBody(jsonResponse) + .withHeader("Content-Type", "application/json"))); stubFor(put(urlPattern) - .willReturn(aResponse() - .withStatus(200))); + .willReturn(aResponse() + .withStatus(200))); // When environmentService.update( - null, - mockEnvironment.getId(), - mockEnvironment.getName(), - mockEnvironment.getResourceGroups(), - mockEnvironment.toDto().parameters(), - null); + null, + mockEnvironment.getId(), + mockEnvironment.getName(), + mockEnvironment.getResourceGroups(), + mockEnvironment.toDto().parameters(), + null); // Then verify(1, putRequestedFor(urlPattern)); @@ -167,21 +167,21 @@ void createOrUpdateEnvironment_whenEnvironmentDoesNotExist_shouldCreateEnvironme var urlPattern = urlPathMatching("/environments/.*/.*/.*"); stubFor(get(urlPattern) - .willReturn(aResponse() - .withStatus(404))); + .willReturn(aResponse() + .withStatus(404))); // Add stub for POST request stubFor(post(urlPattern) - .willReturn(aResponse() - .withStatus(201))); + .willReturn(aResponse() + .withStatus(201))); // When environmentService.create( - null, - mockEnvironment.getId(), - mockEnvironment.getName(), - mockEnvironment.getResourceGroups(), - mockEnvironment.toDto().parameters()); + null, + mockEnvironment.getId(), + mockEnvironment.getName(), + mockEnvironment.getResourceGroups(), + mockEnvironment.toDto().parameters()); // Then @@ -195,42 +195,42 @@ void updateEnvironment_shouldExecutePutRequest() throws Exception { var urlPattern = urlPathMatching("/environments/.*/.*/.*"); var jsonResponse = String.format(""" - { - "id": { - "type": "%s", - "ownerId": "%s", - "shortName": "%s" - }, - "name": "%s", - "resourceGroups": [ - "ebc34d36-532c-45b4-aed9-94c2596d3840" - ], - "parameters": null, - "status": "Active", - "createdAt": "2024-05-20T21:30:27.045813+00:00", - "createdBy": "tests@yanchware.com", - "updatedAt": "2024-05-20T21:30:27.045813+00:00", - "updatedBy": "tests@yanchware.com" - } - """, mockEnvironment.getId().type(), - mockEnvironment.getId().ownerId(), - mockEnvironment.getId().shortName(), - mockEnvironment.toDto().parameters()); + { + "id": { + "type": "%s", + "ownerId": "%s", + "shortName": "%s" + }, + "name": "%s", + "resourceGroups": [ + "ebc34d36-532c-45b4-aed9-94c2596d3840" + ], + "parameters": null, + "status": "Active", + "createdAt": "2024-05-20T21:30:27.045813+00:00", + "createdBy": "tests@yanchware.com", + "updatedAt": "2024-05-20T21:30:27.045813+00:00", + "updatedBy": "tests@yanchware.com" + } + """, mockEnvironment.getId().type(), + mockEnvironment.getId().ownerId(), + mockEnvironment.getId().shortName(), + mockEnvironment.toDto().parameters()); stubFor(put(urlPattern) - .willReturn(aResponse() - .withStatus(200) - .withBody(jsonResponse) - .withHeader("Content-Type", "application/json"))); + .willReturn(aResponse() + .withStatus(200) + .withBody(jsonResponse) + .withHeader("Content-Type", "application/json"))); // When var response = environmentService.update( - null, - mockEnvironment.getId(), - mockEnvironment.getName(), - mockEnvironment.getResourceGroups(), - mockEnvironment.toDto().parameters(), - null); + null, + mockEnvironment.getId(), + mockEnvironment.getName(), + mockEnvironment.getResourceGroups(), + mockEnvironment.toDto().parameters(), + null); // Then @@ -248,20 +248,21 @@ void fetchCurrentInitialization_should_ReturnValidAzureInitializationRunResponse var urlPattern = urlPathMatching("/environments/.*/.*/.*/initializer/azure/status"); var inputStream = getClass().getClassLoader() - .getResourceAsStream("test-resources/fetchCurrentInitializationInProgressResponse.json"); + .getResourceAsStream("test-resources/fetchCurrentInitializationInProgressResponse.json"); assertThat(inputStream).isNotNull(); var fetchCurrentInitializationResponse = StringHandler.getStringFromInputStream(inputStream); // Replace the placeholders - fetchCurrentInitializationResponse = replacePlaceholders(fetchCurrentInitializationResponse, getEnvironmentIdPlaceholders()); + fetchCurrentInitializationResponse = replacePlaceholders(fetchCurrentInitializationResponse, + getEnvironmentIdPlaceholders()); stubFor(get(urlPattern) - .willReturn(aResponse() - .withStatus(200) - .withBody(fetchCurrentInitializationResponse) - .withHeader("Content-Type", "application/json"))); + .willReturn(aResponse() + .withStatus(200) + .withBody(fetchCurrentInitializationResponse) + .withHeader("Content-Type", "application/json"))); // When var response = environmentService.fetchCurrentAzureInitialization(mockEnvironment.getId()); @@ -284,11 +285,11 @@ void initializeAccount_should_HandleInitializationInProgress() throws Exception // When CloudAgentEntity cloudAgent = new AwsCloudAgent( - mockEnvironment.getId(), - AwsRegion.EU_NORTH_1, - "organizationId", - "accountId", - Collections.emptyMap()); + mockEnvironment.getId(), + AwsRegion.EU_NORTH_1, + "organizationId", + "accountId", + Collections.emptyMap()); cloudAgent.initialize(environmentService); // Then @@ -302,11 +303,11 @@ void initializeSubscription_should_HandleInitializationInProgress() throws Excep // When CloudAgentEntity cloudAgent = new AzureCloudAgent( - mockEnvironment.getId(), - AzureRegion.WEST_EUROPE, - UUID.randomUUID(), - UUID.randomUUID(), - Collections.emptyMap()); + mockEnvironment.getId(), + AzureRegion.WEST_EUROPE, + UUID.randomUUID(), + UUID.randomUUID(), + Collections.emptyMap()); cloudAgent.initialize(environmentService); // Then @@ -320,11 +321,11 @@ void initializeProject_should_HandleInitializationInProgress() throws Exception // When CloudAgentEntity cloudAgent = new GcpCloudAgent( - mockEnvironment.getId(), - GcpRegion.EUROPE_WEST1, - "organizationId", - "projectId", - Collections.emptyMap()); + mockEnvironment.getId(), + GcpRegion.EUROPE_WEST1, + "organizationId", + "projectId", + Collections.emptyMap()); cloudAgent.initialize(environmentService); // Then @@ -338,11 +339,11 @@ void initializeCompartment_should_HandleInitializationInProgress() throws Except // When CloudAgentEntity cloudAgent = new OciCloudAgent( - mockEnvironment.getId(), - OciRegion.EU_ZURICH_1, - "tenancyId", - "compartmentId", - Collections.emptyMap()); + mockEnvironment.getId(), + OciRegion.EU_ZURICH_1, + "tenancyId", + "compartmentId", + Collections.emptyMap()); cloudAgent.initialize(environmentService); // Then @@ -354,54 +355,56 @@ private UrlPathPattern prepareMocksForCloudAgentInitializationTest(UrlPathPatter var placeholders = getEnvironmentIdPlaceholders(); var inputStreamInProgress = getClass().getClassLoader() - .getResourceAsStream("test-resources/fetchCurrentInitializationInProgressResponse.json"); + .getResourceAsStream("test-resources/fetchCurrentInitializationInProgressResponse.json"); assertThat(inputStreamInProgress).isNotNull(); var fetchCurrentInitializationInProgressResponse = StringHandler.getStringFromInputStream(inputStreamInProgress); - fetchCurrentInitializationInProgressResponse = replacePlaceholders(fetchCurrentInitializationInProgressResponse, placeholders); + fetchCurrentInitializationInProgressResponse = replacePlaceholders(fetchCurrentInitializationInProgressResponse, + placeholders); // Mocking fetchCurrentInitialization response for "Completed" status var inputStreamCompleted = getClass().getClassLoader() - .getResourceAsStream("test-resources/fetchCurrentInitializationCompletedResponse.json"); + .getResourceAsStream("test-resources/fetchCurrentInitializationCompletedResponse.json"); assertThat(inputStreamCompleted).isNotNull(); var fetchCurrentInitializationCompletedResponse = StringHandler.getStringFromInputStream(inputStreamCompleted); - fetchCurrentInitializationCompletedResponse = replacePlaceholders(fetchCurrentInitializationCompletedResponse, placeholders); + fetchCurrentInitializationCompletedResponse = replacePlaceholders(fetchCurrentInitializationCompletedResponse, + placeholders); stubFor(get(urlPatternStatus) - .inScenario("Initialization Scenario") - .whenScenarioStateIs(Scenario.STARTED) - .willReturn(aResponse() - .withStatus(200) - .withBody(fetchCurrentInitializationInProgressResponse) - .withHeader("Content-Type", "application/json")) - .willSetStateTo("InProgress1")); + .inScenario("Initialization Scenario") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(aResponse() + .withStatus(200) + .withBody(fetchCurrentInitializationInProgressResponse) + .withHeader("Content-Type", "application/json")) + .willSetStateTo("InProgress1")); stubFor(get(urlPatternStatus) - .inScenario("Initialization Scenario") - .whenScenarioStateIs("InProgress1") - .willReturn(aResponse() - .withStatus(200) - .withBody(fetchCurrentInitializationInProgressResponse) - .withHeader("Content-Type", "application/json")) - .willSetStateTo("InProgress2")); + .inScenario("Initialization Scenario") + .whenScenarioStateIs("InProgress1") + .willReturn(aResponse() + .withStatus(200) + .withBody(fetchCurrentInitializationInProgressResponse) + .withHeader("Content-Type", "application/json")) + .willSetStateTo("InProgress2")); stubFor(get(urlPatternStatus) - .inScenario("Initialization Scenario") - .whenScenarioStateIs("InProgress2") - .willReturn(aResponse() - .withStatus(200) - .withBody(fetchCurrentInitializationCompletedResponse) - .withHeader("Content-Type", "application/json")) - .willSetStateTo("Completed")); + .inScenario("Initialization Scenario") + .whenScenarioStateIs("InProgress2") + .willReturn(aResponse() + .withStatus(200) + .withBody(fetchCurrentInitializationCompletedResponse) + .withHeader("Content-Type", "application/json")) + .willSetStateTo("Completed")); return urlPatternStatus; } private Map getEnvironmentIdPlaceholders() { return Map.of( - "$ENVIRONMENT_TYPE", mockEnvironment.getId().type().toString(), - "$ENVIRONMENT_OWNER_ID", mockEnvironment.getId().ownerId().toString(), - "$ENVIRONMENT_SHORT_NAME", mockEnvironment.getId().shortName() + "$ENVIRONMENT_TYPE", mockEnvironment.getId().type().toString(), + "$ENVIRONMENT_OWNER_ID", mockEnvironment.getId().ownerId().toString(), + "$ENVIRONMENT_SHORT_NAME", mockEnvironment.getId().shortName() ); } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentTypeTest.java index 925f087c..ac0b5d93 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/EnvironmentTypeTest.java @@ -6,51 +6,51 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; class EnvironmentTypeTest { - @Test - void should_returnPersonal_when_inputIsPersonal() { - assertThat(EnvironmentType.fromString("Personal")).isEqualTo(EnvironmentType.PERSONAL); - } - - @Test - void should_returnPersonal_when_inputIsPersonalIgnoreCase() { - assertThat(EnvironmentType.fromString("personal")).isEqualTo(EnvironmentType.PERSONAL); - } - - @Test - void should_returnOrganizational_when_inputIsOrganizational() { - assertThat(EnvironmentType.fromString("Organizational")).isEqualTo(EnvironmentType.ORGANIZATIONAL); - } - - @Test - void should_returnOrganizational_when_inputIsOrganizationalIgnoreCase() { - assertThat(EnvironmentType.fromString("organizational")).isEqualTo(EnvironmentType.ORGANIZATIONAL); - } - - @Test - void should_throwException_when_inputIsNull() { - assertThatThrownBy(() -> EnvironmentType.fromString(null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment type cannot be null or blank"); - } - - @Test - void should_throwException_when_inputIsEmpty() { - assertThatThrownBy(() -> EnvironmentType.fromString("")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment type cannot be null or blank"); - } - - @Test - void should_throwException_when_inputIsBlank() { - assertThatThrownBy(() -> EnvironmentType.fromString(" ")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment type cannot be null or blank"); - } - - @Test - void should_throwException_when_inputIsInvalid() { - assertThatThrownBy(() -> EnvironmentType.fromString("InvalidType")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Invalid environment type: 'InvalidType'"); - } + @Test + void should_returnPersonal_when_inputIsPersonal() { + assertThat(EnvironmentType.fromString("Personal")).isEqualTo(EnvironmentType.PERSONAL); + } + + @Test + void should_returnPersonal_when_inputIsPersonalIgnoreCase() { + assertThat(EnvironmentType.fromString("personal")).isEqualTo(EnvironmentType.PERSONAL); + } + + @Test + void should_returnOrganizational_when_inputIsOrganizational() { + assertThat(EnvironmentType.fromString("Organizational")).isEqualTo(EnvironmentType.ORGANIZATIONAL); + } + + @Test + void should_returnOrganizational_when_inputIsOrganizationalIgnoreCase() { + assertThat(EnvironmentType.fromString("organizational")).isEqualTo(EnvironmentType.ORGANIZATIONAL); + } + + @Test + void should_throwException_when_inputIsNull() { + assertThatThrownBy(() -> EnvironmentType.fromString(null)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment type cannot be null or blank"); + } + + @Test + void should_throwException_when_inputIsEmpty() { + assertThatThrownBy(() -> EnvironmentType.fromString("")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment type cannot be null or blank"); + } + + @Test + void should_throwException_when_inputIsBlank() { + assertThatThrownBy(() -> EnvironmentType.fromString(" ")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment type cannot be null or blank"); + } + + @Test + void should_throwException_when_inputIsInvalid() { + assertThatThrownBy(() -> EnvironmentType.fromString("InvalidType")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Invalid environment type: 'InvalidType'"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironmentTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironmentTest.java index d79099ea..d65fd0a7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironmentTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/ManagementEnvironmentTest.java @@ -1,8 +1,8 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsAaaaRecord; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsPtrRecord; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsZone; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsAaaaRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsPtrRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsZone; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.aws.AwsRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.gcp.GcpRegion; @@ -26,128 +26,129 @@ class ManagementEnvironmentTest { @Test public void exceptionThrown_when_environmentCreatedWithNullShortName() { assertThatThrownBy(() -> generateBuilderWithInfo(null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName has not been defined and it is required"); } @Test public void exceptionThrown_when_environmentCreatedWithEmptyShortName() { assertThatThrownBy(() -> generateBuilderWithInfo("")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName has not been defined and it is required"); } @Test public void exceptionThrown_when_environmentCreatedWithBlankShortName() { assertThatThrownBy(() -> generateBuilderWithInfo(" ")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName has not been defined and it is required"); } @Test public void exceptionThrown_when_environmentCreatedWithUppercaseShortName() { assertThatThrownBy(() -> generateBuilderWithInfo("Production-001")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName must only contain lowercase letters, numbers, and dashes."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName must only contain lowercase letters, numbers, and dashes."); } @Test public void exceptionThrown_when_environmentCreatedWithCiCdProfilesButWithoutDefaultCiCdProfile() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom","data", "pass")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("A default CI/CD profile must be set if additional CI/CD profiles are defined"); + .withCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("A default CI/CD profile must be set if additional CI/CD profiles are defined"); } @Test void exceptionThrown_when_environmentCreatedWithEmptyCiCdProfileShortName() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withDefaultCiCdProfile(new CiCdProfile("", "Default", "data", "pass")) // Empty short name - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); // Assuming SHORT_NAME_NOT_VALID is your validation message + .withDefaultCiCdProfile(new CiCdProfile("", "Default", "data", "pass")) // Empty short name + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); // Assuming SHORT_NAME_NOT_VALID is your validation message } @Test void exceptionThrown_when_environmentCreatedWithNullCiCdProfile() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withDefaultCiCdProfile(null) // Null profile - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The default CI/CD profile cannot be null"); // Or a more specific message + .withDefaultCiCdProfile(null) // Null profile + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The default CI/CD profile cannot be null"); // Or a more specific message } @Test void exceptionThrown_when_environmentCreatedWithDuplicateCiCdProfileShortNames() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("default", "Custom", "data", "pass")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); + .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("default", "Custom", "data", "pass")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); } @Test void exceptionThrown_when_nonDefaultCiCdProfileShortNamesAreDuplicated() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); + .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); } @Test void exceptionThrown_when_environmentCreatedWithDuplicateSecretNames() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withSecret(new Secret("my-secret", "My Secret Display Name","My Secret Description", "value1")) - .withSecret(new Secret("my-secret", "My Secret Display Name 2","My Secret Description 2", "value2")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Secret short names must be unique"); + .withSecret(new Secret("my-secret", "My Secret Display Name", "My Secret Description", "value1")) + .withSecret(new Secret("my-secret", "My Secret Display Name 2", "My Secret Description 2", "value2")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Secret short names must be unique"); } @Test void exceptionThrown_when_environmentCreatedWithNullSecret() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withSecret(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The secret cannot be null"); + .withSecret(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The secret cannot be null"); } @Test void exceptionThrown_when_environmentCreatedWithInvalidDnsZone() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withDnsZone(DnsZone.builder().withName("").build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("DnsZone validation failed"); + .withDnsZone(DnsZone.builder().withName("").build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("DnsZone validation failed"); } @Test void exceptionThrown_when_environmentCreatedWithInvalidOperationalEnvironment() { assertThatThrownBy(() -> generateBuilderWithId("production-001") - .withOperationalEnvironment(OperationalEnvironment.builder().withShortName("").build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment validation failed"); + .withOperationalEnvironment(OperationalEnvironment.builder().withShortName("").build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment validation failed"); } @Test void exceptionThrown_when_environmentCreatedWithEmptyResourceGroups() { assertThatThrownBy(() -> ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - UUID.randomUUID(), - "production-001")) - .withResourceGroups(Collections.emptyList()) // Empty resource groups - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ResourceGroups has not been defined and it is required"); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + UUID.randomUUID(), + "production-001")) + .withResourceGroups(Collections.emptyList()) // Empty resource groups + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ResourceGroups has not been defined and it is required"); } @Test @@ -160,30 +161,30 @@ public void noValidationErrors_when_environmentCreatedWithValidShortName() { public void noValidationErrors_when_environmentCreatedWithDnsZone() { var ownerId = UUID.randomUUID(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001")) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .withDnsZone( - DnsZone.builder() - .withName("dns.name") - .withRecords(Map.of("componentId", List.of( - DnsAaaaRecord.builder() - .withName("name") - .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") - .withTtl(Duration.ofMinutes(1)) - .build(), - DnsPtrRecord.builder() - .withName("name") - .withDomainName("") - .withTtl(Duration.ofMinutes(1)) - .build() - ))) - .withParameter("key", "value") - .isPrivate(false) - .build()) - .build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "production-001")) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .withDnsZone( + DnsZone.builder() + .withName("dns.name") + .withRecords(Map.of("componentId", List.of( + DnsAaaaRecord.builder() + .withName("name") + .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") + .withTtl(Duration.ofMinutes(1)) + .build(), + DnsPtrRecord.builder() + .withName("name") + .withDomainName("") + .withTtl(Duration.ofMinutes(1)) + .build() + ))) + .withParameter("key", "value") + .isPrivate(false) + .build()) + .build(); assertThat(managementEnvironment.validate()).isEmpty(); @@ -196,34 +197,34 @@ public void noValidationErrors_when_environmentCreatedWithDnsZone() { public void noValidationErrors_when_environmentCreatedWithRegionTenantIdAndSubscriptionId() { var ownerId = UUID.randomUUID(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001")) - .withAzureCloudAgent( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID(), - UUID.randomUUID()) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .withDnsZone( - DnsZone.builder() - .withName("dns.name") - .withRecords(Map.of("componentId", List.of( - DnsAaaaRecord.builder() - .withName("name") - .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") - .withTtl(Duration.ofMinutes(1)) - .build(), - DnsPtrRecord.builder() - .withName("name") - .withDomainName("") - .withTtl(Duration.ofMinutes(1)) - .build() - ))) - .withParameter("key", "value") - .isPrivate(false) - .build()) - .build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "production-001")) + .withAzureCloudAgent( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID(), + UUID.randomUUID()) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .withDnsZone( + DnsZone.builder() + .withName("dns.name") + .withRecords(Map.of("componentId", List.of( + DnsAaaaRecord.builder() + .withName("name") + .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") + .withTtl(Duration.ofMinutes(1)) + .build(), + DnsPtrRecord.builder() + .withName("name") + .withDomainName("") + .withTtl(Duration.ofMinutes(1)) + .build() + ))) + .withParameter("key", "value") + .isPrivate(false) + .build()) + .build(); assertThat(managementEnvironment.validate()).isEmpty(); @@ -235,19 +236,19 @@ public void noValidationErrors_when_environmentCreatedWithRegionTenantIdAndSubsc public void noValidationErrors_when_environmentCreatedWithTags() { var ownerId = UUID.randomUUID(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001")) - .withAzureCloudAgent( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID(), - UUID.randomUUID()) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .withTags(Map.of("key1", "value1", "key2", "value2")) - .withTag("key1", "value2") - .withTag("key3", "value3") - .build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "production-001")) + .withAzureCloudAgent( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID(), + UUID.randomUUID()) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .withTags(Map.of("key1", "value1", "key2", "value2")) + .withTag("key1", "value2") + .withTag("key3", "value3") + .build(); assertThat(managementEnvironment.validate()).isEmpty(); @@ -266,45 +267,45 @@ public void noValidationErrors_when_environmentCreatedWithOperationalEnvironment var environmentType = EnvironmentType.PERSONAL; var operationalEnvironment = OperationalEnvironment.builder() - .withShortName("operational-001") - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .withAzureSubscription(AzureRegion.WEST_EUROPE, UUID.randomUUID()) - .withTag("key1", "value1") - .withTag("key2", "value3") - .withTag("key3", "value4") - .build(); + .withShortName("operational-001") + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .withAzureSubscription(AzureRegion.WEST_EUROPE, UUID.randomUUID()) + .withTag("key1", "value1") + .withTag("key2", "value3") + .withTag("key3", "value4") + .build(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - environmentType, - ownerId, - "production-001")) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg2", ownerId))) - .withAwsCloudAgent(AwsRegion.EU_NORTH_1, UUID.randomUUID().toString(), UUID.randomUUID().toString()) - .withAzureCloudAgent(AzureRegion.WEST_EUROPE, UUID.randomUUID(), UUID.randomUUID()) - .withGcpCloudAgent(GcpRegion.EUROPE_WEST1, UUID.randomUUID().toString(), UUID.randomUUID().toString()) - .withOciCloudAgent(OciRegion.EU_ZURICH_1, UUID.randomUUID().toString(), UUID.randomUUID().toString()) - .withHetznerCloudAgent(HetznerRegion.DE_FALKENSTEIN_1, UUID.randomUUID().toString()) - .withDnsZone( - DnsZone.builder() - .withName("dns.name") - .withRecords(Map.of("componentId", List.of( - DnsAaaaRecord.builder() - .withName("name") - .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") - .withTtl(Duration.ofMinutes(1)) - .build(), - DnsPtrRecord.builder() - .withName("name") - .withDomainName("") - .withTtl(Duration.ofMinutes(1)) - .build() - ))) - .withParameter("key", "value") - .isPrivate(false) - .build()) - .withOperationalEnvironment(operationalEnvironment) - .build(); + .withId(new EnvironmentIdValue( + environmentType, + ownerId, + "production-001")) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg2", ownerId))) + .withAwsCloudAgent(AwsRegion.EU_NORTH_1, UUID.randomUUID().toString(), UUID.randomUUID().toString()) + .withAzureCloudAgent(AzureRegion.WEST_EUROPE, UUID.randomUUID(), UUID.randomUUID()) + .withGcpCloudAgent(GcpRegion.EUROPE_WEST1, UUID.randomUUID().toString(), UUID.randomUUID().toString()) + .withOciCloudAgent(OciRegion.EU_ZURICH_1, UUID.randomUUID().toString(), UUID.randomUUID().toString()) + .withHetznerCloudAgent(HetznerRegion.DE_FALKENSTEIN_1, UUID.randomUUID().toString()) + .withDnsZone( + DnsZone.builder() + .withName("dns.name") + .withRecords(Map.of("componentId", List.of( + DnsAaaaRecord.builder() + .withName("name") + .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") + .withTtl(Duration.ofMinutes(1)) + .build(), + DnsPtrRecord.builder() + .withName("name") + .withDomainName("") + .withTtl(Duration.ofMinutes(1)) + .build() + ))) + .withParameter("key", "value") + .isPrivate(false) + .build()) + .withOperationalEnvironment(operationalEnvironment) + .build(); assertThat(managementEnvironment.validate()).isEmpty(); @@ -316,21 +317,21 @@ public void noValidationErrors_when_environmentCreatedWithOperationalEnvironment public void noValidationErrors_when_environmentCreatedWithSecrets() { var ownerId = UUID.randomUUID(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001")) - .withAzureCloudAgent( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID(), - UUID.randomUUID()) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .withSecret(new Secret("secret-1", "Secret Display Name","Secret Description", "value-1")) - .withSecret(new Secret("secret-2", "Secret 2 Display Name","Secret 2 Description", "value-2")) - .withSecrets(List.of( - new Secret("secret-3", "Secret 3 Display Name","Secret 3 Description", "value-3"), - new Secret("secret-4", "Secret 4 Display Name","Secret 4 Description", "value-4") - )).build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "production-001")) + .withAzureCloudAgent( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID(), + UUID.randomUUID()) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .withSecret(new Secret("secret-1", "Secret Display Name", "Secret Description", "value-1")) + .withSecret(new Secret("secret-2", "Secret 2 Display Name", "Secret 2 Description", "value-2")) + .withSecrets(List.of( + new Secret("secret-3", "Secret 3 Display Name", "Secret 3 Description", "value-3"), + new Secret("secret-4", "Secret 4 Display Name", "Secret 4 Description", "value-4") + )).build(); assertThat(managementEnvironment.validate()).isEmpty(); @@ -347,19 +348,19 @@ public void noValidationErrors_when_environmentCreatedWithSecrets() { public void noValidationErrors_when_environmentCreatedWithCiCdProfiles() { var ownerId = UUID.randomUUID(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001")) - .withAzureCloudAgent( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID(), - UUID.randomUUID()) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) - .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) - .withCiCdProfile(new CiCdProfile("additional", "Additional","data", "pass")) - .build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "production-001")) + .withAzureCloudAgent( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID(), + UUID.randomUUID()) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))) + .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .withCiCdProfile(new CiCdProfile("additional", "Additional", "data", "pass")) + .build(); assertThat(managementEnvironment.validate()).isEmpty(); assertThat(managementEnvironment.getDefaultCiCdProfile()).isNotNull(); @@ -368,22 +369,22 @@ public void noValidationErrors_when_environmentCreatedWithCiCdProfiles() { assertThat(jsonEnvironment).isNotBlank(); var ciCdProfiles = managementEnvironment.getCiCdProfiles(); - + assertThat(ciCdProfiles).hasSize(2); } @Test public void noValidationErrors_when_environmentCreatedWithDnsZones() { var managementEnvironment = generateBuilderWithId("production-001") - .withDnsZones(List.of( - DnsZone.builder() - .withName("dns.name1") - .build(), - DnsZone.builder() - .withName("dns.name2") - .build() - )) - .build(); + .withDnsZones(List.of( + DnsZone.builder() + .withName("dns.name1") + .build(), + DnsZone.builder() + .withName("dns.name2") + .build() + )) + .build(); assertThat(managementEnvironment.validate()).isEmpty(); @@ -395,15 +396,15 @@ public void noValidationErrors_when_environmentCreatedWithDnsZones() { public void noValidationErrors_when_environmentCreatedWithResourceGroups() { var ownerId = UUID.randomUUID(); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "production-001")) - .withResourceGroups( - List.of( - ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId)), - ResourceGroupId.fromString(String.format("Personal/%s/rg2", ownerId)))) - .build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "production-001")) + .withResourceGroups( + List.of( + ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId)), + ResourceGroupId.fromString(String.format("Personal/%s/rg2", ownerId)))) + .build(); assertThat(managementEnvironment.validate()).isEmpty(); } @@ -411,11 +412,11 @@ public void noValidationErrors_when_environmentCreatedWithResourceGroups() { @Test public void noValidationErrors_when_environmentCreatedWithTag() { var managementEnvironment = generateBuilderWithId("production-001") - .withTag("key1", "value1") - .build(); + .withTag("key1", "value1") + .build(); assertThat(managementEnvironment.validate()).isEmpty(); - + var tags = managementEnvironment.getTags(); assertThat(tags).hasSize(1); } @@ -427,10 +428,10 @@ private ManagementEnvironment generateBuilderWithInfo(String shortName) { private ManagementEnvironment.ManagementEnvironmentBuilder generateBuilderWithId(String shortName) { var ownerId = UUID.randomUUID(); return ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - shortName)) - .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + shortName)) + .withResourceGroup(ResourceGroupId.fromString(String.format("Personal/%s/rg", ownerId))); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironmentTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironmentTest.java index 42cd5d09..c6453782 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironmentTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/OperationalEnvironmentTest.java @@ -1,8 +1,8 @@ package com.yanchware.fractal.sdk.domain.environment; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsAaaaRecord; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsPtrRecord; -import com.yanchware.fractal.sdk.domain.blueprint.iaas.DnsZone; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsAaaaRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsPtrRecord; +import com.yanchware.fractal.sdk.domain.fractal.iaas.DnsZone; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.values.ResourceGroupId; import com.yanchware.fractal.sdk.utils.TestUtils; @@ -18,312 +18,314 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; class OperationalEnvironmentTest { - private static final String VALID_SHORT_NAME = "operational-001"; - private static final UUID VALID_OWNER_ID = UUID.randomUUID(); - private static final String VALID_DISPLAY_NAME = "My Operational Environment"; - private static final ResourceGroupId VALID_RESOURCE_GROUP_ID = ResourceGroupId.fromString(String.format("Personal/%s/rg", VALID_OWNER_ID)); - - @Test - void exceptionThrown_when_environmentCreatedWithNullShortName() { - assertThatThrownBy(() -> generateBuilderWithInfo(null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName has not been defined and it is required"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithEmptyShortName() { - assertThatThrownBy(() -> generateBuilderWithInfo("")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName has not been defined and it is required"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithBlankShortName() { - assertThatThrownBy(() -> generateBuilderWithInfo(" ")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName has not been defined and it is required"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithUppercaseShortName() { - assertThatThrownBy(() -> generateBuilderWithInfo("Production-001")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ShortName must only contain lowercase letters, numbers, and dashes."); - } - - @Test - void exceptionThrown_when_environmentCreatedWithDuplicateSecretNames() { - assertThatThrownBy(() -> generateBuilder("operational-001") - .withSecret(new Secret("my-secret", "My Secret Display Name","My Secret Description", "value1")) - .withSecret(new Secret("my-secret", "My Secret Display Name","My Secret Description", "value2")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Secret short names must be unique"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithNullSecret() { - assertThatThrownBy(() -> generateBuilder("operational-001") - .withSecret(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The secret cannot be null"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithCiCdProfilesButWithoutDefaultCiCdProfile() { - assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) - .withCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom","data", "pass")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("A default CI/CD profile must be set if additional CI/CD profiles are defined"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithEmptyCiCdProfileShortName() { - assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) - .withDefaultCiCdProfile(new CiCdProfile("", "Default", "data", "pass")) // Empty short name - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen"); // Assuming SHORT_NAME_NOT_VALID is your validation message - } - - @Test - void exceptionThrown_when_environmentCreatedWithNullCiCdProfile() { - assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) - .withDefaultCiCdProfile(null) // Null profile - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The default CI/CD profile cannot be null"); // Or a more specific message - } - - @Test - void exceptionThrown_when_environmentCreatedWithDuplicateCiCdProfileShortNames() { - assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) - .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("default", "Custom", "data", "pass")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); - } - - @Test - void exceptionThrown_when_nonDefaultCiCdProfileShortNamesAreDuplicated() { - assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) - .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithInvalidDnsZone() { - assertThatThrownBy(() -> generateBuilder("operational-001") - .withDnsZone(DnsZone.builder().withName("").build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("DnsZone validation failed"); - } - - @Test - void exceptionThrown_when_environmentCreatedWithEmptyResourceGroups() { - assertThatThrownBy(() -> OperationalEnvironment.builder() - .withShortName("production-001") - .withAzureSubscription( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID()).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ResourceGroups has not been defined and it is required"); - } - - @Test - void exceptionThrown_when_environmentResourceGroupsNotDefined() { - assertThatThrownBy(() -> OperationalEnvironment.builder() - .withShortName("production-001") - .withAzureSubscription( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID()).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Environment ResourceGroups has not been defined and it is required"); - } - - @Test - void noValidationErrors_when_environmentCreateWithRequiredData() { - var environment = OperationalEnvironment.builder() - .withShortName("production-001") - .withResourceGroup(VALID_RESOURCE_GROUP_ID) - .withAzureSubscription(AzureRegion.WEST_EUROPE, UUID.randomUUID()) - .build(); - - assertThat(environment.validate()).isEmpty(); - - var jsonEnvironment = TestUtils.getJsonRepresentation(environment); - assertThat(jsonEnvironment).isNotBlank(); - } - - @Test - void noValidationErrors_when_environmentCreatedWithSecrets() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withAzureSubscription( - AzureRegion.JAPAN, - UUID.randomUUID()) - .withSecret(new Secret("secret-1", "My Secret Display Name","My Secret Description", "value-1")) - .withSecret(new Secret("secret-2", "My Secret Display Name","My Secret Description", "value-2")) - .withSecrets(List.of( - new Secret("secret-3", "My Secret Display Name","My Secret Description", "value-3"), - new Secret("secret-4", "My Secret Display Name","My Secret Description", "value-4") - )) - .build(); - - assertValidEnvironment(environment); - - var secrets = environment.getSecrets(); - assertThat(secrets).hasSize(4); - } - - @Test - void noValidationErrors_when_environmentCreatedWithCiCdProfiles() { - var environment = OperationalEnvironment.builder() - .withShortName(VALID_SHORT_NAME) - .withAzureSubscription( - AzureRegion.AUSTRALIA_CENTRAL, - UUID.randomUUID()) - .withResourceGroup(VALID_RESOURCE_GROUP_ID) - .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) - .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) - .withCiCdProfile(new CiCdProfile("additional", "Additional","data", "pass")) - .build(); - - assertThat(environment.validate()).isEmpty(); - assertThat(environment.getDefaultCiCdProfile()).isNotNull(); - - var jsonEnvironment = TestUtils.getJsonRepresentation(environment); - assertThat(jsonEnvironment).isNotBlank(); - - var ciCdProfiles = environment.getCiCdProfiles(); - - assertThat(ciCdProfiles).hasSize(2); - } - - @Test - void noValidationErrors_when_environmentCreatedWithValidShortName() { - var shortName = "operational-001"; - var environment = generateBuilder(shortName).build(); - - assertThat(environment.validate()).isEmpty(); - assertThat(environment.getShortName()).isEqualTo(shortName); - } - - @Test - void noValidationErrors_when_environmentCreatedWithDnsZone() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withDnsZone( - DnsZone.builder() - .withName("dns.name") - .withRecords(Map.of("componentId", List.of( - DnsAaaaRecord.builder() - .withName("name") - .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") - .withTtl(Duration.ofMinutes(1)) - .build(), - DnsPtrRecord.builder() - .withName("name") - .withDomainName("") - .withTtl(Duration.ofMinutes(1)) - .build() - ))) - .withParameter("key", "value") - .isPrivate(false) - .build()) - .build(); - - assertValidEnvironment(environment); - } - - @Test - void noValidationErrors_when_environmentCreatedWithRegionTenantIdAndSubscriptionId() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withAzureSubscription( - AzureRegion.BRAZIL_SOUTH, - UUID.randomUUID()) - .build(); - - assertValidEnvironment(environment); - } - - @Test - void noValidationErrors_when_environmentCreatedWithTags() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withAzureSubscription( - AzureRegion.EAST_US_EUAP, - UUID.randomUUID()) - .withTags(Map.of("key1", "value1", "key2", "value2")) - .withTag("key1", "value2") - .withTag("key3", "value3") - .build(); - - assertValidEnvironment(environment); - - Map tags = environment.getTags(); - assertThat(tags).hasSize(3); - } - - @Test - void noValidationErrors_when_environmentCreatedWithEmptyName() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withAzureSubscription( - AzureRegion.NEWZEALAND, - UUID.randomUUID()) - .withName("") - .build(); - - assertThat(environment.validate()).isEmpty(); - assertThat(environment.getShortName()).isEqualTo(VALID_SHORT_NAME); - assertThat(environment.getName()).isEqualTo(environment.getShortName()); - assertThat(environment.getResourceGroups()).containsExactly(VALID_RESOURCE_GROUP_ID); - } - - @Test - void noValidationErrors_when_environmentCreatedWithNullName() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withName(null) - .build(); - - assertThat(environment.validate()).isEmpty(); - assertThat(environment.getShortName()).isEqualTo(VALID_SHORT_NAME); - assertThat(environment.getName()).isEqualTo(environment.getShortName()); - assertThat(environment.getResourceGroups()).containsExactly(VALID_RESOURCE_GROUP_ID); - } - - @Test - void noValidationErrors_when_environmentCreatedWithEmptyTags() { - var environment = generateBuilder(VALID_SHORT_NAME) - .withTags(Collections.emptyMap()) - .build(); - - assertValidEnvironment(environment); - } - - void generateBuilderWithInfo(String shortName) { - generateBuilder(shortName).build(); - } - - private OperationalEnvironment.OperationalEnvironmentBuilder generateBuilder(String shortName) { - return OperationalEnvironment.builder() - .withShortName(shortName) - .withName(VALID_DISPLAY_NAME) - .withResourceGroup(VALID_RESOURCE_GROUP_ID); - } - - private void assertValidEnvironment(OperationalEnvironment environment) { - assertThat(environment.validate()).isEmpty(); - - // Assert properties - assertThat(environment.getShortName()).isEqualTo(VALID_SHORT_NAME); - assertThat(environment.getName()).isEqualTo(VALID_DISPLAY_NAME); - assertThat(environment.getResourceGroups()).containsExactly(VALID_RESOURCE_GROUP_ID); - } + private static final String VALID_SHORT_NAME = "operational-001"; + private static final UUID VALID_OWNER_ID = UUID.randomUUID(); + private static final String VALID_DISPLAY_NAME = "My Operational Environment"; + private static final ResourceGroupId VALID_RESOURCE_GROUP_ID = ResourceGroupId.fromString(String.format("Personal" + + "/%s/rg", VALID_OWNER_ID)); + + @Test + void exceptionThrown_when_environmentCreatedWithNullShortName() { + assertThatThrownBy(() -> generateBuilderWithInfo(null)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName has not been defined and it is required"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithEmptyShortName() { + assertThatThrownBy(() -> generateBuilderWithInfo("")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName has not been defined and it is required"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithBlankShortName() { + assertThatThrownBy(() -> generateBuilderWithInfo(" ")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName has not been defined and it is required"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithUppercaseShortName() { + assertThatThrownBy(() -> generateBuilderWithInfo("Production-001")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ShortName must only contain lowercase letters, numbers, and dashes."); + } + + @Test + void exceptionThrown_when_environmentCreatedWithDuplicateSecretNames() { + assertThatThrownBy(() -> generateBuilder("operational-001") + .withSecret(new Secret("my-secret", "My Secret Display Name", "My Secret Description", "value1")) + .withSecret(new Secret("my-secret", "My Secret Display Name", "My Secret Description", "value2")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Secret short names must be unique"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithNullSecret() { + assertThatThrownBy(() -> generateBuilder("operational-001") + .withSecret(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The secret cannot be null"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithCiCdProfilesButWithoutDefaultCiCdProfile() { + assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) + .withCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("A default CI/CD profile must be set if additional CI/CD profiles are defined"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithEmptyCiCdProfileShortName() { + assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) + .withDefaultCiCdProfile(new CiCdProfile("", "Default", "data", "pass")) // Empty short name + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The Short Name only allow alphanumeric characters and hyphens, cannot start or end in a " + + "hyphen"); // Assuming SHORT_NAME_NOT_VALID is your validation message + } + + @Test + void exceptionThrown_when_environmentCreatedWithNullCiCdProfile() { + assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) + .withDefaultCiCdProfile(null) // Null profile + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The default CI/CD profile cannot be null"); // Or a more specific message + } + + @Test + void exceptionThrown_when_environmentCreatedWithDuplicateCiCdProfileShortNames() { + assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) + .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("default", "Custom", "data", "pass")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); + } + + @Test + void exceptionThrown_when_nonDefaultCiCdProfileShortNamesAreDuplicated() { + assertThatThrownBy(() -> generateBuilder(VALID_SHORT_NAME) + .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CI/CD profile short names must be unique, including the default profile"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithInvalidDnsZone() { + assertThatThrownBy(() -> generateBuilder("operational-001") + .withDnsZone(DnsZone.builder().withName("").build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("DnsZone validation failed"); + } + + @Test + void exceptionThrown_when_environmentCreatedWithEmptyResourceGroups() { + assertThatThrownBy(() -> OperationalEnvironment.builder() + .withShortName("production-001") + .withAzureSubscription( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID()).build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ResourceGroups has not been defined and it is required"); + } + + @Test + void exceptionThrown_when_environmentResourceGroupsNotDefined() { + assertThatThrownBy(() -> OperationalEnvironment.builder() + .withShortName("production-001") + .withAzureSubscription( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID()).build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Environment ResourceGroups has not been defined and it is required"); + } + + @Test + void noValidationErrors_when_environmentCreateWithRequiredData() { + var environment = OperationalEnvironment.builder() + .withShortName("production-001") + .withResourceGroup(VALID_RESOURCE_GROUP_ID) + .withAzureSubscription(AzureRegion.WEST_EUROPE, UUID.randomUUID()) + .build(); + + assertThat(environment.validate()).isEmpty(); + + var jsonEnvironment = TestUtils.getJsonRepresentation(environment); + assertThat(jsonEnvironment).isNotBlank(); + } + + @Test + void noValidationErrors_when_environmentCreatedWithSecrets() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withAzureSubscription( + AzureRegion.JAPAN, + UUID.randomUUID()) + .withSecret(new Secret("secret-1", "My Secret Display Name", "My Secret Description", "value-1")) + .withSecret(new Secret("secret-2", "My Secret Display Name", "My Secret Description", "value-2")) + .withSecrets(List.of( + new Secret("secret-3", "My Secret Display Name", "My Secret Description", "value-3"), + new Secret("secret-4", "My Secret Display Name", "My Secret Description", "value-4") + )) + .build(); + + assertValidEnvironment(environment); + + var secrets = environment.getSecrets(); + assertThat(secrets).hasSize(4); + } + + @Test + void noValidationErrors_when_environmentCreatedWithCiCdProfiles() { + var environment = OperationalEnvironment.builder() + .withShortName(VALID_SHORT_NAME) + .withAzureSubscription( + AzureRegion.AUSTRALIA_CENTRAL, + UUID.randomUUID()) + .withResourceGroup(VALID_RESOURCE_GROUP_ID) + .withDefaultCiCdProfile(new CiCdProfile("default", "Default", "data", "pass")) + .withCiCdProfile(new CiCdProfile("custom", "Custom", "data", "pass")) + .withCiCdProfile(new CiCdProfile("additional", "Additional", "data", "pass")) + .build(); + + assertThat(environment.validate()).isEmpty(); + assertThat(environment.getDefaultCiCdProfile()).isNotNull(); + + var jsonEnvironment = TestUtils.getJsonRepresentation(environment); + assertThat(jsonEnvironment).isNotBlank(); + + var ciCdProfiles = environment.getCiCdProfiles(); + + assertThat(ciCdProfiles).hasSize(2); + } + + @Test + void noValidationErrors_when_environmentCreatedWithValidShortName() { + var shortName = "operational-001"; + var environment = generateBuilder(shortName).build(); + + assertThat(environment.validate()).isEmpty(); + assertThat(environment.getShortName()).isEqualTo(shortName); + } + + @Test + void noValidationErrors_when_environmentCreatedWithDnsZone() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withDnsZone( + DnsZone.builder() + .withName("dns.name") + .withRecords(Map.of("componentId", List.of( + DnsAaaaRecord.builder() + .withName("name") + .withIpV6Address("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") + .withTtl(Duration.ofMinutes(1)) + .build(), + DnsPtrRecord.builder() + .withName("name") + .withDomainName("") + .withTtl(Duration.ofMinutes(1)) + .build() + ))) + .withParameter("key", "value") + .isPrivate(false) + .build()) + .build(); + + assertValidEnvironment(environment); + } + + @Test + void noValidationErrors_when_environmentCreatedWithRegionTenantIdAndSubscriptionId() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withAzureSubscription( + AzureRegion.BRAZIL_SOUTH, + UUID.randomUUID()) + .build(); + + assertValidEnvironment(environment); + } + + @Test + void noValidationErrors_when_environmentCreatedWithTags() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withAzureSubscription( + AzureRegion.EAST_US_EUAP, + UUID.randomUUID()) + .withTags(Map.of("key1", "value1", "key2", "value2")) + .withTag("key1", "value2") + .withTag("key3", "value3") + .build(); + + assertValidEnvironment(environment); + + Map tags = environment.getTags(); + assertThat(tags).hasSize(3); + } + + @Test + void noValidationErrors_when_environmentCreatedWithEmptyName() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withAzureSubscription( + AzureRegion.NEWZEALAND, + UUID.randomUUID()) + .withName("") + .build(); + + assertThat(environment.validate()).isEmpty(); + assertThat(environment.getShortName()).isEqualTo(VALID_SHORT_NAME); + assertThat(environment.getName()).isEqualTo(environment.getShortName()); + assertThat(environment.getResourceGroups()).containsExactly(VALID_RESOURCE_GROUP_ID); + } + + @Test + void noValidationErrors_when_environmentCreatedWithNullName() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withName(null) + .build(); + + assertThat(environment.validate()).isEmpty(); + assertThat(environment.getShortName()).isEqualTo(VALID_SHORT_NAME); + assertThat(environment.getName()).isEqualTo(environment.getShortName()); + assertThat(environment.getResourceGroups()).containsExactly(VALID_RESOURCE_GROUP_ID); + } + + @Test + void noValidationErrors_when_environmentCreatedWithEmptyTags() { + var environment = generateBuilder(VALID_SHORT_NAME) + .withTags(Collections.emptyMap()) + .build(); + + assertValidEnvironment(environment); + } + + void generateBuilderWithInfo(String shortName) { + generateBuilder(shortName).build(); + } + + private OperationalEnvironment.OperationalEnvironmentBuilder generateBuilder(String shortName) { + return OperationalEnvironment.builder() + .withShortName(shortName) + .withName(VALID_DISPLAY_NAME) + .withResourceGroup(VALID_RESOURCE_GROUP_ID); + } + + private void assertValidEnvironment(OperationalEnvironment environment) { + assertThat(environment.validate()).isEmpty(); + + // Assert properties + assertThat(environment.getShortName()).isEqualTo(VALID_SHORT_NAME); + assertThat(environment.getName()).isEqualTo(VALID_DISPLAY_NAME); + assertThat(environment.getResourceGroups()).containsExactly(VALID_RESOURCE_GROUP_ID); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/SecretTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/SecretTest.java index be222939..3645386b 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/SecretTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/environment/SecretTest.java @@ -11,67 +11,70 @@ class SecretTest { private static final String VALID_DESCRIPTION = "Test secret"; private static final String VALID_VALUE = "secret-value"; - private static final String SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH = "[Secret Validation] The Short Name only allow alphanumeric characters and hyphens"; - private static final String DISPLAY_NAME_NOT_VALID_ERROR_STARTS_WITH = "[Secret Validation] The Display Name cannot be empty or null"; - private static final String VALUE_NOT_VALID_ERROR_STARTS_WITH = "[Secret Validation] The value cannot be empty or null"; + private static final String SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH = "[Secret Validation] The Short Name only allow" + + " alphanumeric characters and hyphens"; + private static final String DISPLAY_NAME_NOT_VALID_ERROR_STARTS_WITH = "[Secret Validation] The Display Name cannot" + + " be empty or null"; + private static final String VALUE_NOT_VALID_ERROR_STARTS_WITH = "[Secret Validation] The value cannot be empty or " + + "null"; @Test void exceptionThrown_when_shortNameIsEmpty() { assertThatThrownBy(() -> new Secret("", VALID_DISPLAY_NAME, VALID_VALUE)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); } @Test void exceptionThrown_when_shortNameIsNull() { assertThatThrownBy(() -> new Secret(null, VALID_DISPLAY_NAME, VALID_VALUE)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); } @Test void exceptionThrown_when_shortNameStartsWithHyphen() { assertThatThrownBy(() -> new Secret("-my-secret", VALID_DISPLAY_NAME, VALID_VALUE)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); } @Test void exceptionThrown_when_shortNameEndsWithHyphen() { assertThatThrownBy(() -> new Secret("my-secret-", VALID_DISPLAY_NAME, VALID_VALUE)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); } @Test void exceptionThrown_when_shortNameContainsInvalidCharacters() { assertThatThrownBy(() -> new Secret("my_secret%", VALID_DISPLAY_NAME, VALID_VALUE)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH); } - + @Test void exceptionThrown_when_valueIsEmpty() { - assertThatThrownBy(() -> new Secret(VALID_SHORT_NAME, VALID_DISPLAY_NAME,"")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(VALUE_NOT_VALID_ERROR_STARTS_WITH); + assertThatThrownBy(() -> new Secret(VALID_SHORT_NAME, VALID_DISPLAY_NAME, "")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(VALUE_NOT_VALID_ERROR_STARTS_WITH); } @Test void exceptionThrown_when_valueIsNull() { - assertThatThrownBy(() -> new Secret(VALID_SHORT_NAME, VALID_DISPLAY_NAME,null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(VALUE_NOT_VALID_ERROR_STARTS_WITH); + assertThatThrownBy(() -> new Secret(VALID_SHORT_NAME, VALID_DISPLAY_NAME, null)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(VALUE_NOT_VALID_ERROR_STARTS_WITH); } @Test void exceptionThrown_when_nameAndValueAreInvalid() { assertThatThrownBy(() -> new Secret(null, null, null)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH) - .hasMessageContaining(DISPLAY_NAME_NOT_VALID_ERROR_STARTS_WITH) - .hasMessageContaining(VALUE_NOT_VALID_ERROR_STARTS_WITH); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(SHORT_NAME_NOT_VALID_ERROR_STARTS_WITH) + .hasMessageContaining(DISPLAY_NAME_NOT_VALID_ERROR_STARTS_WITH) + .hasMessageContaining(VALUE_NOT_VALID_ERROR_STARTS_WITH); } @Test diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintServiceTest.java new file mode 100644 index 00000000..b71d6044 --- /dev/null +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/BlueprintServiceTest.java @@ -0,0 +1,78 @@ +package com.yanchware.fractal.sdk.domain.fractal.service; + +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; +import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; +import com.yanchware.fractal.sdk.domain.fractal.service.commands.CreateBlueprintCommandRequest; +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; +import com.yanchware.fractal.sdk.domain.values.ResourceGroupId; +import com.yanchware.fractal.sdk.domain.values.ResourceGroupType; +import com.yanchware.fractal.sdk.utils.LocalSdkConfiguration; +import com.yanchware.fractal.sdk.utils.StringHandler; +import io.github.resilience4j.retry.RetryRegistry; +import org.junit.jupiter.api.Test; + +import java.net.http.HttpClient; +import java.util.List; +import java.util.UUID; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static java.util.Collections.emptyMap; +import static java.util.Collections.emptySet; +import static org.assertj.core.api.Assertions.assertThat; + +@WireMockTest +public class BlueprintServiceTest { + + @Test + public void urlPathMatching_when_postRequestToBlueprint(WireMockRuntimeInfo wmRuntimeInfo) throws InstantiatorException { + var httpClient = HttpClient.newBuilder() + .version(HttpClient.Version.HTTP_2) + .build(); + var sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); + var blueprintService = new BlueprintService(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); + + var inputStream = getClass().getClassLoader() + .getResourceAsStream("test-resources/postRequestToBlueprintBody.json"); + + assertThat(inputStream).isNotNull(); + + var resourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"); + var postRequestToBlueprintBody = StringHandler.getStringFromInputStream(inputStream); + var url = String.format("/blueprints/%s/fr/fr", resourceGroupId); + + stubFor(post(urlPathMatching(url)) + .withRequestBody(equalToJson(postRequestToBlueprintBody)) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/json"))); + + blueprintService.create( + buildBlueprintRequest(), + new FractalIdValue(resourceGroupId, "fr", "fr")); + + verify(postRequestedFor(urlPathEqualTo(url))); + } + + private CreateBlueprintCommandRequest buildBlueprintRequest() { + return new CreateBlueprintCommandRequest( + "desc", + true, + List.of(buildBlueprintComponent())); + } + + private BlueprintComponentDto buildBlueprintComponent() { + return BlueprintComponentDto.builder() + .withId("0001") + .withDisplayName("blueprint basic") + .withDescription("blueprint basic desc") + .withType("type") + .withVersion("V0.1") + .withParameters(emptyMap()) + .withDependencies(emptySet()) + .withLinks(emptySet()) + .withOutputFields(emptySet()) + .build(); + } +} \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequestTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequestTest.java new file mode 100644 index 00000000..dd13ffe3 --- /dev/null +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/commands/CreateBlueprintCommandRequestTest.java @@ -0,0 +1,22 @@ +package com.yanchware.fractal.sdk.domain.fractal.service.commands; + +import com.yanchware.fractal.sdk.domain.fractal.service.dtos.BlueprintComponentDto; +import com.yanchware.fractal.sdk.utils.TestUtils; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + + +public class CreateBlueprintCommandRequestTest { + + @Test + public void createBlueprintCommandRequestValid_when_liveSystemValid() { + var ls = TestUtils.getLiveSystemExample(); + String fractalId = "fractalId"; + var commandRequest = new CreateBlueprintCommandRequest(ls.getDescription(), true, + BlueprintComponentDto.fromLiveSystemComponents(ls.getComponents())); + assertThat(commandRequest.description()).contains(ls.getDescription()); + assertThat(commandRequest.isPrivate()).isTrue(); + assertThat(commandRequest.components()).isNotEmpty(); + } +} \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDtoTest.java similarity index 61% rename from fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDtoTest.java rename to fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDtoTest.java index 1e13e603..62e89414 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/blueprint/service/dtos/BlueprintComponentDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/fractal/service/dtos/BlueprintComponentDtoTest.java @@ -1,9 +1,9 @@ -package com.yanchware.fractal.sdk.domain.blueprint.service.dtos; +package com.yanchware.fractal.sdk.domain.fractal.service.dtos; -import com.yanchware.fractal.sdk.domain.blueprint.caas.*; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSContainerPlatform; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDatabase; -import com.yanchware.fractal.sdk.domain.blueprint.paas.PaaSRelationalDbms; +import com.yanchware.fractal.sdk.domain.fractal.caas.*; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSContainerPlatform; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDatabase; +import com.yanchware.fractal.sdk.domain.fractal.paas.PaaSRelationalDbms; import com.yanchware.fractal.sdk.domain.livesystem.caas.*; import com.yanchware.fractal.sdk.domain.livesystem.paas.KubernetesCluster; import com.yanchware.fractal.sdk.domain.livesystem.paas.PaaSPostgreSqlDatabase; @@ -32,13 +32,13 @@ public void blueprintComponentValid_when_aksWithPrometheus() { assertGenericComponent(prometheusDto, prometheus, CaaSMonitoring.TYPE); assertSoftly(softly -> softly - .assertThat(prometheusDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - prometheus.getApiGatewayUrl(), - prometheus.getNamespace(), - aksId - )); + .assertThat(prometheusDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + prometheus.getApiGatewayUrl(), + prometheus.getNamespace(), + aksId + )); } @Test @@ -52,16 +52,16 @@ public void blueprintComponentValid_when_aksWithAmbassador() { assertGenericComponent(ambassadorDto, ambassador, CaaSAPIGateway.TYPE); assertSoftly(softly -> softly - .assertThat(ambassadorDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - ambassador.getHost(), - ambassador.getHostOwnerEmail(), - ambassador.getAcmeProviderAuthority(), - ambassador.getTlsSecretName(), - ambassador.getNamespace(), - aksId - )); + .assertThat(ambassadorDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + ambassador.getHost(), + ambassador.getHostOwnerEmail(), + ambassador.getAcmeProviderAuthority(), + ambassador.getTlsSecretName(), + ambassador.getNamespace(), + aksId + )); } @Test @@ -76,17 +76,17 @@ public void blueprintComponentValid_when_aksWithOcelot() { assertGenericComponent(ocelotDto, ocelot, CaaSServiceMeshSecurity.TYPE); assertSoftly(softly -> softly - .assertThat(ocelotDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - ocelot.getNamespace(), - ocelot.getHost(), - ocelot.getHostOwnerEmail(), - ocelot.getCorsOrigins(), - ocelot.getCookieMaxAgeSec(), - ocelot.getPathPrefix(), - aksId - )); + .assertThat(ocelotDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + ocelot.getNamespace(), + ocelot.getHost(), + ocelot.getHostOwnerEmail(), + ocelot.getCorsOrigins(), + ocelot.getCookieMaxAgeSec(), + ocelot.getPathPrefix(), + aksId + )); } @Test @@ -100,20 +100,20 @@ public void blueprintComponentValid_when_aksWithElasticLogging() { assertGenericComponent(elasticLoggingDto, elasticLogging, CaaSLogging.TYPE); assertSoftly(softly -> softly - .assertThat(elasticLoggingDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - elasticLogging.getNamespace(), - elasticLogging.isApmRequired(), - elasticLogging.isKibanaRequired(), - elasticLogging.getElasticVersion(), - elasticLogging.getElasticInstances(), - elasticLogging.getStorage(), - elasticLogging.getStorageClassName(), - elasticLogging.getMemory(), - elasticLogging.getCpu(), - aksId - )); + .assertThat(elasticLoggingDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + elasticLogging.getNamespace(), + elasticLogging.isApmRequired(), + elasticLogging.isKibanaRequired(), + elasticLogging.getElasticVersion(), + elasticLogging.getElasticInstances(), + elasticLogging.getStorage(), + elasticLogging.getStorageClassName(), + elasticLogging.getMemory(), + elasticLogging.getCpu(), + aksId + )); } @Test @@ -127,19 +127,19 @@ public void blueprintComponentValid_when_aksWithElasticDataStore() { assertGenericComponent(elasticDataStoreDto, elasticDataStore, CaaSSearch.TYPE); assertSoftly(softly -> softly - .assertThat(elasticDataStoreDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - elasticDataStore.getNamespace(), - elasticDataStore.isKibanaRequired(), - elasticDataStore.getElasticVersion(), - elasticDataStore.getElasticInstances(), - elasticDataStore.getStorage(), - elasticDataStore.getStorageClassName(), - elasticDataStore.getMemory(), - elasticDataStore.getCpu(), - aksId - )); + .assertThat(elasticDataStoreDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + elasticDataStore.getNamespace(), + elasticDataStore.isKibanaRequired(), + elasticDataStore.getElasticVersion(), + elasticDataStore.getElasticInstances(), + elasticDataStore.getStorage(), + elasticDataStore.getStorageClassName(), + elasticDataStore.getMemory(), + elasticDataStore.getCpu(), + aksId + )); } @Test @@ -153,18 +153,18 @@ public void blueprintComponentValid_when_aksWithK8sWorkload() { assertGenericComponent(k8sWorkloadDto, k8sWorkload, CaaSWorkload.TYPE); assertSoftly(softly -> softly - .assertThat(k8sWorkloadDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - k8sWorkload.getNamespace(), - k8sWorkload.getPrivateSSHKeyPassphraseEnvironmentSecretShortName(), - k8sWorkload.getPrivateSSHKeyEnvironmentSecretShortName(), - k8sWorkload.getSshRepositoryURI(), - k8sWorkload.getRoles(), - k8sWorkload.getRepoId(), - k8sWorkload.getBranchName(), - aksId - )); + .assertThat(k8sWorkloadDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + k8sWorkload.getNamespace(), + k8sWorkload.getPrivateSSHKeyPassphraseEnvironmentSecretShortName(), + k8sWorkload.getPrivateSSHKeyEnvironmentSecretShortName(), + k8sWorkload.getSshRepositoryURI(), + k8sWorkload.getRoles(), + k8sWorkload.getRepoId(), + k8sWorkload.getBranchName(), + aksId + )); } @Test @@ -176,29 +176,29 @@ public void blueprintComponentValid_when_AksLiveSystemComponentConverted() { var aksDto = getBlueprintComponentDto(blueprintComponentDtoList, aks.getId().getValue()); assertGenericComponent(aksDto, aks, PaaSContainerPlatform.TYPE); assertSoftly(softly -> softly - .assertThat(aksDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - aks.getAzureRegion(), - aks.getAzureActiveDirectoryProfile(), - aks.getNodePools(), - aks.getServiceIpRange(), - aks.getPodIpRange(), - aks.getVnetAddressSpaceIpRange(), - aks.getVnetSubnetAddressIpRange(), - aks.getPriorityClasses(), - aks.getPodManagedIdentity(), - aks.getExternalWorkspaceResourceId(), - aks.getOutboundIps(), - aks.getAddonProfiles(), - aks.getRoles(), - aks.getKubernetesVersion(), - aks.getTags(), - aks.getWindowsAdminUsername(), - aks.getWorkloadIdentityEnabled(), - aks.getManagedClusterSkuTier(), - aks.isPrivateClusterDisabled() - )); + .assertThat(aksDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + aks.getAzureRegion(), + aks.getAzureActiveDirectoryProfile(), + aks.getNodePools(), + aks.getServiceIpRange(), + aks.getPodIpRange(), + aks.getVnetAddressSpaceIpRange(), + aks.getVnetSubnetAddressIpRange(), + aks.getPriorityClasses(), + aks.getPodManagedIdentity(), + aks.getExternalWorkspaceResourceId(), + aks.getOutboundIps(), + aks.getAddonProfiles(), + aks.getRoles(), + aks.getKubernetesVersion(), + aks.getTags(), + aks.getWindowsAdminUsername(), + aks.getWorkloadIdentityEnabled(), + aks.getManagedClusterSkuTier(), + aks.isPrivateClusterDisabled() + )); } @Test @@ -210,19 +210,19 @@ public void blueprintComponentValid_when_GkeLiveSystemComponentConverted() { var gkeDto = getBlueprintComponentDto(blueprintComponentDtoList, gke.getId().getValue()); assertGenericComponent(gkeDto, gke, PaaSContainerPlatform.TYPE); assertSoftly(softly -> softly - .assertThat(gkeDto.getParameters().values()) - .as("Component Parameters") - .containsExactlyInAnyOrder( - gke.getNetworkName(), - gke.getPodsRangeName(), - gke.getRegion(), - gke.getServicesRangeName(), - gke.getSubnetworkName(), - gke.getNodePools(), - gke.getServiceIpRange(), - gke.getPodIpRange(), - gke.getSubnetworkIpRange(), - gke.getPriorityClasses())); + .assertThat(gkeDto.getParameters().values()) + .as("Component Parameters") + .containsExactlyInAnyOrder( + gke.getNetworkName(), + gke.getPodsRangeName(), + gke.getRegion(), + gke.getServicesRangeName(), + gke.getSubnetworkName(), + gke.getNodePools(), + gke.getServiceIpRange(), + gke.getPodIpRange(), + gke.getSubnetworkIpRange(), + gke.getPriorityClasses())); } @Test @@ -237,22 +237,23 @@ public void blueprintComponentValid_when_azurePostgresLiveSystemComponentConvert assertGenericComponent(azurePgBlueprintCompDto, apg, PaaSRelationalDbms.TYPE); assertSoftly(softly -> { softly.assertThat(azurePgBlueprintCompDto.getParameters().values()).as("Component Parameters") - .containsExactlyInAnyOrder( - apg.getAzureRegion(), - apg.getRootUser(), - apg.getSkuName().getId(), - apg.getStorageAutoGrow().getId(), - apg.getStorageGb(), - apg.getBackupRetentionDays(), - apg.getName() - ); + .containsExactlyInAnyOrder( + apg.getAzureRegion(), + apg.getRootUser(), + apg.getSkuName().getId(), + apg.getStorageAutoGrow().getId(), + apg.getStorageGb(), + apg.getBackupRetentionDays(), + apg.getName() + ); softly.assertThat(azurePgBlueprintCompDto.getDependencies()).as("Component Dependencies").isEmpty(); softly.assertThat(azurePgBlueprintCompDto.getLinks()).as("Component Links").isEmpty(); }); //assert postgres db#1 var azurePgDbBlueprintCompDto = blueprintComponentDtoList.get(1); - Optional db1Optional = apg.getDatabases().stream().filter(x -> x.getId().getValue().equals(azurePgDbBlueprintCompDto.getId())).findFirst(); + Optional db1Optional = + apg.getDatabases().stream().filter(x -> x.getId().getValue().equals(azurePgDbBlueprintCompDto.getId())).findFirst(); assertThat(db1Optional).isPresent(); var db1 = db1Optional.get(); assertGenericComponent(azurePgDbBlueprintCompDto, db1, PaaSRelationalDatabase.TYPE); @@ -260,14 +261,15 @@ public void blueprintComponentValid_when_azurePostgresLiveSystemComponentConvert softly.assertThat(azurePgDbBlueprintCompDto.getParameters().values()).as("Component Parameters").containsExactlyInAnyOrder( db1.getName(), db1.getSchema(), - ((AzureResourceEntity)db1).getAzureRegion()); + ((AzureResourceEntity) db1).getAzureRegion()); softly.assertThat(azurePgDbBlueprintCompDto.getDependencies()).as("Component Dependencies").containsExactly(apg.getId().getValue()); softly.assertThat(azurePgDbBlueprintCompDto.getLinks()).as("Component Links").isEmpty(); }); //assert postgres db#2 var azurePgDbBlueprintCompDto2 = blueprintComponentDtoList.get(2); - Optional db2Optional = apg.getDatabases().stream().filter(x -> x.getId().getValue().equals(azurePgDbBlueprintCompDto2.getId())).findFirst(); + Optional db2Optional = + apg.getDatabases().stream().filter(x -> x.getId().getValue().equals(azurePgDbBlueprintCompDto2.getId())).findFirst(); assertThat(db2Optional).isPresent(); var db2 = db2Optional.get(); assertGenericComponent(azurePgDbBlueprintCompDto2, db2, PaaSRelationalDatabase.TYPE); @@ -275,7 +277,7 @@ public void blueprintComponentValid_when_azurePostgresLiveSystemComponentConvert softly.assertThat(azurePgDbBlueprintCompDto2.getParameters().values()).as("Component Parameters").containsExactlyInAnyOrder( db2.getSchema(), db2.getName(), - ((AzureResourceEntity)db1).getAzureRegion()); + ((AzureResourceEntity) db1).getAzureRegion()); softly.assertThat(azurePgDbBlueprintCompDto2.getDependencies()).as("Component Dependencies").containsExactly(apg.getId().getValue()); softly.assertThat(azurePgDbBlueprintCompDto2.getLinks()).as("Component Links").containsAll(apg.getLinks()); }); @@ -292,24 +294,30 @@ public void blueprintComponentValid_when_gcpPostgresLiveSystemComponentConverted assertGenericComponent(gcpPgBlueprintCompDto, gcpPostgres, PaaSRelationalDbms.TYPE); assertSoftly(softly -> { softly.assertThat(gcpPgBlueprintCompDto.getParameters().values()).as("Component Parameters") - .containsExactlyInAnyOrder( - gcpPostgres.getRegion(), - gcpPostgres.getNetwork(), - gcpPostgres.getPeeringNetworkAddress(), - gcpPostgres.getPeeringNetworkAddressDescription(), - gcpPostgres.getPeeringNetworkName(), - gcpPostgres.getPeeringNetworkPrefix() - ); + .containsExactlyInAnyOrder( + gcpPostgres.getRegion(), + gcpPostgres.getNetwork(), + gcpPostgres.getPeeringNetworkAddress(), + gcpPostgres.getPeeringNetworkAddressDescription(), + gcpPostgres.getPeeringNetworkName(), + gcpPostgres.getPeeringNetworkPrefix() + ); softly.assertThat(gcpPgBlueprintCompDto.getDependencies()).as("Component Dependencies").isEmpty(); softly.assertThat(gcpPgBlueprintCompDto.getLinks()).as("Component Links").isEmpty(); }); } - private BlueprintComponentDto getBlueprintComponentDto(List blueprintComponentDtoList, String compId) { + private BlueprintComponentDto getBlueprintComponentDto( + List blueprintComponentDtoList, + String compId) + { return blueprintComponentDtoList.stream().filter(dto -> dto.getId().equals(compId)).findFirst().orElse(null); } - private void assertComponentSize(KubernetesCluster kubernetesCluster, List blueprintComponentDtos) { + private void assertComponentSize( + KubernetesCluster kubernetesCluster, + List blueprintComponentDtos) + { int componentSize = 1; //containerPlatform itself componentSize += kubernetesCluster.getK8sWorkloadInstances().size(); componentSize += kubernetesCluster.getMonitoringInstances().size(); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/InstantiateLiveSystemCommandRequestTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/InstantiateLiveSystemCommandRequestTest.java index 635c414d..6ffa084c 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/InstantiateLiveSystemCommandRequestTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/InstantiateLiveSystemCommandRequestTest.java @@ -8,37 +8,36 @@ class InstantiateLiveSystemCommandRequestTest { - @Test - public void instantiateLiveSystemCommandRequestValid_when_liveSystemValid() { - var ls = getLiveSystemExample(); - var commandRequest = new InstantiateLiveSystemCommandRequest( - ls.getId().toString(), - ls.getFractalId().toString(), - ls.getDescription(), - null, - ls.blueprintMapFromLiveSystemComponents(), - ls.getEnvironment()); - - assertLiveSystemInfo(commandRequest, ls); - assertEnvironment(commandRequest.environment(), ls.getEnvironment()); - } - - private void assertLiveSystemInfo(InstantiateLiveSystemCommandRequest commandRequest, LiveSystemAggregate ls) { - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(commandRequest.liveSystemId()).isEqualTo(ls.getId().toString()); - softly.assertThat(commandRequest.fractalId()).isEqualTo(ls.getFractalId().toString()); - softly.assertThat(commandRequest.description()).isEqualTo(ls.getDescription()); - }); - } - - private void assertEnvironment(EnvironmentReference envDto, EnvironmentReference env) { - SoftAssertions.assertSoftly(softly -> { - softly.assertThat(envDto.id().type().toString()).isEqualTo(env.id().type().toString()); - softly.assertThat(envDto.id().ownerId()).isEqualTo(env.id().ownerId()); - softly.assertThat(envDto.id().shortName()).isEqualTo(env.id().shortName()); - }); - } - - + @Test + public void instantiateLiveSystemCommandRequestValid_when_liveSystemValid() { + var ls = getLiveSystemExample(); + var commandRequest = new InstantiateLiveSystemCommandRequest( + ls.getId().toString(), + ls.getFractalId().toString(), + ls.getDescription(), + null, + ls.blueprintMapFromLiveSystemComponents(), + ls.getEnvironment()); + + assertLiveSystemInfo(commandRequest, ls); + assertEnvironment(commandRequest.environment(), ls.getEnvironment()); + } + + private void assertLiveSystemInfo(InstantiateLiveSystemCommandRequest commandRequest, LiveSystemAggregate ls) { + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(commandRequest.liveSystemId()).isEqualTo(ls.getId().toString()); + softly.assertThat(commandRequest.fractalId()).isEqualTo(ls.getFractalId().toString()); + softly.assertThat(commandRequest.description()).isEqualTo(ls.getDescription()); + }); + } + + private void assertEnvironment(EnvironmentReference envDto, EnvironmentReference env) { + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(envDto.id().type().toString()).isEqualTo(env.id().type().toString()); + softly.assertThat(envDto.id().ownerId()).isEqualTo(env.id().ownerId()); + softly.assertThat(envDto.id().shortName()).isEqualTo(env.id().shortName()); + }); + } + } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregateTest.java index 63df8dd5..ab7c21d6 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAggregateTest.java @@ -26,78 +26,80 @@ @WireMockTest class LiveSystemAggregateTest { - private LiveSystemAggregate liveSystemAggregate; - - @BeforeEach - void setUp(WireMockRuntimeInfo wmRuntimeInfo) { - var httpClient = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); - - var sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); - liveSystemAggregate = new LiveSystemsFactory(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()) - .builder() - .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), UUID.randomUUID().toString())) - .withStandardProvider(ProviderType.AZURE) - .withEnvironmentId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - UUID.randomUUID(), - "test-env" - )) - .withComponent(AzureCosmosGremlinDbms.builder() - .withId("cosmos-graph-1") - .withMaxTotalThroughput(500) - .withAzureResourceGroup( - AzureResourceGroup.builder() - .withName("MyRg") - .withRegion(AzureRegion.EAST_ASIA) - .build()) - .withCosmosEntity(AzureCosmosGremlinDatabase.builder() - .withId("graph-db-1") - .build()) - .build()) - .build(); - } - - @Test - void should_throwEnvironmentNotFoundException_when_environmentDoesNotExist() { - // Arrange - var environmentId = liveSystemAggregate.getEnvironment().id(); - - // Configure WireMock to return a 404 Not Found response - stubFor(get(urlEqualTo("/environments/" + environmentId)) - .willReturn(notFound())); - - // Act & Assert - assertThatThrownBy(() -> liveSystemAggregate.instantiate()) - .isInstanceOf(EnvironmentNotFoundException.class) - .hasMessageContaining( - String.format("Unable to instantiate LiveSystem [id: '%s']. Environment [id: '%s'] not found", - liveSystemAggregate.getId(), - environmentId)); - - // Verify that the request was made to the environment service - verify(getRequestedFor(urlEqualTo("/environments/" + environmentId))); - } - - @Test - void should_throwEnvironmentException_when_badRequest() { - // Arrange - var environmentId = liveSystemAggregate.getEnvironment().id(); - - // Configure WireMock to return a 500 Internal Server Error response - stubFor(get(urlEqualTo("/environments/" + environmentId)) - .willReturn(badRequest())); - - // Act & Assert - assertThatThrownBy(() -> liveSystemAggregate.instantiate()) - .isInstanceOf(EnvironmentNotFoundException.class) - .hasMessageContaining(String.format("Unable to instantiate LiveSystem [id: '%s']. Environment [id: '%s'] not found", - liveSystemAggregate.getId(), - environmentId)); - - // Verify that the request was made to the environment service - verify(getRequestedFor(urlEqualTo("/environments/" + environmentId))); - } + private LiveSystemAggregate liveSystemAggregate; + + @BeforeEach + void setUp(WireMockRuntimeInfo wmRuntimeInfo) { + var httpClient = HttpClient.newBuilder() + .version(HttpClient.Version.HTTP_2) + .build(); + + var sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); + liveSystemAggregate = new LiveSystemsFactory(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()) + .builder() + .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), + UUID.randomUUID().toString())) + .withStandardProvider(ProviderType.AZURE) + .withEnvironmentId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + UUID.randomUUID(), + "test-env" + )) + .withComponent(AzureCosmosGremlinDbms.builder() + .withId("cosmos-graph-1") + .withMaxTotalThroughput(500) + .withAzureResourceGroup( + AzureResourceGroup.builder() + .withName("MyRg") + .withRegion(AzureRegion.EAST_ASIA) + .build()) + .withCosmosEntity(AzureCosmosGremlinDatabase.builder() + .withId("graph-db-1") + .build()) + .build()) + .build(); + } + + @Test + void should_throwEnvironmentNotFoundException_when_environmentDoesNotExist() { + // Arrange + var environmentId = liveSystemAggregate.getEnvironment().id(); + + // Configure WireMock to return a 404 Not Found response + stubFor(get(urlEqualTo("/environments/" + environmentId)) + .willReturn(notFound())); + + // Act & Assert + assertThatThrownBy(() -> liveSystemAggregate.instantiate()) + .isInstanceOf(EnvironmentNotFoundException.class) + .hasMessageContaining( + String.format("Unable to instantiate LiveSystem [id: '%s']. Environment [id: '%s'] not found", + liveSystemAggregate.getId(), + environmentId)); + + // Verify that the request was made to the environment service + verify(getRequestedFor(urlEqualTo("/environments/" + environmentId))); + } + + @Test + void should_throwEnvironmentException_when_badRequest() { + // Arrange + var environmentId = liveSystemAggregate.getEnvironment().id(); + + // Configure WireMock to return a 500 Internal Server Error response + stubFor(get(urlEqualTo("/environments/" + environmentId)) + .willReturn(badRequest())); + + // Act & Assert + assertThatThrownBy(() -> liveSystemAggregate.instantiate()) + .isInstanceOf(EnvironmentNotFoundException.class) + .hasMessageContaining(String.format("Unable to instantiate LiveSystem [id: '%s']. Environment [id: '%s'] not " + + "found", + liveSystemAggregate.getId(), + environmentId)); + + // Verify that the request was made to the environment service + verify(getRequestedFor(urlEqualTo("/environments/" + environmentId))); + } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAksComponentDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAksComponentDtoTest.java index e2fc7539..015aaabb 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAksComponentDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemAksComponentDtoTest.java @@ -25,15 +25,15 @@ class LiveSystemAksComponentDtoTest extends LiveSystemKubernetesComponentDtoTest @Test public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forAks() { var factory = new LiveSystemsFactory( - HttpClient.newBuilder().build(), - new LocalSdkConfiguration(""), - RetryRegistry.ofDefaults()); + HttpClient.newBuilder().build(), + new LocalSdkConfiguration(""), + RetryRegistry.ofDefaults()); var aks = TestUtils.getAksExample(); var liveSystem = factory.builder() - .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) - .withStandardProvider(ProviderType.AZURE) - .withComponent(aks) - .build(); + .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) + .withStandardProvider(ProviderType.AZURE) + .withComponent(aks) + .build(); var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); assertAks(aks, lsDtoMap); assertAksNodePool(aks, lsDtoMap); @@ -43,9 +43,9 @@ public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeF private void assertAksNodePool(AzureKubernetesService aks, Map lsDtoMap) { var dto = lsDtoMap.get(aks.getId().getValue()); assertThat(dto.getParameters().get("nodePools")) - .asInstanceOf(InstanceOfAssertFactories.LIST) - .first() - .hasFieldOrProperty("labels"); + .asInstanceOf(InstanceOfAssertFactories.LIST) + .first() + .hasFieldOrProperty("labels"); } private void assertAks(AzureKubernetesService aks, Map lsDtoMap) { @@ -53,37 +53,37 @@ private void assertAks(AzureKubernetesService aks, Map lsDtoMap) { - var dto = lsDtoMap.get(eks.getId().getValue()); - assertGenericComponent(dto, eks, ComponentType.PAAS_KUBERNETES.getId()); - assertThat(dto.getProvider()).isEqualTo(eks.getProvider()); - assertThat(dto.getParameters()) - .extracting( - "podIpRange", - "priorityClasses", - "awsRegion", - "serviceIpRange") - .containsExactly( - eks.getPodIpRange(), - eks.getPriorityClasses(), - eks.getAwsRegion(), - eks.getServiceIpRange()); - } + private void assertEks(AwsElasticKubernetesService eks, Map lsDtoMap) { + var dto = lsDtoMap.get(eks.getId().getValue()); + assertGenericComponent(dto, eks, ComponentType.PAAS_KUBERNETES.getId()); + assertThat(dto.getProvider()).isEqualTo(eks.getProvider()); + assertThat(dto.getParameters()) + .extracting( + "podIpRange", + "priorityClasses", + "awsRegion", + "serviceIpRange") + .containsExactly( + eks.getPodIpRange(), + eks.getPriorityClasses(), + eks.getAwsRegion(), + eks.getServiceIpRange()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemGkeComponentDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemGkeComponentDtoTest.java index 719059ca..befabc13 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemGkeComponentDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemGkeComponentDtoTest.java @@ -21,51 +21,51 @@ import static org.assertj.core.api.Assertions.assertThat; class LiveSystemGkeComponentDtoTest extends LiveSystemKubernetesComponentDtoTest { - @Test - public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forGke() { - var factory = new LiveSystemsFactory( - HttpClient.newBuilder().build(), - new LocalSdkConfiguration(""), - RetryRegistry.ofDefaults()); - var gke = TestUtils.getGkeExample(); - var postgres = TestUtils.getGcpPostgresExample(); - var liveSystem = factory.builder() - .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) - .withStandardProvider(ProviderType.GCP) - .withComponents(List.of(gke, postgres)) - .build(); + @Test + public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forGke() { + var factory = new LiveSystemsFactory( + HttpClient.newBuilder().build(), + new LocalSdkConfiguration(""), + RetryRegistry.ofDefaults()); + var gke = TestUtils.getGkeExample(); + var postgres = TestUtils.getGcpPostgresExample(); + var liveSystem = factory.builder() + .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) + .withStandardProvider(ProviderType.GCP) + .withComponents(List.of(gke, postgres)) + .build(); - var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); - assertGke(gke, lsDtoMap); - assertCaaSComponents(gke, lsDtoMap); - } + var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); + assertGke(gke, lsDtoMap); + assertCaaSComponents(gke, lsDtoMap); + } - private void assertGke(GoogleKubernetesEngine gke, Map lsDtoMap) { - var dto = lsDtoMap.get(gke.getId().getValue()); - assertGenericComponent(dto, gke, ComponentType.PAAS_KUBERNETES.getId()); - assertThat(dto.getProvider()).isEqualTo(gke.getProvider()); - assertThat(dto.getParameters()) - .extracting( - "networkName", - "nodePools", - "podIpRange", - "podsRangeName", - "priorityClasses", - "region", - "serviceIpRange", - "servicesRangeName", - "subnetworkIpRange", - "subnetworkName") - .containsExactly( - gke.getNetworkName(), - gke.getNodePools(), - gke.getPodIpRange(), - gke.getPodsRangeName(), - gke.getPriorityClasses(), - gke.getRegion(), - gke.getServiceIpRange(), - gke.getServicesRangeName(), - gke.getSubnetworkIpRange(), - gke.getSubnetworkName()); - } + private void assertGke(GoogleKubernetesEngine gke, Map lsDtoMap) { + var dto = lsDtoMap.get(gke.getId().getValue()); + assertGenericComponent(dto, gke, ComponentType.PAAS_KUBERNETES.getId()); + assertThat(dto.getProvider()).isEqualTo(gke.getProvider()); + assertThat(dto.getParameters()) + .extracting( + "networkName", + "nodePools", + "podIpRange", + "podsRangeName", + "priorityClasses", + "region", + "serviceIpRange", + "servicesRangeName", + "subnetworkIpRange", + "subnetworkName") + .containsExactly( + gke.getNetworkName(), + gke.getNodePools(), + gke.getPodIpRange(), + gke.getPodsRangeName(), + gke.getPriorityClasses(), + gke.getRegion(), + gke.getServiceIpRange(), + gke.getServicesRangeName(), + gke.getSubnetworkIpRange(), + gke.getSubnetworkName()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemHetznerKubernetesDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemHetznerKubernetesDtoTest.java index 1fc2596d..73606407 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemHetznerKubernetesDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemHetznerKubernetesDtoTest.java @@ -21,39 +21,42 @@ import static org.assertj.core.api.Assertions.assertThat; class LiveSystemHetznerKubernetesDtoTest extends LiveSystemKubernetesComponentDtoTest { - @Test - public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forHetznerKubernetes() { - var factory = new LiveSystemsFactory( - HttpClient.newBuilder().build(), - new LocalSdkConfiguration(""), - RetryRegistry.ofDefaults()); - var hetznerKubernetes = TestUtils.getHetznerKubernetesExample(); - var postgres = TestUtils.getGcpPostgresExample(); - var liveSystem = factory.builder() - .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) - .withStandardProvider(ProviderType.HETZNER) - .withComponents(List.of(hetznerKubernetes, postgres)) - .build(); + @Test + public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forHetznerKubernetes() { + var factory = new LiveSystemsFactory( + HttpClient.newBuilder().build(), + new LocalSdkConfiguration(""), + RetryRegistry.ofDefaults()); + var hetznerKubernetes = TestUtils.getHetznerKubernetesExample(); + var postgres = TestUtils.getGcpPostgresExample(); + var liveSystem = factory.builder() + .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) + .withStandardProvider(ProviderType.HETZNER) + .withComponents(List.of(hetznerKubernetes, postgres)) + .build(); - var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); - assertHetznerKubernetes(hetznerKubernetes, lsDtoMap); - assertCaaSComponents(hetznerKubernetes, lsDtoMap); - } + var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); + assertHetznerKubernetes(hetznerKubernetes, lsDtoMap); + assertCaaSComponents(hetznerKubernetes, lsDtoMap); + } - private void assertHetznerKubernetes(HetznerKubernetes hetznerKubernetes, Map lsDtoMap) { - var dto = lsDtoMap.get(hetznerKubernetes.getId().getValue()); - assertGenericComponent(dto, hetznerKubernetes, ComponentType.PAAS_KUBERNETES.getId()); - assertThat(dto.getProvider()).isEqualTo(hetznerKubernetes.getProvider()); - assertThat(dto.getParameters()) - .extracting( - "podIpRange", - "priorityClasses", - "hetznerRegion", - "serviceIpRange") - .containsExactly( - hetznerKubernetes.getPodIpRange(), - hetznerKubernetes.getPriorityClasses(), - hetznerKubernetes.getHetznerRegion(), - hetznerKubernetes.getServiceIpRange()); - } + private void assertHetznerKubernetes( + HetznerKubernetes hetznerKubernetes, + Map lsDtoMap) + { + var dto = lsDtoMap.get(hetznerKubernetes.getId().getValue()); + assertGenericComponent(dto, hetznerKubernetes, ComponentType.PAAS_KUBERNETES.getId()); + assertThat(dto.getProvider()).isEqualTo(hetznerKubernetes.getProvider()); + assertThat(dto.getParameters()) + .extracting( + "podIpRange", + "priorityClasses", + "hetznerRegion", + "serviceIpRange") + .containsExactly( + hetznerKubernetes.getPodIpRange(), + hetznerKubernetes.getPriorityClasses(), + hetznerKubernetes.getHetznerRegion(), + hetznerKubernetes.getServiceIpRange()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemOkeComponentDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemOkeComponentDtoTest.java index e7472d6d..38c2800f 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemOkeComponentDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemOkeComponentDtoTest.java @@ -21,39 +21,39 @@ import static org.assertj.core.api.Assertions.assertThat; class LiveSystemOkeComponentDtoTest extends LiveSystemKubernetesComponentDtoTest { - @Test - public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forOke() { - var factory = new LiveSystemsFactory( - HttpClient.newBuilder().build(), - new LocalSdkConfiguration(""), - RetryRegistry.ofDefaults()); - var oke = TestUtils.getOkeExample(); - var postgres = TestUtils.getGcpPostgresExample(); - var liveSystem = factory.builder() - .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) - .withStandardProvider(ProviderType.OCI) - .withComponents(List.of(oke, postgres)) - .build(); + @Test + public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forOke() { + var factory = new LiveSystemsFactory( + HttpClient.newBuilder().build(), + new LocalSdkConfiguration(""), + RetryRegistry.ofDefaults()); + var oke = TestUtils.getOkeExample(); + var postgres = TestUtils.getGcpPostgresExample(); + var liveSystem = factory.builder() + .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) + .withStandardProvider(ProviderType.OCI) + .withComponents(List.of(oke, postgres)) + .build(); - var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); - assertOke(oke, lsDtoMap); - assertCaaSComponents(oke, lsDtoMap); - } + var lsDtoMap = liveSystem.blueprintMapFromLiveSystemComponents(); + assertOke(oke, lsDtoMap); + assertCaaSComponents(oke, lsDtoMap); + } - private void assertOke(OciContainerEngineForKubernetes oke, Map lsDtoMap) { - var dto = lsDtoMap.get(oke.getId().getValue()); - assertGenericComponent(dto, oke, ComponentType.PAAS_KUBERNETES.getId()); - assertThat(dto.getProvider()).isEqualTo(oke.getProvider()); - assertThat(dto.getParameters()) - .extracting( - "podIpRange", - "priorityClasses", - "ociRegion", - "serviceIpRange") - .containsExactly( - oke.getPodIpRange(), - oke.getPriorityClasses(), - oke.getOciRegion(), - oke.getServiceIpRange()); - } + private void assertOke(OciContainerEngineForKubernetes oke, Map lsDtoMap) { + var dto = lsDtoMap.get(oke.getId().getValue()); + assertGenericComponent(dto, oke, ComponentType.PAAS_KUBERNETES.getId()); + assertThat(dto.getProvider()).isEqualTo(oke.getProvider()); + assertThat(dto.getParameters()) + .extracting( + "podIpRange", + "priorityClasses", + "ociRegion", + "serviceIpRange") + .containsExactly( + oke.getPodIpRange(), + oke.getPriorityClasses(), + oke.getOciRegion(), + oke.getServiceIpRange()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemPostgresComponentDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemPostgresComponentDtoTest.java index d07a3559..3eae6f17 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemPostgresComponentDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemPostgresComponentDtoTest.java @@ -21,60 +21,60 @@ class LiveSystemPostgresComponentDtoTest { - @Test - public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forAks() { - var factory = new LiveSystemsFactory( - HttpClient.newBuilder().build(), - new LocalSdkConfiguration(""), - RetryRegistry.ofDefaults()); - var postgres = TestUtils.getAzurePostgresExample(); - var liveSystem = factory.builder() - .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) - .withStandardProvider(ProviderType.AZURE) - .withComponent(postgres) - .build(); - assertPostgres(postgres, liveSystem.blueprintMapFromLiveSystemComponents()); - } + @Test + public void liveSystemComponentDto_matches_liveSystemComponents_withCorrectTypeForLiveSystem_forAks() { + var factory = new LiveSystemsFactory( + HttpClient.newBuilder().build(), + new LocalSdkConfiguration(""), + RetryRegistry.ofDefaults()); + var postgres = TestUtils.getAzurePostgresExample(); + var liveSystem = factory.builder() + .withId(new LiveSystemIdValue(new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"), "test")) + .withStandardProvider(ProviderType.AZURE) + .withComponent(postgres) + .build(); + assertPostgres(postgres, liveSystem.blueprintMapFromLiveSystemComponents()); + } - private void assertPostgres(AzurePostgreSqlDbms postgres, Map lsDtoMap) { - assertPostgres(lsDtoMap, postgres); - postgres.getDatabases().forEach(component -> assertPostgresDb(lsDtoMap, (AzurePostgreSqlDatabase) component)); - } + private void assertPostgres(AzurePostgreSqlDbms postgres, Map lsDtoMap) { + assertPostgres(lsDtoMap, postgres); + postgres.getDatabases().forEach(component -> assertPostgresDb(lsDtoMap, (AzurePostgreSqlDatabase) component)); + } - private void assertPostgres(Map lsDtoMap, AzurePostgreSqlDbms postgres) { - var dto = lsDtoMap.get(postgres.getId().getValue()); - assertGenericComponent(dto, postgres, ComponentType.PAAS_POSTGRESQL_DBMS.getId()); - assertThat(dto.getProvider()).isEqualTo(ProviderType.AZURE); - assertThat(dto.getParameters()) - .extracting( - "azureRegion", - "backupRetentionDays", - "name", - "rootUser", - "skuName", - "storageAutoGrow", - "storageGb") - .containsExactly( - postgres.getAzureRegion(), - postgres.getBackupRetentionDays(), - postgres.getName(), - postgres.getRootUser(), - postgres.getSkuName().getId(), - postgres.getStorageAutoGrow().getId(), - postgres.getStorageGb()); - } + private void assertPostgres(Map lsDtoMap, AzurePostgreSqlDbms postgres) { + var dto = lsDtoMap.get(postgres.getId().getValue()); + assertGenericComponent(dto, postgres, ComponentType.PAAS_POSTGRESQL_DBMS.getId()); + assertThat(dto.getProvider()).isEqualTo(ProviderType.AZURE); + assertThat(dto.getParameters()) + .extracting( + "azureRegion", + "backupRetentionDays", + "name", + "rootUser", + "skuName", + "storageAutoGrow", + "storageGb") + .containsExactly( + postgres.getAzureRegion(), + postgres.getBackupRetentionDays(), + postgres.getName(), + postgres.getRootUser(), + postgres.getSkuName().getId(), + postgres.getStorageAutoGrow().getId(), + postgres.getStorageGb()); + } - private void assertPostgresDb(Map lsDtoMap, AzurePostgreSqlDatabase database) { - var dto = lsDtoMap.get(database.getId().getValue()); - assertGenericComponent(dto, database, ComponentType.PAAS_POSTGRESQL_DATABASE.getId()); - assertThat(dto.getParameters()) - .extracting( - "azureRegion", - "name", - "schema") - .containsExactly( - database.getAzureRegion(), - database.getName(), - database.getSchema()); - } + private void assertPostgresDb(Map lsDtoMap, AzurePostgreSqlDatabase database) { + var dto = lsDtoMap.get(database.getId().getValue()); + assertGenericComponent(dto, database, ComponentType.PAAS_POSTGRESQL_DATABASE.getId()); + assertThat(dto.getParameters()) + .extracting( + "azureRegion", + "name", + "schema") + .containsExactly( + database.getAzureRegion(), + database.getName(), + database.getSchema()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemServiceTest.java index c314afaf..03ff67b4 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemServiceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/LiveSystemServiceTest.java @@ -3,11 +3,11 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; import com.github.tomakehurst.wiremock.junit5.WireMockTest; import com.yanchware.fractal.sdk.configuration.SdkConfiguration; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; import com.yanchware.fractal.sdk.domain.environment.EnvironmentType; import com.yanchware.fractal.sdk.domain.environment.ManagementEnvironment; import com.yanchware.fractal.sdk.domain.exceptions.InstantiatorException; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureRegion; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.AzureResourceGroup; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosGremlinDatabase; @@ -35,8 +35,8 @@ public class LiveSystemServiceTest { @Test public void urlPathMatching_when_postRequestToLiveSystem(WireMockRuntimeInfo wmRuntimeInfo) throws InstantiatorException { var httpClient = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); + .version(HttpClient.Version.HTTP_2) + .build(); var sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); var liveSystemsFactory = new LiveSystemsFactory(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); var liveSystemsService = new LiveSystemService(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); @@ -44,53 +44,53 @@ public void urlPathMatching_when_postRequestToLiveSystem(WireMockRuntimeInfo wmR var resourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, ownerId, "rg"); var inputStream = getClass().getClassLoader() - .getResourceAsStream("test-resources/postRequestToLiveSystemBody.json"); + .getResourceAsStream("test-resources/postRequestToLiveSystemBody.json"); assertThat(inputStream).isNotNull(); var postRequestToLiveSystemBody = StringHandler.getStringFromInputStream(inputStream); var managementEnvironment = ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - ownerId, - "5d5bc38d-1d23-4d10-8")) - .withResourceGroup(ResourceGroupId.fromString("Personal/b2bd7eab-ee3d-4603-86ac-3112ff6b2175/rg")) - .build(); - + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + ownerId, + "5d5bc38d-1d23-4d10-8")) + .withResourceGroup(ResourceGroupId.fromString("Personal/b2bd7eab-ee3d-4603-86ac-3112ff6b2175/rg")) + .build(); + var liveSystem = liveSystemsFactory.builder() - .withId(new LiveSystemIdValue(resourceGroupId, "livesystem-name")) - .withFractalId(new FractalIdValue(resourceGroupId, "fractalName", "fractalVersion" )) - .withDescription("prod") - .withEnvironmentId(managementEnvironment.getId()) - .withStandardProvider(ProviderType.AZURE) - .withComponent(AzureCosmosGremlinDbms.builder() - .withId("cosmos-graph-1") - .withMaxTotalThroughput(500) - .withAzureResourceGroup( - AzureResourceGroup.builder() - .withName("MyRg") - .withRegion(AzureRegion.EAST_ASIA) - .build()) - .withCosmosEntity(AzureCosmosGremlinDatabase.builder() - .withId("graph-db-1") - .build()) - .build()) - .build(); + .withId(new LiveSystemIdValue(resourceGroupId, "livesystem-name")) + .withFractalId(new FractalIdValue(resourceGroupId, "fractalName", "fractalVersion")) + .withDescription("prod") + .withEnvironmentId(managementEnvironment.getId()) + .withStandardProvider(ProviderType.AZURE) + .withComponent(AzureCosmosGremlinDbms.builder() + .withId("cosmos-graph-1") + .withMaxTotalThroughput(500) + .withAzureResourceGroup( + AzureResourceGroup.builder() + .withName("MyRg") + .withRegion(AzureRegion.EAST_ASIA) + .build()) + .withCosmosEntity(AzureCosmosGremlinDatabase.builder() + .withId("graph-db-1") + .build()) + .build()) + .build(); stubFor(post(urlPathMatching("/livesystems/")) - .withRequestBody(equalToJson(postRequestToLiveSystemBody, true, false)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json"))); + .withRequestBody(equalToJson(postRequestToLiveSystemBody, true, false)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json"))); liveSystemsService.instantiateLiveSystem( - liveSystem.getId().toString(), - liveSystem.getFractalId(), - liveSystem.getDescription(), - null, - liveSystem.blueprintMapFromLiveSystemComponents(), - liveSystem.getEnvironment()); + liveSystem.getId().toString(), + liveSystem.getFractalId(), + liveSystem.getDescription(), + null, + liveSystem.blueprintMapFromLiveSystemComponents(), + liveSystem.getEnvironment()); verify(postRequestedFor(urlPathEqualTo("/livesystems/"))); } @@ -98,21 +98,53 @@ public void urlPathMatching_when_postRequestToLiveSystem(WireMockRuntimeInfo wmR @Test public void urlPathMatching_when_getRequestToLiveSystemMutation(WireMockRuntimeInfo wmRuntimeInfo) throws InstantiatorException { HttpClient httpClient = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); + .version(HttpClient.Version.HTTP_2) + .build(); SdkConfiguration sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); var liveSystemService = new LiveSystemService(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); var resourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"); var url = String.format("/livesystems/%s/livesystem-name/mutations/mutation-id", resourceGroupId); stubFor(get(urlPathMatching(url)) - .willReturn(aResponse() - .withStatus(200) - .withBody("{\"liveSystemId\":\"fancy-group/CompanyCloud\",\"id\":\"a09f1ca7-5ee8-4d53-a187-644146d19479\",\"status\":\"Completed\",\"created\":\"2023-04-13T23:24:29.503384+00:00\",\"lastUpdated\":\"2023-04-13T23:24:29.503384+00:00\",\"componentsReadyIds\":[\"company-cloud\",\"relational-dbms-platform\"],\"componentsCompletedIds\":[],\"componentsFailedIds\":[],\"componentsById\":{\"company-cloud\":{\"status\":\"Instantiating\",\"outputFields\":{\"cluster\":{\"abc\":123}},\"lastUpdated\":\"2023-04-13T23:24:30.948156+00:00\",\"lastOperationRetried\":0,\"provider\":\"Azure\",\"lastOperationStatusMessage\":\"\",\"displayName\":\"AKS instantiation\",\"description\":\"Cloud AKS cluster\",\"type\":\"NetworkAndCompute.PaaS.ContainerPlatform\",\"id\":\"company-cloud\",\"version\":\"1.0\",\"parameters\":{\"region\":\"westeurope\",\"network\":\"network-host\",\"nodePools\":[{\"name\":\"linuxdynamic\",\"osType\":\"LINUX\",\"maxSurge\":1,\"diskSizeGb\":128,\"machineType\":\"STANDARD_B4MS\",\"maxNodeCount\":9,\"minNodeCount\":1,\"agentPoolMode\":\"SYSTEM\",\"maxPodsPerNode\":30,\"initialNodeCount\":1},{\"name\":\"windyn\",\"osType\":\"WINDOWS\",\"maxSurge\":1,\"diskSizeGb\":128,\"machineType\":\"STANDARD_B4MS\",\"maxNodeCount\":9,\"minNodeCount\":1,\"agentPoolMode\":\"USER\",\"maxPodsPerNode\":30,\"initialNodeCount\":1}],\"podsRange\":\"tier-1-pods\",\"subNetwork\":\"compute-tier-1\",\"serviceRange\":\"tier-1-services\"},\"dependencies\":[],\"links\":[]},\"company-controller\":{\"status\":\"Instantiating\",\"outputFields\":{},\"lastUpdated\":\"2023-04-13T23:24:30.948169+00:00\",\"lastOperationRetried\":0,\"provider\":\"Azure\",\"lastOperationStatusMessage\":\"\",\"displayName\":\"Company controller\",\"description\":\"Company controller\",\"type\":\"CustomWorkloads.Caas.K8sWorkload\",\"id\":\"company-controller\",\"version\":\"1.0\",\"parameters\":{\"roles\":[],\"repoId\":\"Company.Cloud/Company.Cloud.Controller\",\"namespace\":\"company-cloud\",\"sshRepositoryURI\":\"git@ssh.dev.azure.com:v3/CompanyCloud/Company.Cloud/Company.Cloud.Controller\",\"containerPlatform\":\"company-cloud\",\"privateSSHKeySecretId\":\"fractalDeployerSshKey\",\"privateSSHKeyPassphraseSecretId\":\"fractalDeployerSshKeyPassphrase\"},\"dependencies\":[\"company-cloud\"],\"links\":[]},\"relational-dbms-platform\":{\"status\":\"Instantiating\",\"outputFields\":{},\"lastUpdated\":\"2023-04-13T23:24:30.948178+00:00\",\"lastOperationRetried\":0,\"provider\":\"Azure\",\"lastOperationStatusMessage\":\"\",\"displayName\":\"Relational DBMS Platform\",\"description\":\"Platform providing RDBMS as a service\",\"type\":\"DataStorage.PaaS.PostgreSQL\",\"id\":\"relational-dbms-platform\",\"version\":\"1.0\",\"parameters\":{\"tier\":\"GP_Gen5_4\",\"region\":\"westeurope\",\"version\":\"11\",\"storageAutoResize\":true},\"dependencies\":[],\"links\":[]}},\"componentsBlocked\":{\"company-cloud\":[\"company-controller\"]}}") - .withHeader("Content-Type", "application/json"))); + .willReturn(aResponse() + .withStatus(200) + .withBody("{\"liveSystemId\":\"fancy-group/CompanyCloud\",\"id\":\"a09f1ca7-5ee8-4d53-a187-644146d19479\"," + + "\"status\":\"Completed\",\"created\":\"2023-04-13T23:24:29.503384+00:00\"," + + "\"lastUpdated\":\"2023-04-13T23:24:29.503384+00:00\",\"componentsReadyIds\":[\"company-cloud\"," + + "\"relational-dbms-platform\"],\"componentsCompletedIds\":[],\"componentsFailedIds\":[]," + + "\"componentsById\":{\"company-cloud\":{\"status\":\"Instantiating\"," + + "\"outputFields\":{\"cluster\":{\"abc\":123}},\"lastUpdated\":\"2023-04-13T23:24:30.948156+00:00\"," + + "\"lastOperationRetried\":0,\"provider\":\"Azure\",\"lastOperationStatusMessage\":\"\"," + + "\"displayName\":\"AKS instantiation\",\"description\":\"Cloud AKS cluster\",\"type\":\"NetworkAndCompute" + + ".PaaS.ContainerPlatform\",\"id\":\"company-cloud\",\"version\":\"1.0\"," + + "\"parameters\":{\"region\":\"westeurope\",\"network\":\"network-host\"," + + "\"nodePools\":[{\"name\":\"linuxdynamic\",\"osType\":\"LINUX\",\"maxSurge\":1,\"diskSizeGb\":128," + + "\"machineType\":\"STANDARD_B4MS\",\"maxNodeCount\":9,\"minNodeCount\":1,\"agentPoolMode\":\"SYSTEM\"," + + "\"maxPodsPerNode\":30,\"initialNodeCount\":1},{\"name\":\"windyn\",\"osType\":\"WINDOWS\",\"maxSurge\":1," + + "\"diskSizeGb\":128,\"machineType\":\"STANDARD_B4MS\",\"maxNodeCount\":9,\"minNodeCount\":1," + + "\"agentPoolMode\":\"USER\",\"maxPodsPerNode\":30,\"initialNodeCount\":1}],\"podsRange\":\"tier-1-pods\"," + + "\"subNetwork\":\"compute-tier-1\",\"serviceRange\":\"tier-1-services\"},\"dependencies\":[],\"links\":[]}," + + "\"company-controller\":{\"status\":\"Instantiating\",\"outputFields\":{}," + + "\"lastUpdated\":\"2023-04-13T23:24:30.948169+00:00\",\"lastOperationRetried\":0,\"provider\":\"Azure\"," + + "\"lastOperationStatusMessage\":\"\",\"displayName\":\"Company controller\",\"description\":\"Company " + + "controller\",\"type\":\"CustomWorkloads.Caas.K8sWorkload\",\"id\":\"company-controller\",\"version\":\"1" + + ".0\",\"parameters\":{\"roles\":[],\"repoId\":\"Company.Cloud/Company.Cloud.Controller\"," + + "\"namespace\":\"company-cloud\",\"sshRepositoryURI\":\"git@ssh.dev.azure.com:v3/CompanyCloud/Company" + + ".Cloud/Company.Cloud.Controller\",\"containerPlatform\":\"company-cloud\"," + + "\"privateSSHKeySecretId\":\"fractalDeployerSshKey\"," + + "\"privateSSHKeyPassphraseSecretId\":\"fractalDeployerSshKeyPassphrase\"}," + + "\"dependencies\":[\"company-cloud\"],\"links\":[]}," + + "\"relational-dbms-platform\":{\"status\":\"Instantiating\",\"outputFields\":{}," + + "\"lastUpdated\":\"2023-04-13T23:24:30.948178+00:00\",\"lastOperationRetried\":0,\"provider\":\"Azure\"," + + "\"lastOperationStatusMessage\":\"\",\"displayName\":\"Relational DBMS Platform\"," + + "\"description\":\"Platform providing RDBMS as a service\",\"type\":\"DataStorage.PaaS.PostgreSQL\"," + + "\"id\":\"relational-dbms-platform\",\"version\":\"1.0\",\"parameters\":{\"tier\":\"GP_Gen5_4\"," + + "\"region\":\"westeurope\",\"version\":\"11\",\"storageAutoResize\":true},\"dependencies\":[]," + + "\"links\":[]}},\"componentsBlocked\":{\"company-cloud\":[\"company-controller\"]}}") + .withHeader("Content-Type", "application/json"))); liveSystemService.checkLiveSystemMutationStatus( - new LiveSystemIdValue(resourceGroupId, "livesystem-name"), - "mutation-id"); + new LiveSystemIdValue(resourceGroupId, "livesystem-name"), + "mutation-id"); verify(getRequestedFor(urlPathEqualTo(url))); } @@ -120,28 +152,28 @@ public void urlPathMatching_when_getRequestToLiveSystemMutation(WireMockRuntimeI @Test public void testRetrieveLiveSystem_Success(WireMockRuntimeInfo wmRuntimeInfo) throws InstantiatorException { HttpClient httpClient = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .build(); - + .version(HttpClient.Version.HTTP_2) + .build(); + SdkConfiguration sdkConfiguration = new LocalSdkConfiguration(wmRuntimeInfo.getHttpBaseUrl()); - + var liveSystemService = new LiveSystemService(httpClient, sdkConfiguration, RetryRegistry.ofDefaults()); var resourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"); LiveSystemIdValue liveSystemId = new LiveSystemIdValue(resourceGroupId, "Development"); var inputStream = getClass().getClassLoader() - .getResourceAsStream("test-resources/getRequestToLiveSystemResponse.json"); + .getResourceAsStream("test-resources/getRequestToLiveSystemResponse.json"); assertThat(inputStream).isNotNull(); - var liveSystemResponse= StringHandler.getStringFromInputStream(inputStream); - + var liveSystemResponse = StringHandler.getStringFromInputStream(inputStream); + stubFor(get(urlPathMatching(String.format("/livesystems/%s/Development", resourceGroupId))) - .willReturn(aResponse() - .withStatus(200) - .withBody(liveSystemResponse) - .withHeader("Content-Type", "application/json"))); + .willReturn(aResponse() + .withStatus(200) + .withBody(liveSystemResponse) + .withHeader("Content-Type", "application/json"))); var result = liveSystemService.retrieveLiveSystem(liveSystemId); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/OperationalServiceWindowTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/OperationalServiceWindowTest.java index c2538b6c..220414c8 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/OperationalServiceWindowTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/OperationalServiceWindowTest.java @@ -46,7 +46,7 @@ void oneOffRule_allowsOnlyThatDateRange() { var inside = ZonedDateTime.of(2025, 12, 27, 8, 0, 0, 0, ZONE_ID).toInstant(); var before = ZonedDateTime.of(2025, 12, 26, 23, 59, 0, 0, ZONE_ID).toInstant(); - var after = ZonedDateTime.of(2025, 12, 27, 12, 0, 0, 0, ZONE_ID).toInstant(); + var after = ZonedDateTime.of(2025, 12, 27, 12, 0, 0, 0, ZONE_ID).toInstant(); assertTrue(osw.isAllowed(inside)); assertFalse(osw.isAllowed(before)); @@ -115,7 +115,7 @@ void windowsBetween_mergesOverlappingRules() { .build(); var from = ZonedDateTime.of(2025, 6, 3, 0, 0, 0, 0, ZONE_ID); // Tue - var to = from.plusDays(1); + var to = from.plusDays(1); var list = osw.windowsBetween(from, to).toList(); assertEquals(1, list.size(), "overlapping rules should merge into one window"); @@ -132,7 +132,7 @@ void dstSpringForward_isHandledByZonedDateTime() { .build(); var from = ZonedDateTime.of(2025, 3, 30, 0, 0, 0, 0, ZONE_ID); - var to = from.plusDays(1); + var to = from.plusDays(1); var list = osw.windowsBetween(from, to).toList(); assertEquals(1, list.size()); @@ -161,7 +161,7 @@ void windowsBetween_iteratesWithinBounds() { var osw = nightly(); var start = ZonedDateTime.of(2025, 6, 2, 0, 0, 0, 0, ZONE_ID); // Monday - var end = start.plusDays(7); + var end = start.plusDays(7); var windows = osw.windowsBetween(start, end).toList(); assertFalse(windows.isEmpty()); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlTypeTest.java index b555950b..e520d4b4 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/SourceControlTypeTest.java @@ -9,20 +9,20 @@ class SourceControlTypeTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(SourceControlType.fromString("BitbucketGit"), SourceControlType.BITBUCKET_GIT), - () -> assertEquals(SourceControlType.fromString("BitbucketHg"), SourceControlType.BITBUCKET_HG), - () -> assertEquals(SourceControlType.fromString("CodePlexGit"), SourceControlType.CODE_PLEX_GIT), - () -> assertEquals(SourceControlType.fromString("CodePlexHg"), SourceControlType.CODE_PLEX_HG), - () -> assertEquals(SourceControlType.fromString("Dropbox"), SourceControlType.DROPBOX), - () -> assertEquals(SourceControlType.fromString("ExternalGit"), SourceControlType.EXTERNAL_GIT), - () -> assertEquals(SourceControlType.fromString("ExternalHg"), SourceControlType.EXTERNAL_HG), - () -> assertEquals(SourceControlType.fromString("GitHub"), SourceControlType.GIT_HUB), - () -> assertEquals(SourceControlType.fromString("LocalGit"), SourceControlType.LOCAL_GIT), - () -> assertEquals(SourceControlType.fromString("None"), SourceControlType.NONE), - () -> assertEquals(SourceControlType.fromString("OneDrive"), SourceControlType.ONE_DRIVE), - () -> assertEquals(SourceControlType.fromString("Tfs"), SourceControlType.TFS), - () -> assertEquals(SourceControlType.fromString("VSO"), SourceControlType.VSO), - () -> assertEquals(SourceControlType.fromString("VSTSRM"), SourceControlType.VSTSRM) + () -> assertEquals(SourceControlType.fromString("BitbucketGit"), SourceControlType.BITBUCKET_GIT), + () -> assertEquals(SourceControlType.fromString("BitbucketHg"), SourceControlType.BITBUCKET_HG), + () -> assertEquals(SourceControlType.fromString("CodePlexGit"), SourceControlType.CODE_PLEX_GIT), + () -> assertEquals(SourceControlType.fromString("CodePlexHg"), SourceControlType.CODE_PLEX_HG), + () -> assertEquals(SourceControlType.fromString("Dropbox"), SourceControlType.DROPBOX), + () -> assertEquals(SourceControlType.fromString("ExternalGit"), SourceControlType.EXTERNAL_GIT), + () -> assertEquals(SourceControlType.fromString("ExternalHg"), SourceControlType.EXTERNAL_HG), + () -> assertEquals(SourceControlType.fromString("GitHub"), SourceControlType.GIT_HUB), + () -> assertEquals(SourceControlType.fromString("LocalGit"), SourceControlType.LOCAL_GIT), + () -> assertEquals(SourceControlType.fromString("None"), SourceControlType.NONE), + () -> assertEquals(SourceControlType.fromString("OneDrive"), SourceControlType.ONE_DRIVE), + () -> assertEquals(SourceControlType.fromString("Tfs"), SourceControlType.TFS), + () -> assertEquals(SourceControlType.fromString("VSO"), SourceControlType.VSO), + () -> assertEquals(SourceControlType.fromString("VSTSRM"), SourceControlType.VSTSRM) ); } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassadorTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassadorTest.java index 0fcc82e8..93a450bc 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassadorTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSAmbassadorTest.java @@ -14,8 +14,8 @@ public void exceptionThrown_when_ambassadorCreatedWithNullId() { assertThatThrownBy(() -> CaaSAmbassador.builder() .withId("") .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("A valid component id cannot be null, empty or contain spaces"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("A valid component id cannot be null, empty or contain spaces"); } @Test @@ -23,8 +23,8 @@ public void exceptionThrown_when_ambassadorCreatedWithNoNamespace() { assertThatThrownBy(() -> CaaSAmbassador.builder() .withId(ComponentId.from("ambassador")) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[CaaSAmbassador Validation] Namespace has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[CaaSAmbassador Validation] Namespace has not been defined and it is required"); } @Test @@ -33,8 +33,9 @@ public void exceptionThrown_when_ambassadorCreatedWithEmptyContainerPlatform() { .withNamespace("ambassador") .withContainerPlatform("") .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[CaaSAmbassador Validation] ContainerPlatform defined was either empty or blank and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[CaaSAmbassador Validation] ContainerPlatform defined was either empty or blank and it " + + "is required"); } @Test @@ -43,19 +44,21 @@ public void exceptionThrown_when_ambassadorCreatedWithEmptyLicense() { assertThatThrownBy(ambassadorBuilder::build).isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("License Key defined was either empty or blank"); } - + @Test public void exceptionThrown_when_ambassadorCreatedWithEmptyHostOwnerEmail() { var ambassadorBuilder = ambassadorBuilder().withHostOwnerEmail(""); assertThatThrownBy(ambassadorBuilder::build) - .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Host Owner Email has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Host Owner Email has not been defined and " + + "it is required"); } @Test public void exceptionThrown_when_ambassadorCreatedWithEmptyAcmeProviderAuthority() { var ambassadorBuilder = ambassadorBuilder().withAcmeProviderAuthority(""); assertThatThrownBy(ambassadorBuilder::build) - .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("[CaaSAmbassador Validation] Automated Certificate Management Environment (ACME) Provider Authority has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("[CaaSAmbassador Validation] Automated " + + "Certificate Management Environment (ACME) Provider Authority has not been defined and it is required"); } @Test @@ -78,11 +81,11 @@ public void typeIsAmbassador_when_ambassadorIsBuilt() { private CaaSAmbassador.AmbassadorBuilder ambassadorBuilder() { return CaaSAmbassador.builder() - .withId("ambassador") - .withNamespace("ambassador") - .withHost("host") - .withHostOwnerEmail("email@email.com") - .withAcmeProviderAuthority("authority") - .withTlsSecretName("tls"); + .withId("ambassador") + .withNamespace("ambassador") + .withHost("host") + .withHostOwnerEmail("email@email.com") + .withAcmeProviderAuthority("authority") + .withTlsSecretName("tls"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStoreTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStoreTest.java index de0efa20..27714b04 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStoreTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticDataStoreTest.java @@ -7,97 +7,97 @@ import static org.assertj.core.api.Assertions.*; class CaaSElasticDataStoreTest { - @Test - public void exceptionThrown_when_BuiltWithNullId() { - assertThatThrownBy(() -> CaaSElasticDataStore.builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); - } - - @Test - public void exceptionThrown_when_BuiltWithContainerPlatformBlank() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withContainerPlatform("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank"); - } - - @Test - public void exceptionThrown_when_BuiltWithContainerPlatformEmpty() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withContainerPlatform(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank"); - } - - @Test - public void exceptionThrown_when_BuiltWithEmptyValues() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Namespace has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithZeroInstances() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withInstances(0).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Instances defined was either 0 or negative"); - } - - @Test - public void exceptionThrown_when_BuiltWithNegativeInstances() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withInstances(-1).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Instances defined was either 0 or negative"); - } - - @Test - public void exceptionThrown_when_BuiltWithEmptyElasticVersion() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withElasticVersion("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Version has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithBlankElasticVersion() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withElasticVersion(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Version has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithNullElasticVersion() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withElasticVersion(null).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Version has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithEmptyElasticStorage() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withStorage("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Storage has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithBlankElasticStorage() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withStorage(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Storage has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithNullElasticStorage() { - assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withStorage(null).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Storage has not been defined and it is required"); - } - - @Test - public void typeIsElasticDataStore_when_WithAllRequiredValues() { - assertThatCode(TestUtils::getElasticDataStoreExample).doesNotThrowAnyException(); - assertThat(TestUtils.getElasticDataStoreExample().getType()).isEqualTo(CAAS_ELASTIC_DATASTORE); - } - - private static CaaSElasticDataStore.ElasticDataStoreBuilder getElasticDataStoreBuilder() { - return CaaSElasticDataStore.builder().withId("el-data-store"); - } + @Test + public void exceptionThrown_when_BuiltWithNullId() { + assertThatThrownBy(() -> CaaSElasticDataStore.builder().withId("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); + } + + @Test + public void exceptionThrown_when_BuiltWithContainerPlatformBlank() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withContainerPlatform("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank"); + } + + @Test + public void exceptionThrown_when_BuiltWithContainerPlatformEmpty() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withContainerPlatform(" ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank"); + } + + @Test + public void exceptionThrown_when_BuiltWithEmptyValues() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Namespace has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithZeroInstances() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withInstances(0).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Instances defined was either 0 or negative"); + } + + @Test + public void exceptionThrown_when_BuiltWithNegativeInstances() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withInstances(-1).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Instances defined was either 0 or negative"); + } + + @Test + public void exceptionThrown_when_BuiltWithEmptyElasticVersion() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withElasticVersion("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Version has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithBlankElasticVersion() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withElasticVersion(" ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Version has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithNullElasticVersion() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withElasticVersion(null).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Version has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithEmptyElasticStorage() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withStorage("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Storage has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithBlankElasticStorage() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withStorage(" ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Storage has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithNullElasticStorage() { + assertThatThrownBy(() -> getElasticDataStoreBuilder().withNamespace("namespace").withStorage(null).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Storage has not been defined and it is required"); + } + + @Test + public void typeIsElasticDataStore_when_WithAllRequiredValues() { + assertThatCode(TestUtils::getElasticDataStoreExample).doesNotThrowAnyException(); + assertThat(TestUtils.getElasticDataStoreExample().getType()).isEqualTo(CAAS_ELASTIC_DATASTORE); + } + + private static CaaSElasticDataStore.ElasticDataStoreBuilder getElasticDataStoreBuilder() { + return CaaSElasticDataStore.builder().withId("el-data-store"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLoggingTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLoggingTest.java index 6d23b7ac..342f7bb5 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLoggingTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSElasticLoggingTest.java @@ -7,96 +7,97 @@ import static org.assertj.core.api.Assertions.*; class CaaSElasticLoggingTest { - @Test - public void exceptionThrown_when_BuiltWithNullId() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); - } - - @Test - public void exceptionThrown_when_BuiltWithContainerPlatformBlank() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withContainerPlatform("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank"); - } - - @Test - public void exceptionThrown_when_BuiltWithContainerPlatformEmpty() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withContainerPlatform(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank"); - } - - @Test - public void exceptionThrown_when_BuiltWithEmptyValues() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Namespace has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithZeroInstances() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withInstances(0).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Instances defined was either 0 or negative"); - } - - @Test - public void exceptionThrown_when_BuiltWithNegativeInstances() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withInstances(-1).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Instances defined was either 0 or negative"); - } - - @Test - public void exceptionThrown_when_BuiltWithEmptyElasticVersion() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withElasticVersion("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Version has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithBlankElasticVersion() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withElasticVersion(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Version has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithNullElasticVersion() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withElasticVersion(null).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Elastic Version has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithEmptyElasticStorage() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withStorage("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Storage has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithBlankElasticStorage() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withStorage(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Storage has not been defined and it is required"); - } - - @Test - public void exceptionThrown_when_BuiltWithNullElasticStorage() { - assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withStorage(null).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Storage has not been defined and it is required"); - } - - @Test - public void typeIsElasticLogging_when_WithAllRequiredValues() { - assertThatCode(TestUtils::getElasticLoggingExample).doesNotThrowAnyException(); - var elasticLogging = TestUtils.getElasticLoggingExample(); - - assertThat(elasticLogging.getType()).isEqualTo(CAAS_ELASTIC_LOGGING); - assertThat(elasticLogging.isRecreateOnFailure()).isFalse(); - } + @Test + public void exceptionThrown_when_BuiltWithNullId() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); + } + + @Test + public void exceptionThrown_when_BuiltWithContainerPlatformBlank() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withContainerPlatform("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank"); + } + + @Test + public void exceptionThrown_when_BuiltWithContainerPlatformEmpty() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withContainerPlatform(" ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank"); + } + + @Test + public void exceptionThrown_when_BuiltWithEmptyValues() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Namespace has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithZeroInstances() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withInstances(0).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Instances defined was either 0 or negative"); + } + + @Test + public void exceptionThrown_when_BuiltWithNegativeInstances() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withInstances(-1).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Instances defined was either 0 or negative"); + } + + @Test + public void exceptionThrown_when_BuiltWithEmptyElasticVersion() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withElasticVersion("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Version has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithBlankElasticVersion() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withElasticVersion(" ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Version has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithNullElasticVersion() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withElasticVersion(null).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Elastic Version has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithEmptyElasticStorage() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withStorage("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Storage has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithBlankElasticStorage() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withStorage(" " + + " ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Storage has not been defined and it is required"); + } + + @Test + public void exceptionThrown_when_BuiltWithNullElasticStorage() { + assertThatThrownBy(() -> CaaSElasticLogging.builder().withId("el-log").withNamespace("namespace").withStorage(null).build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Storage has not been defined and it is required"); + } + + @Test + public void typeIsElasticLogging_when_WithAllRequiredValues() { + assertThatCode(TestUtils::getElasticLoggingExample).doesNotThrowAnyException(); + var elasticLogging = TestUtils.getElasticLoggingExample(); + + assertThat(elasticLogging.getType()).isEqualTo(CAAS_ELASTIC_LOGGING); + assertThat(elasticLogging.isRecreateOnFailure()).isFalse(); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKafkaClusterTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKafkaClusterTest.java index 7c78209e..0b7968a7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKafkaClusterTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKafkaClusterTest.java @@ -56,7 +56,8 @@ public void propertiesAreSet_when_kafkaCluster_isProperlyConfigured() { .withKafkaTopics(List.of( KafkaTopic.builder().withId(ComponentId.from("topic")).withDisplayName("kafka-topic").build())) .withKafkaUsers(List.of( - KafkaUser.builder().withId(ComponentId.from("user-1")).withDisplayName("kafka-user").withTopicReadACL("svcName").build())).build(); + KafkaUser.builder().withId(ComponentId.from("user-1")).withDisplayName("kafka-user") + .withTopicReadACL("svcName").build())).build(); assertThat(kafkaCluster) .returns("azure-kafka", from(x -> x.getId().getValue())) diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesCustomWorkloadTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesCustomWorkloadTest.java index 6eb40795..163c55a7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesCustomWorkloadTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSKubernetesCustomWorkloadTest.java @@ -12,43 +12,43 @@ public class CaaSKubernetesCustomWorkloadTest { @Test public void exceptionThrown_when_workloadBuiltWithNullId() { assertThatThrownBy(() -> builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); } @Test public void exceptionThrown_when_workloadBuiltWithContainerPlatformBlank() { assertThatThrownBy(() -> generateBuilder().withContainerPlatform("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank and it is required"); } @Test public void exceptionThrown_when_workloadBuiltWithContainerPlatformEmpty() { assertThatThrownBy(() -> generateBuilder().withContainerPlatform(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank and it is required"); } @Test public void exceptionThrown_when_workloadBuiltWithEmptyValues() { assertThatThrownBy(() -> generateBuilder().build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContainingAll( - "Namespace has not been defined and it is required", - "sshRepositoryURI is either empty or blank", - "repoId is either empty or blank"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContainingAll( + "Namespace has not been defined and it is required", + "sshRepositoryURI is either empty or blank", + "repoId is either empty or blank"); } @Test public void typeIsKubernetes_when_workloadBuiltWithAllRequiredValues() { var builder = generateBuilder() - .withNamespace("fractal") - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withBranchName("branch-name"); + .withNamespace("fractal") + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withBranchName("branch-name"); assertThat(builder.build().getType()).isEqualTo(CAAS_K8S_WORKLOAD); assertThatCode(builder::build).doesNotThrowAnyException(); } @@ -57,20 +57,20 @@ public void typeIsKubernetes_when_workloadBuiltWithAllRequiredValues() { public void properValuesSet_when_workloadBuiltWithAllRequiredValues() { var serviceAccountName = "required-service-account-name"; var customWorkload = generateBuilder() - .withNamespace("fractal") - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withBranchName("branch-name") - .withServiceAccountName(serviceAccountName) - .withWorkloadIdentityEnabled(false) - .withEnvironmentSecretShortName("secret-1") - .withEnvironmentSecretShortName("secret-2") - .withEnvironmentSecretShortName("secret-3") - .withCiCdProfileShortName("ci-cd-profile-name") - .build(); - + .withNamespace("fractal") + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withBranchName("branch-name") + .withServiceAccountName(serviceAccountName) + .withWorkloadIdentityEnabled(false) + .withEnvironmentSecretShortName("secret-1") + .withEnvironmentSecretShortName("secret-2") + .withEnvironmentSecretShortName("secret-3") + .withCiCdProfileShortName("ci-cd-profile-name") + .build(); + assertThat(customWorkload.getServiceAccountName()).isEqualTo(serviceAccountName); assertThat(customWorkload.getWorkloadIdentityEnabled()).isFalse(); assertThat(customWorkload.getEnvironmentSecretShortNames()).hasSize(3); @@ -80,43 +80,43 @@ public void properValuesSet_when_workloadBuiltWithAllRequiredValues() { @Test public void exceptionThrown_when_workloadBuiltWithWorkloadSecretIdKeyEmpty() { var builder = generateBuilder() - .withNamespace("fractal") - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withSecretIdKey(""); + .withNamespace("fractal") + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withSecretIdKey(""); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Workload Secret Id Key is either empty or blank"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Workload Secret Id Key is either empty or blank"); } @Test public void exceptionThrown_when_workloadBuiltWithBranchNameKeyEmpty() { var builder = generateBuilder() - .withNamespace("fractal") - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withBranchName(""); + .withNamespace("fractal") + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withBranchName(""); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("branchName is either empty or blank and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("branchName is either empty or blank and it is required"); } @Test public void exceptionThrown_when_workloadBuiltWithWorkloadSecretPasswordKeyEmpty() { var builder = generateBuilder() - .withNamespace("fractal") - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withSecretPasswordKey(""); + .withNamespace("fractal") + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withSecretPasswordKey(""); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Workload Secret Password Key is either empty or blank"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Workload Secret Password Key is either empty or blank"); } private KubernetesWorkloadBuilder generateBuilder() { diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSOcelotTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSOcelotTest.java index 9db8db4e..3e59b876 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSOcelotTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSOcelotTest.java @@ -6,51 +6,52 @@ import static org.assertj.core.api.Assertions.*; class CaaSOcelotTest { - @Test - public void exceptionThrown_when_ocelotBuiltWithNullId() { - assertThatThrownBy(() -> CaaSOcelot.builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); - } + @Test + public void exceptionThrown_when_ocelotBuiltWithNullId() { + assertThatThrownBy(() -> CaaSOcelot.builder().withId("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); + } - @Test - public void exceptionThrown_when_ocelotBuiltWithContainerPlatformBlank() { - assertThatThrownBy(() -> CaaSOcelot.builder().withId("ocelot").withContainerPlatform("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank"); - } + @Test + public void exceptionThrown_when_ocelotBuiltWithContainerPlatformBlank() { + assertThatThrownBy(() -> CaaSOcelot.builder().withId("ocelot").withContainerPlatform("").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank"); + } - @Test - public void exceptionThrown_when_ocelotBuiltWithContainerPlatformEmpty() { - assertThatThrownBy(() -> CaaSOcelot.builder().withId("ocelot").withContainerPlatform(" ").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("ContainerPlatform defined was either empty or blank"); - } + @Test + public void exceptionThrown_when_ocelotBuiltWithContainerPlatformEmpty() { + assertThatThrownBy(() -> CaaSOcelot.builder().withId("ocelot").withContainerPlatform(" ").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("ContainerPlatform defined was either empty or blank"); + } - @Test - public void exceptionThrown_when_ocelotBuiltWithEmptyValues() { - assertThatThrownBy(() -> CaaSOcelot.builder().withId("ocelot").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContainingAll( - "Namespace has not been defined and it is required", - "Host has not been defined and it is required", - "Host Owner Email has not been defined and it is required", - "Cookie max age has not been defined or is less"); - } + @Test + public void exceptionThrown_when_ocelotBuiltWithEmptyValues() { + assertThatThrownBy(() -> CaaSOcelot.builder().withId("ocelot").build()). + isInstanceOf(IllegalArgumentException.class). + hasMessageContainingAll( + "Namespace has not been defined and it is required", + "Host has not been defined and it is required", + "Host Owner Email has not been defined and it is required", + "Cookie max age has not been defined or is less"); + } - @Test - public void typeIsOcelot_when_BuiltWithAllRequiredValues() { - var builder = CaaSOcelot.builder() - .withId("ocelot") - .withNamespace("security") - .withHost("api.fractal-arch.org") - .withHostOwnerEmail("hello@fractal-arch.org") - .withCookieMaxAgeSec(3600) - .withCorsOrigins("https://fractal-arch.org,localhost:8080") - .withPathPrefix("/api/*"); - assertThatCode(builder::build).doesNotThrowAnyException(); - assertThat(builder.build().getType()).isEqualTo(CAAS_OCELOT); - assertThat(builder.build().getCorsOrigins()).hasSize(2); - assertThat(builder.build().getCorsOrigins()).containsExactlyInAnyOrder("https://fractal-arch.org","localhost:8080"); - } + @Test + public void typeIsOcelot_when_BuiltWithAllRequiredValues() { + var builder = CaaSOcelot.builder() + .withId("ocelot") + .withNamespace("security") + .withHost("api.fractal-arch.org") + .withHostOwnerEmail("hello@fractal-arch.org") + .withCookieMaxAgeSec(3600) + .withCorsOrigins("https://fractal-arch.org,localhost:8080") + .withPathPrefix("/api/*"); + assertThatCode(builder::build).doesNotThrowAnyException(); + assertThat(builder.build().getType()).isEqualTo(CAAS_OCELOT); + assertThat(builder.build().getCorsOrigins()).hasSize(2); + assertThat(builder.build().getCorsOrigins()).containsExactlyInAnyOrder("https://fractal-arch.org", "localhost" + + ":8080"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheusTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheusTest.java index dfbca248..35adffa6 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheusTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSPrometheusTest.java @@ -35,7 +35,8 @@ public void exceptionThrown_when_prometheusCreatedWithEmptyContainerPlatform() { assertThatThrownBy(prometheusBuilder::build) .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("[CaaSPrometheus Validation] ContainerPlatform defined was either empty or blank and it is required"); + .hasMessageContainingAll("[CaaSPrometheus Validation] ContainerPlatform defined was either empty or blank and " + + "it is required"); } @Test @@ -56,8 +57,8 @@ public void typeIsPrometheus_when_prometheusIsBuilt() { private CaaSPrometheus.PrometheusBuilder prometheusBuilder() { return CaaSPrometheus.builder() - .withId("prometheus") - .withNamespace("prometheus") - .withApiGatewayUrl("apiGatewayUrl"); + .withId("prometheus") + .withNamespace("prometheus") + .withApiGatewayUrl("apiGatewayUrl"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefikTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefikTest.java index 97529e85..c9335001 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefikTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/CaaSTraefikTest.java @@ -19,30 +19,31 @@ class CaaSTraefikTest extends TestWithFixture { @Test public void exceptionThrown_when_traefikCreatedWithNullId() { assertThatThrownBy(() -> CaaSTraefik.builder().withId("")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("A valid component id cannot be null, empty or contain spaces"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("A valid component id cannot be null, empty or contain spaces"); } @Test public void exceptionThrown_when_traefikCreatedWithNoNamespace() { var traefikBuilder = CaaSTraefik.builder() - .withId(ComponentId.from("traefik")); + .withId(ComponentId.from("traefik")); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[CaaSTraefik Validation] Namespace has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[CaaSTraefik Validation] Namespace has not been defined and it is required"); } @Test public void exceptionThrown_when_traefikCreatedWithEmptyContainerPlatform() { var traefikBuilder = CaaSTraefik.builder() - .withId(ComponentId.from("traefik")) - .withNamespace("traefik") - .withContainerPlatform(""); + .withId(ComponentId.from("traefik")) + .withNamespace("traefik") + .withContainerPlatform(""); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[CaaSTraefik Validation] ContainerPlatform defined was either empty or blank and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[CaaSTraefik Validation] ContainerPlatform defined was either empty or blank and it is " + + "required"); } @Test @@ -50,74 +51,74 @@ public void exceptionThrown_when_ambassadorCreatedWithNullEntryPoints() { var traefikBuilder = traefikBuilderWithoutEntryPoints().withEntryPoints(null); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("at least one entrypoint"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("at least one entrypoint"); } @Test public void exceptionThrown_when_ambassadorCreatedWithEmptyEntryPoints() { var traefikBuilder = traefikBuilderWithoutEntryPoints() - .withEntryPoints(new ArrayList<>()); + .withEntryPoints(new ArrayList<>()); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("at least one entrypoint"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("at least one entrypoint"); } @Test public void exceptionThrown_when_ambassadorCreatedWithForwardAuthSettingsMissingClientId() { var traefikBuilder = traefikBuilder() - .withForwardAuth(new ForwardAuthSettings( - null, - a(String.class), - a(String.class), - a(String.class))); + .withForwardAuth(new ForwardAuthSettings( + null, + a(String.class), + a(String.class), + a(String.class))); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("OIDC has been partially configured"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("OIDC has been partially configured"); } @Test public void exceptionThrown_when_ambassadorCreatedWithForwardAuthSettingsMissingClientSecretId() { var traefikBuilder = traefikBuilder() - .withForwardAuth(new ForwardAuthSettings( - a(String.class), - null, - a(String.class), - a(String.class))); + .withForwardAuth(new ForwardAuthSettings( + a(String.class), + null, + a(String.class), + a(String.class))); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("OIDC has been partially configured"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("OIDC has been partially configured"); } @Test public void exceptionThrown_when_ambassadorCreatedWithForwardAuthSettingsForwardAuthSecret() { var traefikBuilder = traefikBuilder() - .withForwardAuth(new ForwardAuthSettings( - a(String.class), - a(String.class), - null, - a(String.class))); + .withForwardAuth(new ForwardAuthSettings( + a(String.class), + a(String.class), + null, + a(String.class))); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("OIDC has been partially configured"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("OIDC has been partially configured"); } @Test public void exceptionThrown_when_ambassadorCreatedWithForwardAuthSettingsIssuer() { var traefikBuilder = traefikBuilder() - .withForwardAuth(new ForwardAuthSettings( - a(String.class), - a(String.class), - a(String.class), - null)); + .withForwardAuth(new ForwardAuthSettings( + a(String.class), + a(String.class), + a(String.class), + null)); assertThatThrownBy(traefikBuilder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("OIDC has been partially configured"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("OIDC has been partially configured"); } @@ -141,111 +142,111 @@ public void typeIsTraefik_when_traefikIsBuilt() { @Test public void recreateOnFailureIsFalse_when_ProperlySet() { var traefik = traefikBuilder() - .withRecreateOnFailure(false) - .build(); - + .withRecreateOnFailure(false) + .build(); + assertThat(traefik.isRecreateOnFailure()).isFalse(); } @Test public void exceptionThrown_when_traefikCreatedWithTracingJaegerNull() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(null) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("JaegerTracing instance cannot be null"); + .withTracing( + TraefikTracing.builder() + .withJaeger(null) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("JaegerTracing instance cannot be null"); } @Test public void exceptionThrown_when_traefikCreatedWithTracingJaegerCollectorEndpointAndLocalAgentPort() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withCollectorEndpoint("https://local.host.com:5778/sampling") - .withLocalAgentPort(5778) - .build()) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("localAgentPort should not be provided when collectorEndpoint is provided"); + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withCollectorEndpoint("https://local.host.com:5778/sampling") + .withLocalAgentPort(5778) + .build()) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("localAgentPort should not be provided when collectorEndpoint is provided"); } @Test public void exceptionThrown_when_traefikCreatedWithTracingJaegerCollectorEndpointAndLocalAgentUrlPath() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withCollectorEndpoint("https://local.host.com:5778/sampling") - .withLocalAgentUrlPath("/sampling") - .build()) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("localAgentUrlPath should not be provided when collectorEndpoint is provided"); + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withCollectorEndpoint("https://local.host.com:5778/sampling") + .withLocalAgentUrlPath("/sampling") + .build()) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("localAgentUrlPath should not be provided when collectorEndpoint is provided"); } @Test public void exceptionThrown_when_traefikCreatedWithTracingJaegerLocalAgentPortOnly() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withLocalAgentPort(5778) - .build()) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("localAgentUrlPath must be defined"); + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withLocalAgentPort(5778) + .build()) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("localAgentUrlPath must be defined"); } @Test public void exceptionThrown_when_traefikCreatedWithTracingJaegerLocalAgentUrlPathOnly() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withLocalAgentUrlPath("/sampling") - .build()) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("localAgentPort must be defined"); + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withLocalAgentUrlPath("/sampling") + .build()) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("localAgentPort must be defined"); } @Test public void exceptionThrown_when_traefikCreatedWithTracingNegativeJaegerLocalAgentPort() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withLocalAgentUrlPath("/sampling") - .withLocalAgentPort(-1) - .build()) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("localAgentPort must be between 1 and 65535"); + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withLocalAgentUrlPath("/sampling") + .withLocalAgentPort(-1) + .build()) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("localAgentPort must be between 1 and 65535"); } @Test public void exceptionThrown_when_traefikCreatedWithTracingJaegerLocalAgentPort_ToHigh() { assertThatThrownBy(() -> traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withLocalAgentUrlPath("/sampling") - .withLocalAgentPort(65536) - .build()) - .build()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContainingAll("localAgentPort must be between 1 and 65535"); + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withLocalAgentUrlPath("/sampling") + .withLocalAgentPort(65536) + .build()) + .build()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContainingAll("localAgentPort must be between 1 and 65535"); } @Test @@ -254,44 +255,44 @@ public void noValidationErrors_when_traefikBuilderHasRequiredFields() { var localAgentUrlPath = "/sampling"; var traefik = traefikBuilder() - .withTracing( - TraefikTracing.builder() - .withJaeger(JaegerTracing.builder() - .withLocalAgentUrlPath(localAgentUrlPath) - .withLocalAgentPort(localAgentPort) - .build()) - .build()) - .withResourceManagement(ResourceManagement.builder() - .withLimits(ContainerResources.builder() - .withCpu(a(Integer.class).toString()) - .withMemory(a(Integer.class).toString()) - .build()) - .build()) - .withNodeSelectors(Map.of( - a(String.class), a(String.class), - a(String.class), a(String.class))) - .withToleration(Toleration.builder() - .withKey(a(String.class)) - .withOperator(TolerationOperator.EQUAL) - .withValue(a(String.class)) - .withEffect(TaintEffect.NO_EXECUTE) + .withTracing( + TraefikTracing.builder() + .withJaeger(JaegerTracing.builder() + .withLocalAgentUrlPath(localAgentUrlPath) + .withLocalAgentPort(localAgentPort) .build()) - .withTolerations(List.of( - Toleration.builder() - .withKey(a(String.class)) - .withOperator(TolerationOperator.EXISTS) - .withValue(a(String.class)) - .withEffect(TaintEffect.NO_EXECUTE) - .build(), - Toleration.builder() - .withKey(a(String.class)) - .withOperator(TolerationOperator.EXISTS) - .withValue(a(String.class)) - .withEffect(TaintEffect.NO_EXECUTE) - .build() - )) - .withPriorityClassName(a(String.class)) - .build(); + .build()) + .withResourceManagement(ResourceManagement.builder() + .withLimits(ContainerResources.builder() + .withCpu(a(Integer.class).toString()) + .withMemory(a(Integer.class).toString()) + .build()) + .build()) + .withNodeSelectors(Map.of( + a(String.class), a(String.class), + a(String.class), a(String.class))) + .withToleration(Toleration.builder() + .withKey(a(String.class)) + .withOperator(TolerationOperator.EQUAL) + .withValue(a(String.class)) + .withEffect(TaintEffect.NO_EXECUTE) + .build()) + .withTolerations(List.of( + Toleration.builder() + .withKey(a(String.class)) + .withOperator(TolerationOperator.EXISTS) + .withValue(a(String.class)) + .withEffect(TaintEffect.NO_EXECUTE) + .build(), + Toleration.builder() + .withKey(a(String.class)) + .withOperator(TolerationOperator.EXISTS) + .withValue(a(String.class)) + .withEffect(TaintEffect.NO_EXECUTE) + .build() + )) + .withPriorityClassName(a(String.class)) + .build(); var json = TestUtils.getJsonRepresentation(traefik); assertThat(traefik.validate()).isEmpty(); @@ -306,8 +307,8 @@ public void noValidationErrors_when_traefikBuilderHasRequiredFields() { assertThat(localAgentUrlPathFromJson).isEqualTo(localAgentUrlPath); assertThat(traefik.getTracing().getJaeger()) - .extracting(JaegerTracing::getLocalAgentUrlPath, JaegerTracing::getLocalAgentPort) - .containsExactly(localAgentUrlPath, localAgentPort); + .extracting(JaegerTracing::getLocalAgentUrlPath, JaegerTracing::getLocalAgentPort) + .containsExactly(localAgentUrlPath, localAgentPort); assertThat(traefik.getNodeSelectors()).hasSize(2); assertThat(traefik.getTolerations()).hasSize(3); @@ -315,23 +316,23 @@ public void noValidationErrors_when_traefikBuilderHasRequiredFields() { private CaaSTraefik.TraefikBuilder traefikBuilder() { return traefikBuilderWithoutEntryPoints() - .withEntryPoints(aListOf(TraefikEntryPoint.class)); + .withEntryPoints(aListOf(TraefikEntryPoint.class)); } private CaaSTraefik.TraefikBuilder traefikBuilderWithoutEntryPoints() { return CaaSTraefik.builder() - .withId("traefik") - .withNamespace(a(String.class)) - .withHostname(a(String.class)); + .withId("traefik") + .withNamespace(a(String.class)) + .withHostname(a(String.class)); } private CaaSTraefik.TraefikBuilder traefikBuilderWithForwardAuth() { return traefikBuilder() - .withForwardAuth(new ForwardAuthSettings( - a(String.class), - a(String.class), - a(String.class), - a(String.class))); + .withForwardAuth(new ForwardAuthSettings( + a(String.class), + a(String.class), + a(String.class), + a(String.class))); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResourcesTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResourcesTest.java index 98e77d7a..60b14b99 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResourcesTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ContainerResourcesTest.java @@ -11,56 +11,56 @@ class ContainerResourcesTest { void cpuValueIsSetCorrectly_when_withCpuIsCalledWithValidInput() { String cpu = "250m"; // Quarter of a CPU core ContainerResources resources = ContainerResources.builder().withCpu(cpu).build(); - + assertThat(resources.getCpu()) - .as("CPU should be set correctly when withCpu is called with valid input") - .isEqualTo(cpu); + .as("CPU should be set correctly when withCpu is called with valid input") + .isEqualTo(cpu); } @Test void memoryValueIsSetCorrectly_when_withMemoryIsCalledWithValidInput() { String memory = "64Mi"; // 64 Mebibytes ContainerResources resources = ContainerResources.builder().withMemory(memory).build(); - + assertThat(resources.getMemory()) - .as("Memory should be set correctly when withMemory is called with valid input") - .isEqualTo(memory); + .as("Memory should be set correctly when withMemory is called with valid input") + .isEqualTo(memory); } @Test void noErrorsReturned_when_ValidateCalledWithValidCpuAndMemory() { ContainerResources resources = ContainerResources.builder().withCpu("500m").withMemory("1Gi").build(); - + assertThat(resources.validate()) - .as("No validation errors should be returned with valid CPU and memory") - .isEmpty(); + .as("No validation errors should be returned with valid CPU and memory") + .isEmpty(); } @Test void exceptionThrown_when_ValidateCalledWithInvalidCpu() { assertThatThrownBy(() -> ContainerResources.builder().withCpu("-1").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("CPU quantity is not in a valid format"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CPU quantity is not in a valid format"); } @Test void exceptionThrown_when_ValidateCalledWithToLowCpu() { assertThatThrownBy(() -> ContainerResources.builder().withCpu("0.0001").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("CPU quantity must be at least 0.001 CPU (1m) for decimal values"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CPU quantity must be at least 0.001 CPU (1m) for decimal values"); } @Test void exceptionThrown_when_ValidateCalledWithInvalidMemorySuffix() { assertThatThrownBy(() -> ContainerResources.builder().withMemory("500m").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The 'm' suffix is not valid for memory quantities."); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The 'm' suffix is not valid for memory quantities."); } @Test void exceptionThrown_when_ValidateCalledWithInvalidMemoryInputFormat() { assertThatThrownBy(() -> ContainerResources.builder().withMemory("-500").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Memory quantity is not in a valid format"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Memory quantity is not in a valid format"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagementTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagementTest.java index ec008446..c273ecb7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagementTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/ResourceManagementTest.java @@ -23,10 +23,10 @@ void resourceRequestsAreCorrectlyAssigned_when_withRequestsIsCalled() { ResourceManagement resourceManagement = builder.withRequests(requests).build(); assertThat(resourceManagement.getRequests()) - .as("Resource requests should be correctly assigned") - .isNotNull() - .usingRecursiveComparison() - .isEqualTo(requests); + .as("Resource requests should be correctly assigned") + .isNotNull() + .usingRecursiveComparison() + .isEqualTo(requests); } @Test @@ -38,9 +38,9 @@ void resourceLimitsAreCorrectlyAssigned_when_withLimitsIsCalled() { ResourceManagement resourceManagement = builder.withLimits(limits).build(); assertThat(resourceManagement.getLimits()) - .as("Resource limits should be correctly assigned") - .isNotNull() - .usingRecursiveComparison() - .isEqualTo(limits); + .as("Resource limits should be correctly assigned") + .isNotNull() + .usingRecursiveComparison() + .isEqualTo(limits); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/RoleTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/RoleTypeTest.java index 697a8dc9..dbd051eb 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/RoleTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/RoleTypeTest.java @@ -10,10 +10,10 @@ class RoleTypeTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(RoleType.fromString("AppRoleAssignment"), RoleType.APP_ROLE_ASSIGNMENT), - () -> assertEquals(RoleType.fromString("BuiltInRole"), RoleType.BUILT_IN_ROLE), - () -> assertEquals(RoleType.fromString("CustomRole"), RoleType.CUSTOM_ROLE), - () -> assertEquals(RoleType.fromString("OcelotRole"), RoleType.OCELOT_ROLE) + () -> assertEquals(RoleType.fromString("AppRoleAssignment"), RoleType.APP_ROLE_ASSIGNMENT), + () -> assertEquals(RoleType.fromString("BuiltInRole"), RoleType.BUILT_IN_ROLE), + () -> assertEquals(RoleType.fromString("CustomRole"), RoleType.CUSTOM_ROLE), + () -> assertEquals(RoleType.fromString("OcelotRole"), RoleType.OCELOT_ROLE) ); } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationTest.java index fc9e6a53..6b950f58 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/caas/TolerationTest.java @@ -15,11 +15,11 @@ void tolerationIsCorrectlyCreated_when_AllFieldsAreValid() { TaintEffect effect = TaintEffect.NO_SCHEDULE; Toleration toleration = Toleration.builder() - .withKey(key) - .withOperator(operator) - .withValue(value) - .withEffect(effect) - .build(); + .withKey(key) + .withOperator(operator) + .withValue(value) + .withEffect(effect) + .build(); assertThat(toleration).isNotNull(); assertThat(toleration.getKey()).isEqualTo(key); @@ -31,36 +31,36 @@ void tolerationIsCorrectlyCreated_when_AllFieldsAreValid() { @Test void exceptionThrown_when_KeyIsMissing() { Throwable thrown = catchThrowable(() -> Toleration.builder() - .withOperator(TolerationOperator.EQUAL) - .withValue("example-value") - .withEffect(TaintEffect.NO_SCHEDULE) - .build()); + .withOperator(TolerationOperator.EQUAL) + .withValue("example-value") + .withEffect(TaintEffect.NO_SCHEDULE) + .build()); assertThat(thrown).isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The key must be provided for a toleration"); + .hasMessageContaining("The key must be provided for a toleration"); } @Test void exceptionThrown_when_EffectIsMissing() { Throwable thrown = catchThrowable(() -> Toleration.builder() - .withKey("example-key") - .withOperator(TolerationOperator.EQUAL) - .withValue("example-value") - .build()); + .withKey("example-key") + .withOperator(TolerationOperator.EQUAL) + .withValue("example-value") + .build()); assertThat(thrown).isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The effect must be provided for a toleration"); + .hasMessageContaining("The effect must be provided for a toleration"); } @Test void illegalStateExceptionThrown_when_EqualOperatorUsedWithoutValue() { Throwable thrown = catchThrowable(() -> Toleration.builder() - .withKey("example-key") - .withOperator(TolerationOperator.EQUAL) - .withEffect(TaintEffect.NO_SCHEDULE) - .build()); + .withKey("example-key") + .withOperator(TolerationOperator.EQUAL) + .withEffect(TaintEffect.NO_SCHEDULE) + .build()); assertThat(thrown).isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("A value must be provided when the operator is 'Equal'"); + .hasMessageContaining("A value must be provided when the operator is 'Equal'"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/SupportedTlsVersionsTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/SupportedTlsVersionsTest.java index 3d547bd7..9d9e3c26 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/SupportedTlsVersionsTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/SupportedTlsVersionsTest.java @@ -9,9 +9,9 @@ class SupportedTlsVersionsTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(SupportedTlsVersions.fromString("1.0"), SupportedTlsVersions.ONE_ZERO), - () -> assertEquals(SupportedTlsVersions.fromString("1.1"), SupportedTlsVersions.ONE_ONE), - () -> assertEquals(SupportedTlsVersions.fromString("1.2"), SupportedTlsVersions.ONE_TWO) + () -> assertEquals(SupportedTlsVersions.fromString("1.0"), SupportedTlsVersions.ONE_ZERO), + () -> assertEquals(SupportedTlsVersions.fromString("1.1"), SupportedTlsVersions.ONE_ONE), + () -> assertEquals(SupportedTlsVersions.fromString("1.2"), SupportedTlsVersions.ONE_TWO) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesServiceTest.java index 9b80cdcd..fb0f7660 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesServiceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsElasticKubernetesServiceTest.java @@ -12,314 +12,314 @@ public class AwsElasticKubernetesServiceTest { - @Test - public void noValidationErrors_when_eksHasRequiredFields() { - var eks = getDefaultEks().build(); - assertThat(eks.validate()).isEmpty(); - } - - @Test - public void exceptionThrown_when_eksCreatedWithNullId() { - assertThatThrownBy(() -> getDefaultEks().withId("").build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("A valid component id cannot be null, empty or contain spaces"); - } - - @Test - public void exceptionThrown_when_eksCreatedWithNullRegion() { - assertThatThrownBy(() -> getDefaultEks().withRegion(null).build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Region is not specified and it is required"); - } - - @Test - public void typeIsKubernetes_when_eksIsBuiltWithoutSpecifyType() { - var eksBuilder = getDefaultEks(); - assertThat(eksBuilder.build().getType()).isEqualTo(PAAS_KUBERNETES); - assertThatCode(eksBuilder::build).doesNotThrowAnyException(); - } - - @Test - public void withName_setsNameCorrectly() { - var eks = getDefaultEks() - .withName("valid-name_123") - .build(); - - assertThat(eks.getName()).isEqualTo("valid-name_123"); - } - - @Test - public void withName_allowsNullOrEmptyName() { - var eks = getDefaultEks() - .withName(null) - .build(); - - assertThat(eks.getName()).isNull(); - - eks = getDefaultEks() - .withName("") - .build(); - - assertThat(eks.getName()).isEmpty(); - } - - - @Test - public void validate_addsError_whenNameIsInvalid() { - var eks = getDefaultEks() - .withName("Invalid*Name!"); - - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("The name can contain only letters, numbers, underscores, and hyphens"); - } - - @Test - public void validate_addsError_whenNameIsTooLong() { - var longName = "a".repeat(64); // 64 chars > 63 max - - var eks = getDefaultEks() - .withName(longName); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("must be between 1 and 63 characters long"); - } - - @Test - public void withTags_setsTagsMap() { - var tags = new HashMap(); - tags.put("env", "prod"); - tags.put("team", "devops"); - - var eks = getDefaultEks() - .withTags(tags) - .build(); - - assertThat(eks.getTags()) - .isNotNull() - .containsEntry("env", "prod") - .containsEntry("team", "devops"); - } - - @Test - public void withTag_addsSingleTagToExistingTags() { - var eksBuilder = getDefaultEks() - .withTags(new HashMap<>(Map.of("env", "prod"))); - - eksBuilder.withTag("team", "devops"); - var eks = eksBuilder.build(); - - assertThat(eks.getTags()) - .isNotNull() - .containsEntry("env", "prod") - .containsEntry("team", "devops"); - } - - @Test - public void withTag_initializesTagsMapIfNullAndAddsTag() { - var eksBuilder = getDefaultEks() - .withTags(null); // simulate starting from no tags - - eksBuilder.withTag("env", "prod"); - var eks = eksBuilder.build(); - - assertThat(eks.getTags()) - .isNotNull() - .hasSize(1) - .containsEntry("env", "prod"); - } - - @Test - public void exceptionThrown_when_desiredAvailabilityZoneCountInvalid() { - assertThatThrownBy(() -> getDefaultEks().withDesiredAvailabilityZoneCount(0).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("desiredAvailabilityZoneCount must be greater than 0"); - - assertThatThrownBy(() -> getDefaultEks().withDesiredAvailabilityZoneCount(5).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("desiredAvailabilityZoneCount cannot be greater than 3 (AWS best practice)"); - } - - @Test - public void validationFails_when_zoneCountDoesNotMatchPrivateSubnets() { - var eks = getDefaultEks() - .withDesiredAvailabilityZoneCount(2) - .withPrivateSubnetCidrs(List.of("172.33.128.0/20")); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(("privateSubnetCidrs size (1) must match desiredAvailabilityZoneCount (2)") - ); - } - - @Test - public void noValidationErrors_when_subnetCountMatchesZoneCount() { - var eks = getDefaultEks() - .withDesiredAvailabilityZoneCount(3) - .withPrivateSubnetCidrs(List.of( - "172.33.128.0/20", - "172.33.144.0/20", - "172.33.160.0/20" - )) - .withVpcCidrBlock("172.33.0.0/16") - .build(); - - assertThat(eks.validate()).isEmpty(); - } - - @Test - public void validationFails_when_vpcCidrBlockIsInvalidFormat() { - var eks = getDefaultEks() - .withVpcCidrBlock("INVALID_CIDR"); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(("vpcCidrBlock is not a valid CIDR") - ); - } - - @Test - public void validationFails_when_subnetNotWithinVpcCidr() { - var eks = getDefaultEks() - .withVpcCidrBlock("172.33.0.0/16") - .withDesiredAvailabilityZoneCount(1) - .withPrivateSubnetCidrs(List.of("10.0.0.0/24")); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(("is not within the VPC CIDR range") - ); - } - - @Test - public void validate_shouldAddError_whenVpcCidrBlockMaskOutOfRange() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/15"); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(("vpcCidrBlock mask must be between /16 and /24")); - - eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/25"); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(("vpcCidrBlock mask must be between /16 and /24")); - } - - @Test - public void validate_shouldNotAddError_whenVpcCidrBlockMaskIsValid() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/20") - .build(); - - assertThat(eks.validate()).isEmpty(); - } - - @Test - public void validate_shouldAddError_whenSubnetMaskNotGreaterThanVpcMask() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/20") - .withPrivateSubnetCidrs(List.of("10.0.0.0/20")); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Subnet 10.0.0.0/20 mask must be greater than VPC's (10.0.0.0/20)"); - } - - @Test - public void validate_shouldAddError_whenSubnetHasInvalidCidrFormat() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/20") - .withPrivateSubnetCidrs(List.of("invalid-cidr")); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Invalid CIDR format: invalid-cidr"); - } - - @Test - public void validate_shouldAddError_whenPrivateSubnetsOverlap() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/20") - .withPrivateSubnetCidrs(List.of("10.0.1.0/24", "10.0.1.128/25")); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Subnet CIDRs 10.0.1.0/24 and 10.0.1.128/25 overlap"); - } - - - @Test - public void noErrors_whenPrivateSubnetsDoNotOverlap() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/16") - .withPrivateSubnetCidrs(List.of( - "10.0.1.0/24", - "10.0.2.0/24", - "10.0.3.0/24" - )) - .build(); - - var errors = eks.validate(); - - // Should not have overlap error - assertThat(errors) - .noneMatch(msg -> msg.contains("overlap")); - } - - @Test - public void errors_whenPrivateSubnetsOverlap() { - var eks = getDefaultEks() - .withVpcCidrBlock("10.0.0.0/16") - .withPrivateSubnetCidrs(List.of( - "10.0.1.0/24", - "10.0.1.128/25" - )); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("overlap"); - } - - @Test - public void errors_whenPrivateSubnetHasInvalidCidrFormat() { - var eks = AwsElasticKubernetesService.builder() - .withVpcCidrBlock("10.0.0.0/16") - .withPrivateSubnetCidrs(List.of( - "10.0.1.0/24", - "invalid_cidr" - )); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Invalid CIDR format"); - } - - @Test - public void errors_whenSubnetMaskIsNotGreaterThanVpcMask() { - var eks = AwsElasticKubernetesService.builder() - .withVpcCidrBlock("10.0.0.0/24") - .withPrivateSubnetCidrs(List.of( - "10.0.0.0/24" // equal mask, invalid - )); - - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("mask must be greater than VPC's"); - } - - @Test - public void compareIpsReturnsZero_whenIpAddressesAreIdentical() { - var eks = AwsElasticKubernetesService.builder() - .withVpcCidrBlock("10.0.0.0/16") - .withPrivateSubnetCidrs(List.of( - "10.0.1.0/25", - "10.0.1.0/25" - )); - - assertThatThrownBy(eks::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("overlap"); - } + @Test + public void noValidationErrors_when_eksHasRequiredFields() { + var eks = getDefaultEks().build(); + assertThat(eks.validate()).isEmpty(); + } + + @Test + public void exceptionThrown_when_eksCreatedWithNullId() { + assertThatThrownBy(() -> getDefaultEks().withId("").build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("A valid component id cannot be null, empty or contain spaces"); + } + + @Test + public void exceptionThrown_when_eksCreatedWithNullRegion() { + assertThatThrownBy(() -> getDefaultEks().withRegion(null).build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Region is not specified and it is required"); + } + + @Test + public void typeIsKubernetes_when_eksIsBuiltWithoutSpecifyType() { + var eksBuilder = getDefaultEks(); + assertThat(eksBuilder.build().getType()).isEqualTo(PAAS_KUBERNETES); + assertThatCode(eksBuilder::build).doesNotThrowAnyException(); + } + + @Test + public void withName_setsNameCorrectly() { + var eks = getDefaultEks() + .withName("valid-name_123") + .build(); + + assertThat(eks.getName()).isEqualTo("valid-name_123"); + } + + @Test + public void withName_allowsNullOrEmptyName() { + var eks = getDefaultEks() + .withName(null) + .build(); + + assertThat(eks.getName()).isNull(); + + eks = getDefaultEks() + .withName("") + .build(); + + assertThat(eks.getName()).isEmpty(); + } + + + @Test + public void validate_addsError_whenNameIsInvalid() { + var eks = getDefaultEks() + .withName("Invalid*Name!"); + + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("The name can contain only letters, numbers, underscores, and hyphens"); + } + + @Test + public void validate_addsError_whenNameIsTooLong() { + var longName = "a".repeat(64); // 64 chars > 63 max + + var eks = getDefaultEks() + .withName(longName); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("must be between 1 and 63 characters long"); + } + + @Test + public void withTags_setsTagsMap() { + var tags = new HashMap(); + tags.put("env", "prod"); + tags.put("team", "devops"); + + var eks = getDefaultEks() + .withTags(tags) + .build(); + + assertThat(eks.getTags()) + .isNotNull() + .containsEntry("env", "prod") + .containsEntry("team", "devops"); + } + + @Test + public void withTag_addsSingleTagToExistingTags() { + var eksBuilder = getDefaultEks() + .withTags(new HashMap<>(Map.of("env", "prod"))); + + eksBuilder.withTag("team", "devops"); + var eks = eksBuilder.build(); + + assertThat(eks.getTags()) + .isNotNull() + .containsEntry("env", "prod") + .containsEntry("team", "devops"); + } + + @Test + public void withTag_initializesTagsMapIfNullAndAddsTag() { + var eksBuilder = getDefaultEks() + .withTags(null); // simulate starting from no tags + + eksBuilder.withTag("env", "prod"); + var eks = eksBuilder.build(); + + assertThat(eks.getTags()) + .isNotNull() + .hasSize(1) + .containsEntry("env", "prod"); + } + + @Test + public void exceptionThrown_when_desiredAvailabilityZoneCountInvalid() { + assertThatThrownBy(() -> getDefaultEks().withDesiredAvailabilityZoneCount(0).build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("desiredAvailabilityZoneCount must be greater than 0"); + + assertThatThrownBy(() -> getDefaultEks().withDesiredAvailabilityZoneCount(5).build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("desiredAvailabilityZoneCount cannot be greater than 3 (AWS best practice)"); + } + + @Test + public void validationFails_when_zoneCountDoesNotMatchPrivateSubnets() { + var eks = getDefaultEks() + .withDesiredAvailabilityZoneCount(2) + .withPrivateSubnetCidrs(List.of("172.33.128.0/20")); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(("privateSubnetCidrs size (1) must match desiredAvailabilityZoneCount (2)") + ); + } + + @Test + public void noValidationErrors_when_subnetCountMatchesZoneCount() { + var eks = getDefaultEks() + .withDesiredAvailabilityZoneCount(3) + .withPrivateSubnetCidrs(List.of( + "172.33.128.0/20", + "172.33.144.0/20", + "172.33.160.0/20" + )) + .withVpcCidrBlock("172.33.0.0/16") + .build(); + + assertThat(eks.validate()).isEmpty(); + } + + @Test + public void validationFails_when_vpcCidrBlockIsInvalidFormat() { + var eks = getDefaultEks() + .withVpcCidrBlock("INVALID_CIDR"); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(("vpcCidrBlock is not a valid CIDR") + ); + } + + @Test + public void validationFails_when_subnetNotWithinVpcCidr() { + var eks = getDefaultEks() + .withVpcCidrBlock("172.33.0.0/16") + .withDesiredAvailabilityZoneCount(1) + .withPrivateSubnetCidrs(List.of("10.0.0.0/24")); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(("is not within the VPC CIDR range") + ); + } + + @Test + public void validate_shouldAddError_whenVpcCidrBlockMaskOutOfRange() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/15"); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(("vpcCidrBlock mask must be between /16 and /24")); + + eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/25"); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(("vpcCidrBlock mask must be between /16 and /24")); + } + + @Test + public void validate_shouldNotAddError_whenVpcCidrBlockMaskIsValid() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/20") + .build(); + + assertThat(eks.validate()).isEmpty(); + } + + @Test + public void validate_shouldAddError_whenSubnetMaskNotGreaterThanVpcMask() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/20") + .withPrivateSubnetCidrs(List.of("10.0.0.0/20")); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Subnet 10.0.0.0/20 mask must be greater than VPC's (10.0.0.0/20)"); + } + + @Test + public void validate_shouldAddError_whenSubnetHasInvalidCidrFormat() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/20") + .withPrivateSubnetCidrs(List.of("invalid-cidr")); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Invalid CIDR format: invalid-cidr"); + } + + @Test + public void validate_shouldAddError_whenPrivateSubnetsOverlap() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/20") + .withPrivateSubnetCidrs(List.of("10.0.1.0/24", "10.0.1.128/25")); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Subnet CIDRs 10.0.1.0/24 and 10.0.1.128/25 overlap"); + } + + + @Test + public void noErrors_whenPrivateSubnetsDoNotOverlap() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/16") + .withPrivateSubnetCidrs(List.of( + "10.0.1.0/24", + "10.0.2.0/24", + "10.0.3.0/24" + )) + .build(); + + var errors = eks.validate(); + + // Should not have overlap error + assertThat(errors) + .noneMatch(msg -> msg.contains("overlap")); + } + + @Test + public void errors_whenPrivateSubnetsOverlap() { + var eks = getDefaultEks() + .withVpcCidrBlock("10.0.0.0/16") + .withPrivateSubnetCidrs(List.of( + "10.0.1.0/24", + "10.0.1.128/25" + )); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("overlap"); + } + + @Test + public void errors_whenPrivateSubnetHasInvalidCidrFormat() { + var eks = AwsElasticKubernetesService.builder() + .withVpcCidrBlock("10.0.0.0/16") + .withPrivateSubnetCidrs(List.of( + "10.0.1.0/24", + "invalid_cidr" + )); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Invalid CIDR format"); + } + + @Test + public void errors_whenSubnetMaskIsNotGreaterThanVpcMask() { + var eks = AwsElasticKubernetesService.builder() + .withVpcCidrBlock("10.0.0.0/24") + .withPrivateSubnetCidrs(List.of( + "10.0.0.0/24" // equal mask, invalid + )); + + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("mask must be greater than VPC's"); + } + + @Test + public void compareIpsReturnsZero_whenIpAddressesAreIdentical() { + var eks = AwsElasticKubernetesService.builder() + .withVpcCidrBlock("10.0.0.0/16") + .withPrivateSubnetCidrs(List.of( + "10.0.1.0/25", + "10.0.1.0/25" + )); + + assertThatThrownBy(eks::build) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("overlap"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegionTest.java index 6fc23e24..fabd030f 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/aws/AwsRegionTest.java @@ -11,181 +11,181 @@ public class AwsRegionTest { @Test public void awsActionConstants_shouldNotBeBlank() { AwsRegion.values().forEach(x -> - assertThat(x.toString()).isNotBlank()); + assertThat(x.toString()).isNotBlank()); } @Test public void fromString_shouldReturnCorrespondingAwsAction() { assertThat(AwsRegion.fromString("us-east-1")) - .as("fromString should return US_EAST_1 for 'us-east-1'") - .isEqualTo(AwsRegion.US_EAST_1); + .as("fromString should return US_EAST_1 for 'us-east-1'") + .isEqualTo(AwsRegion.US_EAST_1); assertThat(AwsRegion.fromString("us-east-1")) - .as("fromString should return US_EAST_1 for 'us-east-1'") - .isEqualTo(AwsRegion.US_EAST_1); + .as("fromString should return US_EAST_1 for 'us-east-1'") + .isEqualTo(AwsRegion.US_EAST_1); assertThat(AwsRegion.fromString("us-east-2")) - .as("fromString should return US_EAST_2 for 'us-east-2'") - .isEqualTo(AwsRegion.US_EAST_2); + .as("fromString should return US_EAST_2 for 'us-east-2'") + .isEqualTo(AwsRegion.US_EAST_2); assertThat(AwsRegion.fromString("us-west-1")) - .as("fromString should return US_WEST_1 for 'us-west-1'") - .isEqualTo(AwsRegion.US_WEST_1); + .as("fromString should return US_WEST_1 for 'us-west-1'") + .isEqualTo(AwsRegion.US_WEST_1); assertThat(AwsRegion.fromString("us-west-2")) - .as("fromString should return US_WEST_2 for 'us-west-2'") - .isEqualTo(AwsRegion.US_WEST_2); + .as("fromString should return US_WEST_2 for 'us-west-2'") + .isEqualTo(AwsRegion.US_WEST_2); assertThat(AwsRegion.fromString("af-south-1")) - .as("fromString should return AF_SOUTH_1 for 'af-south-1'") - .isEqualTo(AwsRegion.AF_SOUTH_1); + .as("fromString should return AF_SOUTH_1 for 'af-south-1'") + .isEqualTo(AwsRegion.AF_SOUTH_1); assertThat(AwsRegion.fromString("ap-east-1")) - .as("fromString should return AP_EAST_1 for 'ap-east-1'") - .isEqualTo(AwsRegion.AP_EAST_1); + .as("fromString should return AP_EAST_1 for 'ap-east-1'") + .isEqualTo(AwsRegion.AP_EAST_1); assertThat(AwsRegion.fromString("ap-south-2")) - .as("fromString should return AP_SOUTH_2 for 'ap-south-2'") - .isEqualTo(AwsRegion.AP_SOUTH_2); + .as("fromString should return AP_SOUTH_2 for 'ap-south-2'") + .isEqualTo(AwsRegion.AP_SOUTH_2); assertThat(AwsRegion.fromString("ap-southeast-3")) - .as("fromString should return AP_SOUTHEAST_3 for 'ap-southeast-3'") - .isEqualTo(AwsRegion.AP_SOUTHEAST_3); + .as("fromString should return AP_SOUTHEAST_3 for 'ap-southeast-3'") + .isEqualTo(AwsRegion.AP_SOUTHEAST_3); assertThat(AwsRegion.fromString("ap-southeast-5")) - .as("fromString should return AP_SOUTHEAST_5 for 'ap-southeast-5'") - .isEqualTo(AwsRegion.AP_SOUTHEAST_5); + .as("fromString should return AP_SOUTHEAST_5 for 'ap-southeast-5'") + .isEqualTo(AwsRegion.AP_SOUTHEAST_5); assertThat(AwsRegion.fromString("ap-southeast-4")) - .as("fromString should return AP_SOUTHEAST_4 for 'ap-southeast-4'") - .isEqualTo(AwsRegion.AP_SOUTHEAST_4); + .as("fromString should return AP_SOUTHEAST_4 for 'ap-southeast-4'") + .isEqualTo(AwsRegion.AP_SOUTHEAST_4); assertThat(AwsRegion.fromString("ap-south-1")) - .as("fromString should return AP_SOUTH_1 for 'ap-south-1'") - .isEqualTo(AwsRegion.AP_SOUTH_1); + .as("fromString should return AP_SOUTH_1 for 'ap-south-1'") + .isEqualTo(AwsRegion.AP_SOUTH_1); assertThat(AwsRegion.fromString("ap-northeast-3")) - .as("fromString should return AP_NORTHEAST_3 for 'ap-northeast-3'") - .isEqualTo(AwsRegion.AP_NORTHEAST_3); + .as("fromString should return AP_NORTHEAST_3 for 'ap-northeast-3'") + .isEqualTo(AwsRegion.AP_NORTHEAST_3); assertThat(AwsRegion.fromString("ap-northeast-2")) - .as("fromString should return AP_NORTHEAST_2 for 'ap-northeast-2'") - .isEqualTo(AwsRegion.AP_NORTHEAST_2); + .as("fromString should return AP_NORTHEAST_2 for 'ap-northeast-2'") + .isEqualTo(AwsRegion.AP_NORTHEAST_2); assertThat(AwsRegion.fromString("ap-southeast-1")) - .as("fromString should return AP_SOUTHEAST_1 for 'ap-southeast-1'") - .isEqualTo(AwsRegion.AP_SOUTHEAST_1); + .as("fromString should return AP_SOUTHEAST_1 for 'ap-southeast-1'") + .isEqualTo(AwsRegion.AP_SOUTHEAST_1); assertThat(AwsRegion.fromString("ap-southeast-2")) - .as("fromString should return AP_SOUTHEAST_2 for 'ap-southeast-2'") - .isEqualTo(AwsRegion.AP_SOUTHEAST_2); + .as("fromString should return AP_SOUTHEAST_2 for 'ap-southeast-2'") + .isEqualTo(AwsRegion.AP_SOUTHEAST_2); assertThat(AwsRegion.fromString("ap-northeast-1")) - .as("fromString should return AP_NORTHEAST_1 for 'ap-northeast-1'") - .isEqualTo(AwsRegion.AP_NORTHEAST_1); + .as("fromString should return AP_NORTHEAST_1 for 'ap-northeast-1'") + .isEqualTo(AwsRegion.AP_NORTHEAST_1); assertThat(AwsRegion.fromString("ca-central-1")) - .as("fromString should return CA_CENTRAL_1 for 'ca-central-1'") - .isEqualTo(AwsRegion.CA_CENTRAL_1); + .as("fromString should return CA_CENTRAL_1 for 'ca-central-1'") + .isEqualTo(AwsRegion.CA_CENTRAL_1); assertThat(AwsRegion.fromString("ca-west-1")) - .as("fromString should return CA_WEST_1 for 'ca-west-1'") - .isEqualTo(AwsRegion.CA_WEST_1); + .as("fromString should return CA_WEST_1 for 'ca-west-1'") + .isEqualTo(AwsRegion.CA_WEST_1); assertThat(AwsRegion.fromString("cn-north-1")) - .as("fromString should return CN_NORTH_1 for 'cn-north-1'") - .isEqualTo(AwsRegion.CN_NORTH_1); + .as("fromString should return CN_NORTH_1 for 'cn-north-1'") + .isEqualTo(AwsRegion.CN_NORTH_1); assertThat(AwsRegion.fromString("cn-northwest-1")) - .as("fromString should return CN_NORTHWEST_1 for 'cn-northwest-1'") - .isEqualTo(AwsRegion.CN_NORTHWEST_1); + .as("fromString should return CN_NORTHWEST_1 for 'cn-northwest-1'") + .isEqualTo(AwsRegion.CN_NORTHWEST_1); assertThat(AwsRegion.fromString("eu-central-1")) - .as("fromString should return EU_CENTRAL_1 for 'eu-central-1'") - .isEqualTo(AwsRegion.EU_CENTRAL_1); + .as("fromString should return EU_CENTRAL_1 for 'eu-central-1'") + .isEqualTo(AwsRegion.EU_CENTRAL_1); assertThat(AwsRegion.fromString("eu-west-1")) - .as("fromString should return EU_WEST_1 for 'eu-west-1'") - .isEqualTo(AwsRegion.EU_WEST_1); + .as("fromString should return EU_WEST_1 for 'eu-west-1'") + .isEqualTo(AwsRegion.EU_WEST_1); assertThat(AwsRegion.fromString("eu-west-2")) - .as("fromString should return EU_WEST_2 for 'eu-west-2'") - .isEqualTo(AwsRegion.EU_WEST_2); + .as("fromString should return EU_WEST_2 for 'eu-west-2'") + .isEqualTo(AwsRegion.EU_WEST_2); assertThat(AwsRegion.fromString("eu-south-1")) - .as("fromString should return EU_SOUTH_1 for 'eu-south-1'") - .isEqualTo(AwsRegion.EU_SOUTH_1); + .as("fromString should return EU_SOUTH_1 for 'eu-south-1'") + .isEqualTo(AwsRegion.EU_SOUTH_1); assertThat(AwsRegion.fromString("eu-west-3")) - .as("fromString should return EU_WEST_3 for 'eu-west-3'") - .isEqualTo(AwsRegion.EU_WEST_3); + .as("fromString should return EU_WEST_3 for 'eu-west-3'") + .isEqualTo(AwsRegion.EU_WEST_3); assertThat(AwsRegion.fromString("eu-south-2")) - .as("fromString should return EU_SOUTH_2 for 'eu-south-2'") - .isEqualTo(AwsRegion.EU_SOUTH_2); + .as("fromString should return EU_SOUTH_2 for 'eu-south-2'") + .isEqualTo(AwsRegion.EU_SOUTH_2); assertThat(AwsRegion.fromString("eu-north-1")) - .as("fromString should return EU_NORTH_1 for 'eu-north-1'") - .isEqualTo(AwsRegion.EU_NORTH_1); + .as("fromString should return EU_NORTH_1 for 'eu-north-1'") + .isEqualTo(AwsRegion.EU_NORTH_1); assertThat(AwsRegion.fromString("eu-central-2")) - .as("fromString should return EU_CENTRAL_2 for 'eu-central-2'") - .isEqualTo(AwsRegion.EU_CENTRAL_2); + .as("fromString should return EU_CENTRAL_2 for 'eu-central-2'") + .isEqualTo(AwsRegion.EU_CENTRAL_2); assertThat(AwsRegion.fromString("il-central-1")) - .as("fromString should return IL_CENTRAL_1 for 'il-central-1'") - .isEqualTo(AwsRegion.IL_CENTRAL_1); + .as("fromString should return IL_CENTRAL_1 for 'il-central-1'") + .isEqualTo(AwsRegion.IL_CENTRAL_1); assertThat(AwsRegion.fromString("me-south-1")) - .as("fromString should return ME_SOUTH_1 for 'me-south-1'") - .isEqualTo(AwsRegion.ME_SOUTH_1); + .as("fromString should return ME_SOUTH_1 for 'me-south-1'") + .isEqualTo(AwsRegion.ME_SOUTH_1); assertThat(AwsRegion.fromString("me-central-1")) - .as("fromString should return ME_CENTRAL_1 for 'me-central-1'") - .isEqualTo(AwsRegion.ME_CENTRAL_1); + .as("fromString should return ME_CENTRAL_1 for 'me-central-1'") + .isEqualTo(AwsRegion.ME_CENTRAL_1); assertThat(AwsRegion.fromString("sa-east-1")) - .as("fromString should return SA_EAST_1 for 'sa-east-1'") - .isEqualTo(AwsRegion.SA_EAST_1); + .as("fromString should return SA_EAST_1 for 'sa-east-1'") + .isEqualTo(AwsRegion.SA_EAST_1); } @Test public void valuesMethod_shouldContainAllAwsActionsWithCorrectSize() { Collection values = AwsRegion.values(); - + assertThat(values) - .as("Values should contain all specified AwsRegions") - .contains( - AwsRegion.US_EAST_1, - AwsRegion.US_EAST_2, - AwsRegion.US_WEST_1, - AwsRegion.US_WEST_2, - AwsRegion.AF_SOUTH_1, - AwsRegion.AP_EAST_1, - AwsRegion.AP_SOUTH_2, - AwsRegion.AP_SOUTHEAST_3, - AwsRegion.AP_SOUTHEAST_5, - AwsRegion.AP_SOUTHEAST_4, - AwsRegion.AP_SOUTH_1, - AwsRegion.AP_NORTHEAST_3, - AwsRegion.AP_NORTHEAST_2, - AwsRegion.AP_SOUTHEAST_1, - AwsRegion.AP_SOUTHEAST_2, - AwsRegion.AP_NORTHEAST_1, - AwsRegion.CA_CENTRAL_1, - AwsRegion.CA_WEST_1, - AwsRegion.CN_NORTH_1, - AwsRegion.CN_NORTHWEST_1, - AwsRegion.EU_CENTRAL_1, - AwsRegion.EU_WEST_1, - AwsRegion.EU_WEST_2, - AwsRegion.EU_SOUTH_1, - AwsRegion.EU_WEST_3, - AwsRegion.EU_SOUTH_2, - AwsRegion.EU_NORTH_1, - AwsRegion.EU_CENTRAL_2, - AwsRegion.IL_CENTRAL_1, - AwsRegion.ME_SOUTH_1, - AwsRegion.ME_CENTRAL_1, - AwsRegion.SA_EAST_1); + .as("Values should contain all specified AwsRegions") + .contains( + AwsRegion.US_EAST_1, + AwsRegion.US_EAST_2, + AwsRegion.US_WEST_1, + AwsRegion.US_WEST_2, + AwsRegion.AF_SOUTH_1, + AwsRegion.AP_EAST_1, + AwsRegion.AP_SOUTH_2, + AwsRegion.AP_SOUTHEAST_3, + AwsRegion.AP_SOUTHEAST_5, + AwsRegion.AP_SOUTHEAST_4, + AwsRegion.AP_SOUTH_1, + AwsRegion.AP_NORTHEAST_3, + AwsRegion.AP_NORTHEAST_2, + AwsRegion.AP_SOUTHEAST_1, + AwsRegion.AP_SOUTHEAST_2, + AwsRegion.AP_NORTHEAST_1, + AwsRegion.CA_CENTRAL_1, + AwsRegion.CA_WEST_1, + AwsRegion.CN_NORTH_1, + AwsRegion.CN_NORTHWEST_1, + AwsRegion.EU_CENTRAL_1, + AwsRegion.EU_WEST_1, + AwsRegion.EU_WEST_2, + AwsRegion.EU_SOUTH_1, + AwsRegion.EU_WEST_3, + AwsRegion.EU_SOUTH_2, + AwsRegion.EU_NORTH_1, + AwsRegion.EU_CENTRAL_2, + AwsRegion.IL_CENTRAL_1, + AwsRegion.ME_SOUTH_1, + AwsRegion.ME_CENTRAL_1, + AwsRegion.SA_EAST_1); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActionTest.java index 90ed5525..fed19b70 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActionTest.java @@ -16,12 +16,12 @@ public void azureActionConstants_shouldNotBeNull() { @Test public void fromString_shouldReturnCorrespondingAzureAction() { assertThat(AzureAction.fromString("Allow")) - .as("fromString should return ALLOW for 'Allow'") - .isEqualTo(AzureAction.ALLOW); + .as("fromString should return ALLOW for 'Allow'") + .isEqualTo(AzureAction.ALLOW); assertThat(AzureAction.fromString("Deny")) - .as("fromString should return DENY for 'Deny'") - .isEqualTo(AzureAction.DENY); + .as("fromString should return DENY for 'Deny'") + .isEqualTo(AzureAction.DENY); } @Test @@ -29,7 +29,7 @@ public void valuesMethod_shouldContainAllAzureActionsWithCorrectSize() { Collection values = AzureAction.values(); assertThat(values) - .as("Values should contain ALLOW, DENY and have exactly 2 values") - .containsExactlyInAnyOrder(AzureAction.ALLOW, AzureAction.DENY); + .as("Values should contain ALLOW, DENY and have exactly 2 values") + .containsExactlyInAnyOrder(AzureAction.ALLOW, AzureAction.DENY); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActiveDirectoryProfileTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActiveDirectoryProfileTest.java index df109195..6ac66ad8 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActiveDirectoryProfileTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureActiveDirectoryProfileTest.java @@ -13,7 +13,7 @@ public class AzureActiveDirectoryProfileTest { @Test public void returns_nulls_when_azureActiveDirectoryProfileWithDefaultBuilder() { var aadProfile = AzureActiveDirectoryProfile.builder() - .build(); + .build(); assertThat(aadProfile.getManaged()).isEqualTo(null); assertThat(aadProfile.getEnableAzureRbac()).isEqualTo(null); @@ -23,8 +23,8 @@ public void returns_nulls_when_azureActiveDirectoryProfileWithDefaultBuilder() { @Test public void returns_managed_false_when_azureActiveDirectoryProfileWithManagedFalseBuilder() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withManaged(false) - .build(); + .withManaged(false) + .build(); assertThat(aadProfile.getManaged()).isEqualTo(false); assertThat(aadProfile.getEnableAzureRbac()).isEqualTo(null); @@ -34,8 +34,8 @@ public void returns_managed_false_when_azureActiveDirectoryProfileWithManagedFal @Test public void returns_managed_true_when_azureActiveDirectoryProfileWithManagedTrueBuilder() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withManaged(true) - .build(); + .withManaged(true) + .build(); assertThat(aadProfile.getManaged()).isEqualTo(true); assertThat(aadProfile.getEnableAzureRbac()).isEqualTo(null); @@ -45,9 +45,9 @@ public void returns_managed_true_when_azureActiveDirectoryProfileWithManagedTrue @Test public void returns_enableAzureRbac_false_when_azureActiveDirectoryProfileWithEnableAzureRbacFalseBuilder() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withManaged(true) - .withEnableAzureRbac(false) - .build(); + .withManaged(true) + .withEnableAzureRbac(false) + .build(); assertThat(aadProfile.getManaged()).isEqualTo(true); assertThat(aadProfile.getEnableAzureRbac()).isEqualTo(false); @@ -57,10 +57,10 @@ public void returns_enableAzureRbac_false_when_azureActiveDirectoryProfileWithEn @Test public void returns_enableAzureRbac_true_when_azureActiveDirectoryProfileWithEnableAzureRbacTrueBuilder() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withManaged(true) - .withEnableAzureRbac(true) - .build(); - + .withManaged(true) + .withEnableAzureRbac(true) + .build(); + assertThat(aadProfile.getManaged()).isEqualTo(true); assertThat(aadProfile.getEnableAzureRbac()).isEqualTo(true); assertThat(aadProfile.getAdminGroupObjectIDs()).isEqualTo(null); @@ -69,17 +69,17 @@ public void returns_enableAzureRbac_true_when_azureActiveDirectoryProfileWithEna @Test public void returns_one_AdminGroupObjectIDs_when_azureActiveDirectoryProfileWithOneGroupId() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withAdminGroupObjectId(UUID.randomUUID().toString()) - .build(); - + .withAdminGroupObjectId(UUID.randomUUID().toString()) + .build(); + assertThat(aadProfile.getAdminGroupObjectIDs().size()).isEqualTo(1); } @Test public void returns_two_AdminGroupObjectIDs_when_azureActiveDirectoryProfileWithListGroupIds() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withAdminGroupObjectIDs(List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())) - .build(); + .withAdminGroupObjectIDs(List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())) + .build(); assertThat(aadProfile.getAdminGroupObjectIDs().size()).isEqualTo(2); } @@ -87,10 +87,10 @@ public void returns_two_AdminGroupObjectIDs_when_azureActiveDirectoryProfileWith @Test public void returns_without_errors_when_azureActiveDirectoryProfileBuilderWithAllParameters() { var aadProfile = AzureActiveDirectoryProfile.builder() - .withManaged(true) - .withEnableAzureRbac(true) - .withAdminGroupObjectIDs(List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())) - .build(); + .withManaged(true) + .withEnableAzureRbac(true) + .withAdminGroupObjectIDs(List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())) + .build(); assertThat(aadProfile.getManaged()).isEqualTo(true); assertThat(aadProfile.getEnableAzureRbac()).isEqualTo(true); @@ -100,12 +100,12 @@ public void returns_without_errors_when_azureActiveDirectoryProfileBuilderWithAl @Test public void validationError_when_azureActiveDirectoryProfileWithAdminGroupObjectIDsEmptyBuilder() { assertThatThrownBy(() -> AzureActiveDirectoryProfile.builder() - .withManaged(true) - .withEnableAzureRbac(true) - .withAdminGroupObjectIDs(List.of()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("adminGroupObjectIDs is empty but it is required"); + .withManaged(true) + .withEnableAzureRbac(true) + .withAdminGroupObjectIDs(List.of()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("adminGroupObjectIDs is empty but it is required"); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesPodManagedIdentityTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesPodManagedIdentityTest.java index c24d37f3..7a72499b 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesPodManagedIdentityTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesPodManagedIdentityTest.java @@ -13,70 +13,70 @@ public class AzureKubernetesPodManagedIdentityTest { @Test public void exceptionThrown_when_aksCreatedWithNameNotValid() { assertThatThrownBy(() -> getDefaultAks() - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("") - .build()) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name has not been defined and it is required"); + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("") + .build()) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name has not been defined and it is required"); } @Test public void exceptionThrown_when_aksCreatedWithNamespaceNotValid() { assertThatThrownBy(() -> getDefaultAks() - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("azure-pod-identity") - .withNamespace("") - .build()) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Namespace has not been defined and it is required"); + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("azure-pod-identity") + .withNamespace("") + .build()) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Namespace has not been defined and it is required"); } @Test public void exceptionThrown_when_aksCreatedWithExceptionPodLabelsNotValid() { assertThatThrownBy(() -> getDefaultAks() - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("azure-pod-identity") - .withNamespace("kube-system") - .withExceptionPodLabels(null) - .build()) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Exception pod labels has not been defined and it is required"); + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("azure-pod-identity") + .withNamespace("kube-system") + .withExceptionPodLabels(null) + .build()) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Exception pod labels has not been defined and it is required"); } @Test public void exceptionThrown_when_aksCreatedWithEnableNotValid() { assertThatThrownBy(() -> getDefaultAks() - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("azure-pod-identity") - .withNamespace("kube-system") - .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) - .withEnable(null) - .build()) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Enable has not been defined and it is required"); + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("azure-pod-identity") + .withNamespace("kube-system") + .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) + .withEnable(null) + .build()) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Enable has not been defined and it is required"); } @Test public void exceptionThrown_when_aksCreatedWithAllowNetworkPluginKubeNetNotValid() { assertThatThrownBy(() -> getDefaultAks() - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("azure-pod-identity") - .withNamespace("kube-system") - .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) - .withEnable(true) - .withAllowNetworkPluginKubeNet(null) - .build()) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("AllowNetworkPluginKubeNet has not been defined and it is required"); + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("azure-pod-identity") + .withNamespace("kube-system") + .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) + .withEnable(true) + .withAllowNetworkPluginKubeNet(null) + .build()) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("AllowNetworkPluginKubeNet has not been defined and it is required"); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceIpRangeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceIpRangeTest.java index 541ebc36..f688a373 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceIpRangeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceIpRangeTest.java @@ -13,79 +13,79 @@ public class AzureKubernetesServiceIpRangeTest { @ValueSource(strings = {"255.255.255.256", "10.2.0.0/33", "1.1.1.1"}) public void exceptionThrown_when_aksCreatedWithServiceIpRangeNotValid(String input) { assertThatThrownBy(() -> getDefaultAks() - .withServiceIpRange(input) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Service IP Range does not contain a valid ip with mask"); + .withServiceIpRange(input) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Service IP Range does not contain a valid ip with mask"); } @ParameterizedTest @ValueSource(strings = {"255.255.255.256", "10.2.0.0/33", "1.1.1.1"}) public void exceptionThrown_when_aksCreatedWithPodIpRangeNotValid(String input) { assertThatThrownBy(() -> getDefaultAks() - .withPodIpRange(input) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Pod IP Range does not contain a valid ip with mask"); + .withPodIpRange(input) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Pod IP Range does not contain a valid ip with mask"); } @ParameterizedTest @ValueSource(strings = {"255.255.255.256", "10.2.0.0/33", "1.1.1.1"}) public void exceptionThrown_when_aksCreatedWithVnetAddressSpaceIpRangeNotValid(String input) { assertThatThrownBy(() -> getDefaultAks() - .withVnetAddressSpaceIpRange(input) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("VNet Address Space IP Range does not contain a valid ip with mask"); + .withVnetAddressSpaceIpRange(input) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("VNet Address Space IP Range does not contain a valid ip with mask"); } @ParameterizedTest @ValueSource(strings = {"255.255.255.256", "10.2.0.0/33", "1.1.1.1"}) public void exceptionThrown_when_aksCreatedWithVnetSubnetAddressIpRangeNotValid(String input) { assertThatThrownBy(() -> getDefaultAks() - .withVnetSubnetAddressIpRange(input) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("VNet Subnet Address IP Range does not contain a valid ip with mask"); + .withVnetSubnetAddressIpRange(input) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("VNet Subnet Address IP Range does not contain a valid ip with mask"); } @ParameterizedTest @ValueSource(strings = {"10.2.0.0/16", "10.2.0.255/16", "10.2.0.0/32"}) public void exceptionThrown_when_aksCreatedWithServiceIpRangeValid(String input) { assertThat(getDefaultAks() - .withServiceIpRange(input) - .build() - .validate()).isEmpty(); + .withServiceIpRange(input) + .build() + .validate()).isEmpty(); } @ParameterizedTest @ValueSource(strings = {"10.2.0.0/16", "10.2.0.255/16", "10.2.0.0/32"}) public void exceptionThrown_when_aksCreatedWithPodIpRangeValid(String input) { assertThat(getDefaultAks() - .withPodIpRange(input) - .build() - .validate()).isEmpty(); + .withPodIpRange(input) + .build() + .validate()).isEmpty(); } @ParameterizedTest @ValueSource(strings = {"10.2.0.0/16", "10.2.0.255/16", "10.2.0.0/32"}) public void exceptionThrown_when_aksCreatedWithVnetAddressSpaceIpRangeValid(String input) { assertThat(getDefaultAks() - .withVnetAddressSpaceIpRange(input) - .build() - .validate()).isEmpty(); + .withVnetAddressSpaceIpRange(input) + .build() + .validate()).isEmpty(); } @ParameterizedTest @ValueSource(strings = {"10.2.0.0/16", "10.2.0.255/16", "10.2.0.0/32"}) public void exceptionThrown_when_aksCreatedWithVnetSubnetAddressIpRangeValid(String input) { assertThat(getDefaultAks() - .withVnetSubnetAddressIpRange(input) - .build() - .validate()).isEmpty(); + .withVnetSubnetAddressIpRange(input) + .build() + .validate()).isEmpty(); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceTest.java index ba2df97d..8365022b 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureKubernetesServiceTest.java @@ -25,25 +25,25 @@ public void noValidationErrors_when_aksHasRequiredFields() { assertThat(aks.validate()).isEmpty(); assertThat(aks.getManagedClusterSkuTier()).isEqualTo(ManagedClusterSkuTier.FREE); assertThat(aks.getNodePools()).first() - .extracting(AzureNodePool::getAgentPoolMode, AzureNodePool::getOsType) - .containsExactly(AzureAgentPoolMode.SYSTEM, AzureOsType.LINUX); + .extracting(AzureNodePool::getAgentPoolMode, AzureNodePool::getOsType) + .containsExactly(AzureAgentPoolMode.SYSTEM, AzureOsType.LINUX); } - + @Test public void noValidationErrors_when_aksHasRequiredFieldsAndManagedClusterSkuTierChanged() { var aks = getDefaultAks() - .withManagedClusterSkuTier(ManagedClusterSkuTier.PREMIUM) - .build(); + .withManagedClusterSkuTier(ManagedClusterSkuTier.PREMIUM) + .build(); assertThat(aks.validate()).isEmpty(); - + assertThat(aks.getManagedClusterSkuTier()).isEqualTo(ManagedClusterSkuTier.PREMIUM); } @Test public void noValidationErrors_when_aksHasRequiredFieldsAndPrivateClusterDisabled() { var aks = getDefaultAks() - .disablePrivateCluster() - .build(); + .disablePrivateCluster() + .build(); assertThat(aks.validate()).isEmpty(); @@ -57,34 +57,34 @@ public void noValidationErrors_when_getAksBuilderHasRequiredFields() { assertThat(aks.validate()).isEmpty(); assertThat(json).isNotBlank(); assertThat(aks.getNodePools()).first() - .extracting(AzureNodePool::getAgentPoolMode, AzureNodePool::getOsType) - .containsExactly(AzureAgentPoolMode.SYSTEM, AzureOsType.LINUX); + .extracting(AzureNodePool::getAgentPoolMode, AzureNodePool::getOsType) + .containsExactly(AzureAgentPoolMode.SYSTEM, AzureOsType.LINUX); } @Test public void noValidationErrors_when_aksHasRequiredFieldsAndMultipleNodePool() { var aks = getDefaultAks().withNodePool( - AzureNodePool.builder() - .withName("winds") - .withDiskSizeGb(30) - .withMachineType(AzureMachineType.STANDARD_B2S) - .withOsType(AzureOsType.WINDOWS) - .withAgentPoolMode(AzureAgentPoolMode.USER) - .withInitialNodeCount(1) - .withAutoscalingEnabled(false) - .build()) - .withPriorityClass(PriorityClass.builder() - .withName("priority-class") - .withDescription("description") - .withPreemptionPolicy(PreemptionPolicy.PREEMPT_LOWER_PRIORITY) - .withValue(1) - .build()) - .build(); + AzureNodePool.builder() + .withName("winds") + .withDiskSizeGb(30) + .withMachineType(AzureMachineType.STANDARD_B2S) + .withOsType(AzureOsType.WINDOWS) + .withAgentPoolMode(AzureAgentPoolMode.USER) + .withInitialNodeCount(1) + .withAutoscalingEnabled(false) + .build()) + .withPriorityClass(PriorityClass.builder() + .withName("priority-class") + .withDescription("description") + .withPreemptionPolicy(PreemptionPolicy.PREEMPT_LOWER_PRIORITY) + .withValue(1) + .build()) + .build(); assertThat(aks.validate()).isEmpty(); assertThat(aks.getNodePools()).first() - .extracting(AzureNodePool::getAgentPoolMode) - .isEqualTo(AzureAgentPoolMode.SYSTEM); + .extracting(AzureNodePool::getAgentPoolMode) + .isEqualTo(AzureAgentPoolMode.SYSTEM); } @Test @@ -107,77 +107,81 @@ public void typeIsKubernetes_when_aksIsBuiltWithoutSpecifyType() { @Test public void exceptionThrown_when_aksCreatedWithNullNodePools() { var aks = AzureKubernetesService.builder() - .withId(ComponentId.from("test")); - assertThatThrownBy(aks::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list is null or empty"); + .withId(ComponentId.from("test")); + assertThatThrownBy(aks::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list " + + "is null or empty"); } @Test public void exceptionThrown_when_aksCreatedWithEmptyNodePools() { var aks = AzureKubernetesService.builder() - .withId(ComponentId.from("test")) - .withNodePools(emptyList()); - assertThatThrownBy(aks::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list is null or empty"); + .withId(ComponentId.from("test")) + .withNodePools(emptyList()); + assertThatThrownBy(aks::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list " + + "is null or empty"); } @Test public void exceptionThrown_when_aksCreatedWithPriorityClassValueNegative() { var priorityClass = PriorityClass.builder().withValue(-123); - assertThatThrownBy(priorityClass::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Value must be between 1 and 1_000_000_000"); + assertThatThrownBy(priorityClass::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Value" + + " must be between 1 and 1_000_000_000"); } @Test public void exceptionThrown_when_aksCreatedWithPriorityClassValueOverMax() { var priorityClass = PriorityClass.builder().withValue(2_000_000_001); - assertThatThrownBy(priorityClass::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Value must be between 1 and 1_000_000_000"); + assertThatThrownBy(priorityClass::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Value" + + " must be between 1 and 1_000_000_000"); } @Test public void exceptionThrown_when_aksCreatedWithWindowsSystemNodePools() { assertThatThrownBy(() -> getDefaultAks().withNodePool( - AzureNodePool.builder() - .withName("broken-node-pool-name") - .withDiskSizeGb(30) - .withOsType(AzureOsType.WINDOWS) - .build()) - .build() - .validate()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Pool Mode is set to SYSTEM"); + AzureNodePool.builder() + .withName("broken-node-pool-name") + .withDiskSizeGb(30) + .withOsType(AzureOsType.WINDOWS) + .build()) + .build() + .validate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Pool Mode is set to SYSTEM"); } @Test public void noValidationErrors_when_aksHasRequiredFieldsAndMultipleNodePoolWithCustomMachineType() { var machineType = "This_Not_Exist_For_Sure"; var aks = AzureKubernetesService.builder() - .withId(ComponentId.from("test")) + .withId(ComponentId.from("test")) + .withRegion(WEST_EUROPE) + .withResourceGroup(AzureResourceGroup.builder() .withRegion(WEST_EUROPE) - .withResourceGroup(AzureResourceGroup.builder() - .withRegion(WEST_EUROPE) - .withName("rg-test") - .build()) - .withNodePool( - AzureNodePool.builder() - .withName("winds") - .withDiskSizeGb(30) - .withMachineType(AzureMachineType.fromString(machineType)) - .withOsType(AzureOsType.WINDOWS) - .withAgentPoolMode(AzureAgentPoolMode.USER) - .withInitialNodeCount(1) - .withAutoscalingEnabled(false) - .build()) - .withPriorityClass(PriorityClass.builder() - .withName("priority-class") - .withDescription("description") - .withPreemptionPolicy(PreemptionPolicy.PREEMPT_LOWER_PRIORITY) - .withValue(1) - .build()) - .build(); + .withName("rg-test") + .build()) + .withNodePool( + AzureNodePool.builder() + .withName("winds") + .withDiskSizeGb(30) + .withMachineType(AzureMachineType.fromString(machineType)) + .withOsType(AzureOsType.WINDOWS) + .withAgentPoolMode(AzureAgentPoolMode.USER) + .withInitialNodeCount(1) + .withAutoscalingEnabled(false) + .build()) + .withPriorityClass(PriorityClass.builder() + .withName("priority-class") + .withDescription("description") + .withPreemptionPolicy(PreemptionPolicy.PREEMPT_LOWER_PRIORITY) + .withValue(1) + .build()) + .build(); var json = TestUtils.getJsonRepresentation(aks); assertThat(aks.validate()).isEmpty(); assertThat(json).isNotBlank(); assertThat(aks.getNodePools()).first() - .extracting(a -> a.getMachineType().toString()) - .isEqualTo(machineType); + .extracting(a -> a.getMachineType().toString()) + .isEqualTo(machineType); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineTypeTest.java index 6c4f3cd7..b1f34052 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureMachineTypeTest.java @@ -13,13 +13,13 @@ public void valuesContainsNewValue_when_CustomValueAdded() { var newValue = AzureMachineType.fromString("This_Not_Exist_For_Sure"); assertThat(AzureMachineType.values()).contains(newValue); } - + @Test @Order(2) public void correctValues_when_customEnum() { var valueToExtend = "This_Not_Exist_For_Sure"; var enumValue = AzureMachineType.fromString(valueToExtend); - + assertThat(valueToExtend).isEqualTo(enumValue.toString()); } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureNodePoolTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureNodePoolTest.java index d1f793f4..6be5e793 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureNodePoolTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureNodePoolTest.java @@ -15,43 +15,43 @@ public class AzureNodePoolTest { @Test public void validationError_when_azureNodePoolWithNullName() { assertThatThrownBy(() -> getAzureNodePoolBuilder(null, 30, false).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name has not been defined and it is required"); } @Test public void validationError_when_azureNodePoolWithEmptyName() { assertThatThrownBy(() -> getAzureNodePoolBuilder("", 30, false).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name has not been defined and it is required"); } @Test public void validationError_when_azureNodePoolWithBlankName() { assertThatThrownBy(() -> getAzureNodePoolBuilder(" ", 30, false).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name has not been defined and it is required"); } @Test public void validationError_when_azureNodePoolWithNullMachineType() { assertThatThrownBy(() -> getAzureNodePoolBuilder("test", 30, false).withMachineType(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Machine Type has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Machine Type has not been defined and it is required"); } @Test public void validationError_when_azureNodePoolWithNameThatContainOtherCharacters() { assertThatThrownBy(() -> getAzureNodePoolBuilder("name-name", 30, false).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name should only contain lowercase alphanumeric characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name should only contain lowercase alphanumeric characters"); } @Test public void validationError_when_azureNodePoolWithNameThatContainUpperCase() { assertThatThrownBy(() -> getAzureNodePoolBuilder("Name", 30, false).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name should only contain lowercase alphanumeric characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name should only contain lowercase alphanumeric characters"); } @Test @@ -59,8 +59,8 @@ public void validationError_when_azureNodePoolWithNameTooLongForWindows() { var builder = getAzureNodePoolBuilder("nametoolong", 30, false); builder.withOsType(AzureOsType.WINDOWS); assertThatThrownBy(builder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name for node with Windows OS Type should be between 1 and 6 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name for node with Windows OS Type should be between 1 and 6 characters"); } @Test @@ -68,45 +68,45 @@ public void validationError_when_azureNodePoolWithNameTooLongForLinux() { var builder = getAzureNodePoolBuilder("namewaytoooooolong", 30, false); builder.withOsType(AzureOsType.LINUX); assertThatThrownBy(builder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name for node with Linux OS Type should be between 1 and 12 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name for node with Linux OS Type should be between 1 and 12 characters"); } @Test public void validationError_when_azureNodePoolWithDiskSizeLessThan30Gb() { assertThatThrownBy(() -> getAzureNodePoolBuilder("name", 29, false).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Disk size must be at least 30GB"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Disk size must be at least 30GB"); } @Test public void validationError_when_SystemNodePoolWithMinNodeCountEqualTo0() { assertThatThrownBy(() -> - AzureNodePool.builder() - .withName("name") - .withDiskSizeGb(30) - .withMachineType(AzureMachineType.STANDARD_B2S) - .withAutoscalingEnabled(true) - .withMinNodeCount(0) - .withMaxNodeCount(3) - .build() - ) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("MinNodeCount must be between 1 and 1000, the value entered is: 0"); - } - - @Test - public void noValidationErrors_when_UserNodePoolWithMinNodeCountEqualTo0() { - assertThat(AzureNodePool.builder() + AzureNodePool.builder() .withName("name") .withDiskSizeGb(30) .withMachineType(AzureMachineType.STANDARD_B2S) - .withAgentPoolMode(AzureAgentPoolMode.USER) .withAutoscalingEnabled(true) .withMinNodeCount(0) .withMaxNodeCount(3) .build() - .validate()).isEmpty(); + ) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("MinNodeCount must be between 1 and 1000, the value entered is: 0"); + } + + @Test + public void noValidationErrors_when_UserNodePoolWithMinNodeCountEqualTo0() { + assertThat(AzureNodePool.builder() + .withName("name") + .withDiskSizeGb(30) + .withMachineType(AzureMachineType.STANDARD_B2S) + .withAgentPoolMode(AzureAgentPoolMode.USER) + .withAutoscalingEnabled(true) + .withMinNodeCount(0) + .withMaxNodeCount(3) + .build() + .validate()).isEmpty(); } @Test @@ -117,8 +117,8 @@ public void noValidationErrors_when_azureNodePoolWithValidFields() { @Test public void noValidationErrors_when_azureNodePoolMinimalFields() { var builder = AzureNodePool.builder() - .withName("azurenode") - .withMachineType(AzureMachineType.STANDARD_B2S); + .withName("azurenode") + .withMachineType(AzureMachineType.STANDARD_B2S); assertThat(builder.build().validate()).isEmpty(); } @@ -131,100 +131,104 @@ public void returns_3_nodeTaints_when_azureNodePoolWithValidFields() { @Test public void validationError_when_azureNodePoolWithMaxNodeCountNullAndAutoscalingEnabled() { assertThatThrownBy(() -> getAzureNodePoolBuilder("name", 30, true).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("MinNodeCount has not been defined and it is required when autoscaling is enabled"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("MinNodeCount has not been defined and it is required when autoscaling is enabled"); } @Test public void correctValues_when_azureNodePoolBuilt() { var nodePool = getAzureNodePoolBuilder("linux", 50, true) - .withMinNodeCount(1) - .withMaxNodeCount(2) - .build(); + .withMinNodeCount(1) + .withMaxNodeCount(2) + .build(); assertThat(nodePool) - .extracting("name", "diskSizeGb", "autoscalingEnabled", "minNodeCount", "maxNodeCount") - .contains("linux", 50, true, 1, 2); + .extracting("name", "diskSizeGb", "autoscalingEnabled", "minNodeCount", "maxNodeCount") + .contains("linux", 50, true, 1, 2); } - private AzureNodePool.AzureNodePoolBuilder getAzureNodePoolBuilder(String name, int diskSizeGb, boolean autoscalingEnabled) { + private AzureNodePool.AzureNodePoolBuilder getAzureNodePoolBuilder( + String name, + int diskSizeGb, + boolean autoscalingEnabled) + { return AzureNodePool.builder() - .withName(name) - .withDiskSizeGb(diskSizeGb) - .withMachineType(AzureMachineType.STANDARD_B2S) - .withInitialNodeCount(1) - .withMaxNodeCount(3) - .withNodeTaint(NodeTaint.builder() - .withKey("testKey") - .withValue("testValue") - .withEffect(TaintEffect.NO_EXECUTE) - .build()) - .withNodeTaints(List.of( - NodeTaint.builder().withKey("key1").withValue("value1").withEffect(TaintEffect.NO_SCHEDULE).build(), - NodeTaint.builder().withKey("key2").withValue("value3").withEffect(TaintEffect.PREFER_NO_SCHEDULE).build() - )) - .withAutoscalingEnabled(autoscalingEnabled); + .withName(name) + .withDiskSizeGb(diskSizeGb) + .withMachineType(AzureMachineType.STANDARD_B2S) + .withInitialNodeCount(1) + .withMaxNodeCount(3) + .withNodeTaint(NodeTaint.builder() + .withKey("testKey") + .withValue("testValue") + .withEffect(TaintEffect.NO_EXECUTE) + .build()) + .withNodeTaints(List.of( + NodeTaint.builder().withKey("key1").withValue("value1").withEffect(TaintEffect.NO_SCHEDULE).build(), + NodeTaint.builder().withKey("key2").withValue("value3").withEffect(TaintEffect.PREFER_NO_SCHEDULE).build() + )) + .withAutoscalingEnabled(autoscalingEnabled); } @Test public void correctValues_when_azureNodePoolWithAzureLinuxOsSkuBuilt() { var nodePoolName = "azlinuxpool"; var nodePool = AzureNodePool.builder() - .withName(nodePoolName) - .withMachineType(AzureMachineType.STANDARD_B2S) - .withOsType(AzureOsType.LINUX) - .withOsSku(AzureOsSku.AZURE_LINUX) - .build(); - - + .withName(nodePoolName) + .withMachineType(AzureMachineType.STANDARD_B2S) + .withOsType(AzureOsType.LINUX) + .withOsSku(AzureOsSku.AZURE_LINUX) + .build(); + + assertThat(nodePool) - .extracting("name", "osType", "osSku", "agentPoolMode") - .contains(nodePoolName, AzureOsType.LINUX, AzureOsSku.AZURE_LINUX, AzureAgentPoolMode.SYSTEM); + .extracting("name", "osType", "osSku", "agentPoolMode") + .contains(nodePoolName, AzureOsType.LINUX, AzureOsSku.AZURE_LINUX, AzureAgentPoolMode.SYSTEM); } @Test public void validationError_when_azureNodePoolWithLinuxOsTypeAndWindowsOsSku() { assertThatThrownBy(() -> AzureNodePool.builder() - .withName("azlinuxpool") - .withMachineType(AzureMachineType.STANDARD_B2S) - .withOsType(AzureOsType.LINUX) - .withOsSku(AzureOsSku.WINDOWS2019) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Windows OS SKU cannot be used with Linux OS Type"); + .withName("azlinuxpool") + .withMachineType(AzureMachineType.STANDARD_B2S) + .withOsType(AzureOsType.LINUX) + .withOsSku(AzureOsSku.WINDOWS2019) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Windows OS SKU cannot be used with Linux OS Type"); } @Test public void validationError_when_azureNodePoolWithWindowsOsTypeAndAzureLinuxOsSku() { assertThatThrownBy(() -> AzureNodePool.builder() - .withName("windowspool") - .withMachineType(AzureMachineType.STANDARD_B2S) - .withOsType(AzureOsType.WINDOWS) - .withOsSku(AzureOsSku.AZURE_LINUX) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Linux OS SKU cannot be used with Windows OS Type"); + .withName("windowspool") + .withMachineType(AzureMachineType.STANDARD_B2S) + .withOsType(AzureOsType.WINDOWS) + .withOsSku(AzureOsSku.AZURE_LINUX) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Linux OS SKU cannot be used with Windows OS Type"); } @Test public void useGen2VirtualMachineIsTrue_when_defaultConfiguration() { var nodePool = getAzureNodePoolBuilder("linux", 50, true) - .withMinNodeCount(1) - .withMaxNodeCount(2) - .build(); + .withMinNodeCount(1) + .withMaxNodeCount(2) + .build(); assertThat(nodePool.isUseGen2VirtualMachine()) - .isEqualTo(true); + .isEqualTo(true); } @Test public void useGen2VirtualMachineIsFalse_when_properlyConfigured() { var nodePool = getAzureNodePoolBuilder("linux", 50, true) - .withUseGen2VirtualMachine(false) - .withMinNodeCount(1) - .withMaxNodeCount(2) - .build(); + .withUseGen2VirtualMachine(false) + .withMinNodeCount(1) + .withMaxNodeCount(2) + .build(); assertThat(nodePool.isUseGen2VirtualMachine()) - .isEqualTo(false); + .isEqualTo(false); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSkuTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSkuTest.java index 30c6a034..0fd1a798 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSkuTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureOsSkuTest.java @@ -6,7 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class AzureOsSkuTest { - + @Test public void testAzureLinuxInstance() { assertEquals("AzureLinux", AzureOsSku.AZURE_LINUX.toString()); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSQLDBTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSQLDBTest.java index 6a8877a5..0e3a89f3 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSQLDBTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSQLDBTest.java @@ -8,55 +8,62 @@ class AzurePostgreSQLDBTest { - @Test - public void validationError_when_dbWithNullName() { - var db = AzurePostgreSqlDatabase.builder(); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"); - } - - @Test - public void validationError_when_dbWithEmptyName() { - var db = AzurePostgreSqlDatabase.builder().withName(""); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"); - } - - @Test - public void validationError_when_dbWithBlankName() { - var db = AzurePostgreSqlDatabase.builder().withName(" "); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"); - } - - @Test - public void validationError_when_dbWithBlankCollation() { - var db = AzurePostgreSqlDatabase.builder().withCollation(" "); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB collation defined was either empty or blank and it is required"); - } - - @Test - public void validationError_when_dbWithEmptyCollation() { - var db = AzurePostgreSqlDatabase.builder().withCollation(""); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB collation defined was either empty or blank and it is required"); - } - - @Test - public void validationError_when_dbWithBlankSchema() { - var db = AzurePostgreSqlDatabase.builder().withSchema(" "); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB schema defined was either empty or blank and it is required"); - } - - @Test - public void validationError_when_dbWithEmptySchema() { - var db = AzurePostgreSqlDatabase.builder().withSchema(""); - assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB schema defined was either empty or blank and it is required"); - } - - @Test - public void noValidationError_when_dbWithValidName() { - var pgdb = AzurePostgreSqlDatabase.builder().withId(ComponentId.from("dbid")).withName("db").build(); - assertThat(pgdb.validate()).isEmpty(); - assertThat(pgdb.getCharset()).isNull(); - assertThat(pgdb.getCollation()).isNull(); - assertThat(pgdb.getSchema()).isNull(); - } + @Test + public void validationError_when_dbWithNullName() { + var db = AzurePostgreSqlDatabase.builder(); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining( + "[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"); + } + + @Test + public void validationError_when_dbWithEmptyName() { + var db = AzurePostgreSqlDatabase.builder().withName(""); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining( + "[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"); + } + + @Test + public void validationError_when_dbWithBlankName() { + var db = AzurePostgreSqlDatabase.builder().withName(" "); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining( + "[AzurePostgreSqlDatabase Validation] name has not been defined and it is required"); + } + + @Test + public void validationError_when_dbWithBlankCollation() { + var db = AzurePostgreSqlDatabase.builder().withCollation(" "); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB " + + "collation defined was either empty or blank and it is required"); + } + + @Test + public void validationError_when_dbWithEmptyCollation() { + var db = AzurePostgreSqlDatabase.builder().withCollation(""); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB " + + "collation defined was either empty or blank and it is required"); + } + + @Test + public void validationError_when_dbWithBlankSchema() { + var db = AzurePostgreSqlDatabase.builder().withSchema(" "); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB " + + "schema defined was either empty or blank and it is required"); + } + + @Test + public void validationError_when_dbWithEmptySchema() { + var db = AzurePostgreSqlDatabase.builder().withSchema(""); + assertThatThrownBy(db::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("PostgreSQLDB " + + "schema defined was either empty or blank and it is required"); + } + + @Test + public void noValidationError_when_dbWithValidName() { + var pgdb = AzurePostgreSqlDatabase.builder().withId(ComponentId.from("dbid")).withName("db").build(); + assertThat(pgdb.validate()).isEmpty(); + assertThat(pgdb.getCharset()).isNull(); + assertThat(pgdb.getCollation()).isNull(); + assertThat(pgdb.getSchema()).isNull(); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlTest.java index 8a0979aa..99d43057 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzurePostgreSqlTest.java @@ -20,37 +20,37 @@ public class AzurePostgreSqlTest { public void exceptionThrown_when_azurePgCreatedWithNoIdNoRegionNoNetwork() { var azurePg = AzurePostgreSqlDbms.builder(); assertThatThrownBy(azurePg::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "Component id has not been defined and it is required", - "[AzurePostgreSQL Validation] Region has not been defined and it is required"); + "Component id has not been defined and it is required", + "[AzurePostgreSQL Validation] Region has not been defined and it is required"); } @Test public void exceptionThrown_when_azurePgCreatedWithJustId() { var azurePg = AzurePostgreSqlDbms.builder().withId(ComponentId.from("azure-pg")); assertThatThrownBy(azurePg::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[AzurePostgreSQL Validation] Region has not been defined and it is required"); + "[AzurePostgreSQL Validation] Region has not been defined and it is required"); } @Test public void exceptionThrown_when_azurePgCreatedWithBackUpRetentionDaysLessThan7() { var azurePg = AzurePostgreSqlDbms.builder() - .withId(ComponentId.from("azure-pg")) - .withRegion(WEST_EUROPE) - .withStorageGb(1234) - .withBackupRetentionDays(6); + .withId(ComponentId.from("azure-pg")) + .withRegion(WEST_EUROPE) + .withStorageGb(1234) + .withBackupRetentionDays(6); assertThatThrownBy(azurePg::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[AzurePostgreSQL Validation] Backup Retention Days must be between 7 and 35 days"); + "[AzurePostgreSQL Validation] Backup Retention Days must be between 7 and 35 days"); } @Test public void exceptionThrown_when_azurePgCreatedWithBackUpRetentionDaysHigherThan35() { var azurePg = AzurePostgreSqlDbms.builder() - .withId(ComponentId.from("azure-pg")) - .withRegion(WEST_EUROPE) - .withStorageGb(1234) - .withBackupRetentionDays(36); + .withId(ComponentId.from("azure-pg")) + .withRegion(WEST_EUROPE) + .withStorageGb(1234) + .withBackupRetentionDays(36); assertThatThrownBy(azurePg::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[AzurePostgreSQL Validation] Backup Retention Days must be between 7 and 35 days"); + "[AzurePostgreSQL Validation] Backup Retention Days must be between 7 and 35 days"); } @Test @@ -62,39 +62,39 @@ public void propertiesAreSet_when_azurePgCreatedWithJustIdAndRegion() { @Test public void propertiesAreSet_when_azurePostgresIsCreated() { var azurePostgreSql = AzurePostgreSqlDbms.builder() - .withId(ComponentId.from("azure-psg")) - .withRegion(WEST_EUROPE) - .withRootUser("rootUser") - .withSkuName(B_GEN5_1) - .withStorageAutoGrow(ENABLED) - .withStorageGb(5 * 1024) - .withBackupRetentionDays(12) - .withDatabase(AzurePostgreSqlDatabase.builder() - .withId(ComponentId.from("db-1")) - .withName("db") - .withCharset(UTF8) - .withCollation("collation") - .withSchema("schema") - .build()) - .build(); + .withId(ComponentId.from("azure-psg")) + .withRegion(WEST_EUROPE) + .withRootUser("rootUser") + .withSkuName(B_GEN5_1) + .withStorageAutoGrow(ENABLED) + .withStorageGb(5 * 1024) + .withBackupRetentionDays(12) + .withDatabase(AzurePostgreSqlDatabase.builder() + .withId(ComponentId.from("db-1")) + .withName("db") + .withCharset(UTF8) + .withCollation("collation") + .withSchema("schema") + .build()) + .build(); assertThat(azurePostgreSql) - .returns(PAAS_POSTGRESQL_DBMS, from(AzurePostgreSqlDbms::getType)) - .returns(AZURE, from(AzurePostgreSqlDbms::getProvider)) - .returns(WEST_EUROPE, from(AzurePostgreSqlDbms::getAzureRegion)) - .returns("rootUser", from(AzurePostgreSqlDbms::getRootUser)) - .returns(B_GEN5_1, from(AzurePostgreSqlDbms::getSkuName)) - .returns(ENABLED, from(AzurePostgreSqlDbms::getStorageAutoGrow)) - .returns(5 * 1024, from(AzurePostgreSqlDbms::getStorageGb)) - .returns(12, from(AzurePostgreSqlDbms::getBackupRetentionDays)) - .returns(1, from(x -> x.getDatabases().size())); + .returns(PAAS_POSTGRESQL_DBMS, from(AzurePostgreSqlDbms::getType)) + .returns(AZURE, from(AzurePostgreSqlDbms::getProvider)) + .returns(WEST_EUROPE, from(AzurePostgreSqlDbms::getAzureRegion)) + .returns("rootUser", from(AzurePostgreSqlDbms::getRootUser)) + .returns(B_GEN5_1, from(AzurePostgreSqlDbms::getSkuName)) + .returns(ENABLED, from(AzurePostgreSqlDbms::getStorageAutoGrow)) + .returns(5 * 1024, from(AzurePostgreSqlDbms::getStorageGb)) + .returns(12, from(AzurePostgreSqlDbms::getBackupRetentionDays)) + .returns(1, from(x -> x.getDatabases().size())); Optional postgreSqlDbOptional = azurePostgreSql.getDatabases().stream().findFirst(); assertThat(postgreSqlDbOptional).isPresent(); assertThat(postgreSqlDbOptional.get()) - .returns("db", from(PaaSPostgreSqlDatabase::getName)) - .returns(UTF8, from(PaaSPostgreSqlDatabase::getCharset)) - .returns("collation", from(PaaSPostgreSqlDatabase::getCollation)) - .returns("schema", from(PaaSPostgreSqlDatabase::getSchema)) - .returns(AZURE, from(PaaSPostgreSqlDatabase::getProvider)); + .returns("db", from(PaaSPostgreSqlDatabase::getName)) + .returns(UTF8, from(PaaSPostgreSqlDatabase::getCharset)) + .returns("collation", from(PaaSPostgreSqlDatabase::getCollation)) + .returns("schema", from(PaaSPostgreSqlDatabase::getSchema)) + .returns(AZURE, from(PaaSPostgreSqlDatabase::getProvider)); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegionTest.java index 95551bf1..88e7bc06 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureRegionTest.java @@ -11,478 +11,478 @@ public class AzureRegionTest { @Test public void azureActionConstants_shouldNotBeBlank() { AzureRegion.values().forEach(x -> - assertThat(x.toString()).isNotBlank()); + assertThat(x.toString()).isNotBlank()); } @Test public void fromString_shouldReturnCorrespondingAzureAction() { assertThat(AzureRegion.fromString("eastus")) - .as("fromString should return EAST_US for 'eastus'") - .isEqualTo(AzureRegion.EAST_US); + .as("fromString should return EAST_US for 'eastus'") + .isEqualTo(AzureRegion.EAST_US); assertThat(AzureRegion.fromString("eastus2")) - .as("fromString should return EAST_US2 for 'eastus2'") - .isEqualTo(AzureRegion.EAST_US2); + .as("fromString should return EAST_US2 for 'eastus2'") + .isEqualTo(AzureRegion.EAST_US2); assertThat(AzureRegion.fromString("southcentralus")) - .as("fromString should return SOUTH_CENTRAL_US for 'southcentralus'") - .isEqualTo(AzureRegion.SOUTH_CENTRAL_US); + .as("fromString should return SOUTH_CENTRAL_US for 'southcentralus'") + .isEqualTo(AzureRegion.SOUTH_CENTRAL_US); assertThat(AzureRegion.fromString("westus2")) - .as("fromString should return WEST_US2 for 'westus2'") - .isEqualTo(AzureRegion.WEST_US2); + .as("fromString should return WEST_US2 for 'westus2'") + .isEqualTo(AzureRegion.WEST_US2); assertThat(AzureRegion.fromString("westus3")) - .as("fromString should return WEST_US_3 for 'westus3'") - .isEqualTo(AzureRegion.WEST_US3); + .as("fromString should return WEST_US_3 for 'westus3'") + .isEqualTo(AzureRegion.WEST_US3); assertThat(AzureRegion.fromString("australiaeast")) - .as("fromString should return AUSTRALIA_EAST for 'australiaeast'") - .isEqualTo(AzureRegion.AUSTRALIA_EAST); + .as("fromString should return AUSTRALIA_EAST for 'australiaeast'") + .isEqualTo(AzureRegion.AUSTRALIA_EAST); assertThat(AzureRegion.fromString("southeastasia")) - .as("fromString should return SOUTHEAST_ASIA for 'southeastasia'") - .isEqualTo(AzureRegion.SOUTHEAST_ASIA); + .as("fromString should return SOUTHEAST_ASIA for 'southeastasia'") + .isEqualTo(AzureRegion.SOUTHEAST_ASIA); assertThat(AzureRegion.fromString("northeurope")) - .as("fromString should return NORTH_EUROPE for 'northeurope'") - .isEqualTo(AzureRegion.NORTH_EUROPE); + .as("fromString should return NORTH_EUROPE for 'northeurope'") + .isEqualTo(AzureRegion.NORTH_EUROPE); assertThat(AzureRegion.fromString("swedencentral")) - .as("fromString should return SWEDEN_CENTRAL for 'swedencentral'") - .isEqualTo(AzureRegion.SWEDEN_CENTRAL); + .as("fromString should return SWEDEN_CENTRAL for 'swedencentral'") + .isEqualTo(AzureRegion.SWEDEN_CENTRAL); assertThat(AzureRegion.fromString("uksouth")) - .as("fromString should return UK_SOUTH for 'uksouth'") - .isEqualTo(AzureRegion.UK_SOUTH); + .as("fromString should return UK_SOUTH for 'uksouth'") + .isEqualTo(AzureRegion.UK_SOUTH); assertThat(AzureRegion.fromString("westeurope")) - .as("fromString should return WEST_EUROPE for 'westeurope'") - .isEqualTo(AzureRegion.WEST_EUROPE); + .as("fromString should return WEST_EUROPE for 'westeurope'") + .isEqualTo(AzureRegion.WEST_EUROPE); assertThat(AzureRegion.fromString("centralus")) - .as("fromString should return CENTRAL_US for 'centralus'") - .isEqualTo(AzureRegion.CENTRAL_US); + .as("fromString should return CENTRAL_US for 'centralus'") + .isEqualTo(AzureRegion.CENTRAL_US); assertThat(AzureRegion.fromString("southafricanorth")) - .as("fromString should return SOUTH_AFRICA_NORTH for 'southafricanorth'") - .isEqualTo(AzureRegion.SOUTH_AFRICA_NORTH); + .as("fromString should return SOUTH_AFRICA_NORTH for 'southafricanorth'") + .isEqualTo(AzureRegion.SOUTH_AFRICA_NORTH); assertThat(AzureRegion.fromString("centralindia")) - .as("fromString should return CENTRAL_INDIA for 'centralindia'") - .isEqualTo(AzureRegion.CENTRAL_INDIA); + .as("fromString should return CENTRAL_INDIA for 'centralindia'") + .isEqualTo(AzureRegion.CENTRAL_INDIA); assertThat(AzureRegion.fromString("eastasia")) - .as("fromString should return EAST_ASIA for 'eastasia'") - .isEqualTo(AzureRegion.EAST_ASIA); + .as("fromString should return EAST_ASIA for 'eastasia'") + .isEqualTo(AzureRegion.EAST_ASIA); assertThat(AzureRegion.fromString("japaneast")) - .as("fromString should return JAPAN_EAST for 'japaneast'") - .isEqualTo(AzureRegion.JAPAN_EAST); + .as("fromString should return JAPAN_EAST for 'japaneast'") + .isEqualTo(AzureRegion.JAPAN_EAST); assertThat(AzureRegion.fromString("koreacentral")) - .as("fromString should return KOREA_CENTRAL for 'koreacentral'") - .isEqualTo(AzureRegion.KOREA_CENTRAL); + .as("fromString should return KOREA_CENTRAL for 'koreacentral'") + .isEqualTo(AzureRegion.KOREA_CENTRAL); assertThat(AzureRegion.fromString("newzealandnorth")) - .as("fromString should return NEWZEALAND_NORTH for 'newzealandnorth'") - .isEqualTo(AzureRegion.NEWZEALAND_NORTH); + .as("fromString should return NEWZEALAND_NORTH for 'newzealandnorth'") + .isEqualTo(AzureRegion.NEWZEALAND_NORTH); assertThat(AzureRegion.fromString("canadacentral")) - .as("fromString should return CANADA_CENTRAL for 'canadacentral'") - .isEqualTo(AzureRegion.CANADA_CENTRAL); + .as("fromString should return CANADA_CENTRAL for 'canadacentral'") + .isEqualTo(AzureRegion.CANADA_CENTRAL); assertThat(AzureRegion.fromString("francecentral")) - .as("fromString should return FRANCE_CENTRAL for 'francecentral'") - .isEqualTo(AzureRegion.FRANCE_CENTRAL); + .as("fromString should return FRANCE_CENTRAL for 'francecentral'") + .isEqualTo(AzureRegion.FRANCE_CENTRAL); assertThat(AzureRegion.fromString("germanywestcentral")) - .as("fromString should return GERMANY_WEST_CENTRAL for 'germanywestcentral'") - .isEqualTo(AzureRegion.GERMANY_WEST_CENTRAL); + .as("fromString should return GERMANY_WEST_CENTRAL for 'germanywestcentral'") + .isEqualTo(AzureRegion.GERMANY_WEST_CENTRAL); assertThat(AzureRegion.fromString("italynorth")) - .as("fromString should return ITALY_NORTH for 'italynorth'") - .isEqualTo(AzureRegion.ITALY_NORTH); + .as("fromString should return ITALY_NORTH for 'italynorth'") + .isEqualTo(AzureRegion.ITALY_NORTH); assertThat(AzureRegion.fromString("norwayeast")) - .as("fromString should return NORWAY_EAST for 'norwayeast'") - .isEqualTo(AzureRegion.NORWAY_EAST); + .as("fromString should return NORWAY_EAST for 'norwayeast'") + .isEqualTo(AzureRegion.NORWAY_EAST); assertThat(AzureRegion.fromString("polandcentral")) - .as("fromString should return POLAND_CENTRAL for 'polandcentral'") - .isEqualTo(AzureRegion.POLAND_CENTRAL); + .as("fromString should return POLAND_CENTRAL for 'polandcentral'") + .isEqualTo(AzureRegion.POLAND_CENTRAL); assertThat(AzureRegion.fromString("spaincentral")) - .as("fromString should return SPAIN_CENTRAL for 'spaincentral'") - .isEqualTo(AzureRegion.SPAIN_CENTRAL); + .as("fromString should return SPAIN_CENTRAL for 'spaincentral'") + .isEqualTo(AzureRegion.SPAIN_CENTRAL); assertThat(AzureRegion.fromString("switzerlandnorth")) - .as("fromString should return SWITZERLAND_NORTH for 'switzerlandnorth'") - .isEqualTo(AzureRegion.SWITZERLAND_NORTH); + .as("fromString should return SWITZERLAND_NORTH for 'switzerlandnorth'") + .isEqualTo(AzureRegion.SWITZERLAND_NORTH); assertThat(AzureRegion.fromString("mexicocentral")) - .as("fromString should return SWITZERLAND_NORTH for 'mexicocentral'") - .isEqualTo(AzureRegion.MEXICO_CENTRAL); + .as("fromString should return SWITZERLAND_NORTH for 'mexicocentral'") + .isEqualTo(AzureRegion.MEXICO_CENTRAL); assertThat(AzureRegion.fromString("uaenorth")) - .as("fromString should return UAE_NORTH for 'uaenorth'") - .isEqualTo(AzureRegion.UAE_NORTH); + .as("fromString should return UAE_NORTH for 'uaenorth'") + .isEqualTo(AzureRegion.UAE_NORTH); assertThat(AzureRegion.fromString("brazilsouth")) - .as("fromString should return BRAZIL_SOUTH for 'brazilsouth'") - .isEqualTo(AzureRegion.BRAZIL_SOUTH); + .as("fromString should return BRAZIL_SOUTH for 'brazilsouth'") + .isEqualTo(AzureRegion.BRAZIL_SOUTH); assertThat(AzureRegion.fromString("israelcentral")) - .as("fromString should return ISRAEL_CENTRAL for 'israelcentral'") - .isEqualTo(AzureRegion.ISRAEL_CENTRAL); + .as("fromString should return ISRAEL_CENTRAL for 'israelcentral'") + .isEqualTo(AzureRegion.ISRAEL_CENTRAL); assertThat(AzureRegion.fromString("centralusstage")) - .as("fromString should return CENTRAL_US_STAGE for 'qatarcencentralusstagetral'") - .isEqualTo(AzureRegion.CENTRAL_US_STAGE); + .as("fromString should return CENTRAL_US_STAGE for 'qatarcencentralusstagetral'") + .isEqualTo(AzureRegion.CENTRAL_US_STAGE); assertThat(AzureRegion.fromString("eastusstage")) - .as("fromString should return EAST_US_STAGE for 'eastusstage'") - .isEqualTo(AzureRegion.EAST_US_STAGE); + .as("fromString should return EAST_US_STAGE for 'eastusstage'") + .isEqualTo(AzureRegion.EAST_US_STAGE); assertThat(AzureRegion.fromString("eastus2stage")) - .as("fromString should return EAST_US2_STAGE for 'eastus2stage'") - .isEqualTo(AzureRegion.EAST_US2_STAGE); + .as("fromString should return EAST_US2_STAGE for 'eastus2stage'") + .isEqualTo(AzureRegion.EAST_US2_STAGE); assertThat(AzureRegion.fromString("northcentralusstage")) - .as("fromString should return NORTH_CENTRAL_US_STAGE for 'northcentralusstage'") - .isEqualTo(AzureRegion.NORTH_CENTRAL_US_STAGE); + .as("fromString should return NORTH_CENTRAL_US_STAGE for 'northcentralusstage'") + .isEqualTo(AzureRegion.NORTH_CENTRAL_US_STAGE); assertThat(AzureRegion.fromString("southcentralusstage")) - .as("fromString should return SOUTH_CENTRAL_US_STAGE for 'southcentralusstage'") - .isEqualTo(AzureRegion.SOUTH_CENTRAL_US_STAGE); + .as("fromString should return SOUTH_CENTRAL_US_STAGE for 'southcentralusstage'") + .isEqualTo(AzureRegion.SOUTH_CENTRAL_US_STAGE); assertThat(AzureRegion.fromString("westusstage")) - .as("fromString should return WEST_US_STAGE for 'westusstage'") - .isEqualTo(AzureRegion.WEST_US_STAGE); + .as("fromString should return WEST_US_STAGE for 'westusstage'") + .isEqualTo(AzureRegion.WEST_US_STAGE); assertThat(AzureRegion.fromString("westus2stage")) - .as("fromString should return WEST_US2_STAGE for 'westus2stage'") - .isEqualTo(AzureRegion.WEST_US2_STAGE); + .as("fromString should return WEST_US2_STAGE for 'westus2stage'") + .isEqualTo(AzureRegion.WEST_US2_STAGE); assertThat(AzureRegion.fromString("asia")) - .as("fromString should return ASIA for 'asia'") - .isEqualTo(AzureRegion.ASIA); + .as("fromString should return ASIA for 'asia'") + .isEqualTo(AzureRegion.ASIA); assertThat(AzureRegion.fromString("asiapacific")) - .as("fromString should return ASIA_PACIFIC for 'asiapacific'") - .isEqualTo(AzureRegion.ASIA_PACIFIC); + .as("fromString should return ASIA_PACIFIC for 'asiapacific'") + .isEqualTo(AzureRegion.ASIA_PACIFIC); assertThat(AzureRegion.fromString("australia")) - .as("fromString should return AUSTRALIA for 'australia'") - .isEqualTo(AzureRegion.AUSTRALIA); + .as("fromString should return AUSTRALIA for 'australia'") + .isEqualTo(AzureRegion.AUSTRALIA); assertThat(AzureRegion.fromString("brazil")) - .as("fromString should return BRAZIL for 'brazil'") - .isEqualTo(AzureRegion.BRAZIL); + .as("fromString should return BRAZIL for 'brazil'") + .isEqualTo(AzureRegion.BRAZIL); assertThat(AzureRegion.fromString("canada")) - .as("fromString should return CANADA for 'canada'") - .isEqualTo(AzureRegion.CANADA); + .as("fromString should return CANADA for 'canada'") + .isEqualTo(AzureRegion.CANADA); assertThat(AzureRegion.fromString("europe")) - .as("fromString should return EUROPE for 'europe'") - .isEqualTo(AzureRegion.EUROPE); + .as("fromString should return EUROPE for 'europe'") + .isEqualTo(AzureRegion.EUROPE); assertThat(AzureRegion.fromString("france")) - .as("fromString should return FRANCE for 'france'") - .isEqualTo(AzureRegion.FRANCE); + .as("fromString should return FRANCE for 'france'") + .isEqualTo(AzureRegion.FRANCE); assertThat(AzureRegion.fromString("germany")) - .as("fromString should return GERMANY for 'germany'") - .isEqualTo(AzureRegion.GERMANY); + .as("fromString should return GERMANY for 'germany'") + .isEqualTo(AzureRegion.GERMANY); assertThat(AzureRegion.fromString("global")) - .as("fromString should return GLOBAL for 'global'") - .isEqualTo(AzureRegion.GLOBAL); + .as("fromString should return GLOBAL for 'global'") + .isEqualTo(AzureRegion.GLOBAL); assertThat(AzureRegion.fromString("india")) - .as("fromString should return INDIA for 'india'") - .isEqualTo(AzureRegion.INDIA); + .as("fromString should return INDIA for 'india'") + .isEqualTo(AzureRegion.INDIA); assertThat(AzureRegion.fromString("israel")) - .as("fromString should return ISRAEL for 'israel'") - .isEqualTo(AzureRegion.ISRAEL); + .as("fromString should return ISRAEL for 'israel'") + .isEqualTo(AzureRegion.ISRAEL); assertThat(AzureRegion.fromString("italy")) - .as("fromString should return ITALY for 'italy'") - .isEqualTo(AzureRegion.ITALY); + .as("fromString should return ITALY for 'italy'") + .isEqualTo(AzureRegion.ITALY); assertThat(AzureRegion.fromString("japan")) - .as("fromString should return JAPAN for 'japan'") - .isEqualTo(AzureRegion.JAPAN); + .as("fromString should return JAPAN for 'japan'") + .isEqualTo(AzureRegion.JAPAN); assertThat(AzureRegion.fromString("korea")) - .as("fromString should return KOREA for 'korea'") - .isEqualTo(AzureRegion.KOREA); + .as("fromString should return KOREA for 'korea'") + .isEqualTo(AzureRegion.KOREA); assertThat(AzureRegion.fromString("newzealand")) - .as("fromString should return NEWZEALAND for 'newzealand'") - .isEqualTo(AzureRegion.NEWZEALAND); + .as("fromString should return NEWZEALAND for 'newzealand'") + .isEqualTo(AzureRegion.NEWZEALAND); assertThat(AzureRegion.fromString("norway")) - .as("fromString should return NORWAY for 'norway'") - .isEqualTo(AzureRegion.NORWAY); + .as("fromString should return NORWAY for 'norway'") + .isEqualTo(AzureRegion.NORWAY); assertThat(AzureRegion.fromString("poland")) - .as("fromString should return POLAND for 'poland'") - .isEqualTo(AzureRegion.POLAND); + .as("fromString should return POLAND for 'poland'") + .isEqualTo(AzureRegion.POLAND); assertThat(AzureRegion.fromString("qatar")) - .as("fromString should return QATAR for 'qatar'") - .isEqualTo(AzureRegion.QATAR); + .as("fromString should return QATAR for 'qatar'") + .isEqualTo(AzureRegion.QATAR); assertThat(AzureRegion.fromString("singapore")) - .as("fromString should return SINGAPORE for 'singapore'") - .isEqualTo(AzureRegion.SINGAPORE); + .as("fromString should return SINGAPORE for 'singapore'") + .isEqualTo(AzureRegion.SINGAPORE); assertThat(AzureRegion.fromString("southafrica")) - .as("fromString should return SOUTHAFRICA for 'southafrica'") - .isEqualTo(AzureRegion.SOUTHAFRICA); + .as("fromString should return SOUTHAFRICA for 'southafrica'") + .isEqualTo(AzureRegion.SOUTHAFRICA); assertThat(AzureRegion.fromString("sweden")) - .as("fromString should return SWEDEN for 'sweden'") - .isEqualTo(AzureRegion.SWEDEN); + .as("fromString should return SWEDEN for 'sweden'") + .isEqualTo(AzureRegion.SWEDEN); assertThat(AzureRegion.fromString("switzerland")) - .as("fromString should return SWITZERLAND for 'switzerland'") - .isEqualTo(AzureRegion.SWITZERLAND); + .as("fromString should return SWITZERLAND for 'switzerland'") + .isEqualTo(AzureRegion.SWITZERLAND); assertThat(AzureRegion.fromString("uae")) - .as("fromString should return UAE for 'uae'") - .isEqualTo(AzureRegion.UAE); + .as("fromString should return UAE for 'uae'") + .isEqualTo(AzureRegion.UAE); assertThat(AzureRegion.fromString("uk")) - .as("fromString should return UK for 'uk'") - .isEqualTo(AzureRegion.UK); + .as("fromString should return UK for 'uk'") + .isEqualTo(AzureRegion.UK); assertThat(AzureRegion.fromString("unitedstates")) - .as("fromString should return UNITEDSTATES for 'unitedstates'") - .isEqualTo(AzureRegion.UNITEDSTATES); + .as("fromString should return UNITEDSTATES for 'unitedstates'") + .isEqualTo(AzureRegion.UNITEDSTATES); assertThat(AzureRegion.fromString("unitedstateseuap")) - .as("fromString should return UNITEDSTATES_EUAP for 'unitedstateseuap'") - .isEqualTo(AzureRegion.UNITEDSTATES_EUAP); + .as("fromString should return UNITEDSTATES_EUAP for 'unitedstateseuap'") + .isEqualTo(AzureRegion.UNITEDSTATES_EUAP); assertThat(AzureRegion.fromString("eastasiastage")) - .as("fromString should return EAST_ASIA_STAGE for 'eastasiastage'") - .isEqualTo(AzureRegion.EAST_ASIA_STAGE); + .as("fromString should return EAST_ASIA_STAGE for 'eastasiastage'") + .isEqualTo(AzureRegion.EAST_ASIA_STAGE); assertThat(AzureRegion.fromString("southeastasiastage")) - .as("fromString should return SOUTHEAST_ASIA_STAGE for 'southeastasiastage'") - .isEqualTo(AzureRegion.SOUTHEAST_ASIA_STAGE); + .as("fromString should return SOUTHEAST_ASIA_STAGE for 'southeastasiastage'") + .isEqualTo(AzureRegion.SOUTHEAST_ASIA_STAGE); assertThat(AzureRegion.fromString("brazilus")) - .as("fromString should return BRAZIL_US for 'brazilus'") - .isEqualTo(AzureRegion.BRAZIL_US); + .as("fromString should return BRAZIL_US for 'brazilus'") + .isEqualTo(AzureRegion.BRAZIL_US); assertThat(AzureRegion.fromString("eastusstg")) - .as("fromString should return EAST_US_STG for 'eastusstg'") - .isEqualTo(AzureRegion.EAST_US_STG); + .as("fromString should return EAST_US_STG for 'eastusstg'") + .isEqualTo(AzureRegion.EAST_US_STG); assertThat(AzureRegion.fromString("northcentralus")) - .as("fromString should return NORTH_CENTRAL_US for 'northcentralus'") - .isEqualTo(AzureRegion.NORTH_CENTRAL_US); + .as("fromString should return NORTH_CENTRAL_US for 'northcentralus'") + .isEqualTo(AzureRegion.NORTH_CENTRAL_US); assertThat(AzureRegion.fromString("westus")) - .as("fromString should return WEST_US for 'westus'") - .isEqualTo(AzureRegion.WEST_US); + .as("fromString should return WEST_US for 'westus'") + .isEqualTo(AzureRegion.WEST_US); assertThat(AzureRegion.fromString("japanwest")) - .as("fromString should return JAPAN_WEST for 'japanwest'") - .isEqualTo(AzureRegion.JAPAN_WEST); + .as("fromString should return JAPAN_WEST for 'japanwest'") + .isEqualTo(AzureRegion.JAPAN_WEST); assertThat(AzureRegion.fromString("jioindiawest")) - .as("fromString should return JIO_INDIA_WEST for 'jioindiawest'") - .isEqualTo(AzureRegion.JIO_INDIA_WEST); + .as("fromString should return JIO_INDIA_WEST for 'jioindiawest'") + .isEqualTo(AzureRegion.JIO_INDIA_WEST); assertThat(AzureRegion.fromString("centraluseuap")) - .as("fromString should return CENTRAL_US_EUAP for 'centraluseuap'") - .isEqualTo(AzureRegion.CENTRAL_US_EUAP); + .as("fromString should return CENTRAL_US_EUAP for 'centraluseuap'") + .isEqualTo(AzureRegion.CENTRAL_US_EUAP); assertThat(AzureRegion.fromString("eastus2euap")) - .as("fromString should return EAST_US_EUAP for 'eastus2euap'") - .isEqualTo(AzureRegion.EAST_US_EUAP); + .as("fromString should return EAST_US_EUAP for 'eastus2euap'") + .isEqualTo(AzureRegion.EAST_US_EUAP); assertThat(AzureRegion.fromString("southcentralusstg")) - .as("fromString should return SOUTH_CENTRAL_US_STG for 'southcentralusstg'") - .isEqualTo(AzureRegion.SOUTH_CENTRAL_US_STG); + .as("fromString should return SOUTH_CENTRAL_US_STG for 'southcentralusstg'") + .isEqualTo(AzureRegion.SOUTH_CENTRAL_US_STG); assertThat(AzureRegion.fromString("westcentralus")) - .as("fromString should return WEST_CENTRAL_US for 'westcentralus'") - .isEqualTo(AzureRegion.WEST_CENTRAL_US); + .as("fromString should return WEST_CENTRAL_US for 'westcentralus'") + .isEqualTo(AzureRegion.WEST_CENTRAL_US); assertThat(AzureRegion.fromString("southafricawest")) - .as("fromString should return SOUTH_AFRICA_WEST for 'southafricawest'") - .isEqualTo(AzureRegion.SOUTH_AFRICA_WEST); + .as("fromString should return SOUTH_AFRICA_WEST for 'southafricawest'") + .isEqualTo(AzureRegion.SOUTH_AFRICA_WEST); assertThat(AzureRegion.fromString("australiacentral")) - .as("fromString should return AUSTRALIA_CENTRAL for 'australiacentral'") - .isEqualTo(AzureRegion.AUSTRALIA_CENTRAL); + .as("fromString should return AUSTRALIA_CENTRAL for 'australiacentral'") + .isEqualTo(AzureRegion.AUSTRALIA_CENTRAL); assertThat(AzureRegion.fromString("australiacentral2")) - .as("fromString should return AUSTRALIA_CENTRAL2 for 'australiacentral2'") - .isEqualTo(AzureRegion.AUSTRALIA_CENTRAL2); + .as("fromString should return AUSTRALIA_CENTRAL2 for 'australiacentral2'") + .isEqualTo(AzureRegion.AUSTRALIA_CENTRAL2); assertThat(AzureRegion.fromString("australiasoutheast")) - .as("fromString should return AUSTRALIA_SOUTHEAST for 'australiasoutheast'") - .isEqualTo(AzureRegion.AUSTRALIA_SOUTHEAST); + .as("fromString should return AUSTRALIA_SOUTHEAST for 'australiasoutheast'") + .isEqualTo(AzureRegion.AUSTRALIA_SOUTHEAST); assertThat(AzureRegion.fromString("jioindiacentral")) - .as("fromString should return JIO_INDIA_CENTRAL for 'jioindiacentral'") - .isEqualTo(AzureRegion.JIO_INDIA_CENTRAL); + .as("fromString should return JIO_INDIA_CENTRAL for 'jioindiacentral'") + .isEqualTo(AzureRegion.JIO_INDIA_CENTRAL); assertThat(AzureRegion.fromString("koreasouth")) - .as("fromString should return KOREA_SOUTH for 'koreasouth'") - .isEqualTo(AzureRegion.KOREA_SOUTH); + .as("fromString should return KOREA_SOUTH for 'koreasouth'") + .isEqualTo(AzureRegion.KOREA_SOUTH); assertThat(AzureRegion.fromString("southindia")) - .as("fromString should return SOUTH_INDIA for 'southindia'") - .isEqualTo(AzureRegion.SOUTH_INDIA); + .as("fromString should return SOUTH_INDIA for 'southindia'") + .isEqualTo(AzureRegion.SOUTH_INDIA); assertThat(AzureRegion.fromString("westindia")) - .as("fromString should return WEST_INDIA for 'westindia'") - .isEqualTo(AzureRegion.WEST_INDIA); + .as("fromString should return WEST_INDIA for 'westindia'") + .isEqualTo(AzureRegion.WEST_INDIA); assertThat(AzureRegion.fromString("canadaeast")) - .as("fromString should return CANADA_EAST for 'canadaeast'") - .isEqualTo(AzureRegion.CANADA_EAST); + .as("fromString should return CANADA_EAST for 'canadaeast'") + .isEqualTo(AzureRegion.CANADA_EAST); assertThat(AzureRegion.fromString("francesouth")) - .as("fromString should return FRANCE_SOUTH for 'francesouth'") - .isEqualTo(AzureRegion.FRANCE_SOUTH); + .as("fromString should return FRANCE_SOUTH for 'francesouth'") + .isEqualTo(AzureRegion.FRANCE_SOUTH); assertThat(AzureRegion.fromString("germanynorth")) - .as("fromString should return GERMANY_NORTH for 'germanynorth'") - .isEqualTo(AzureRegion.GERMANY_NORTH); + .as("fromString should return GERMANY_NORTH for 'germanynorth'") + .isEqualTo(AzureRegion.GERMANY_NORTH); assertThat(AzureRegion.fromString("norwaywest")) - .as("fromString should return NORWAY_WEST for 'norwaywest'") - .isEqualTo(AzureRegion.NORWAY_WEST); + .as("fromString should return NORWAY_WEST for 'norwaywest'") + .isEqualTo(AzureRegion.NORWAY_WEST); assertThat(AzureRegion.fromString("switzerlandwest")) - .as("fromString should return SWITZERLAND_WEST for 'switzerlandwest'") - .isEqualTo(AzureRegion.SWITZERLAND_WEST); + .as("fromString should return SWITZERLAND_WEST for 'switzerlandwest'") + .isEqualTo(AzureRegion.SWITZERLAND_WEST); assertThat(AzureRegion.fromString("ukwest")) - .as("fromString should return UK_WEST for 'ukwest'") - .isEqualTo(AzureRegion.UK_WEST); + .as("fromString should return UK_WEST for 'ukwest'") + .isEqualTo(AzureRegion.UK_WEST); assertThat(AzureRegion.fromString("uaecentral")) - .as("fromString should return UAE_CENTRAL for 'uaecentral'") - .isEqualTo(AzureRegion.UAE_CENTRAL); + .as("fromString should return UAE_CENTRAL for 'uaecentral'") + .isEqualTo(AzureRegion.UAE_CENTRAL); assertThat(AzureRegion.fromString("brazilsoutheast")) - .as("fromString should return BRAZIL_SOUTHEAST for 'brazilsoutheast'") - .isEqualTo(AzureRegion.BRAZIL_SOUTHEAST); + .as("fromString should return BRAZIL_SOUTHEAST for 'brazilsoutheast'") + .isEqualTo(AzureRegion.BRAZIL_SOUTHEAST); assertThat(AzureRegion.fromString("global")) - .as("fromString should return GLOBAL for 'global'") - .isEqualTo(AzureRegion.GLOBAL); + .as("fromString should return GLOBAL for 'global'") + .isEqualTo(AzureRegion.GLOBAL); } @Test public void valuesMethod_shouldContainAllAzureActionsWithCorrectSize() { Collection values = AzureRegion.values(); - + assertThat(values) - .as("Values should contain all specified AzureRegions") - .contains( - AzureRegion.EAST_US, - AzureRegion.SOUTH_CENTRAL_US, - AzureRegion.WEST_US2, - AzureRegion.WEST_US3, - AzureRegion.AUSTRALIA_EAST, - AzureRegion.SOUTHEAST_ASIA, - AzureRegion.NORTH_EUROPE, - AzureRegion.SWEDEN_CENTRAL, - AzureRegion.UK_SOUTH, - AzureRegion.WEST_EUROPE, - AzureRegion.CENTRAL_US, - AzureRegion.SOUTH_AFRICA_NORTH, - AzureRegion.CENTRAL_INDIA, - AzureRegion.EAST_ASIA, - AzureRegion.JAPAN_EAST, - AzureRegion.KOREA_CENTRAL, - AzureRegion.NEWZEALAND_NORTH, - AzureRegion.CANADA_CENTRAL, - AzureRegion.FRANCE_CENTRAL, - AzureRegion.GERMANY_WEST_CENTRAL, - AzureRegion.ITALY_NORTH, - AzureRegion.NORWAY_EAST, - AzureRegion.POLAND_CENTRAL, - AzureRegion.SPAIN_CENTRAL, - AzureRegion.SWITZERLAND_NORTH, - AzureRegion.MEXICO_CENTRAL, - AzureRegion.UAE_NORTH, - AzureRegion.BRAZIL_SOUTH, - AzureRegion.ISRAEL_CENTRAL, - AzureRegion.QATAR_CENTRAL, - AzureRegion.CENTRAL_US_STAGE, - AzureRegion.EAST_US_STAGE, - AzureRegion.EAST_US2_STAGE, - AzureRegion.NORTH_CENTRAL_US_STAGE, - AzureRegion.SOUTH_CENTRAL_US_STAGE, - AzureRegion.WEST_US_STAGE, - AzureRegion.WEST_US2_STAGE, - AzureRegion.ASIA, - AzureRegion.ASIA_PACIFIC, - AzureRegion.AUSTRALIA, - AzureRegion.BRAZIL, - AzureRegion.CANADA, - AzureRegion.EUROPE, - AzureRegion.FRANCE, - AzureRegion.GERMANY, - AzureRegion.GLOBAL, - AzureRegion.INDIA, - AzureRegion.ISRAEL, - AzureRegion.ITALY, - AzureRegion.JAPAN, - AzureRegion.KOREA, - AzureRegion.NEWZEALAND, - AzureRegion.NORWAY, - AzureRegion.POLAND, - AzureRegion.QATAR, - AzureRegion.SINGAPORE, - AzureRegion.SOUTHAFRICA, - AzureRegion.SWEDEN, - AzureRegion.SWITZERLAND, - AzureRegion.UAE, - AzureRegion.UK, - AzureRegion.UNITEDSTATES, - AzureRegion.UNITEDSTATES_EUAP, - AzureRegion.EAST_ASIA_STAGE, - AzureRegion.SOUTHEAST_ASIA_STAGE, - AzureRegion.BRAZIL_US, - AzureRegion.EAST_US2, - AzureRegion.EAST_US_STG, - AzureRegion.NORTH_CENTRAL_US, - AzureRegion.WEST_US, - AzureRegion.JAPAN_WEST, - AzureRegion.JIO_INDIA_WEST, - AzureRegion.CENTRAL_US_EUAP, - AzureRegion.EAST_US_EUAP, - AzureRegion.SOUTH_CENTRAL_US_STG, - AzureRegion.WEST_CENTRAL_US, - AzureRegion.SOUTH_AFRICA_WEST, - AzureRegion.AUSTRALIA_CENTRAL, - AzureRegion.AUSTRALIA_CENTRAL2, - AzureRegion.AUSTRALIA_SOUTHEAST, - AzureRegion.JIO_INDIA_CENTRAL, - AzureRegion.KOREA_SOUTH, - AzureRegion.SOUTH_INDIA, - AzureRegion.WEST_INDIA, - AzureRegion.CANADA_EAST, - AzureRegion.FRANCE_SOUTH, - AzureRegion.GERMANY_NORTH, - AzureRegion.NORWAY_WEST, - AzureRegion.SWITZERLAND_WEST, - AzureRegion.UK_WEST, - AzureRegion.UAE_CENTRAL, - AzureRegion.BRAZIL_SOUTHEAST); + .as("Values should contain all specified AzureRegions") + .contains( + AzureRegion.EAST_US, + AzureRegion.SOUTH_CENTRAL_US, + AzureRegion.WEST_US2, + AzureRegion.WEST_US3, + AzureRegion.AUSTRALIA_EAST, + AzureRegion.SOUTHEAST_ASIA, + AzureRegion.NORTH_EUROPE, + AzureRegion.SWEDEN_CENTRAL, + AzureRegion.UK_SOUTH, + AzureRegion.WEST_EUROPE, + AzureRegion.CENTRAL_US, + AzureRegion.SOUTH_AFRICA_NORTH, + AzureRegion.CENTRAL_INDIA, + AzureRegion.EAST_ASIA, + AzureRegion.JAPAN_EAST, + AzureRegion.KOREA_CENTRAL, + AzureRegion.NEWZEALAND_NORTH, + AzureRegion.CANADA_CENTRAL, + AzureRegion.FRANCE_CENTRAL, + AzureRegion.GERMANY_WEST_CENTRAL, + AzureRegion.ITALY_NORTH, + AzureRegion.NORWAY_EAST, + AzureRegion.POLAND_CENTRAL, + AzureRegion.SPAIN_CENTRAL, + AzureRegion.SWITZERLAND_NORTH, + AzureRegion.MEXICO_CENTRAL, + AzureRegion.UAE_NORTH, + AzureRegion.BRAZIL_SOUTH, + AzureRegion.ISRAEL_CENTRAL, + AzureRegion.QATAR_CENTRAL, + AzureRegion.CENTRAL_US_STAGE, + AzureRegion.EAST_US_STAGE, + AzureRegion.EAST_US2_STAGE, + AzureRegion.NORTH_CENTRAL_US_STAGE, + AzureRegion.SOUTH_CENTRAL_US_STAGE, + AzureRegion.WEST_US_STAGE, + AzureRegion.WEST_US2_STAGE, + AzureRegion.ASIA, + AzureRegion.ASIA_PACIFIC, + AzureRegion.AUSTRALIA, + AzureRegion.BRAZIL, + AzureRegion.CANADA, + AzureRegion.EUROPE, + AzureRegion.FRANCE, + AzureRegion.GERMANY, + AzureRegion.GLOBAL, + AzureRegion.INDIA, + AzureRegion.ISRAEL, + AzureRegion.ITALY, + AzureRegion.JAPAN, + AzureRegion.KOREA, + AzureRegion.NEWZEALAND, + AzureRegion.NORWAY, + AzureRegion.POLAND, + AzureRegion.QATAR, + AzureRegion.SINGAPORE, + AzureRegion.SOUTHAFRICA, + AzureRegion.SWEDEN, + AzureRegion.SWITZERLAND, + AzureRegion.UAE, + AzureRegion.UK, + AzureRegion.UNITEDSTATES, + AzureRegion.UNITEDSTATES_EUAP, + AzureRegion.EAST_ASIA_STAGE, + AzureRegion.SOUTHEAST_ASIA_STAGE, + AzureRegion.BRAZIL_US, + AzureRegion.EAST_US2, + AzureRegion.EAST_US_STG, + AzureRegion.NORTH_CENTRAL_US, + AzureRegion.WEST_US, + AzureRegion.JAPAN_WEST, + AzureRegion.JIO_INDIA_WEST, + AzureRegion.CENTRAL_US_EUAP, + AzureRegion.EAST_US_EUAP, + AzureRegion.SOUTH_CENTRAL_US_STG, + AzureRegion.WEST_CENTRAL_US, + AzureRegion.SOUTH_AFRICA_WEST, + AzureRegion.AUSTRALIA_CENTRAL, + AzureRegion.AUSTRALIA_CENTRAL2, + AzureRegion.AUSTRALIA_SOUTHEAST, + AzureRegion.JIO_INDIA_CENTRAL, + AzureRegion.KOREA_SOUTH, + AzureRegion.SOUTH_INDIA, + AzureRegion.WEST_INDIA, + AzureRegion.CANADA_EAST, + AzureRegion.FRANCE_SOUTH, + AzureRegion.GERMANY_NORTH, + AzureRegion.NORWAY_WEST, + AzureRegion.SWITZERLAND_WEST, + AzureRegion.UK_WEST, + AzureRegion.UAE_CENTRAL, + AzureRegion.BRAZIL_SOUTHEAST); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroupTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroupTest.java index 521ec070..11c24432 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroupTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureResourceGroupTest.java @@ -12,13 +12,13 @@ public void correctValues_when_AzureResourceGroupWithEnumBuilt() { var region = AzureRegion.WEST_EUROPE; var azureResourceGroup = AzureResourceGroup.builder() - .withName(resourceGroupName) - .withRegion(region) - .build(); + .withName(resourceGroupName) + .withRegion(region) + .build(); assertThat(azureResourceGroup) - .extracting("name", "region") - .contains(resourceGroupName, region); + .extracting("name", "region") + .contains(resourceGroupName, region); } @Test @@ -26,22 +26,22 @@ public void correctValues_when_AzureResourceGroupWithEnumAsStringBuilt() { var resourceGroupName = "resourceGroupName"; var azureResourceGroup = AzureResourceGroup.builder() - .withName(resourceGroupName) - .withRegion(AzureRegion.fromString("eastus2")) - .build(); + .withName(resourceGroupName) + .withRegion(AzureRegion.fromString("eastus2")) + .build(); assertThat(azureResourceGroup) - .extracting("name", "region") - .contains(resourceGroupName, AzureRegion.EAST_US2); + .extracting("name", "region") + .contains(resourceGroupName, AzureRegion.EAST_US2); } @Test public void validationError_when_AzureResourceGroupWithWrongNameAsStringBuilt() { assertThatThrownBy(() -> AzureResourceGroup.builder() - .withName("") - .withRegion(AzureRegion.fromString("wrong_enum")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("[AzureResourceGroup Validation] Name cannot be null or empty"); + .withName("") + .withRegion(AzureRegion.fromString("wrong_enum")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("[AzureResourceGroup Validation] Name cannot be null or empty"); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersionTest.java index 8ed7b36c..c687ecd3 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/AzureTlsVersionTest.java @@ -17,16 +17,16 @@ public void tlsVersionsConstants_shouldNotBeNull() { @Test public void fromString_shouldReturnCorrespondingTlsVersion() { assertThat(AzureTlsVersion.fromString("TLS1_0")) - .as("fromString should return TLS1_0 for 'TLS1_0'") - .isEqualTo(AzureTlsVersion.TLS1_0); + .as("fromString should return TLS1_0 for 'TLS1_0'") + .isEqualTo(AzureTlsVersion.TLS1_0); assertThat(AzureTlsVersion.fromString("TLS1_1")) - .as("fromString should return TLS1_1 for 'TLS1_1'") - .isEqualTo(AzureTlsVersion.TLS1_1); + .as("fromString should return TLS1_1 for 'TLS1_1'") + .isEqualTo(AzureTlsVersion.TLS1_1); assertThat(AzureTlsVersion.fromString("TLS1_2")) - .as("fromString should return TLS1_2 for 'TLS1_2'") - .isEqualTo(AzureTlsVersion.TLS1_2); + .as("fromString should return TLS1_2 for 'TLS1_2'") + .isEqualTo(AzureTlsVersion.TLS1_2); } @Test @@ -34,7 +34,7 @@ public void valuesMethod_shouldContainAllTlsVersionsWithCorrectSize() { Collection values = AzureTlsVersion.values(); assertThat(values) - .as("Values should contain TLS1_0, TLS1_1, and TLS1_2 and have exactly 3 values") - .containsExactlyInAnyOrder(AzureTlsVersion.TLS1_0, AzureTlsVersion.TLS1_1, AzureTlsVersion.TLS1_2); + .as("Values should contain TLS1_0, TLS1_1, and TLS1_2 and have exactly 3 values") + .containsExactlyInAnyOrder(AzureTlsVersion.TLS1_0, AzureTlsVersion.TLS1_1, AzureTlsVersion.TLS1_2); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosAccountTest.java index 79b618bd..ae5e2c9a 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.jayway.jsonpath.JsonPath; @@ -33,19 +32,19 @@ public abstract class CosmosAccountTest getBuilder().withId("a-legal-id").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Region has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Region has not been defined and it is required"); } @Test public void exceptionThrown_when_entityIsInvalid() { assertThatThrownBy(() -> getBuilder() - .withId("a-legal-id") - .withMaxTotalThroughput(a(Integer.class)) - .withCosmosEntity(getInvalidCosmosEntity()) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Region has not been defined and it is required"); + .withId("a-legal-id") + .withMaxTotalThroughput(a(Integer.class)) + .withCosmosEntity(getInvalidCosmosEntity()) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Region has not been defined and it is required"); } @Test @@ -54,63 +53,63 @@ public void exceptionThrown_when_bothRegionAndResourceGroupAreNotDefined() { var entities = getValidCosmosEntities(); var throughput = a(Integer.class); var builder = getBuilder() - .withId(accountId) - .withMaxTotalThroughput(throughput) - .withCosmosEntities(entities); + .withId(accountId) + .withMaxTotalThroughput(throughput) + .withCosmosEntities(entities); assertThatThrownBy(builder::build) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Region has not been defined and it is required"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Region has not been defined and it is required"); } @Test public void typeIsAsExpected_when_BuiltWithoutEntitiesInRegion() { var throughput = a(Integer.class); var builder = getBuilder() - .withId("a-legal-id") - .withRegion(AzureRegion.EAST_ASIA) - .withMaxTotalThroughput(throughput); + .withId("a-legal-id") + .withRegion(AzureRegion.EAST_ASIA) + .withMaxTotalThroughput(throughput); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) - .containsExactly(Collections.EMPTY_LIST, throughput); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) + .containsExactly(Collections.EMPTY_LIST, throughput); } @Test public void tagsAreAsExpected_when_TagsAreSet() { var builder = getBuilder() - .withId("a-legal-id") - .withRegion(AzureRegion.EAST_ASIA) - .withTags(Map.ofEntries( - entry("a", "tag A"), - entry("b", "tag B") - )); + .withId("a-legal-id") + .withRegion(AzureRegion.EAST_ASIA) + .withTags(Map.ofEntries( + entry("a", "tag A"), + entry("b", "tag B") + )); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); - assert(component.getTags()).equals(Map.ofEntries( - entry("a", "tag A"), - entry("b", "tag B") + assert (component.getTags()).equals(Map.ofEntries( + entry("a", "tag A"), + entry("b", "tag B") )); } @Test public void tagsAreAsExpected_when_ASingleTagIsSet() { var builder = getBuilder() - .withId("a-legal-id") - .withRegion(AzureRegion.EAST_ASIA) - .withTag("a", "tag A"); + .withId("a-legal-id") + .withRegion(AzureRegion.EAST_ASIA) + .withTag("a", "tag A"); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); - assert(component.getTags()).equals(Map.ofEntries( - entry("a", "tag A") + assert (component.getTags()).equals(Map.ofEntries( + entry("a", "tag A") )); } @@ -118,27 +117,27 @@ public void tagsAreAsExpected_when_ASingleTagIsSet() { public void typeIsAsExpected_when_BuiltWithoutEntitiesInResourceGroup() { var throughput = a(Integer.class); var builder = getBuilder() - .withId("a-legal-id") - .withAzureResourceGroup( - AzureResourceGroup.builder() - .withName(a(String.class)) - .withRegion(AzureRegion.SOUTHEAST_ASIA) - .build()) - .withMaxTotalThroughput(throughput) - .withBackupPolicy(AzureCosmosBackupPolicy.builder() - .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) - .withBackupIntervalInMinutes(1440) - .withBackupRetentionIntervalInHours(720) - .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) - .build()); + .withId("a-legal-id") + .withAzureResourceGroup( + AzureResourceGroup.builder() + .withName(a(String.class)) + .withRegion(AzureRegion.SOUTHEAST_ASIA) + .build()) + .withMaxTotalThroughput(throughput) + .withBackupPolicy(AzureCosmosBackupPolicy.builder() + .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) + .withBackupIntervalInMinutes(1440) + .withBackupRetentionIntervalInHours(720) + .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) + .build()); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) - .containsExactly(Collections.EMPTY_LIST, throughput); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) + .containsExactly(Collections.EMPTY_LIST, throughput); } @@ -146,54 +145,54 @@ public void typeIsAsExpected_when_BuiltWithoutEntitiesInResourceGroup() { public void typeIsAsExpected_when_BuiltWithoutEntitiesInRegionAndResourceGroup() { var throughput = a(Integer.class); var builder = getBuilder() - .withId("a-legal-id") - .withBackupPolicy(AzureCosmosBackupPolicy.builder() - .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) - .withBackupIntervalInMinutes(60) - .withBackupRetentionIntervalInHours(8) - .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) - .build()) - .withRegion(AzureRegion.EAST_ASIA) - .withAzureResourceGroup( - AzureResourceGroup.builder() - .withName(a(String.class)) - .withRegion(AzureRegion.SOUTHEAST_ASIA) - .build()) - .withMaxTotalThroughput(throughput); + .withId("a-legal-id") + .withBackupPolicy(AzureCosmosBackupPolicy.builder() + .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) + .withBackupIntervalInMinutes(60) + .withBackupRetentionIntervalInHours(8) + .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) + .build()) + .withRegion(AzureRegion.EAST_ASIA) + .withAzureResourceGroup( + AzureResourceGroup.builder() + .withName(a(String.class)) + .withRegion(AzureRegion.SOUTHEAST_ASIA) + .build()) + .withMaxTotalThroughput(throughput); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) - .containsExactly(Collections.EMPTY_LIST, throughput); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) + .containsExactly(Collections.EMPTY_LIST, throughput); } @Test public void typeIsAsExpected_when_BuiltWithoutEntitiesAndMaxTotalThroughputInRegionAndResourceGroup() { var builder = getBuilder() - .withId("a-legal-id") - .withBackupPolicy(AzureCosmosBackupPolicy.builder() - .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) - .withBackupIntervalInMinutes(60) - .withBackupRetentionIntervalInHours(8) - .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) - .build()) - .withRegion(AzureRegion.EAST_ASIA) - .withAzureResourceGroup( - AzureResourceGroup.builder() - .withName(a(String.class)) - .withRegion(AzureRegion.SOUTHEAST_ASIA) - .build()); + .withId("a-legal-id") + .withBackupPolicy(AzureCosmosBackupPolicy.builder() + .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) + .withBackupIntervalInMinutes(60) + .withBackupRetentionIntervalInHours(8) + .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) + .build()) + .withRegion(AzureRegion.EAST_ASIA) + .withAzureResourceGroup( + AzureResourceGroup.builder() + .withName(a(String.class)) + .withRegion(AzureRegion.SOUTHEAST_ASIA) + .build()); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) - .containsExactly(Collections.EMPTY_LIST, null); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) + .containsExactly(Collections.EMPTY_LIST, null); } @Test @@ -202,21 +201,21 @@ public void typeIsAsExpected_when_BuiltWithEntities() { var entities = getValidCosmosEntities(); var throughput = a(Integer.class); var builder = getBuilder() - .withId(accountId) - .withRegion(AzureRegion.EAST_ASIA) - .withMaxTotalThroughput(throughput) - .withCosmosEntities(entities); + .withId(accountId) + .withRegion(AzureRegion.EAST_ASIA) + .withMaxTotalThroughput(throughput) + .withCosmosEntities(entities); var component = builder.build(); - + assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) - .containsExactly(entities, throughput); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) + .containsExactly(entities, throughput); assertThat(component.getCosmosEntities().stream().allMatch(x -> x.getDependencies().contains(ComponentId.from(accountId)))) - .isTrue(); + .isTrue(); } @@ -226,18 +225,18 @@ public void typeIsAsExpected_when_BuiltWithSingleEntity() { assertThat(entity).isNotNull(); var throughput = a(Integer.class); var builder = getBuilder() - .withId("a-legal-id") - .withRegion(AzureRegion.EAST_ASIA) - .withMaxTotalThroughput(throughput) - .withCosmosEntity(entity); + .withId("a-legal-id") + .withRegion(AzureRegion.EAST_ASIA) + .withMaxTotalThroughput(throughput) + .withCosmosEntity(entity); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) - .containsExactly(List.of(entity), throughput); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, AzureCosmosAccount::getMaxTotalThroughput) + .containsExactly(List.of(entity), throughput); } @Test @@ -246,18 +245,18 @@ public void typeIsAsExpected_when_BuiltWithBackupPolicyAndSingleEntity() { assertThat(entity).isNotNull(); var throughput = a(Integer.class); var backupPolicy = AzureCosmosBackupPolicy.builder() - .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) - .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) - .withBackupIntervalInMinutes(1440) - .withBackupRetentionIntervalInHours(720) - .build(); - + .withBackupPolicyType(AzureCosmosBackupPolicyType.PERIODIC) + .withBackupStorageRedundancy(BackupStorageRedundancy.GEO) + .withBackupIntervalInMinutes(1440) + .withBackupRetentionIntervalInHours(720) + .build(); + var builder = getBuilder() - .withId("a-legal-id") - .withRegion(AzureRegion.EAST_ASIA) - .withMaxTotalThroughput(throughput) - .withBackupPolicy(backupPolicy) - .withCosmosEntity(entity); + .withId("a-legal-id") + .withRegion(AzureRegion.EAST_ASIA) + .withMaxTotalThroughput(throughput) + .withBackupPolicy(backupPolicy) + .withCosmosEntity(entity); var component = builder.build(); @@ -266,10 +265,10 @@ public void typeIsAsExpected_when_BuiltWithBackupPolicyAndSingleEntity() { assertThat(jsonMap.keySet()).contains("backupPolicy"); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) - .extracting(AzureCosmosAccount::getCosmosEntities, - AzureCosmosAccount::getMaxTotalThroughput, - AzureCosmosAccount::getBackupPolicy) - .containsExactly(List.of(entity), throughput, backupPolicy); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosAccount.class)) + .extracting(AzureCosmosAccount::getCosmosEntities, + AzureCosmosAccount::getMaxTotalThroughput, + AzureCosmosAccount::getBackupPolicy) + .containsExactly(List.of(entity), throughput, backupPolicy); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosCassandraTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosCassandraTest.java index e615fd8c..9cdb0806 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosCassandraTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosCassandraTest.java @@ -15,7 +15,8 @@ public class CosmosCassandraTest extends TestWithFixture { public void exceptionThrown_when_componentBuiltWithEmptyValues() { assertThatThrownBy(() -> AzureCosmosCassandraCluster.builder().withId("a-legal-id").build()). isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Cosmos Cassandra Cluster periodic backup feature needs a value of hours between backups that is larger or equal to 1"); + hasMessageContaining("Cosmos Cassandra Cluster periodic backup feature needs a value of hours between backups " + + "that is larger or equal to 1"); } @Test @@ -36,7 +37,7 @@ public void typeIsAsExpected_when_BuiltWithAllRequiredValues() { .withDelegatedManagementSubnetId(subnetId) .withAuditLoggingEnabled(enableAuditLogging) .withHoursBetweenBackups(hoursBetweenBackups) - .build(); + .build(); assertThat(component.getType()).isEqualTo(PAAS_CASANDRA_DBMS); assertThat(component) diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosEntityTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosEntityTest.java index 61a6bd15..1ddb0692 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosEntityTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosEntityTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.TestWithFixture; @@ -20,19 +19,20 @@ public abstract class CosmosEntityTest x.contains("Region has not been defined and it is required")); + .isNotEmpty() + .anyMatch(x -> x.contains("Region has not been defined and it is required")); } @Test public void exceptionThrown_when_throughputLargerThanMaxThroughput() { assertThat(AzureCosmosEntity.validateCosmosEntity(getBuilder() - .withId("a-legal-id") - .withMaxThroughput(a(Integer.class)) - .withThroughput(a(Integer.class)) - .build())) - .isNotEmpty() - .anyMatch(x -> x.contains("Defined both throughput and max throughput. Only one of them can be defined and not both")); + .withId("a-legal-id") + .withMaxThroughput(a(Integer.class)) + .withThroughput(a(Integer.class)) + .build())) + .isNotEmpty() + .anyMatch(x -> x.contains("Defined both throughput and max throughput. Only one of them can be defined and not " + + "both")); } @Test @@ -40,31 +40,33 @@ public void typeIsAsExpected_when_BuiltWithAllRequiredValues() { var cosmosAccount = String.format("comp-%s", a(String.class)); var throughput = a(Integer.class); var builder = getBuilder() - .withId("a-legal-id") - .withName("a-legal-name") - .withCosmosAccount(ComponentId.from(cosmosAccount)) - .withMaxThroughput(throughput + 1) - .withThroughput(throughput); + .withId("a-legal-id") + .withName("a-legal-name") + .withCosmosAccount(ComponentId.from(cosmosAccount)) + .withMaxThroughput(throughput + 1) + .withThroughput(throughput); var component = builder.build(); assertThat(component.getType()).isEqualTo(getExpectedType()); assertThat(component) - .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosEntity.class)) - .extracting(AzureCosmosEntity::getMaxThroughput, AzureCosmosEntity::getThroughput) - .containsExactly(throughput + 1, throughput); + .asInstanceOf(InstanceOfAssertFactories.type(AzureCosmosEntity.class)) + .extracting(AzureCosmosEntity::getMaxThroughput, AzureCosmosEntity::getThroughput) + .containsExactly(throughput + 1, throughput); } @Test public void exceptionThrown_when_nameIsToLong() { var throughput = a(Integer.class); assertThat(AzureCosmosEntity.validateCosmosEntity(getBuilder() - .withId("a-legal-id") - .withName("MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName") - .withMaxThroughput(throughput + 1) - .withThroughput(throughput) - .build())) - .isNotEmpty() - .anyMatch(x -> x.contains("The Name is invalid. Ensure to provide a unique non-empty string less than '255' characters")); + .withId("a-legal-id") + .withName( + "MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName_MaximumLengthOfDatabaseOrContainerName") + .withMaxThroughput(throughput + 1) + .withThroughput(throughput) + .build())) + .isNotEmpty() + .anyMatch(x -> x.contains("The Name is invalid. Ensure to provide a unique non-empty string less than '255' " + + "characters")); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinAccountTest.java index b2fec596..07133dca 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosGremlinDatabase; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinDatabaseTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinDatabaseTest.java index e0c17855..ceee4827 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinDatabaseTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosGremlinDatabaseTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosGremlinDatabase; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoAccountTest.java index e2bbd85b..3b947834 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosMongoDatabase; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoDatabaseTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoDatabaseTest.java index e14eb642..8811bfc7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoDatabaseTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosMongoDatabaseTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosMongoDatabase; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlAccountTest.java index e0efe58b..a20b8997 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosNoSqlDatabase; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlDatabaseTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlDatabaseTest.java index 89a3d7c7..4403acdb 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlDatabaseTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosNoSqlDatabaseTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosNoSqlDatabase; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosPostgreSqlAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosPostgreSqlAccountTest.java index 4da60efc..43221e01 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosPostgreSqlAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosPostgreSqlAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.TestWithFixture; @@ -32,7 +31,7 @@ public void tagsAreAsExpected_when_TagsAreSet() { var component = builder.build(); - assert(component.getTags()).equals(Map.ofEntries( + assert (component.getTags()).equals(Map.ofEntries( entry("a", "tag A"), entry("b", "tag B") )); @@ -47,7 +46,7 @@ public void tagsAreAsExpected_when_ASingleTagIsSet() { var component = builder.build(); - assert(component.getTags()).equals(Map.ofEntries( + assert (component.getTags()).equals(Map.ofEntries( entry("a", "tag A") )); } @@ -101,7 +100,7 @@ public void propertiesAreAsExpected() { var component = builder.build(); assertThat(component).extracting( - "id", + "id", "backupRetentionDays", "coordinatorCores", "coordinatorStorageGb", diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableAccountTest.java index 56f5a79c..4b21246a 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosTableDbms; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableEntityTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableEntityTest.java index 90250bcd..8817acbb 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableEntityTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/CosmosTableEntityTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure; import com.yanchware.fractal.sdk.domain.livesystem.paas.providers.azure.cosmos.AzureCosmosTableEntity; diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonProfileTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonProfileTest.java index 0470d626..987c52b6 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonProfileTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonProfileTest.java @@ -11,33 +11,33 @@ class AzureKubernetesAddonProfileTest { @Test public void validationError_when_profileNameIsNull() { assertThatThrownBy(() -> AzureKubernetesAddonProfile.builder() - .withAddonToEnable(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("addonToEnable variable is not set"); + .withAddonToEnable(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("addonToEnable variable is not set"); } @Test public void noValidationErrors_when_allRequiredVariablesProvided() { assertThat(AzureKubernetesAddonProfile.builder() - .withAddonToEnable(AzureKubernetesAddon.AZURE_POLICY) - .build() - .validate() + .withAddonToEnable(AzureKubernetesAddon.AZURE_POLICY) + .build() + .validate() ).isEmpty(); } @Test public void azureAddonProfileHasAllVariables() { AzureKubernetesAddonProfile addonProfile = AzureKubernetesAddonProfile - .builder() - .withAddonToEnable(AzureKubernetesAddon.MONITORING) - .withConfig(Map.of("logAnalyticsWorkspaceResourceID", - "/subscriptions//resourceGroups/", - "useAADAuth", - "False")) - .build(); + .builder() + .withAddonToEnable(AzureKubernetesAddon.MONITORING) + .withConfig(Map.of("logAnalyticsWorkspaceResourceID", + "/subscriptions//resourceGroups/", + "useAADAuth", + "False")) + .build(); assertThat(addonProfile.getAddonToEnable()).isEqualTo(AzureKubernetesAddon.MONITORING); assertThat(addonProfile.getConfig()).extracting("logAnalyticsWorkspaceResourceID", "useAADAuth") - .containsExactly("/subscriptions//resourceGroups/", "False"); + .containsExactly("/subscriptions//resourceGroups/", "False"); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonTest.java index aec85c21..b44e85a2 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureKubernetesAddonTest.java @@ -9,15 +9,19 @@ class AzureKubernetesAddonTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureKubernetesAddon.fromString("httpApplicationRouting"), AzureKubernetesAddon.HTTP_APPLICATION_ROUTING), - () -> assertEquals(AzureKubernetesAddon.fromString("omsagent"), AzureKubernetesAddon.MONITORING), - () -> assertEquals(AzureKubernetesAddon.fromString("aciConnectorLinux"), AzureKubernetesAddon.VIRTUAL_NODE), - () -> assertEquals(AzureKubernetesAddon.fromString("azurepolicy"), AzureKubernetesAddon.AZURE_POLICY), - () -> assertEquals(AzureKubernetesAddon.fromString("ingressApplicationGateway"), AzureKubernetesAddon.INGRESS_APPGW), - () -> assertEquals(AzureKubernetesAddon.fromString("ACCSGXDevicePlugin"), AzureKubernetesAddon.CONFCOM), - () -> assertEquals(AzureKubernetesAddon.fromString("openServiceMesh"), AzureKubernetesAddon.OPEN_SERVICE_MESH), - () -> assertEquals(AzureKubernetesAddon.fromString("azureKeyvaultSecretsProvider"), AzureKubernetesAddon.AZURE_KEYVAULT_SECRETS_PROVIDER), - () -> assertEquals(AzureKubernetesAddon.fromString("webAppRouting"), AzureKubernetesAddon.WEB_APPLICATION_ROUTING)); + () -> assertEquals(AzureKubernetesAddon.fromString("httpApplicationRouting"), + AzureKubernetesAddon.HTTP_APPLICATION_ROUTING), + () -> assertEquals(AzureKubernetesAddon.fromString("omsagent"), AzureKubernetesAddon.MONITORING), + () -> assertEquals(AzureKubernetesAddon.fromString("aciConnectorLinux"), AzureKubernetesAddon.VIRTUAL_NODE), + () -> assertEquals(AzureKubernetesAddon.fromString("azurepolicy"), AzureKubernetesAddon.AZURE_POLICY), + () -> assertEquals(AzureKubernetesAddon.fromString("ingressApplicationGateway"), + AzureKubernetesAddon.INGRESS_APPGW), + () -> assertEquals(AzureKubernetesAddon.fromString("ACCSGXDevicePlugin"), AzureKubernetesAddon.CONFCOM), + () -> assertEquals(AzureKubernetesAddon.fromString("openServiceMesh"), AzureKubernetesAddon.OPEN_SERVICE_MESH), + () -> assertEquals(AzureKubernetesAddon.fromString("azureKeyvaultSecretsProvider"), + AzureKubernetesAddon.AZURE_KEYVAULT_SECRETS_PROVIDER), + () -> assertEquals(AzureKubernetesAddon.fromString("webAppRouting"), + AzureKubernetesAddon.WEB_APPLICATION_ROUTING)); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIpTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIpTest.java index cabe3863..b8a385c3 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIpTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/AzureOutboundIpTest.java @@ -11,15 +11,16 @@ class AzureOutboundIpTest { @Test public void validationError_when_azureOutboundIpWithNullName() { assertThatThrownBy(() -> AzureOutboundIp.builder().withName(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("name is empty or it exceeds 80 characters"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("name is empty or it exceeds 80 characters"); } - + @Test public void validationError_when_azureOutboundIpWithNameTooLong() { - assertThatThrownBy(() -> AzureOutboundIp.builder().withName("fractalfractalfractalfractalfractalfractalfractalfractalfractalfractalfractalfractal").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("name is empty or it exceeds 80 characters"); + assertThatThrownBy(() -> AzureOutboundIp.builder().withName( + "fractalfractalfractalfractalfractalfractalfractalfractalfractalfractalfractalfractal").build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("name is empty or it exceeds 80 characters"); } @Test @@ -30,14 +31,14 @@ public void noValidationErrors_when_azureOutboundIpWithValidFields() { @Test public void azureOutboundIpHasAllFields() { AzureOutboundIp outboundIp = AzureOutboundIp + .builder() + .withName("fractal") + .withAzureResourceGroup(AzureResourceGroup .builder() - .withName("fractal") - .withAzureResourceGroup(AzureResourceGroup - .builder() - .withName("name") - .withRegion(WEST_EUROPE) - .build()) - .build(); + .withName("name") + .withRegion(WEST_EUROPE) + .build()) + .build(); assertThat(outboundIp.getName()).isEqualTo("fractal"); assertThat(outboundIp.getAzureResourceGroup()).extracting("name", "region").containsExactly("name", WEST_EUROPE); } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTierTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTierTest.java index 1074e4bf..2b6f191c 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTierTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/aks/ManagedClusterSkuTierTest.java @@ -17,16 +17,16 @@ public void managedClusterSkuTierConstants_shouldNotBeNull() { @Test public void fromString_shouldReturnCorrespondingManagedClusterSkuTier() { assertThat(ManagedClusterSkuTier.fromString("Premium")) - .as("fromString should return PREMIUM for 'Premium'") - .isEqualTo(ManagedClusterSkuTier.PREMIUM); + .as("fromString should return PREMIUM for 'Premium'") + .isEqualTo(ManagedClusterSkuTier.PREMIUM); assertThat(ManagedClusterSkuTier.fromString("Standard")) - .as("fromString should return STANDARD for 'Standard'") - .isEqualTo(ManagedClusterSkuTier.STANDARD); + .as("fromString should return STANDARD for 'Standard'") + .isEqualTo(ManagedClusterSkuTier.STANDARD); assertThat(ManagedClusterSkuTier.fromString("Free")) - .as("fromString should return FREE for 'Free'") - .isEqualTo(ManagedClusterSkuTier.FREE); + .as("fromString should return FREE for 'Free'") + .isEqualTo(ManagedClusterSkuTier.FREE); } @Test @@ -34,9 +34,9 @@ public void valuesMethod_shouldContainAllManagedClusterSkuTiersWithCorrectSize() Collection values = ManagedClusterSkuTier.values(); assertThat(values) - .as("Values should contain PREMIUM, STANDARD, FREE and have exactly 3 values") - .containsExactlyInAnyOrder(ManagedClusterSkuTier.PREMIUM, - ManagedClusterSkuTier.STANDARD, - ManagedClusterSkuTier.FREE); + .as("Values should contain PREMIUM, STANDARD, FREE and have exactly 3 values") + .containsExactlyInAnyOrder(ManagedClusterSkuTier.PREMIUM, + ManagedClusterSkuTier.STANDARD, + ManagedClusterSkuTier.FREE); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServicePlanTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServicePlanTest.java index a4f87413..56325626 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServicePlanTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServicePlanTest.java @@ -17,62 +17,68 @@ public class AzureAppServicePlanTest { private final static AzureOsType SELECTED_OPERATING_SYSTEM = AzureOsType.LINUX; private final static AzurePricingPlan SELECTED_PRICING_PLAN = AzurePricingPlan.BASIC_B1; private final static AzureResourceGroup AZURE_RESOURCE_GROUP = AzureResourceGroup.builder() - .withName("new-resource-group") - .withRegion(SELECTED_REGION) - .build(); + .withName("new-resource-group") + .withRegion(SELECTED_REGION) + .build(); @Test public void exceptionThrown_when_appServicePlanBuiltWithNullName() { assertThatThrownBy(() -> AzureAppServicePlan.builder().withName(null).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than or equal to 40 characters"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen," + + " and must be less than or equal to 40 characters"); } @Test public void exceptionThrown_when_appServicePlanBuiltWithEmptyName() { assertThatThrownBy(() -> AzureAppServicePlan.builder().withName("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than or equal to 40 characters"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen," + + " and must be less than or equal to 40 characters"); } @Test public void exceptionThrown_when_appServicePlanBuiltWithToLongName() { var veryLongName = "aTfR2EbiZzWwaCLdGWy2pCujyFCbFzLgCkYQeU9zF"; assertThatThrownBy(() -> AzureAppServicePlan.builder().withName(veryLongName).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than or equal to 40 characters"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen," + + " and must be less than or equal to 40 characters"); } @Test public void exceptionThrown_when_appServicePlanBuiltWithNameThatStartsWithHyphen() { var veryLongName = "-name"; assertThatThrownBy(() -> AzureAppServicePlan.builder().withName(veryLongName).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than or equal to 40 characters"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen," + + " and must be less than or equal to 40 characters"); } @Test public void exceptionThrown_when_appServicePlanBuiltWithNameThatEndsWithHyphen() { var veryLongName = "name-"; assertThatThrownBy(() -> AzureAppServicePlan.builder().withName(veryLongName).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than or equal to 40 characters"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen," + + " and must be less than or equal to 40 characters"); } @Test public void exceptionThrown_when_appServicePlanBuiltWithNameThatContainsUnderscore() { var veryLongName = "name_test"; assertThatThrownBy(() -> AzureAppServicePlan.builder().withName(veryLongName).build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than or equal to 40 characters"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The name only allow alphanumeric characters and hyphens, cannot start or end in a hyphen," + + " and must be less than or equal to 40 characters"); } @Test public void returns_without_errors_when_appServicePlanBuiltWithProperName() { var appServicePlanName = "name-test"; var appServicePlan = getAppServicePlanBuilder() - .withName(appServicePlanName) - .build(); + .withName(appServicePlanName) + .build(); assertThat(appServicePlan.getName()).isEqualTo(appServicePlanName); } @@ -80,7 +86,7 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperName() { @Test public void returns_without_errors_when_appServicePlanBuiltWithProperNameAndResourceGroup() { var appServicePlan = getAppServicePlanBuilder() - .build(); + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -91,7 +97,7 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc var appServicePlan = getAppServicePlanBuilder() - .build(); + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -101,7 +107,7 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc @Test public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourceGroupRegionAndOperatingSystem() { var appServicePlan = getAppServicePlanBuilder() - .build(); + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -112,7 +118,7 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc @Test public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourceGroupRegionOperatingSystemAndPricingPlan() { var appServicePlan = getAppServicePlanBuilder() - .build(); + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -124,8 +130,8 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc @Test public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourceGroupRegionOperatingSystemPricingPlanAndEnabledZoneRedundancy() { var appServicePlan = getAppServicePlanBuilder() - .withZoneRedundancyEnabled() - .build(); + .withZoneRedundancyEnabled() + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -139,9 +145,9 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourceGroupRegionOperatingSystemPricingPlanEnabledZoneRedundancyAndTags() { var tags = Map.of("tags_Key1", "tags_Value1", "tags_Key2", "tags_Value2"); var appServicePlan = getAppServicePlanBuilder() - .withZoneRedundancyEnabled() - .withTags(tags) - .build(); + .withZoneRedundancyEnabled() + .withTags(tags) + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -159,10 +165,10 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc var tagValue = "tagValue"; var appServicePlan = getAppServicePlanBuilder() - .withZoneRedundancyEnabled() - .withNumberOfWorkers(3) - .withTag(tagKey, tagValue) - .build(); + .withZoneRedundancyEnabled() + .withNumberOfWorkers(3) + .withTag(tagKey, tagValue) + .build(); assertThat(appServicePlan.getName()).isEqualTo(APP_SERVICE_PLAN_NAME); assertThat(appServicePlan.getAzureResourceGroup()).isEqualTo(AZURE_RESOURCE_GROUP); @@ -177,10 +183,10 @@ public void returns_without_errors_when_appServicePlanBuiltWithProperNameResourc private AzureAppServicePlan.AzureAppServicePlanBuilder getAppServicePlanBuilder() { return AzureAppServicePlan.builder() - .withName(APP_SERVICE_PLAN_NAME) - .withAzureResourceGroup(AZURE_RESOURCE_GROUP) - .withRegion(SELECTED_REGION) - .withOperatingSystem(SELECTED_OPERATING_SYSTEM) - .withPricingPlan(SELECTED_PRICING_PLAN); + .withName(APP_SERVICE_PLAN_NAME) + .withAzureResourceGroup(AZURE_RESOURCE_GROUP) + .withRegion(SELECTED_REGION) + .withOperatingSystem(SELECTED_OPERATING_SYSTEM) + .withPricingPlan(SELECTED_PRICING_PLAN); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServiceTest.java index 559ea1bc..c9c2d984 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServiceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureAppServiceTest.java @@ -25,28 +25,28 @@ public class AzureAppServiceTest { @Test public void exceptionThrown_when_workloadBuiltWithNullId() { assertThatThrownBy(() -> builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); } @Test public void exceptionThrown_when_workloadBuiltWithEmptyValues() { assertThatThrownBy(() -> generateBuilder().build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContainingAll( - "sshRepositoryURI is either empty or blank", - "repoId is either empty or blank"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContainingAll( + "sshRepositoryURI is either empty or blank", + "repoId is either empty or blank"); } @Test public void typeIsWebApp_when_workloadBuiltWithAllRequiredValues() { var builder = generateBuilder() - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withBranchName("branch-name") - .withConfiguration(AzureWebAppConfiguration.builder().withDotnetVersion("DOTNET:***").build()); + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withBranchName("branch-name") + .withConfiguration(AzureWebAppConfiguration.builder().withDotnetVersion("DOTNET:***").build()); assertThat(builder.build().getType()).isEqualTo(PAAS_WEBAPP); assertThatCode(builder::build).doesNotThrowAnyException(); } @@ -54,91 +54,93 @@ public void typeIsWebApp_when_workloadBuiltWithAllRequiredValues() { @Test public void exceptionThrown_when_workloadBuiltWithWorkloadSecretIdKeyEmpty() { var builder = generateBuilder() - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withSecretIdKey(""); + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withSecretIdKey(""); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Workload Secret Id Key is either empty or blank"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Workload Secret Id Key is either empty or blank"); } @Test public void exceptionThrown_when_workloadBuiltWithBranchNameKeyEmpty() { var builder = generateBuilder() - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withBranchName(""); + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withBranchName(""); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("branchName is either empty or blank and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("branchName is either empty or blank and it is required"); } @Test public void exceptionThrown_when_workloadBuiltWithWorkloadSecretPasswordKeyEmpty() { var builder = generateBuilder() - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withSecretPasswordKey(""); + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withSecretPasswordKey(""); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Workload Secret Password Key is either empty or blank"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Workload Secret Password Key is either empty or blank"); } @Test public void exceptionThrown_when_mixingWindowsRuntimeStackWithLinuxOs() { var builder = generateSampleBuilder() - .withOperatingSystem(AzureOsType.LINUX) - .withRuntimeStack(AzureWebAppWindowsRuntimeStack.DOTNET_7); + .withOperatingSystem(AzureOsType.LINUX) + .withRuntimeStack(AzureWebAppWindowsRuntimeStack.DOTNET_7); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The Runtime Stack and Operating System mismatches. Please choose AzureWebAppLinuxRuntimeStack or change Operating System to WINDOWS"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The Runtime Stack and Operating System mismatches. Please choose " + + "AzureWebAppLinuxRuntimeStack or change Operating System to WINDOWS"); } @Test public void exceptionThrown_when_mixingLinuxRuntimeStackWithWindowsOs() { var builder = generateSampleBuilder() - .withOperatingSystem(AzureOsType.WINDOWS) - .withRuntimeStack(AzureWebAppLinuxRuntimeStack.DOTNET_CORE_7_0); + .withOperatingSystem(AzureOsType.WINDOWS) + .withRuntimeStack(AzureWebAppLinuxRuntimeStack.DOTNET_CORE_7_0); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("The Runtime Stack and Operating System mismatches. Please choose AzureWebAppWindowsRuntimeStack or change Operating System to LINUX"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("The Runtime Stack and Operating System mismatches. Please choose " + + "AzureWebAppWindowsRuntimeStack or change Operating System to LINUX"); } @Test public void exceptionThrown_when_mixingJavaAndDotnetHosting() { var builder = AzureWebAppConfiguration.builder() - .withDotnetVersion("DOTNETCORE:7.0") - .withJavaVersion("JAVA:17-java17"); - + .withDotnetVersion("DOTNETCORE:7.0") + .withJavaVersion("JAVA:17-java17"); + assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Only one hosting configuration can be set. [DOTNET] has already been set"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Only one hosting configuration can be set. [DOTNET] has already been set"); } @Test public void exceptionThrown_when_mixingJavaAndPhpHosting() { var builder = AzureWebAppConfiguration.builder() - .withJavaVersion("JAVA:17-java17") - .withPhpVersion("PHP:8.1"); - + .withJavaVersion("JAVA:17-java17") + .withPhpVersion("PHP:8.1"); + assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Only one hosting configuration can be set. [JAVA] has already been set]"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Only one hosting configuration can be set. [JAVA] has already been set]"); } @Test public void hostingIsDotnet_when_settingDotnetVersion() { var builder = generateSampleBuilder() - .withConfiguration(AzureWebAppConfiguration.builder() - .withDotnetVersion("DOTNETCORE:7.0") - .build() - ); + .withConfiguration(AzureWebAppConfiguration.builder() + .withDotnetVersion("DOTNETCORE:7.0") + .build() + ); assertThat(builder.build().getConfiguration().getDotnetVersion()).isEqualTo("DOTNETCORE:7.0"); assertThatCode(builder::build).doesNotThrowAnyException(); } @@ -146,12 +148,12 @@ public void hostingIsDotnet_when_settingDotnetVersion() { @Test public void hostingIsPhp_when_settingPhpVersion() { var builder = generateSampleBuilder() - .withOperatingSystem(AzureOsType.LINUX) - .withRuntimeStack(AzureWebAppLinuxRuntimeStack.DOTNET_CORE_6_0) - .withConfiguration(AzureWebAppConfiguration.builder() - .withPhpVersion("PHP:8.1") - .build() - ); + .withOperatingSystem(AzureOsType.LINUX) + .withRuntimeStack(AzureWebAppLinuxRuntimeStack.DOTNET_CORE_6_0) + .withConfiguration(AzureWebAppConfiguration.builder() + .withPhpVersion("PHP:8.1") + .build() + ); assertThat(builder.build().getConfiguration().getPhpVersion()).isEqualTo("PHP:8.1"); assertThat(builder.build().getConfiguration().getPythonVersion()).isEqualTo(null); assertThatCode(builder::build).doesNotThrowAnyException(); @@ -160,11 +162,11 @@ public void hostingIsPhp_when_settingPhpVersion() { @Test public void hostingIsJavaContainer_when_settingJavaContainerHosting() { var builder = generateSampleBuilder() - .withConfiguration(AzureWebAppConfiguration.builder() - .withJavaContainer("xxx") - .withJavaContainerVersion("yyy") - .build() - ); + .withConfiguration(AzureWebAppConfiguration.builder() + .withJavaContainer("xxx") + .withJavaContainerVersion("yyy") + .build() + ); assertThat(builder.build().getConfiguration().getJavaContainer()).isEqualTo("xxx"); assertThat(builder.build().getConfiguration().getJavaContainerVersion()).isEqualTo("yyy"); assertThat(builder.build().getConfiguration().getDotnetVersion()).isEqualTo(null); @@ -177,126 +179,129 @@ public void hostingIsJavaContainer_when_settingJavaContainerHosting() { @Test public void exceptionThrown_when_missingJavaContainerVersionHosting() { var builder = AzureWebAppConfiguration.builder() - .withJavaContainer("xxx"); - + .withJavaContainer("xxx"); + assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Incomplete hosting types definition. Both [javaContainer] and [javaContainerVersion] must be set"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Incomplete hosting types definition. Both [javaContainer] and [javaContainerVersion] must" + + " be set"); } @Test public void exceptionThrown_when_missingJavaContainerHosting() { var builder = AzureWebAppConfiguration.builder() - .withJavaContainerVersion("yyy"); - + .withJavaContainerVersion("yyy"); + assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Incomplete hosting types definition. Both [javaContainer] and [javaContainerVersion] must be set"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Incomplete hosting types definition. Both [javaContainer] and [javaContainerVersion] must" + + " be set"); } @Test public void exceptionThrown_when_missingRuntimeStack() { var builder = generateSampleBuilder() - .withConfiguration(AzureWebAppConfiguration.builder().build()); + .withConfiguration(AzureWebAppConfiguration.builder().build()); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("[AzureWebApp Validation] The Runtime Stack is either empty or blank and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("[AzureWebApp Validation] The Runtime Stack is either empty or blank and it is required"); } @Test public void exceptionThrown_when_wrongCustomDomain() { var builder = generateSampleBuilder() - .withCustomDomain("wrong"); + .withCustomDomain("wrong"); assertThatThrownBy(builder::build). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("[AzureWebApp Validation] The CustomDomain must contain at least one period, cannot start or end with a period. CustomDomain are made up of letters, numbers, periods, and dashes"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("[AzureWebApp Validation] The CustomDomain must contain at least one period, cannot start " + + "or end with a period. CustomDomain are made up of letters, numbers, periods, and dashes"); } @Test public void returns_without_errors_when_settingConfiguration() { var webApp = generateSampleBuilder() - .withOperatingSystem(AzureOsType.LINUX) - .withRuntimeStack(AzureWebAppLinuxRuntimeStack.JAVA_17) - .withConfiguration(AzureWebAppConfiguration.builder() - .withJavaVersion("java version") - .withApiManagementConfigId("withApiManagementConfigId") - .withApiDefinitionUrl("apiDefinitionUrl") - .withCorsSettings(AzureWebAppCorsSettings.builder() - .withSupportCredentials(true) - .build()) - .withHttp20Enabled(true) - .withHttpLoggingEnabled(true) - .withMinTlsVersion(SupportedTlsVersions.ONE_ONE) - .withRequestTracingEnabled(true) - .withTracingOptions("withTracingOptions") - .withWebSocketsEnabled(true) - .withJavaVersion("java version") - .withAppSettings(new HashMap<>()) - .withAlwaysOn(true) - .withAppCommandLine("appCommandLine") - .withAutoSwapSlotName("autoSwapSlotName") - .withConnectionStrings(new ArrayList<>()) - .withDefaultDocuments(new ArrayList<>()) - .withDocumentRoot("documentRoot") - .withNumberOfWorkers(1) - .withUse32BitWorkerProcess(true) - .withRemoteDebuggingEnabled(true) - .withRemoteDebuggingVersion("remoteDebuggingVersion") - .withWebsiteTimeZone("websiteTimezone") - .withJavaVersion("java version") - .withAcrUseManagedIdentityCredentials(true) - .withAcrUserManagedIdentityId("acrUserManagedIdentityId") - .withDetailedErrorLoggingEnabled(true) - .withFtpsState(AzureFtpsState.FTPS_ONLY) - .withFunctionAppScaleLimit(1) - .withFunctionsRuntimeScaleMonitoringEnabled(true) - .withHealthCheckPath("healthCheckPath") - .withKeyVaultReferenceIdentity("keyVaultReferenceIdentity") - .withLimits(AzureSiteLimits.builder() - .withMaxDiskSizeInMb(100) - .withMaxMemoryInMb(128) - .withMaxPercentageCpu(50.0) - .build()) - .withLocalMySqlEnabled(true) - .withLogsDirectorySizeLimit(100) - .withManagedServiceIdentityId(1) - .withMinimumElasticInstanceCount(1) - .withPreWarmedInstanceCount(1) - .withPublicNetworkAccess("publicNetworkAccess") - .withPublishingUsername("publishingUsername") - .withVnetName("vnetName") - .withVnetRouteAllEnabled(true) - .withVnetPrivatePortsCount(1) - .withXManagedServiceIdentityId(1) - .build() - ) - .withClientAffinityEnabled(true) - .withClientCertEnabled(true) - .withClientCertExclusionPaths("withClientCertExclusionPaths") - .withClientCertMode(AzureAppServiceClientCertMode.REQUIRED) - .withHttpsOnly(true) - .withContainerSize(100) - .withCustomDomainVerificationId("customDomainVerificationId") - .withDailyMemoryTimeQuota(100) - .withEnabled(true) - .withHostNamesDisabled(true) - .withHyperV(true) - .withRedundancyMode(AzureAppServiceRedundancyMode.GEO_REDUNDANT) - .withReserved(true) - .withStorageAccountRequired(true) - .withVirtualNetworkSubnetId("virtualNetworkSubnetId") - .withVnetContentShareEnabled(true) - .withVnetImagePullEnabled(true) - .withCloningInfo(AzureWebAppCloningInfo.builder() - .withOverwrite(true) - .build()) - .withHostingEnvironmentProfileId("HostingEnvironmentProfileId") - .withScmSiteAlsoStopped(true) - .withEnvironmentSecretShortName("secret-1") - .withEnvironmentSecretShortName("secret-2") - .withEnvironmentSecretShortName("secret-3") - .withCiCdProfileShortName("default") - .build(); + .withOperatingSystem(AzureOsType.LINUX) + .withRuntimeStack(AzureWebAppLinuxRuntimeStack.JAVA_17) + .withConfiguration(AzureWebAppConfiguration.builder() + .withJavaVersion("java version") + .withApiManagementConfigId("withApiManagementConfigId") + .withApiDefinitionUrl("apiDefinitionUrl") + .withCorsSettings(AzureWebAppCorsSettings.builder() + .withSupportCredentials(true) + .build()) + .withHttp20Enabled(true) + .withHttpLoggingEnabled(true) + .withMinTlsVersion(SupportedTlsVersions.ONE_ONE) + .withRequestTracingEnabled(true) + .withTracingOptions("withTracingOptions") + .withWebSocketsEnabled(true) + .withJavaVersion("java version") + .withAppSettings(new HashMap<>()) + .withAlwaysOn(true) + .withAppCommandLine("appCommandLine") + .withAutoSwapSlotName("autoSwapSlotName") + .withConnectionStrings(new ArrayList<>()) + .withDefaultDocuments(new ArrayList<>()) + .withDocumentRoot("documentRoot") + .withNumberOfWorkers(1) + .withUse32BitWorkerProcess(true) + .withRemoteDebuggingEnabled(true) + .withRemoteDebuggingVersion("remoteDebuggingVersion") + .withWebsiteTimeZone("websiteTimezone") + .withJavaVersion("java version") + .withAcrUseManagedIdentityCredentials(true) + .withAcrUserManagedIdentityId("acrUserManagedIdentityId") + .withDetailedErrorLoggingEnabled(true) + .withFtpsState(AzureFtpsState.FTPS_ONLY) + .withFunctionAppScaleLimit(1) + .withFunctionsRuntimeScaleMonitoringEnabled(true) + .withHealthCheckPath("healthCheckPath") + .withKeyVaultReferenceIdentity("keyVaultReferenceIdentity") + .withLimits(AzureSiteLimits.builder() + .withMaxDiskSizeInMb(100) + .withMaxMemoryInMb(128) + .withMaxPercentageCpu(50.0) + .build()) + .withLocalMySqlEnabled(true) + .withLogsDirectorySizeLimit(100) + .withManagedServiceIdentityId(1) + .withMinimumElasticInstanceCount(1) + .withPreWarmedInstanceCount(1) + .withPublicNetworkAccess("publicNetworkAccess") + .withPublishingUsername("publishingUsername") + .withVnetName("vnetName") + .withVnetRouteAllEnabled(true) + .withVnetPrivatePortsCount(1) + .withXManagedServiceIdentityId(1) + .build() + ) + .withClientAffinityEnabled(true) + .withClientCertEnabled(true) + .withClientCertExclusionPaths("withClientCertExclusionPaths") + .withClientCertMode(AzureAppServiceClientCertMode.REQUIRED) + .withHttpsOnly(true) + .withContainerSize(100) + .withCustomDomainVerificationId("customDomainVerificationId") + .withDailyMemoryTimeQuota(100) + .withEnabled(true) + .withHostNamesDisabled(true) + .withHyperV(true) + .withRedundancyMode(AzureAppServiceRedundancyMode.GEO_REDUNDANT) + .withReserved(true) + .withStorageAccountRequired(true) + .withVirtualNetworkSubnetId("virtualNetworkSubnetId") + .withVnetContentShareEnabled(true) + .withVnetImagePullEnabled(true) + .withCloningInfo(AzureWebAppCloningInfo.builder() + .withOverwrite(true) + .build()) + .withHostingEnvironmentProfileId("HostingEnvironmentProfileId") + .withScmSiteAlsoStopped(true) + .withEnvironmentSecretShortName("secret-1") + .withEnvironmentSecretShortName("secret-2") + .withEnvironmentSecretShortName("secret-3") + .withCiCdProfileShortName("default") + .build(); assertThat(webApp.getConfiguration().getApiManagementConfigId()).isEqualTo("withApiManagementConfigId"); assertThat(webApp.getConfiguration().getApiDefinitionUrl()).isEqualTo("apiDefinitionUrl"); @@ -374,66 +379,66 @@ public void returns_without_errors_when_appServiceBuiltWithProperAppServicePlan( var resourceGroup = AzureResourceGroup.builder() - .withName("new-resource-group") - .withRegion(selectedRegion) - .build(); + .withName("new-resource-group") + .withRegion(selectedRegion) + .build(); var appServicePlan = AzureAppServicePlan.builder() - .withName(appServicePlanName) - .withAzureResourceGroup(resourceGroup) - .withRegion(selectedRegion) - .withOperatingSystem(selectedOperatingSystem) - .withPricingPlan(selectedPricingPlan) - .withZoneRedundancyEnabled() - .withTags(tags) - .build(); - + .withName(appServicePlanName) + .withAzureResourceGroup(resourceGroup) + .withRegion(selectedRegion) + .withOperatingSystem(selectedOperatingSystem) + .withPricingPlan(selectedPricingPlan) + .withZoneRedundancyEnabled() + .withTags(tags) + .build(); + var certificate = AzureKeyVaultCertificate.builder() - .withKeyVaultId("key-vault-id") - .withName("certificate-name") - .build(); + .withKeyVaultId("key-vault-id") + .withName("certificate-name") + .build(); var webApp = generateSampleBuilder() - .withOperatingSystem(AzureOsType.WINDOWS) - .withRuntimeStack(AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_10_0) - .withAppServicePlan(appServicePlan) - .withConfiguration(AzureWebAppConfiguration.builder() - .withJavaVersion("java version") - .build()) - .withCertificate(certificate) - .withCustomDomain("custom.domain.com") - .withCustomDomain("custom1.domain.com") - .withResourceGroup(resourceGroup) - .withTags(tags) - .build(); + .withOperatingSystem(AzureOsType.WINDOWS) + .withRuntimeStack(AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_10_0) + .withAppServicePlan(appServicePlan) + .withConfiguration(AzureWebAppConfiguration.builder() + .withJavaVersion("java version") + .build()) + .withCertificate(certificate) + .withCustomDomain("custom.domain.com") + .withCustomDomain("custom1.domain.com") + .withResourceGroup(resourceGroup) + .withTags(tags) + .build(); var json = TestUtils.getJsonRepresentation(webApp); - + assertThat(json).isNotBlank(); - + assertThat(appServicePlan.getName()).isEqualTo(appServicePlanName); assertThat(appServicePlan.getTags().size()).isEqualTo(1); assertThat(appServicePlan.getTags()).isEqualTo(tags); - - + + assertThat(webApp.getAppServicePlan()).isEqualTo(appServicePlan); assertThat(webApp.getTags().size()).isEqualTo(1); assertThat(webApp.getTags()).isEqualTo(tags); } - + private AzureWebApp.AzureWebAppBuilder generateBuilder() { return builder().withId("webapp"); } private AzureWebApp.AzureWebAppBuilder generateSampleBuilder() { return generateBuilder() - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") - .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") - .withSSHRepositoryURI("ssh") - .withRepoId("repo-id") - .withBranchName("env/test") - .withSecretPasswordKey("***") - .withRegion(AzureRegion.WEST_EUROPE); + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("svc-private-ssh-key-pass") + .withPrivateSSHKeyEnvironmentSecretShortName("svc-private-ssh-key-secret") + .withSSHRepositoryURI("ssh") + .withRepoId("repo-id") + .withBranchName("env/test") + .withSecretPasswordKey("***") + .withRegion(AzureRegion.WEST_EUROPE); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringTypeTest.java index ac3226cf..268f123e 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureConnectionStringTypeTest.java @@ -9,17 +9,18 @@ class AzureConnectionStringTypeTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureConnectionStringType.fromString("ApiHub"), AzureConnectionStringType.API_HUB), - () -> assertEquals(AzureConnectionStringType.fromString("Custom"), AzureConnectionStringType.CUSTOM), - () -> assertEquals(AzureConnectionStringType.fromString("DocDb"), AzureConnectionStringType.DOC_DB), - () -> assertEquals(AzureConnectionStringType.fromString("EventHub"), AzureConnectionStringType.EVENT_HUB), - () -> assertEquals(AzureConnectionStringType.fromString("MySql"), AzureConnectionStringType.MY_SQL), - () -> assertEquals(AzureConnectionStringType.fromString("NotificationHub"), AzureConnectionStringType.NOTIFICATION_HUB), - () -> assertEquals(AzureConnectionStringType.fromString("PostgreSQL"), AzureConnectionStringType.POSTGRE_SQL), - () -> assertEquals(AzureConnectionStringType.fromString("RedisCache"), AzureConnectionStringType.REDIS_CACHE), - () -> assertEquals(AzureConnectionStringType.fromString("SQLAzure"), AzureConnectionStringType.SQL_AZURE), - () -> assertEquals(AzureConnectionStringType.fromString("SQLServer"), AzureConnectionStringType.SQL_SERVER), - () -> assertEquals(AzureConnectionStringType.fromString("ServiceBus"), AzureConnectionStringType.SERVICE_BUS) + () -> assertEquals(AzureConnectionStringType.fromString("ApiHub"), AzureConnectionStringType.API_HUB), + () -> assertEquals(AzureConnectionStringType.fromString("Custom"), AzureConnectionStringType.CUSTOM), + () -> assertEquals(AzureConnectionStringType.fromString("DocDb"), AzureConnectionStringType.DOC_DB), + () -> assertEquals(AzureConnectionStringType.fromString("EventHub"), AzureConnectionStringType.EVENT_HUB), + () -> assertEquals(AzureConnectionStringType.fromString("MySql"), AzureConnectionStringType.MY_SQL), + () -> assertEquals(AzureConnectionStringType.fromString("NotificationHub"), + AzureConnectionStringType.NOTIFICATION_HUB), + () -> assertEquals(AzureConnectionStringType.fromString("PostgreSQL"), AzureConnectionStringType.POSTGRE_SQL), + () -> assertEquals(AzureConnectionStringType.fromString("RedisCache"), AzureConnectionStringType.REDIS_CACHE), + () -> assertEquals(AzureConnectionStringType.fromString("SQLAzure"), AzureConnectionStringType.SQL_AZURE), + () -> assertEquals(AzureConnectionStringType.fromString("SQLServer"), AzureConnectionStringType.SQL_SERVER), + () -> assertEquals(AzureConnectionStringType.fromString("ServiceBus"), AzureConnectionStringType.SERVICE_BUS) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureDeploymentSlotTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureDeploymentSlotTest.java index 943a989e..bb99f9f7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureDeploymentSlotTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureDeploymentSlotTest.java @@ -12,13 +12,13 @@ void builder_withCloneSettingsFromWebApp_createsExpectedDeploymentSlot() { // Act var deploymentSlot = AzureWebAppDeploymentSlot.builder() - .withName("slot") - .withCloneSettingsFromWebApp(expectedCloneSettings) - .build(); + .withName("slot") + .withCloneSettingsFromWebApp(expectedCloneSettings) + .build(); // Assert assertEquals(expectedCloneSettings, deploymentSlot.isCloneSettingsFromWebApp(), - "The cloneSettingsFromWebApp should match the expected value."); + "The cloneSettingsFromWebApp should match the expected value."); } @Test @@ -29,14 +29,14 @@ void builder_withCloneSettingsFromWebApp_createsExpectedDeploymentSlotName() { // Act var deploymentSlot = AzureWebAppDeploymentSlot.builder() - .withName(slotName) - .build(); + .withName(slotName) + .build(); // Assert assertEquals(expectedCloneSettings, deploymentSlot.isCloneSettingsFromWebApp(), - "The cloneSettingsFromWebApp should match the expected value."); + "The cloneSettingsFromWebApp should match the expected value."); assertEquals(slotName, deploymentSlot.getName(), - "The name should match the expected value."); + "The name should match the expected value."); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureIpFilterTagTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureIpFilterTagTest.java index bc91ed8d..d2b83dc0 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureIpFilterTagTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureIpFilterTagTest.java @@ -9,9 +9,9 @@ class AzureIpFilterTagTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureIpFilterTag.fromString("Default"), AzureIpFilterTag.DEFAULT), - () -> assertEquals(AzureIpFilterTag.fromString("ServiceTag"), AzureIpFilterTag.SERVICE_TAG), - () -> assertEquals(AzureIpFilterTag.fromString("XffProxy"), AzureIpFilterTag.XFF_PROXY) + () -> assertEquals(AzureIpFilterTag.fromString("Default"), AzureIpFilterTag.DEFAULT), + () -> assertEquals(AzureIpFilterTag.fromString("ServiceTag"), AzureIpFilterTag.SERVICE_TAG), + () -> assertEquals(AzureIpFilterTag.fromString("XffProxy"), AzureIpFilterTag.XFF_PROXY) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificateTest.java index cf29ea62..e9f86e5e 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureKeyVaultCertificateTest.java @@ -13,41 +13,41 @@ class AzureKeyVaultCertificateTest { @Test public void exceptionThrown_when_certificateWithEmptyKeyVaultId() { assertThatThrownBy(() -> AzureKeyVaultCertificate.builder() - .withKeyVaultId("") - .withName("certificate-name") - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("KeyVaultId has not been defined and it is required"); + .withKeyVaultId("") + .withName("certificate-name") + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("KeyVaultId has not been defined and it is required"); } @Test public void exceptionThrown_when_certificateWithNullAsKeyVaultId() { assertThatThrownBy(() -> AzureKeyVaultCertificate.builder() - .withKeyVaultId(null) - .withName("certificate-name") - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("KeyVaultId has not been defined and it is required"); + .withKeyVaultId(null) + .withName("certificate-name") + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("KeyVaultId has not been defined and it is required"); } @Test public void exceptionThrown_when_certificateWithEmptyName() { assertThatThrownBy(() -> AzureKeyVaultCertificate.builder() - .withKeyVaultId("key-vault-id") - .withName("") - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name has not been defined and it is required"); + .withKeyVaultId("key-vault-id") + .withName("") + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name has not been defined and it is required"); } @Test public void exceptionThrown_when_certificateWithNullAsName() { assertThatThrownBy(() -> AzureKeyVaultCertificate.builder() - .withKeyVaultId("key-vault-id") - .withName(null) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Name has not been defined and it is required"); + .withKeyVaultId("key-vault-id") + .withName(null) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Name has not been defined and it is required"); } @Test @@ -56,30 +56,30 @@ public void noValidationErrors_when_certificateHasRequiredFields() { var certificateName = "certificate-name"; var certificatePassword = "password"; var tags = Map.of("key3", "value3", "key4", "value4"); - + var certificate = AzureKeyVaultCertificate.builder() - .withKeyVaultId(keyVaultId) - .withName(certificateName) - .withPassword(certificatePassword) - .withRegion(AzureRegion.WEST_EUROPE) - .withTags(tags) - .withTag("key1", "value1") - .withTag("key2", "value2") - .build(); + .withKeyVaultId(keyVaultId) + .withName(certificateName) + .withPassword(certificatePassword) + .withRegion(AzureRegion.WEST_EUROPE) + .withTags(tags) + .withTag("key1", "value1") + .withTag("key2", "value2") + .build(); assertThat(certificate.validate()).isEmpty(); assertThat(certificate) - .asInstanceOf(InstanceOfAssertFactories.type(AzureKeyVaultCertificate.class)) - .extracting(AzureKeyVaultCertificate::getKeyVaultId, - AzureKeyVaultCertificate::getName, - AzureKeyVaultCertificate::getPassword, - AzureKeyVaultCertificate::getRegion, - AzureKeyVaultCertificate::getTags) - .containsExactly(keyVaultId, - certificateName, - certificatePassword, - AzureRegion.WEST_EUROPE, - Map.of("key1", "value1", "key2", "value2", "key3", "value3", "key4", "value4")); + .asInstanceOf(InstanceOfAssertFactories.type(AzureKeyVaultCertificate.class)) + .extracting(AzureKeyVaultCertificate::getKeyVaultId, + AzureKeyVaultCertificate::getName, + AzureKeyVaultCertificate::getPassword, + AzureKeyVaultCertificate::getRegion, + AzureKeyVaultCertificate::getTags) + .containsExactly(keyVaultId, + certificateName, + certificatePassword, + AzureRegion.WEST_EUROPE, + Map.of("key1", "value1", "key2", "value2", "key3", "value3", "key4", "value4")); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureManagedPipelineModeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureManagedPipelineModeTest.java index 17ecd43e..d95a4273 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureManagedPipelineModeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureManagedPipelineModeTest.java @@ -9,8 +9,8 @@ class AzureManagedPipelineModeTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureManagedPipelineMode.fromString("Classic"), AzureManagedPipelineMode.CLASSIC), - () -> assertEquals(AzureManagedPipelineMode.fromString("Integrated"), AzureManagedPipelineMode.INTEGRATED) + () -> assertEquals(AzureManagedPipelineMode.fromString("Classic"), AzureManagedPipelineMode.CLASSIC), + () -> assertEquals(AzureManagedPipelineMode.fromString("Integrated"), AzureManagedPipelineMode.INTEGRATED) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancingTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancingTest.java index 6dd18981..bfad17bf 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancingTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureSiteLoadBalancingTest.java @@ -9,12 +9,16 @@ class AzureSiteLoadBalancingTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureSiteLoadBalancing.fromString("LeastRequests"), AzureSiteLoadBalancing.LEAST_REQUESTS), - () -> assertEquals(AzureSiteLoadBalancing.fromString("LeastResponseTime"), AzureSiteLoadBalancing.LEAST_RESPONSE_TIME), - () -> assertEquals(AzureSiteLoadBalancing.fromString("PerSiteRoundRobin"), AzureSiteLoadBalancing.PER_SITE_ROUND_ROBIN), - () -> assertEquals(AzureSiteLoadBalancing.fromString("RequestHash"), AzureSiteLoadBalancing.REQUEST_HASH), - () -> assertEquals(AzureSiteLoadBalancing.fromString("WeightedRoundRobin"), AzureSiteLoadBalancing.WEIGHTED_ROUND_ROBIN), - () -> assertEquals(AzureSiteLoadBalancing.fromString("WeightedTotalTraffic"), AzureSiteLoadBalancing.WEIGHTED_TOTAL_TRAFFIC) + () -> assertEquals(AzureSiteLoadBalancing.fromString("LeastRequests"), AzureSiteLoadBalancing.LEAST_REQUESTS), + () -> assertEquals(AzureSiteLoadBalancing.fromString("LeastResponseTime"), + AzureSiteLoadBalancing.LEAST_RESPONSE_TIME), + () -> assertEquals(AzureSiteLoadBalancing.fromString("PerSiteRoundRobin"), + AzureSiteLoadBalancing.PER_SITE_ROUND_ROBIN), + () -> assertEquals(AzureSiteLoadBalancing.fromString("RequestHash"), AzureSiteLoadBalancing.REQUEST_HASH), + () -> assertEquals(AzureSiteLoadBalancing.fromString("WeightedRoundRobin"), + AzureSiteLoadBalancing.WEIGHTED_ROUND_ROBIN), + () -> assertEquals(AzureSiteLoadBalancing.fromString("WeightedTotalTraffic"), + AzureSiteLoadBalancing.WEIGHTED_TOTAL_TRAFFIC) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStackTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStackTest.java index 13551bbd..b6171dde 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStackTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppLinuxRuntimeStackTest.java @@ -9,36 +9,62 @@ class AzureWebAppLinuxRuntimeStackTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("DOTNETCORE|8.0"), AzureWebAppLinuxRuntimeStack.DOTNET_CORE_8_0), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("DOTNETCORE|7.0"), AzureWebAppLinuxRuntimeStack.DOTNET_CORE_7_0), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("DOTNETCORE|6.0"), AzureWebAppLinuxRuntimeStack.DOTNET_CORE_6_0), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("NODE|20-lts"), AzureWebAppLinuxRuntimeStack.NODE_20_LTS), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("NODE|18-lts"), AzureWebAppLinuxRuntimeStack.NODE_18_LTS), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("NODE|16-lts"), AzureWebAppLinuxRuntimeStack.NODE_16_LTS), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.12"), AzureWebAppLinuxRuntimeStack.PYTHON_3_12), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.11"), AzureWebAppLinuxRuntimeStack.PYTHON_3_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.10"), AzureWebAppLinuxRuntimeStack.PYTHON_3_10), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.9"), AzureWebAppLinuxRuntimeStack.PYTHON_3_9), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.8"), AzureWebAppLinuxRuntimeStack.PYTHON_3_8), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PHP|8.2"), AzureWebAppLinuxRuntimeStack.PHP_8_2), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PHP|8.1"), AzureWebAppLinuxRuntimeStack.PHP_8_1), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PHP|8.0"), AzureWebAppLinuxRuntimeStack.PHP_8_0), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JAVA|17-java17"), AzureWebAppLinuxRuntimeStack.JAVA_17), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JAVA|11-java11"), AzureWebAppLinuxRuntimeStack.JAVA_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JAVA|8-jre8"), AzureWebAppLinuxRuntimeStack.JAVA_8), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JBOSSEAP|7-java17"), AzureWebAppLinuxRuntimeStack.JBOSS_EAP_7_JAVA_17), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JBOSSEAP|7-java11"), AzureWebAppLinuxRuntimeStack.JBOSS_EAP_7_JAVA_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JBOSSEAP|7-java8"), AzureWebAppLinuxRuntimeStack.JBOSS_EAP_7_JAVA_8), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.1-java17"), AzureWebAppLinuxRuntimeStack.TOMCAT_10_1_JAVA_17), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.1-java11"), AzureWebAppLinuxRuntimeStack.TOMCAT_10_1_JAVA_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.0-java17"), AzureWebAppLinuxRuntimeStack.TOMCAT_10_0_JAVA_17), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.0-java11"), AzureWebAppLinuxRuntimeStack.TOMCAT_10_0_JAVA_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.0-jre8"), AzureWebAppLinuxRuntimeStack.TOMCAT_10_0_JRE_8), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|9.0-java17"), AzureWebAppLinuxRuntimeStack.TOMCAT_9_0_JAVA_17), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|9.0-java11"), AzureWebAppLinuxRuntimeStack.TOMCAT_9_0_JAVA_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|9.0-jre8"), AzureWebAppLinuxRuntimeStack.TOMCAT_9_0_JRE_8), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|8.5-java11"), AzureWebAppLinuxRuntimeStack.TOMCAT_8_5_JAVA_11), - () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|8.5-jre8"), AzureWebAppLinuxRuntimeStack.TOMCAT_8_5_JRE_8) + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("DOTNETCORE|8.0"), + AzureWebAppLinuxRuntimeStack.DOTNET_CORE_8_0), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("DOTNETCORE|7.0"), + AzureWebAppLinuxRuntimeStack.DOTNET_CORE_7_0), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("DOTNETCORE|6.0"), + AzureWebAppLinuxRuntimeStack.DOTNET_CORE_6_0), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("NODE|20-lts"), + AzureWebAppLinuxRuntimeStack.NODE_20_LTS), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("NODE|18-lts"), + AzureWebAppLinuxRuntimeStack.NODE_18_LTS), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("NODE|16-lts"), + AzureWebAppLinuxRuntimeStack.NODE_16_LTS), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.12"), + AzureWebAppLinuxRuntimeStack.PYTHON_3_12), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.11"), + AzureWebAppLinuxRuntimeStack.PYTHON_3_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.10"), + AzureWebAppLinuxRuntimeStack.PYTHON_3_10), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.9"), + AzureWebAppLinuxRuntimeStack.PYTHON_3_9), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PYTHON|3.8"), + AzureWebAppLinuxRuntimeStack.PYTHON_3_8), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PHP|8.2"), AzureWebAppLinuxRuntimeStack.PHP_8_2), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PHP|8.1"), AzureWebAppLinuxRuntimeStack.PHP_8_1), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("PHP|8.0"), AzureWebAppLinuxRuntimeStack.PHP_8_0), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JAVA|17-java17"), + AzureWebAppLinuxRuntimeStack.JAVA_17), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JAVA|11-java11"), + AzureWebAppLinuxRuntimeStack.JAVA_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JAVA|8-jre8"), AzureWebAppLinuxRuntimeStack.JAVA_8), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JBOSSEAP|7-java17"), + AzureWebAppLinuxRuntimeStack.JBOSS_EAP_7_JAVA_17), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JBOSSEAP|7-java11"), + AzureWebAppLinuxRuntimeStack.JBOSS_EAP_7_JAVA_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("JBOSSEAP|7-java8"), + AzureWebAppLinuxRuntimeStack.JBOSS_EAP_7_JAVA_8), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.1-java17"), + AzureWebAppLinuxRuntimeStack.TOMCAT_10_1_JAVA_17), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.1-java11"), + AzureWebAppLinuxRuntimeStack.TOMCAT_10_1_JAVA_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.0-java17"), + AzureWebAppLinuxRuntimeStack.TOMCAT_10_0_JAVA_17), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.0-java11"), + AzureWebAppLinuxRuntimeStack.TOMCAT_10_0_JAVA_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|10.0-jre8"), + AzureWebAppLinuxRuntimeStack.TOMCAT_10_0_JRE_8), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|9.0-java17"), + AzureWebAppLinuxRuntimeStack.TOMCAT_9_0_JAVA_17), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|9.0-java11"), + AzureWebAppLinuxRuntimeStack.TOMCAT_9_0_JAVA_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|9.0-jre8"), + AzureWebAppLinuxRuntimeStack.TOMCAT_9_0_JRE_8), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|8.5-java11"), + AzureWebAppLinuxRuntimeStack.TOMCAT_8_5_JAVA_11), + () -> assertEquals(AzureWebAppLinuxRuntimeStack.fromString("TOMCAT|8.5-jre8"), + AzureWebAppLinuxRuntimeStack.TOMCAT_8_5_JRE_8) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppWindowsRuntimeStackTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppWindowsRuntimeStackTest.java index 01a57b35..893f6ede 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppWindowsRuntimeStackTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/AzureWebAppWindowsRuntimeStackTest.java @@ -9,29 +9,52 @@ class AzureWebAppWindowsRuntimeStackTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("dotnet|v8.0"), AzureWebAppWindowsRuntimeStack.DOTNET_8), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("dotnet|v7.0"), AzureWebAppWindowsRuntimeStack.DOTNET_7), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("dotnet|v6.0"), AzureWebAppWindowsRuntimeStack.DOTNET_6), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("ASPNET|v4.8"), AzureWebAppWindowsRuntimeStack.ASPNET_4_8), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("ASPNET|v3.5"), AzureWebAppWindowsRuntimeStack.ASPNET_3_5), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("NODE|20LTS"), AzureWebAppWindowsRuntimeStack.NODE_20_LTS), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("NODE|18LTS"), AzureWebAppWindowsRuntimeStack.NODE_18_LTS), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("NODE|16LTS"), AzureWebAppWindowsRuntimeStack.NODE_16_LTS), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|JAVA|SE"), AzureWebAppWindowsRuntimeStack.JAVA_SE_8), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|JAVA|SE"), AzureWebAppWindowsRuntimeStack.JAVA_SE_11), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|JAVA|SE"), AzureWebAppWindowsRuntimeStack.JAVA_SE_17), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|10.0"), AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_10_0), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|10.1"), AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_10_1), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|10.0"), AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_10_0), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|10.1"), AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_10_1), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|10.0"), AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_10_0), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|10.1"), AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_10_1), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|9.0"), AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_9_0), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|9.0"), AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_9_0), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|9.0"), AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_9_0), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|8.5"), AzureWebAppWindowsRuntimeStack.JAVA_1_8_TOMCAT_8_5), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|8.5"), AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_8_5), - () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|8.5"), AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_8_5) + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("dotnet|v8.0"), + AzureWebAppWindowsRuntimeStack.DOTNET_8), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("dotnet|v7.0"), + AzureWebAppWindowsRuntimeStack.DOTNET_7), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("dotnet|v6.0"), + AzureWebAppWindowsRuntimeStack.DOTNET_6), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("ASPNET|v4.8"), + AzureWebAppWindowsRuntimeStack.ASPNET_4_8), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("ASPNET|v3.5"), + AzureWebAppWindowsRuntimeStack.ASPNET_3_5), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("NODE|20LTS"), + AzureWebAppWindowsRuntimeStack.NODE_20_LTS), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("NODE|18LTS"), + AzureWebAppWindowsRuntimeStack.NODE_18_LTS), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("NODE|16LTS"), + AzureWebAppWindowsRuntimeStack.NODE_16_LTS), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|JAVA|SE"), + AzureWebAppWindowsRuntimeStack.JAVA_SE_8), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|JAVA|SE"), + AzureWebAppWindowsRuntimeStack.JAVA_SE_11), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|JAVA|SE"), + AzureWebAppWindowsRuntimeStack.JAVA_SE_17), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|10.0"), + AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_10_0), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|10.1"), + AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_10_1), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|10.0"), + AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_10_0), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|10.1"), + AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_10_1), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|10.0"), + AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_10_0), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|10.1"), + AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_10_1), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|9.0"), + AzureWebAppWindowsRuntimeStack.JAVA_8_TOMCAT_9_0), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|9.0"), + AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_9_0), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|9.0"), + AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_9_0), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|1.8|TOMCAT|8.5"), + AzureWebAppWindowsRuntimeStack.JAVA_1_8_TOMCAT_8_5), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|11|TOMCAT|8.5"), + AzureWebAppWindowsRuntimeStack.JAVA_11_TOMCAT_8_5), + () -> assertEquals(AzureWebAppWindowsRuntimeStack.fromString("java|17|TOMCAT|8.5"), + AzureWebAppWindowsRuntimeStack.JAVA_17_TOMCAT_8_5) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/valueobjects/AzureFtpsStateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/valueobjects/AzureFtpsStateTest.java index a7875457..c374c520 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/valueobjects/AzureFtpsStateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/appservice/valueobjects/AzureFtpsStateTest.java @@ -9,9 +9,9 @@ class AzureFtpsStateTest { @Test public void shouldReturnProperValue() { assertAll( - () -> assertEquals(AzureFtpsState.fromString("AllAllowed"), AzureFtpsState.ALL_ALLOWED), - () -> assertEquals(AzureFtpsState.fromString("Disabled"), AzureFtpsState.DISABLED), - () -> assertEquals(AzureFtpsState.fromString("FtpsOnly"), AzureFtpsState.FTPS_ONLY) + () -> assertEquals(AzureFtpsState.fromString("AllAllowed"), AzureFtpsState.ALL_ALLOWED), + () -> assertEquals(AzureFtpsState.fromString("Disabled"), AzureFtpsState.DISABLED), + () -> assertEquals(AzureFtpsState.fromString("FtpsOnly"), AzureFtpsState.FTPS_ONLY) ); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnSkuTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnSkuTest.java index 9031d60c..6862f034 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnSkuTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/cdn/AzureCdnSkuTest.java @@ -10,52 +10,52 @@ class AzureCdnSkuTest { @Test public void azureCdnSkuTestConstants_shouldNotBeNull() { assertThat(AzureCdnSku.STANDARD_EDGIO) - .as("STANDARD_EDGIO constant should not be null") - .isNotNull(); + .as("STANDARD_EDGIO constant should not be null") + .isNotNull(); assertThat(AzureCdnSku.PREMIUM_EDGIO) - .as("PREMIUM_EDGIO constant should not be null") - .isNotNull(); - + .as("PREMIUM_EDGIO constant should not be null") + .isNotNull(); + assertThat(AzureCdnSku.STANDARD_MICROSOFT) - .as("STANDARD_MICROSOFT constant should not be null") - .isNotNull(); + .as("STANDARD_MICROSOFT constant should not be null") + .isNotNull(); assertThat(AzureCdnSku.STANDARD_AZURE_FRONT_DOOR) - .as("STANDARD_AZURE_FRONT_DOOR constant should not be null") - .isNotNull(); + .as("STANDARD_AZURE_FRONT_DOOR constant should not be null") + .isNotNull(); assertThat(AzureCdnSku.STANDARD_AZURE_FRONT_DOOR) - .as("STANDARD_AZURE_FRONT_DOOR constant should not be null") - .isNotNull(); + .as("STANDARD_AZURE_FRONT_DOOR constant should not be null") + .isNotNull(); assertThat(AzureCdnSku.PREMIUM_AZURE_FRONT_DOOR) - .as("PREMIUM_AZURE_FRONT_DOOR constant should not be null") - .isNotNull(); + .as("PREMIUM_AZURE_FRONT_DOOR constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureCdnSku() { assertThat(AzureCdnSku.fromString("Standard_Verizon")) - .as("fromString should return STANDARD_EDGIO for 'Standard_Verizon'") - .isEqualTo(AzureCdnSku.STANDARD_EDGIO); + .as("fromString should return STANDARD_EDGIO for 'Standard_Verizon'") + .isEqualTo(AzureCdnSku.STANDARD_EDGIO); assertThat(AzureCdnSku.fromString("Premium_Verizon")) - .as("fromString should return PREMIUM_EDGIO for 'Premium_Verizon'") - .isEqualTo(AzureCdnSku.PREMIUM_EDGIO); + .as("fromString should return PREMIUM_EDGIO for 'Premium_Verizon'") + .isEqualTo(AzureCdnSku.PREMIUM_EDGIO); assertThat(AzureCdnSku.fromString("Standard_Microsoft")) - .as("fromString should return STANDARD_MICROSOFT for 'Standard_Microsoft'") - .isEqualTo(AzureCdnSku.STANDARD_MICROSOFT); + .as("fromString should return STANDARD_MICROSOFT for 'Standard_Microsoft'") + .isEqualTo(AzureCdnSku.STANDARD_MICROSOFT); assertThat(AzureCdnSku.fromString("Standard_AzureFrontDoor")) - .as("fromString should return STANDARD_AZURE_FRONT_DOOR for 'Standard_AzureFrontDoor'") - .isEqualTo(AzureCdnSku.STANDARD_AZURE_FRONT_DOOR); - + .as("fromString should return STANDARD_AZURE_FRONT_DOOR for 'Standard_AzureFrontDoor'") + .isEqualTo(AzureCdnSku.STANDARD_AZURE_FRONT_DOOR); + assertThat(AzureCdnSku.fromString("Premium_AzureFrontDoor")) - .as("fromString should return PREMIUM_AZURE_FRONT_DOOR for 'Premium_AzureFrontDoor'") - .isEqualTo(AzureCdnSku.PREMIUM_AZURE_FRONT_DOOR); + .as("fromString should return PREMIUM_AZURE_FRONT_DOOR for 'Premium_AzureFrontDoor'") + .isEqualTo(AzureCdnSku.PREMIUM_AZURE_FRONT_DOOR); } @Test @@ -63,11 +63,11 @@ public void valuesMethod_shouldContainAllAzureCdnSkusWithCorrectSize() { Collection values = AzureCdnSku.values(); assertThat(values) - .as("Values should contain all specified AzureCdnSku's") - .containsExactlyInAnyOrder(AzureCdnSku.STANDARD_EDGIO, - AzureCdnSku.PREMIUM_EDGIO, - AzureCdnSku.STANDARD_MICROSOFT, - AzureCdnSku.STANDARD_AZURE_FRONT_DOOR, - AzureCdnSku.PREMIUM_AZURE_FRONT_DOOR); + .as("Values should contain all specified AzureCdnSku's") + .containsExactlyInAnyOrder(AzureCdnSku.STANDARD_EDGIO, + AzureCdnSku.PREMIUM_EDGIO, + AzureCdnSku.STANDARD_MICROSOFT, + AzureCdnSku.STANDARD_AZURE_FRONT_DOOR, + AzureCdnSku.PREMIUM_AZURE_FRONT_DOOR); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelayTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelayTest.java index 75c6d611..1028d529 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelayTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureRelayTest.java @@ -12,26 +12,28 @@ public class AzureRelayTest { @Test public void exceptionThrown_when_idIsLessThan6Characters() { assertThatThrownBy(() -> AzureRelay.builder().withId("comp-id").withName("test").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("valid Relay name must be between 6 and 50 characters of length"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("valid Relay name must be between 6 and 50 characters of length"); } @Test public void exceptionThrown_when_idIsMoreThan50Characters() { - assertThatThrownBy(() -> AzureRelay.builder().withId("comp-id").withName("ttttttttttttttttttttttttttttttttttttttttttttttttttt").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("valid Relay name must be between 6 and 50 characters of length"); + assertThatThrownBy(() -> AzureRelay.builder().withId("comp-id").withName( + "ttttttttttttttttttttttttttttttttttttttttttttttttttt").build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("valid Relay name must be between 6 and 50 characters of length"); } @Test public void noValidationErrors_when_relayHasRequiredFields() { - AzureResourceGroup azureResourceGroup = AzureResourceGroup.builder().withName("az-group").withRegion(WEST_EUROPE).build(); + AzureResourceGroup azureResourceGroup = + AzureResourceGroup.builder().withName("az-group").withRegion(WEST_EUROPE).build(); var relay = AzureRelay.builder() - .withId("relay-test-x") - .withName("relay-test-x") - .withRegion(AzureRegion.WEST_EUROPE) - .withAzureResourceGroup(azureResourceGroup) - .build(); + .withId("relay-test-x") + .withName("relay-test-x") + .withRegion(AzureRegion.WEST_EUROPE) + .withAzureResourceGroup(azureResourceGroup) + .build(); assertThat(relay.validate()).isEmpty(); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTest.java index 6b89829e..560e5d70 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/servicebus/AzureServiceBusTest.java @@ -23,87 +23,88 @@ public class AzureServiceBusTest { @Test public void exceptionThrown_when_idIsLessThan6Characters() { assertThatThrownBy(() -> AzureServiceBus.builder().withId("comp-id").withName("test").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("valid Service Bus name must be between 6 and 50 characters of length"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("valid Service Bus name must be between 6 and 50 characters of length"); } @Test public void exceptionThrown_when_idIsMoreThan50Characters() { - assertThatThrownBy(() -> AzureServiceBus.builder().withId("comp-id").withName("ttttttttttttttttttttttttttttttttttttttttttttttttttt").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("valid Service Bus name must be between 6 and 50 characters of length"); + assertThatThrownBy(() -> AzureServiceBus.builder().withId("comp-id").withName( + "ttttttttttttttttttttttttttttttttttttttttttttttttttt").build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("valid Service Bus name must be between 6 and 50 characters of length"); } @Test public void noValidationErrors_when_serviceBusHasRequiredFields() { var azureResourceGroup = AzureResourceGroup.builder().withName("az-group").withRegion(WEST_EUROPE).build(); - + var idOrName = "sb-test-x"; - + var tags = Map.of("tagKey1", "tagValue1"); - + var sku = ServiceBusSku.builder() - .withTier(ServiceBusSkuTier.BASIC) - .build(); - + .withTier(ServiceBusSkuTier.BASIC) + .build(); + var encryption = Encryption.builder() - .withKeySource(KeySource.MICROSOFT_KEYVAULT) - .build(); - + .withKeySource(KeySource.MICROSOFT_KEYVAULT) + .build(); + var queue = AzureServiceBusQueue.builder() - .withId("queue-id") - .withDisplayName("queue1") - .build(); - + .withId("queue-id") + .withDisplayName("queue1") + .build(); + var topic = AzureServiceBusTopic.builder() - .withId("topic-id") - .withDisplayName("topic1") - .build(); - + .withId("topic-id") + .withDisplayName("topic1") + .build(); + var serviceBus = AzureServiceBus.builder() - .withId(idOrName) - .withName(idOrName) - .withRegion(AzureRegion.WEST_EUROPE) - .withAzureResourceGroup(azureResourceGroup) - .withTags(tags) - .withSku(sku) - .withIdentity(AzureIdentityType.USER_ASSIGNED) - .withEncryption(encryption) - .withDisableLocalAuth(Boolean.FALSE) - .withZoneRedundant(Boolean.FALSE) - .withQueue(queue) - .withTopic(topic) - .build(); - + .withId(idOrName) + .withName(idOrName) + .withRegion(AzureRegion.WEST_EUROPE) + .withAzureResourceGroup(azureResourceGroup) + .withTags(tags) + .withSku(sku) + .withIdentity(AzureIdentityType.USER_ASSIGNED) + .withEncryption(encryption) + .withDisableLocalAuth(Boolean.FALSE) + .withZoneRedundant(Boolean.FALSE) + .withQueue(queue) + .withTopic(topic) + .build(); + assertThat(serviceBus.validate()).isEmpty(); - + assertThat(serviceBus) - .asInstanceOf(InstanceOfAssertFactories.type(AzureServiceBus.class)) - .extracting( - AzureServiceBus::getId, - AzureServiceBus::getName, - AzureServiceBus::getAzureRegion, - AzureServiceBus::getAzureResourceGroup, - AzureServiceBus::getTags, - AzureServiceBus::getSku, - AzureServiceBus::getIdentity, - AzureServiceBus::getEncryption, - AzureServiceBus::getDisableLocalAuth, - AzureServiceBus::getZoneRedundant, - AzureServiceBus::getQueues, - AzureServiceBus::getTopics) - - .containsExactly(ComponentId.from(idOrName), - idOrName, - AzureRegion.WEST_EUROPE, - azureResourceGroup, - tags, - sku, - AzureIdentityType.USER_ASSIGNED, - encryption, - Boolean.FALSE, - Boolean.FALSE, - List.of(queue), - List.of(topic)); + .asInstanceOf(InstanceOfAssertFactories.type(AzureServiceBus.class)) + .extracting( + AzureServiceBus::getId, + AzureServiceBus::getName, + AzureServiceBus::getAzureRegion, + AzureServiceBus::getAzureResourceGroup, + AzureServiceBus::getTags, + AzureServiceBus::getSku, + AzureServiceBus::getIdentity, + AzureServiceBus::getEncryption, + AzureServiceBus::getDisableLocalAuth, + AzureServiceBus::getZoneRedundant, + AzureServiceBus::getQueues, + AzureServiceBus::getTopics) + + .containsExactly(ComponentId.from(idOrName), + idOrName, + AzureRegion.WEST_EUROPE, + azureResourceGroup, + tags, + sku, + AzureIdentityType.USER_ASSIGNED, + encryption, + Boolean.FALSE, + Boolean.FALSE, + List.of(queue), + List.of(topic)); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccountTest.java index 77c4e74a..f5c05659 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlobStorageAccountTest.java @@ -15,15 +15,15 @@ public class AzureBlobStorageAccountTest extends TestWithFixture { @Test public void kindIsValid_when_ValidationPasses() throws JsonProcessingException { var storage = AzureBlobStorageAccount.builder() - .withId(aComponentId()) - .withName(aLowerCaseAlphanumericString(10)) - .withDisplayName(aAlphanumericString(50)) - .withRegion(a(AzureRegion.class)) - .withResourceGroup(a(AzureResourceGroup.class)) - .withTag(a(String.class), a(String.class)) - .withContainer(a(AzureBlobContainer.class)) - .build(); - + .withId(aComponentId()) + .withName(aLowerCaseAlphanumericString(10)) + .withDisplayName(aAlphanumericString(50)) + .withRegion(a(AzureRegion.class)) + .withResourceGroup(a(AzureResourceGroup.class)) + .withTag(a(String.class), a(String.class)) + .withContainer(a(AzureBlobContainer.class)) + .build(); + assertTrue(storage.validate().isEmpty()); var json = TestUtils.getJsonRepresentation(storage); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccountTest.java index 56cfb9cd..0703fa4d 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBlockBlobStorageAccountTest.java @@ -10,18 +10,18 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AzureBlockBlobStorageAccountTest extends TestWithFixture { +public class AzureBlockBlobStorageAccountTest extends TestWithFixture { @Test public void kindIsValid_when_ValidationPasses() throws JsonProcessingException { var storage = AzureBlockBlobStorageAccount.builder() - .withId(aComponentId()) - .withName(aLowerCaseAlphanumericString(10)) - .withDisplayName(aAlphanumericString(50)) - .withRegion(a(AzureRegion.class)) - .withResourceGroup(a(AzureResourceGroup.class)) - .withTag(a(String.class), a(String.class)) - .build(); - + .withId(aComponentId()) + .withName(aLowerCaseAlphanumericString(10)) + .withDisplayName(aAlphanumericString(50)) + .withRegion(a(AzureRegion.class)) + .withResourceGroup(a(AzureResourceGroup.class)) + .withTag(a(String.class), a(String.class)) + .build(); + assertThat(storage.validate().isEmpty()).isTrue(); var json = TestUtils.getJsonRepresentation(storage); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypassTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypassTest.java index f7c30009..46ddc57d 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypassTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureBypassTest.java @@ -10,39 +10,39 @@ public class AzureBypassTest { @Test public void azureBypassConstants_shouldNotBeNull() { assertThat(AzureBypass.NONE) - .as("NONE constant should not be null") - .isNotNull(); + .as("NONE constant should not be null") + .isNotNull(); assertThat(AzureBypass.LOGGING) - .as("LOGGING constant should not be null") - .isNotNull(); + .as("LOGGING constant should not be null") + .isNotNull(); assertThat(AzureBypass.METRICS) - .as("METRICS constant should not be null") - .isNotNull(); + .as("METRICS constant should not be null") + .isNotNull(); assertThat(AzureBypass.AZURE_SERVICES) - .as("AZURE_SERVICES constant should not be null") - .isNotNull(); + .as("AZURE_SERVICES constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureBypass() { assertThat(AzureBypass.fromString("None")) - .as("fromString should return NONE for 'None'") - .isEqualTo(AzureBypass.NONE); + .as("fromString should return NONE for 'None'") + .isEqualTo(AzureBypass.NONE); assertThat(AzureBypass.fromString("Logging")) - .as("fromString should return LOGGING for 'Logging'") - .isEqualTo(AzureBypass.LOGGING); + .as("fromString should return LOGGING for 'Logging'") + .isEqualTo(AzureBypass.LOGGING); assertThat(AzureBypass.fromString("Metrics")) - .as("fromString should return METRICS for 'Metrics'") - .isEqualTo(AzureBypass.METRICS); + .as("fromString should return METRICS for 'Metrics'") + .isEqualTo(AzureBypass.METRICS); assertThat(AzureBypass.fromString("AzureServices")) - .as("fromString should return AZURE_SERVICES for 'AzureServices'") - .isEqualTo(AzureBypass.AZURE_SERVICES); + .as("fromString should return AZURE_SERVICES for 'AzureServices'") + .isEqualTo(AzureBypass.AZURE_SERVICES); } @Test @@ -50,10 +50,10 @@ public void valuesMethod_shouldContainAllAzureBypassesWithCorrectSize() { Collection values = AzureBypass.values(); assertThat(values) - .as("Values should contain NONE, LOGGING, METRICS, and AZURE_SERVICES and have exactly 4 values") - .containsExactlyInAnyOrder(AzureBypass.NONE, - AzureBypass.LOGGING, - AzureBypass.METRICS, - AzureBypass.AZURE_SERVICES); + .as("Values should contain NONE, LOGGING, METRICS, and AZURE_SERVICES and have exactly 4 values") + .containsExactlyInAnyOrder(AzureBypass.NONE, + AzureBypass.LOGGING, + AzureBypass.METRICS, + AzureBypass.AZURE_SERVICES); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationActionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationActionTest.java index 0c73e746..15d93ebd 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationActionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureExpirationActionTest.java @@ -10,15 +10,15 @@ public class AzureExpirationActionTest { @Test public void azureExpirationActionConstants_shouldNotBeNull() { assertThat(AzureExpirationAction.LOG) - .as("LOG constant should not be null") - .isNotNull(); + .as("LOG constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureExpirationAction() { assertThat(AzureExpirationAction.fromString("Log")) - .as("fromString should return LOG for 'Log'") - .isEqualTo(AzureExpirationAction.LOG); + .as("fromString should return LOG for 'Log'") + .isEqualTo(AzureExpirationAction.LOG); } @Test @@ -26,7 +26,7 @@ public void valuesMethod_shouldContainAllAzureExpirationActionsWithCorrectSize() Collection values = AzureExpirationAction.values(); assertThat(values) - .as("Values should contain LOG and have exactly 1 value") - .containsExactlyInAnyOrder(AzureExpirationAction.LOG); + .as("Values should contain LOG and have exactly 1 value") + .containsExactlyInAnyOrder(AzureExpirationAction.LOG); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicyTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicyTest.java index 8bb4b9e5..44f8e361 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicyTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessPolicyTest.java @@ -15,10 +15,10 @@ public void validPolicyCreated_when_BuilderUsedWithValidValues() { String permission = "rwx"; AzureFileShareAccessPolicy policy = AzureFileShareAccessPolicy.builder() - .withStartTime(startTime) - .withExpiryTime(expiryTime) - .withPermission(permission) - .build(); + .withStartTime(startTime) + .withExpiryTime(expiryTime) + .withPermission(permission) + .build(); assertEquals(startTime, policy.getStartTime()); assertEquals(expiryTime, policy.getExpiryTime()); @@ -28,10 +28,10 @@ public void validPolicyCreated_when_BuilderUsedWithValidValues() { @Test public void exceptionThrown_when_ExpiryTimeIsNull() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShareAccessPolicy.builder() - .withPermission("rwx") - .withStartTime(OffsetDateTime.now()) - .build() + AzureFileShareAccessPolicy.builder() + .withPermission("rwx") + .withStartTime(OffsetDateTime.now()) + .build() ); assertTrue(exception.getMessage().contains("Expiry time cannot be null")); @@ -42,11 +42,11 @@ public void exceptionThrown_when_ExpiryTimeBeforeStartTime() { OffsetDateTime time = OffsetDateTime.now(); Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShareAccessPolicy.builder() - .withStartTime(time) - .withExpiryTime(time.minusHours(1)) - .withPermission("rwx") - .build() + AzureFileShareAccessPolicy.builder() + .withStartTime(time) + .withExpiryTime(time.minusHours(1)) + .withPermission("rwx") + .build() ); assertTrue(exception.getMessage().contains("Expiry time must be after start time")); @@ -55,10 +55,10 @@ public void exceptionThrown_when_ExpiryTimeBeforeStartTime() { @Test public void exceptionThrown_when_PermissionIsNull() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShareAccessPolicy.builder() - .withStartTime(OffsetDateTime.now()) - .withExpiryTime(OffsetDateTime.now().plusHours(1)) - .build() + AzureFileShareAccessPolicy.builder() + .withStartTime(OffsetDateTime.now()) + .withExpiryTime(OffsetDateTime.now().plusHours(1)) + .build() ); assertTrue(exception.getMessage().contains("Permission cannot be null or empty")); @@ -67,10 +67,10 @@ public void exceptionThrown_when_PermissionIsNull() { @Test public void exceptionThrown_when_StartTimeIsNull() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShareAccessPolicy.builder() - .withExpiryTime(OffsetDateTime.now().plusHours(1)) - .withPermission("rwx") - .build() + AzureFileShareAccessPolicy.builder() + .withExpiryTime(OffsetDateTime.now().plusHours(1)) + .withPermission("rwx") + .build() ); assertTrue(exception.getMessage().contains("Start time cannot be null")); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTierTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTierTest.java index 36a0fb3d..5fe2dc7b 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTierTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareAccessTierTest.java @@ -18,20 +18,20 @@ public void azureFileShareAccessTierConstants_shouldNotBeNull() { @Test public void fromString_shouldReturnCorrespondingAzureFileShareAccessTier() { assertThat(AzureFileShareAccessTier.fromString("Cool")) - .as("fromString should return COOL for 'Cool'") - .isEqualTo(AzureFileShareAccessTier.COOL); - + .as("fromString should return COOL for 'Cool'") + .isEqualTo(AzureFileShareAccessTier.COOL); + assertThat(AzureFileShareAccessTier.fromString("Hot")) - .as("fromString should return HOT for 'Hot'") - .isEqualTo(AzureFileShareAccessTier.HOT); - + .as("fromString should return HOT for 'Hot'") + .isEqualTo(AzureFileShareAccessTier.HOT); + assertThat(AzureFileShareAccessTier.fromString("Premium")) - .as("fromString should return PREMIUM for 'Premium'") - .isEqualTo(AzureFileShareAccessTier.PREMIUM); - + .as("fromString should return PREMIUM for 'Premium'") + .isEqualTo(AzureFileShareAccessTier.PREMIUM); + assertThat(AzureFileShareAccessTier.fromString("TransactionOptimized")) - .as("fromString should return TRANSACTION_OPTIMIZED for 'TransactionOptimized'") - .isEqualTo(AzureFileShareAccessTier.TRANSACTION_OPTIMIZED); + .as("fromString should return TRANSACTION_OPTIMIZED for 'TransactionOptimized'") + .isEqualTo(AzureFileShareAccessTier.TRANSACTION_OPTIMIZED); } @Test @@ -39,10 +39,10 @@ public void valuesMethod_shouldContainAllAzureFileShareAccessTiersWithCorrectSiz Collection values = AzureFileShareAccessTier.values(); assertThat(values) - .as("Values should contain COOL, HOT, PREMIUM, and TRANSACTION_OPTIMIZED and have exactly 4 values") - .containsExactlyInAnyOrder(AzureFileShareAccessTier.COOL, - AzureFileShareAccessTier.HOT, - AzureFileShareAccessTier.PREMIUM, - AzureFileShareAccessTier.TRANSACTION_OPTIMIZED); + .as("Values should contain COOL, HOT, PREMIUM, and TRANSACTION_OPTIMIZED and have exactly 4 values") + .containsExactlyInAnyOrder(AzureFileShareAccessTier.COOL, + AzureFileShareAccessTier.HOT, + AzureFileShareAccessTier.PREMIUM, + AzureFileShareAccessTier.TRANSACTION_OPTIMIZED); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocolsTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocolsTest.java index f0389b78..e8af0413 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocolsTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareEnabledProtocolsTest.java @@ -10,23 +10,23 @@ public class AzureFileShareEnabledProtocolsTest { @Test public void azureFileShareEnabledProtocolsConstants_shouldNotBeNull() { assertThat(AzureFileShareEnabledProtocols.NFS) - .as("NFS constant should not be null") - .isNotNull(); + .as("NFS constant should not be null") + .isNotNull(); assertThat(AzureFileShareEnabledProtocols.SMB) - .as("SMB constant should not be null") - .isNotNull(); + .as("SMB constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureFileShareEnabledProtocols() { assertThat(AzureFileShareEnabledProtocols.fromString("NFS")) - .as("fromString should return NFS for 'NFS'") - .isEqualTo(AzureFileShareEnabledProtocols.NFS); - + .as("fromString should return NFS for 'NFS'") + .isEqualTo(AzureFileShareEnabledProtocols.NFS); + assertThat(AzureFileShareEnabledProtocols.fromString("SMB")) - .as("fromString should return SMB for 'SMB'") - .isEqualTo(AzureFileShareEnabledProtocols.SMB); + .as("fromString should return SMB for 'SMB'") + .isEqualTo(AzureFileShareEnabledProtocols.SMB); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAllAzureFileShareEnabledProtocolsWithCorre Collection values = AzureFileShareEnabledProtocols.values(); assertThat(values) - .as("Values should contain NFS, and SMB and have exactly 2 values") - .containsExactlyInAnyOrder(AzureFileShareEnabledProtocols.NFS, - AzureFileShareEnabledProtocols.SMB); + .as("Values should contain NFS, and SMB and have exactly 2 values") + .containsExactlyInAnyOrder(AzureFileShareEnabledProtocols.NFS, + AzureFileShareEnabledProtocols.SMB); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareRootSquashTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareRootSquashTypeTest.java index 2d778f28..b46e70e9 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareRootSquashTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareRootSquashTypeTest.java @@ -11,31 +11,31 @@ public class AzureFileShareRootSquashTypeTest { @Test public void azureFileShareRootSquashTypeConstants_shouldNotBeNull() { assertThat(AzureFileShareRootSquashType.ALL_SQUASH) - .as("ALL_SQUASH constant should not be null") - .isNotNull(); + .as("ALL_SQUASH constant should not be null") + .isNotNull(); assertThat(AzureFileShareRootSquashType.NO_ROOT_SQUASH) - .as("NO_ROOT_SQUASH constant should not be null") - .isNotNull(); + .as("NO_ROOT_SQUASH constant should not be null") + .isNotNull(); assertThat(AzureFileShareRootSquashType.ROOT_SQUASH) - .as("ROOT_SQUASH constant should not be null") - .isNotNull(); + .as("ROOT_SQUASH constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureFileShareRootSquashType() { assertThat(AzureFileShareRootSquashType.fromString("AllSquash")) - .as("fromString should return ALL_SQUASH for 'AllSquash'") - .isEqualTo(AzureFileShareRootSquashType.ALL_SQUASH); + .as("fromString should return ALL_SQUASH for 'AllSquash'") + .isEqualTo(AzureFileShareRootSquashType.ALL_SQUASH); assertThat(AzureFileShareRootSquashType.fromString("NoRootSquash")) - .as("fromString should return NO_ROOT_SQUASH for 'NoRootSquash'") - .isEqualTo(AzureFileShareRootSquashType.NO_ROOT_SQUASH); + .as("fromString should return NO_ROOT_SQUASH for 'NoRootSquash'") + .isEqualTo(AzureFileShareRootSquashType.NO_ROOT_SQUASH); assertThat(AzureFileShareRootSquashType.fromString("RootSquash")) - .as("fromString should return ROOT_SQUASH for 'RootSquash'") - .isEqualTo(AzureFileShareRootSquashType.ROOT_SQUASH); + .as("fromString should return ROOT_SQUASH for 'RootSquash'") + .isEqualTo(AzureFileShareRootSquashType.ROOT_SQUASH); } @Test @@ -43,9 +43,9 @@ public void valuesMethod_shouldContainAllAzureFileShareRootSquashTypesWithCorrec Collection values = AzureFileShareRootSquashType.values(); assertThat(values) - .as("Values should contain ALL_SQUASH, NO_ROOT_SQUASH, and ROOT_SQUASH and have exactly 3 values") - .containsExactlyInAnyOrder(AzureFileShareRootSquashType.ALL_SQUASH, - AzureFileShareRootSquashType.NO_ROOT_SQUASH, - AzureFileShareRootSquashType.ROOT_SQUASH); + .as("Values should contain ALL_SQUASH, NO_ROOT_SQUASH, and ROOT_SQUASH and have exactly 3 values") + .containsExactlyInAnyOrder(AzureFileShareRootSquashType.ALL_SQUASH, + AzureFileShareRootSquashType.NO_ROOT_SQUASH, + AzureFileShareRootSquashType.ROOT_SQUASH); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifierTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifierTest.java index 33a80e5a..020f500d 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifierTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareSignedIdentifierTest.java @@ -7,7 +7,7 @@ import static org.junit.jupiter.api.Assertions.*; public class AzureFileShareSignedIdentifierTest { - + @Test public void validSignedIdentifierCreated_when_BuilderUsedWithValidValues() { String testId = "testId"; @@ -16,15 +16,15 @@ public void validSignedIdentifierCreated_when_BuilderUsedWithValidValues() { String permission = "rwx"; AzureFileShareAccessPolicy testPolicy = AzureFileShareAccessPolicy.builder() - .withStartTime(startTime) - .withExpiryTime(expiryTime) - .withPermission(permission) - .build(); + .withStartTime(startTime) + .withExpiryTime(expiryTime) + .withPermission(permission) + .build(); AzureFileShareSignedIdentifier signedIdentifier = AzureFileShareSignedIdentifier.builder() - .withId(testId) - .withAccessPolicy(testPolicy) - .build(); + .withId(testId) + .withAccessPolicy(testPolicy) + .build(); assertEquals(testId, signedIdentifier.getId()); assertEquals(testPolicy, signedIdentifier.getAccessPolicy()); @@ -37,15 +37,15 @@ public void exceptionThrown_when_IdIsNull() { String permission = "rwx"; AzureFileShareAccessPolicy testPolicy = AzureFileShareAccessPolicy.builder() - .withStartTime(startTime) - .withExpiryTime(expiryTime) - .withPermission(permission) - .build(); - + .withStartTime(startTime) + .withExpiryTime(expiryTime) + .withPermission(permission) + .build(); + Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShareSignedIdentifier.builder() - .withAccessPolicy(testPolicy) - .build() + AzureFileShareSignedIdentifier.builder() + .withAccessPolicy(testPolicy) + .build() ); assertTrue(exception.getMessage().contains("ID cannot be null or empty.")); @@ -54,9 +54,9 @@ public void exceptionThrown_when_IdIsNull() { @Test public void exceptionThrown_when_AccessPolicyIsNull() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShareSignedIdentifier.builder() - .withId("validId") - .build() + AzureFileShareSignedIdentifier.builder() + .withId("validId") + .build() ); assertTrue(exception.getMessage().contains("Access policy cannot be null.")); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareTest.java index f183fb38..f649e467 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileShareTest.java @@ -15,21 +15,21 @@ public class AzureFileShareTest { private final AzureFileShareEnabledProtocols validEnabledProtocols = AzureFileShareEnabledProtocols.SMB; private final AzureFileShareRootSquashType validRootSquash = AzureFileShareRootSquashType.NO_ROOT_SQUASH; private final AzureFileShareSignedIdentifier validSignedIdentifier = AzureFileShareSignedIdentifier.builder() - .withId("validId") - .withAccessPolicy(AzureFileShareAccessPolicy.builder() - .withStartTime(OffsetDateTime.now()) - .withExpiryTime(OffsetDateTime.now().plusHours(1)) - .withPermission("rwx") - .build()) - .build(); + .withId("validId") + .withAccessPolicy(AzureFileShareAccessPolicy.builder() + .withStartTime(OffsetDateTime.now()) + .withExpiryTime(OffsetDateTime.now().plusHours(1)) + .withPermission("rwx") + .build()) + .build(); @Test public void exceptionThrown_when_NameIsInvalid() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShare.builder() - .withName("invalid_name!") - .build() + AzureFileShare.builder() + .withName("invalid_name!") + .build() ); assertTrue(exception.getMessage().contains("Name must use numbers, lower-case letters, and dash (-) only")); @@ -38,12 +38,12 @@ public void exceptionThrown_when_NameIsInvalid() { @Test public void exceptionThrown_when_MetadataIsInvalid() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShare.builder() - .withName("validname") - .withAccessTier(AzureFileShareAccessTier.HOT) - .withEnabledProtocols(AzureFileShareEnabledProtocols.SMB) - .withMetadata(Map.of("", "value")) - .build() + AzureFileShare.builder() + .withName("validname") + .withAccessTier(AzureFileShareAccessTier.HOT) + .withEnabledProtocols(AzureFileShareEnabledProtocols.SMB) + .withMetadata(Map.of("", "value")) + .build() ); assertTrue(exception.getMessage().contains("Metadata key cannot be null or empty")); @@ -52,12 +52,12 @@ public void exceptionThrown_when_MetadataIsInvalid() { @Test public void exceptionThrown_when_ShareQuotaIsInvalid() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShare.builder() - .withName("validname") - .withAccessTier(AzureFileShareAccessTier.HOT) - .withEnabledProtocols(AzureFileShareEnabledProtocols.SMB) - .withShareQuota(-1) - .build() + AzureFileShare.builder() + .withName("validname") + .withAccessTier(AzureFileShareAccessTier.HOT) + .withEnabledProtocols(AzureFileShareEnabledProtocols.SMB) + .withShareQuota(-1) + .build() ); assertTrue(exception.getMessage().contains("Share quota must be greater than 0")); @@ -66,14 +66,14 @@ public void exceptionThrown_when_ShareQuotaIsInvalid() { @Test public void exceptionThrown_when_RootSquashIsNullForNFS() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShare.builder() - .withName("validname") - .withAccessTier(validAccessTier) - .withEnabledProtocols(AzureFileShareEnabledProtocols.NFS) - .withRootSquash(null) - .withShareQuota(1000) - .withSignedIdentifiers(Collections.singletonList(validSignedIdentifier)) - .build() + AzureFileShare.builder() + .withName("validname") + .withAccessTier(validAccessTier) + .withEnabledProtocols(AzureFileShareEnabledProtocols.NFS) + .withRootSquash(null) + .withShareQuota(1000) + .withSignedIdentifiers(Collections.singletonList(validSignedIdentifier)) + .build() ); assertTrue(exception.getMessage().contains("Root squash type must be specified for NFS shares")); @@ -82,17 +82,17 @@ public void exceptionThrown_when_RootSquashIsNullForNFS() { @Test public void exceptionThrown_when_SignedIdentifiersAreInvalid() { Exception exception = assertThrows(IllegalArgumentException.class, () -> - AzureFileShare.builder() - .withName("validname") - .withAccessTier(validAccessTier) - .withEnabledProtocols(validEnabledProtocols) - .withRootSquash(validRootSquash) - .withShareQuota(1000) - .withSignedIdentifiers(Arrays.asList(validSignedIdentifier, - AzureFileShareSignedIdentifier.builder() - .withId(null) - .build())) - .build() + AzureFileShare.builder() + .withName("validname") + .withAccessTier(validAccessTier) + .withEnabledProtocols(validEnabledProtocols) + .withRootSquash(validRootSquash) + .withShareQuota(1000) + .withSignedIdentifiers(Arrays.asList(validSignedIdentifier, + AzureFileShareSignedIdentifier.builder() + .withId(null) + .build())) + .build() ); assertTrue(exception.getMessage().contains("AzureFileShareSignedIdentifier validation failed")); @@ -102,14 +102,14 @@ public void exceptionThrown_when_SignedIdentifiersAreInvalid() { public void validAzureFileShareCreated_when_ValidDataProvided() { // Test creating a valid AzureFileShare var fileShare = AzureFileShare.builder() - .withName("validname") - .withAccessTier(validAccessTier) - .withEnabledProtocols(validEnabledProtocols) - .withRootSquash(validRootSquash) - .withShareQuota(1000) - .withSignedIdentifier(validSignedIdentifier) - .build(); - + .withName("validname") + .withAccessTier(validAccessTier) + .withEnabledProtocols(validEnabledProtocols) + .withRootSquash(validRootSquash) + .withShareQuota(1000) + .withSignedIdentifier(validSignedIdentifier) + .build(); + assertEquals(fileShare.getName(), "validname"); assertEquals(fileShare.getAccessTier(), validAccessTier); assertEquals(fileShare.getEnabledProtocols(), validEnabledProtocols); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccountTest.java index e82f1661..ae9c3e6f 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureFileStorageAccountTest.java @@ -15,13 +15,13 @@ public class AzureFileStorageAccountTest extends TestWithFixture { @Test public void kindIsValid_when_ValidationPasses() throws JsonProcessingException { var storage = AzureFileStorageAccount.builder() - .withId(aComponentId()) - .withName(aLowerCaseAlphanumericString(10)) - .withDisplayName(aAlphanumericString(50)) - .withRegion(a(AzureRegion.class)) - .withResourceGroup(a(AzureResourceGroup.class)) - .withTag(a(String.class), a(String.class)) - .build(); + .withId(aComponentId()) + .withName(aLowerCaseAlphanumericString(10)) + .withDisplayName(aAlphanumericString(50)) + .withRegion(a(AzureRegion.class)) + .withResourceGroup(a(AzureResourceGroup.class)) + .withTag(a(String.class), a(String.class)) + .build(); assertTrue(storage.validate().isEmpty()); var json = TestUtils.getJsonRepresentation(storage); @@ -42,43 +42,43 @@ public void fileShareIsValid_when_ValidationPasses() throws JsonProcessingExcept var storageName = aLowerCaseAlphanumericString(10); var storageDisplayName = aAlphanumericString(50, false, false, " "); var storageRegion = AzureRegion.WEST_EUROPE; - + var storage = AzureFileStorageAccount.builder() - .withId(storageId) - .withName(storageName) - .withDisplayName(storageDisplayName) + .withId(storageId) + .withName(storageName) + .withDisplayName(storageDisplayName) + .withRegion(storageRegion) + .withResourceGroup(AzureResourceGroup.builder() + .withName(aLowerCaseAlphanumericString(10)) .withRegion(storageRegion) - .withResourceGroup(AzureResourceGroup.builder() - .withName(aLowerCaseAlphanumericString(10)) - .withRegion(storageRegion) - .build()) - .withFileShare(AzureFileShare.builder() - .withId(aLowerCaseAlphanumericString(10, true, "-")) - .withName(aLowerCaseAlphanumericString(10, true, "-")) - .withDisplayName(aAlphanumericString(50)) - .withEnabledProtocols(AzureFileShareEnabledProtocols.SMB) - .withShareQuota(100) - .withAccessTier(a(AzureFileShareAccessTier.class)) - .build()) - .withFileShare(AzureFileShare.builder() - .withId(aLowerCaseAlphanumericString(10, true, "-")) - .withName(aLowerCaseAlphanumericString(10, true, "-")) - .withDisplayName(aAlphanumericString(50)) - .withEnabledProtocols(AzureFileShareEnabledProtocols.NFS) - .withRootSquash(a(AzureFileShareRootSquashType.class)) - .withShareQuota(100) - .withAccessTier(a(AzureFileShareAccessTier.class)) - .build()) - .withTag(a(String.class), a(String.class)) - .build(); - + .build()) + .withFileShare(AzureFileShare.builder() + .withId(aLowerCaseAlphanumericString(10, true, "-")) + .withName(aLowerCaseAlphanumericString(10, true, "-")) + .withDisplayName(aAlphanumericString(50)) + .withEnabledProtocols(AzureFileShareEnabledProtocols.SMB) + .withShareQuota(100) + .withAccessTier(a(AzureFileShareAccessTier.class)) + .build()) + .withFileShare(AzureFileShare.builder() + .withId(aLowerCaseAlphanumericString(10, true, "-")) + .withName(aLowerCaseAlphanumericString(10, true, "-")) + .withDisplayName(aAlphanumericString(50)) + .withEnabledProtocols(AzureFileShareEnabledProtocols.NFS) + .withRootSquash(a(AzureFileShareRootSquashType.class)) + .withShareQuota(100) + .withAccessTier(a(AzureFileShareAccessTier.class)) + .build()) + .withTag(a(String.class), a(String.class)) + .build(); + assertThat(storage.validate().isEmpty()).isTrue(); assertThat(storage.getId().getValue()).isEqualTo(storageId); assertThat(storage.getName()).isEqualTo(storageName); assertThat(storage.getDisplayName()).isEqualTo(storageDisplayName); assertThat(storage.getAzureRegion()).isEqualTo(storageRegion); assertThat(storage.getAzureResourceGroup().getRegion()).isEqualTo(storageRegion); - + var json = TestUtils.getJsonRepresentation(storage); assertThat(json).isNotBlank(); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRuleActionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRuleActionTest.java index 0cd4dc50..57eab91f 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRuleActionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureIpRuleActionTest.java @@ -10,15 +10,15 @@ public class AzureIpRuleActionTest { @Test public void azureNetworkActionConstants_shouldNotBeNull() { assertThat(AzureNetworkAction.ALLOW) - .as("ALLOW constant should not be null") - .isNotNull(); + .as("ALLOW constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureNetworkAction() { assertThat(AzureNetworkAction.fromString("Allow")) - .as("fromString should return ALLOW for 'Allow'") - .isEqualTo(AzureNetworkAction.ALLOW); + .as("fromString should return ALLOW for 'Allow'") + .isEqualTo(AzureNetworkAction.ALLOW); } @Test @@ -26,7 +26,7 @@ public void valuesMethod_shouldContainAllAzureNetworkActionsWithCorrectSize() { Collection values = AzureNetworkAction.values(); assertThat(values) - .as("Values should contain ALLOW and have exactly 1 value") - .containsExactlyInAnyOrder(AzureNetworkAction.ALLOW); + .as("Values should contain ALLOW and have exactly 1 value") + .containsExactlyInAnyOrder(AzureNetworkAction.ALLOW); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccountTest.java index 352e7c77..db35728d 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureLegacyStorageAccountTest.java @@ -17,157 +17,157 @@ public class AzureLegacyStorageAccountTest extends TestWithFixture { @Test public void exceptionThrown_when_storageAccountBuiltWithEmptyId() { assertThatThrownBy(() -> generateBuilder().withId("").build()) - .isInstanceOf(IllegalArgumentException.class - ).hasMessageContaining("Component Id is illegal"); + .isInstanceOf(IllegalArgumentException.class + ).hasMessageContaining("Component Id is illegal"); } @Test public void exceptionThrown_when_storageAccountBuiltWithEmptyName() { assertThatThrownBy(() -> generateBuilder() - .withName("") - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); + .withName("") + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithNullName() { assertThatThrownBy(() -> generateBuilder().withName(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithToShortName() { assertThatThrownBy(() -> generateBuilder().withName(aLowerCaseAlphanumericString(2)).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithToLongName() { assertThatThrownBy(() -> generateBuilder().withName(aLowerCaseAlphanumericString(25)).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(BaseAzureStorageAccount.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithNullAzureRegion() { assertThatThrownBy(() -> generateBuilder().withRegion(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AZURE_REGION_IS_BLANK); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AZURE_REGION_IS_BLANK); } @Test public void exceptionThrown_when_storageAccountBuiltWithNullAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder().withResourceGroup(null).build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AZURE_RESOURCE_GROUP_IS_BLANK); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AZURE_RESOURCE_GROUP_IS_BLANK); } @Test public void exceptionThrown_when_storageAccountBuiltWithEmptyNameInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder() - .withResourceGroup(AzureResourceGroup.builder() - .withName("") - .build()) + .withResourceGroup(AzureResourceGroup.builder() + .withName("") .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.NAME_IS_NULL_OR_EMPTY); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.NAME_IS_NULL_OR_EMPTY); } @Test public void exceptionThrown_when_storageAccountBuiltWithNullNameInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder() - .withResourceGroup(AzureResourceGroup.builder() - .withName(null) - .build()) + .withResourceGroup(AzureResourceGroup.builder() + .withName(null) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.NAME_IS_NULL_OR_EMPTY); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.NAME_IS_NULL_OR_EMPTY); } @Test public void exceptionThrown_when_storageAccountBuiltWithNullRegionInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder() - .withResourceGroup(AzureResourceGroup.builder() - .withName(aLowerCaseAlphanumericString(10, true, "-")) - .withRegion(null) - .build()) + .withResourceGroup(AzureResourceGroup.builder() + .withName(aLowerCaseAlphanumericString(10, true, "-")) + .withRegion(null) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.REGION_IS_BLANK); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.REGION_IS_BLANK); } @Test public void exceptionThrown_when_storageAccountBuiltWithInvalidNameWithSpacesInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder().withResourceGroup(AzureResourceGroup.builder() - .withName("invalid name with spaces") - .withRegion(a(AzureRegion.class)) - .build()) + .withName("invalid name with spaces") + .withRegion(a(AzureRegion.class)) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithInvalidNameEndsWithDotInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder() - .withResourceGroup(AzureResourceGroup.builder() - .withName("invalid.name.") - .withRegion(a(AzureRegion.class)) - .build()) + .withResourceGroup(AzureResourceGroup.builder() + .withName("invalid.name.") + .withRegion(a(AzureRegion.class)) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithInvalidCharacterAsPartOfNameInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder() - .withResourceGroup(AzureResourceGroup.builder() - .withName("invalid?name") - .withRegion(a(AzureRegion.class)) - .build()) + .withResourceGroup(AzureResourceGroup.builder() + .withName("invalid?name") + .withRegion(a(AzureRegion.class)) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithInvalidCharactersAsPartOfNameInAzureResourceGroup() { assertThatThrownBy(() -> generateBuilder() - .withResourceGroup(AzureResourceGroup.builder() - .withName("!invalid@name#") - .withRegion(a(AzureRegion.class)) - .build()) + .withResourceGroup(AzureResourceGroup.builder() + .withName("!invalid@name#") + .withRegion(a(AzureRegion.class)) .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(AzureResourceGroup.NAME_IS_NOT_VALID); } @Test public void exceptionThrown_when_storageAccountBuiltWithEmptyKeyAndProperValueInTags() { assertThatThrownBy(() -> generateBuilder() - .withTag("", aLowerCaseAlphanumericString(5)) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(TAG_KEY_IS_BLANK); + .withTag("", aLowerCaseAlphanumericString(5)) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(TAG_KEY_IS_BLANK); } @Test public void exceptionThrown_when_storageAccountBuiltWithEmptyValueInTags() { var tagKey = aLowerCaseAlphanumericString(10); assertThatThrownBy(() -> generateBuilder().withTag(tagKey, "").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Tag value for key '" + tagKey + "' cannot be null or empty"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Tag value for key '" + tagKey + "' cannot be null or empty"); } @Test public void nameIsValid_when_MinimumValidLengthNameSet() { var storage = generateBuilder() - .withName(aLowerCaseAlphanumericString(3)) - .build(); + .withName(aLowerCaseAlphanumericString(3)) + .build(); assertThat(storage.validate().isEmpty()).isTrue(); } @@ -175,8 +175,8 @@ public void nameIsValid_when_MinimumValidLengthNameSet() { @Test public void nameIsValid_when_MaximumValidLengthNameSet() { var storage = generateBuilder() - .withName(aLowerCaseAlphanumericString(24)) - .build(); + .withName(aLowerCaseAlphanumericString(24)) + .build(); assertThat(storage.validate().isEmpty()).isTrue(); } @@ -184,8 +184,8 @@ public void nameIsValid_when_MaximumValidLengthNameSet() { @Test public void tagsAreValid_when_KeyAndValueProvided() { var storage = generateBuilder() - .withTag(aLowerCaseAlphanumericString(10), aLowerCaseAlphanumericString(10)) - .build(); + .withTag(aLowerCaseAlphanumericString(10), aLowerCaseAlphanumericString(10)) + .build(); assertThat(storage.validate().isEmpty()).isTrue(); } @@ -193,8 +193,8 @@ public void tagsAreValid_when_KeyAndValueProvided() { @Test public void kindIsValid_when_ValidationPasses() throws JsonProcessingException { var storage = generateBuilder() - .withTag(aLowerCaseAlphanumericString(10), aLowerCaseAlphanumericString(10)) - .build(); + .withTag(aLowerCaseAlphanumericString(10), aLowerCaseAlphanumericString(10)) + .build(); assertThat(storage.validate().isEmpty()).isTrue(); @@ -213,8 +213,8 @@ public void kindIsValid_when_ValidationPasses() throws JsonProcessingException { @Test public void exceptionThrown_when_storageAccountBuiltWithNullId() { assertThatThrownBy(() -> generateBuilder().withId("").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Component Id is illegal"); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Component Id is illegal"); } @Test @@ -237,49 +237,49 @@ public void backupIsValid_when_backupIsSet() { var vaultResourceGroupName = aLowerCaseAlphanumericString(10); var storageAccountBackup = generateBuilder() - .withBackup(AzureStorageAccountBackup.builder() - .withEtag(etag) - .withPolicy(policy) - .withPolicyLocation(policyLocation) - .withPolicyName(policyName) - .withSku(AzureRecoveryServicesSkuName.STANDARD) - .withPolicyResourceGroupName(policyResourceGroupName) - .withPolicyType(AzureRecoveryServicesBackupPolicyWorkloadType.AzureStorage) - .withVaultLocation(vaultLocation).withVaultName(vaultName) - .withVaultResourceGroupName(vaultResourceGroupName) - .build()) - .build() - .getBackup(); + .withBackup(AzureStorageAccountBackup.builder() + .withEtag(etag) + .withPolicy(policy) + .withPolicyLocation(policyLocation) + .withPolicyName(policyName) + .withSku(AzureRecoveryServicesSkuName.STANDARD) + .withPolicyResourceGroupName(policyResourceGroupName) + .withPolicyType(AzureRecoveryServicesBackupPolicyWorkloadType.AzureStorage) + .withVaultLocation(vaultLocation).withVaultName(vaultName) + .withVaultResourceGroupName(vaultResourceGroupName) + .build()) + .build() + .getBackup(); assertThat(storageAccountBackup.getEtag()) - .isEqualTo(etag); + .isEqualTo(etag); assertThat(storageAccountBackup.getPolicy()) - .isEqualTo(policy); + .isEqualTo(policy); assertThat(storageAccountBackup.getPolicyLocation()) - .isEqualTo(policyLocation); + .isEqualTo(policyLocation); assertThat(storageAccountBackup.getPolicyName()) - .isEqualTo(policyName); + .isEqualTo(policyName); assertThat(storageAccountBackup.getPolicyResourceGroupName()) - .isEqualTo(policyResourceGroupName); + .isEqualTo(policyResourceGroupName); assertThat(storageAccountBackup.getVaultLocation()) - .isEqualTo(vaultLocation); + .isEqualTo(vaultLocation); assertThat(storageAccountBackup.getVaultName()) - .isEqualTo(vaultName); + .isEqualTo(vaultName); assertThat(storageAccountBackup.getVaultResourceGroupName()) - .isEqualTo(vaultResourceGroupName); + .isEqualTo(vaultResourceGroupName); assertThat(storageAccountBackup.getSku()) - .isEqualTo(AzureRecoveryServicesSkuName.STANDARD); + .isEqualTo(AzureRecoveryServicesSkuName.STANDARD); assertThat(storageAccountBackup.getPolicyType()) - .isEqualTo(AzureRecoveryServicesBackupPolicyWorkloadType.AzureStorage); + .isEqualTo(AzureRecoveryServicesBackupPolicyWorkloadType.AzureStorage); } @Test @@ -288,18 +288,18 @@ public void fileServiceIsValid_when_fileServiceIsSet() { var deleteRetentionDays = aPositiveInteger(); var storageAccountFileService = generateBuilder() - .withFileService(AzureStorageAccountFileService.builder() - .withDeleteRetentionEnabled(deleteRetentionEnabled) - .withDeleteRetentionDays(deleteRetentionDays) - .build()) - .build() - .getFileService(); + .withFileService(AzureStorageAccountFileService.builder() + .withDeleteRetentionEnabled(deleteRetentionEnabled) + .withDeleteRetentionDays(deleteRetentionDays) + .build()) + .build() + .getFileService(); assertThat(storageAccountFileService.getDeleteRetentionEnabled()) - .isEqualTo(deleteRetentionEnabled); + .isEqualTo(deleteRetentionEnabled); assertThat(storageAccountFileService.getDeleteRetentionDays()) - .isEqualTo(deleteRetentionDays); + .isEqualTo(deleteRetentionDays); } @Test @@ -375,170 +375,171 @@ public void storageAccountIsValid_when_EverythingIsSet() { var extendedLocation = AzureStorageAccountExtendedLocation.builder() - .withName(extendedLocationName) - .withType(extendedLocationType) - .build(); + .withName(extendedLocationName) + .withType(extendedLocationType) + .build(); var identity = AzureStorageAccountIdentity.builder() - .withIdentityType(identityType) - .withUserAssignedIdentity(userAssignedIdentityKey, AzureUserAssignedIdentity.builder() - .withClientId(userAssignedIdentityClientId) - .withPrincipalId(userAssignedIdentityPrincipalId) - .build()) - .build(); + .withIdentityType(identityType) + .withUserAssignedIdentity(userAssignedIdentityKey, AzureUserAssignedIdentity.builder() + .withClientId(userAssignedIdentityClientId) + .withPrincipalId(userAssignedIdentityPrincipalId) + .build()) + .build(); var activeDirectoryProperties = AzureActiveDirectoryProperties.builder() - .withAccountType(activeDirectoryAccountType) - .withAzureStorageSid(activeDirectoryAzureStorageSid) - .withDomainGuid(activeDirectoryDomainGuid) - .withDomainName(activeDirectoryDomainName) - .withDomainSid(activeDirectoryDomainSid) - .withForestName(activeDirectoryForestName) - .withNetBiosDomainName(activeDirectoryNetBiosDomainName) - .withSamAccountName(activeDirectorySamAccountName) - .build(); + .withAccountType(activeDirectoryAccountType) + .withAzureStorageSid(activeDirectoryAzureStorageSid) + .withDomainGuid(activeDirectoryDomainGuid) + .withDomainName(activeDirectoryDomainName) + .withDomainSid(activeDirectoryDomainSid) + .withForestName(activeDirectoryForestName) + .withNetBiosDomainName(activeDirectoryNetBiosDomainName) + .withSamAccountName(activeDirectorySamAccountName) + .build(); var azureFilesIdentityBasedAuthentication = AzureFilesIdentityBasedAuthentication.builder() - .withActiveDirectoryProperties(activeDirectoryProperties) - .withDefaultSharePermission(activeDirectoryDefaultSharePermission) - .withDirectoryServiceOptions(activeDirectoryDirectoryServiceOptions) - .build(); + .withActiveDirectoryProperties(activeDirectoryProperties) + .withDefaultSharePermission(activeDirectoryDefaultSharePermission) + .withDirectoryServiceOptions(activeDirectoryDirectoryServiceOptions) + .build(); var customDomain = AzureStorageAccountCustomDomain.builder() - .withName(customDomainName) - .withUseSubDomainName(customDomainUseSubDomainName) - .build(); + .withName(customDomainName) + .withUseSubDomainName(customDomainUseSubDomainName) + .build(); var encryptionIdentity = AzureStorageAccountEncryptionIdentity.builder() - .withFederatedIdentityClientId(encryptionIdentityFederatedIdentityClientId) - .withUserAssignedIdentity(encryptionIdentityUserAssignedIdentity) - .build(); + .withFederatedIdentityClientId(encryptionIdentityFederatedIdentityClientId) + .withUserAssignedIdentity(encryptionIdentityUserAssignedIdentity) + .build(); var encryptionKeyVaultProperties = AzureStorageAccountKeyVaultProperties.builder() - .withKeyName(encryptionKeyVaultPropertiesKeyName) - .withKeyVaultUri(encryptionKeyVaultPropertiesKeyVaultUri) - .withKeyVersion(encryptionKeyVaultPropertiesKeyVersion) - .build(); + .withKeyName(encryptionKeyVaultPropertiesKeyName) + .withKeyVaultUri(encryptionKeyVaultPropertiesKeyVaultUri) + .withKeyVersion(encryptionKeyVaultPropertiesKeyVersion) + .build(); var blobEncryptionService = AzureStorageAccountEncryptionService.builder() - .withEnabled(blobEncryptionServiceEnabled) - .withKeyType(blobEncryptionServiceKeyType) - .build(); + .withEnabled(blobEncryptionServiceEnabled) + .withKeyType(blobEncryptionServiceKeyType) + .build(); var fileEncryptionService = AzureStorageAccountEncryptionService.builder() - .withEnabled(fileEncryptionServiceEnabled) - .withKeyType(fileEncryptionServiceKeyType) - .build(); + .withEnabled(fileEncryptionServiceEnabled) + .withKeyType(fileEncryptionServiceKeyType) + .build(); var queueEncryptionService = AzureStorageAccountEncryptionService.builder() - .withEnabled(queueEncryptionServiceEnabled) - .withKeyType(queueEncryptionServiceKeyType) - .build(); + .withEnabled(queueEncryptionServiceEnabled) + .withKeyType(queueEncryptionServiceKeyType) + .build(); var tableEncryptionService = AzureStorageAccountEncryptionService.builder() - .withEnabled(tableEncryptionServiceEnabled) - .withKeyType(tableEncryptionServiceKeyType) - .build(); + .withEnabled(tableEncryptionServiceEnabled) + .withKeyType(tableEncryptionServiceKeyType) + .build(); var encryptionServices = AzureStorageAccountEncryptionServices.builder() - .withBlob(blobEncryptionService) - .withFile(fileEncryptionService) - .withQueue(queueEncryptionService) - .withTable(tableEncryptionService) - .build(); + .withBlob(blobEncryptionService) + .withFile(fileEncryptionService) + .withQueue(queueEncryptionService) + .withTable(tableEncryptionService) + .build(); var encryption = AzureStorageAccountEncryption.builder() - .withIdentity(encryptionIdentity) - .withKeySource(encryptionKeySource) - .withKeyVaultProperties(encryptionKeyVaultProperties) - .withRequireInfrastructureEncryption(encryptionRequireInfrastructureEncryption) - .withServices(encryptionServices) - .build(); + .withIdentity(encryptionIdentity) + .withKeySource(encryptionKeySource) + .withKeyVaultProperties(encryptionKeyVaultProperties) + .withRequireInfrastructureEncryption(encryptionRequireInfrastructureEncryption) + .withServices(encryptionServices) + .build(); var immutabilityPolicy = AzureStorageAccountImmutabilityPolicyProperties.builder() - .withAllowProtectedAppendWrites(immutabilityPolicyAllowProtectedAppendWrites) - .withImmutabilityPeriodSinceCreationInDays(immutabilityPolicyImmutabilityPeriodSinceCreationInDays) - .withState(immutabilityPolicyState) - .build(); + .withAllowProtectedAppendWrites(immutabilityPolicyAllowProtectedAppendWrites) + .withImmutabilityPeriodSinceCreationInDays(immutabilityPolicyImmutabilityPeriodSinceCreationInDays) + .withState(immutabilityPolicyState) + .build(); var immutableStorage = AzureImmutableStorageAccount.builder() - .withEnabled(immutableStorageEnabled) - .withImmutabilityPolicy(immutabilityPolicy) - .build(); + .withEnabled(immutableStorageEnabled) + .withImmutabilityPolicy(immutabilityPolicy) + .build(); var keyPolicy = AzureStorageAccountKeyPolicy.builder() - .withKeyExpirationPeriodInDays(keyPolicyExpirationPeriodInDays) - .build(); + .withKeyExpirationPeriodInDays(keyPolicyExpirationPeriodInDays) + .build(); var networkRuleSetIpRule = AzureIpRule.builder() - .withAction(networkRuleSetIpRuleAction) - .withIpAddressOrRange(networkRuleSetIpRuleIpAddressOrRange) - .build(); + .withAction(networkRuleSetIpRuleAction) + .withIpAddressOrRange(networkRuleSetIpRuleIpAddressOrRange) + .build(); var networkRuleSetResourceAccessRule = AzureResourceAccessRule.builder() - .withResourceId(networkRuleSetResourceAccessRuleResourceId) - .withTenantId(networkRuleSetResourceAccessRuleTenantId) - .build(); + .withResourceId(networkRuleSetResourceAccessRuleResourceId) + .withTenantId(networkRuleSetResourceAccessRuleTenantId) + .build(); var networkRuleSetVirtualNetworkRule = AzureVirtualNetworkRule.builder() - .withAction(networkRuleSetVirtualNetworkRuleAction) - .withVirtualNetworkResourceId(networkRuleSetVirtualNetworkRuleResourceId) - .withState(networkRuleSetVirtualNetworkRuleState) - .build(); + .withAction(networkRuleSetVirtualNetworkRuleAction) + .withVirtualNetworkResourceId(networkRuleSetVirtualNetworkRuleResourceId) + .withState(networkRuleSetVirtualNetworkRuleState) + .build(); var networkRuleSet = AzureNetworkRuleSet.builder() - .withBypass(networkRuleSetBypass) - .withDefaultAction(networkRuleSetDefaultAction) - .withIpRule(networkRuleSetIpRule) - .withResourceAccessRule(networkRuleSetResourceAccessRule) - .withVirtualNetworkRule(networkRuleSetVirtualNetworkRule) - .build(); + .withBypass(networkRuleSetBypass) + .withDefaultAction(networkRuleSetDefaultAction) + .withIpRule(networkRuleSetIpRule) + .withResourceAccessRule(networkRuleSetResourceAccessRule) + .withVirtualNetworkRule(networkRuleSetVirtualNetworkRule) + .build(); var routingPreference = AzureStorageAccountRoutingPreference.builder() - .withPublishInternetEndpoints(routingPreferencePublishInternetEndpoints) - .withPublishMicrosoftEndpoints(routingPreferencePublishMicrosoftEndpoints) - .withRoutingChoice(routingPreferenceRoutingChoice) - .build(); + .withPublishInternetEndpoints(routingPreferencePublishInternetEndpoints) + .withPublishMicrosoftEndpoints(routingPreferencePublishMicrosoftEndpoints) + .withRoutingChoice(routingPreferenceRoutingChoice) + .build(); var sasPolicy = AzureStorageAccountSasPolicy.builder() - .withExpirationAction(sasPolicyExpirationAction) - .withSasExpirationPeriod(sasPolicyExpirationPeriod) - .build(); + .withExpirationAction(sasPolicyExpirationAction) + .withSasExpirationPeriod(sasPolicyExpirationPeriod) + .build(); var storageAccount = generateBuilder() - .withSku(storageAccountSku) - .withExtendedLocation(extendedLocation) - .withIdentity(identity) - .withAccessTier(accessTier) - .withAllowBlobPublicAccess(allowBlobPublicAccess) - .withAllowCrossTenantReplication(allowCrossTenantReplication) - .withAllowSharedKeyAccess(allowSharedKeyAccess) - .withAllowedCopyScope(allowedCopyScope) - .withAzureFilesIdentityBasedAuthentication(azureFilesIdentityBasedAuthentication) - .withCustomDomain(customDomain) - .withDefaultToOAuthAuthentication(defaultToOAuthAuthentication) - .withDnsEndpointType(dnsEndpointType) - .withEncryption(encryption) - .withImmutableStorageWithVersioning(immutableStorage) - .withIsLocalUserEnabled(isLocalUserEnabled) - .withIsNfsV3Enabled(isNfsV3Enabled) - .withIsSftpEnabled(isSftpEnabled) - .withKeyPolicy(keyPolicy) - .withLargeFileSharesState(largeFileSharesState) - .withMinimumTlsVersion(minimumTlsVersion) - .withNetworkRuleSet(networkRuleSet) - .withPublicNetworkAccess(publicNetworkAccess) - .withRoutingPreference(routingPreference) - .withSasPolicy(sasPolicy) - .withSupportsHttpsTrafficOnly(supportsHttpsTrafficOnly) - .build(); + .withSku(storageAccountSku) + .withExtendedLocation(extendedLocation) + .withIdentity(identity) + .withAccessTier(accessTier) + .withAllowBlobPublicAccess(allowBlobPublicAccess) + .withAllowCrossTenantReplication(allowCrossTenantReplication) + .withAllowSharedKeyAccess(allowSharedKeyAccess) + .withAllowedCopyScope(allowedCopyScope) + .withAzureFilesIdentityBasedAuthentication(azureFilesIdentityBasedAuthentication) + .withCustomDomain(customDomain) + .withDefaultToOAuthAuthentication(defaultToOAuthAuthentication) + .withDnsEndpointType(dnsEndpointType) + .withEncryption(encryption) + .withImmutableStorageWithVersioning(immutableStorage) + .withIsLocalUserEnabled(isLocalUserEnabled) + .withIsNfsV3Enabled(isNfsV3Enabled) + .withIsSftpEnabled(isSftpEnabled) + .withKeyPolicy(keyPolicy) + .withLargeFileSharesState(largeFileSharesState) + .withMinimumTlsVersion(minimumTlsVersion) + .withNetworkRuleSet(networkRuleSet) + .withPublicNetworkAccess(publicNetworkAccess) + .withRoutingPreference(routingPreference) + .withSasPolicy(sasPolicy) + .withSupportsHttpsTrafficOnly(supportsHttpsTrafficOnly) + .build(); var storageAccountJson = TestUtils.getJsonRepresentation(storageAccount); assertThat(storageAccountJson).isNotBlank(); var storageAccountExtendedLocation = storageAccount.getExtendedLocation(); var storageAccountIdentity = storageAccount.getIdentity(); - var storageAccountUserAssignedIdentity = storageAccountIdentity.getUserAssignedIdentities().get(userAssignedIdentityKey); + var storageAccountUserAssignedIdentity = + storageAccountIdentity.getUserAssignedIdentities().get(userAssignedIdentityKey); var storageAccountBasedAuthentication = storageAccount.getAzureFilesIdentityBasedAuthentication(); var storageAccountActiveDirectoryProperties = storageAccountBasedAuthentication.getActiveDirectoryProperties(); var storageAccountCustomDomain = storageAccount.getCustomDomain(); @@ -555,277 +556,279 @@ public void storageAccountIsValid_when_EverythingIsSet() { var storageAccountKeyPolicy = storageAccount.getKeyPolicy(); var storageAccountNetworkRuleSet = storageAccount.getNetworkRuleSet(); var storageAccountNetworkRuleSetIpRule = storageAccountNetworkRuleSet.getIpRules().getFirst(); - var storageAccountNetworkRuleSetResourceAccessRule = storageAccountNetworkRuleSet.getResourceAccessRules().getFirst(); - var storageAccountNetworkRuleSetVirtualNetworkRule = storageAccountNetworkRuleSet.getVirtualNetworkRules().getFirst(); + var storageAccountNetworkRuleSetResourceAccessRule = + storageAccountNetworkRuleSet.getResourceAccessRules().getFirst(); + var storageAccountNetworkRuleSetVirtualNetworkRule = + storageAccountNetworkRuleSet.getVirtualNetworkRules().getFirst(); var storageAccountRoutingPreference = storageAccount.getRoutingPreference(); var storageAccountSasPolicy = storageAccount.getSasPolicy(); assertThat(storageAccount.getSku()) - .isEqualTo(storageAccountSku); + .isEqualTo(storageAccountSku); assertThat(storageAccount.getExtendedLocation()) - .isEqualTo(storageAccountExtendedLocation); + .isEqualTo(storageAccountExtendedLocation); assertThat(storageAccountExtendedLocation.getName()) - .isEqualTo(extendedLocationName); + .isEqualTo(extendedLocationName); assertThat(storageAccountExtendedLocation.getType()) - .isEqualTo(extendedLocationType); + .isEqualTo(extendedLocationType); assertThat(storageAccount.getIdentity()) - .isEqualTo(storageAccountIdentity); + .isEqualTo(storageAccountIdentity); assertThat(storageAccountIdentity.getIdentityType()) - .isEqualTo(identityType); + .isEqualTo(identityType); assertThat(storageAccountIdentity.getUserAssignedIdentities()) - .hasSize(1); + .hasSize(1); assertThat(storageAccountIdentity.getUserAssignedIdentities()) - .containsKey(userAssignedIdentityKey); + .containsKey(userAssignedIdentityKey); assertThat(storageAccountUserAssignedIdentity.getClientId()) - .isEqualTo(userAssignedIdentityClientId); + .isEqualTo(userAssignedIdentityClientId); assertThat(storageAccountUserAssignedIdentity.getPrincipalId()) - .isEqualTo(userAssignedIdentityPrincipalId); + .isEqualTo(userAssignedIdentityPrincipalId); assertThat(storageAccount.getAccessTier()) - .isEqualTo(accessTier); + .isEqualTo(accessTier); assertThat(storageAccount.getAllowBlobPublicAccess()) - .isEqualTo(allowBlobPublicAccess); + .isEqualTo(allowBlobPublicAccess); assertThat(storageAccount.getAllowCrossTenantReplication()) - .isEqualTo(allowCrossTenantReplication); + .isEqualTo(allowCrossTenantReplication); assertThat(storageAccount.getAllowSharedKeyAccess()) - .isEqualTo(allowSharedKeyAccess); + .isEqualTo(allowSharedKeyAccess); assertThat(storageAccount.getAllowedCopyScope()) - .isEqualTo(allowedCopyScope); + .isEqualTo(allowedCopyScope); assertThat(storageAccount.getAzureFilesIdentityBasedAuthentication()) - .isEqualTo(azureFilesIdentityBasedAuthentication); + .isEqualTo(azureFilesIdentityBasedAuthentication); assertThat(storageAccountBasedAuthentication.getActiveDirectoryProperties()) - .isEqualTo(storageAccountActiveDirectoryProperties); + .isEqualTo(storageAccountActiveDirectoryProperties); assertThat(storageAccountActiveDirectoryProperties.getAccountType()) - .isEqualTo(activeDirectoryAccountType); + .isEqualTo(activeDirectoryAccountType); assertThat(storageAccountActiveDirectoryProperties.getAzureStorageSid()) - .isEqualTo(activeDirectoryAzureStorageSid); + .isEqualTo(activeDirectoryAzureStorageSid); assertThat(storageAccountActiveDirectoryProperties.getDomainGuid()) - .isEqualTo(activeDirectoryDomainGuid); + .isEqualTo(activeDirectoryDomainGuid); assertThat(storageAccountActiveDirectoryProperties.getDomainName()) - .isEqualTo(activeDirectoryDomainName); + .isEqualTo(activeDirectoryDomainName); assertThat(storageAccountActiveDirectoryProperties.getDomainSid()) - .isEqualTo(activeDirectoryDomainSid); + .isEqualTo(activeDirectoryDomainSid); assertThat(storageAccountActiveDirectoryProperties.getForestName()) - .isEqualTo(activeDirectoryForestName); + .isEqualTo(activeDirectoryForestName); assertThat(storageAccountActiveDirectoryProperties.getNetBiosDomainName()) - .isEqualTo(activeDirectoryNetBiosDomainName); + .isEqualTo(activeDirectoryNetBiosDomainName); assertThat(storageAccountActiveDirectoryProperties.getSamAccountName()) - .isEqualTo(activeDirectorySamAccountName); + .isEqualTo(activeDirectorySamAccountName); assertThat(storageAccountBasedAuthentication.getDefaultSharePermission()) - .isEqualTo(activeDirectoryDefaultSharePermission); + .isEqualTo(activeDirectoryDefaultSharePermission); assertThat(storageAccountBasedAuthentication.getDirectoryServiceOptions()) - .isEqualTo(activeDirectoryDirectoryServiceOptions); + .isEqualTo(activeDirectoryDirectoryServiceOptions); assertThat(storageAccount.getCustomDomain()) - .isEqualTo(storageAccountCustomDomain); + .isEqualTo(storageAccountCustomDomain); assertThat(storageAccountCustomDomain.getName()) - .isEqualTo(customDomainName); + .isEqualTo(customDomainName); assertThat(storageAccountCustomDomain.getUseSubDomainName()) - .isEqualTo(customDomainUseSubDomainName); + .isEqualTo(customDomainUseSubDomainName); assertThat(storageAccount.getDefaultToOAuthAuthentication()) - .isEqualTo(defaultToOAuthAuthentication); + .isEqualTo(defaultToOAuthAuthentication); assertThat(storageAccount.getDnsEndpointType()) - .isEqualTo(dnsEndpointType); + .isEqualTo(dnsEndpointType); assertThat(storageAccount.getEncryption()) - .isEqualTo(storageAccountEncryption); + .isEqualTo(storageAccountEncryption); assertThat(storageAccountEncryption.getIdentity()) - .isEqualTo(encryptionIdentity); + .isEqualTo(encryptionIdentity); assertThat(storageAccountEncryption.getKeySource()) - .isEqualTo(encryptionKeySource); + .isEqualTo(encryptionKeySource); assertThat(storageAccountEncryption.getKeyVaultProperties()) - .isEqualTo(encryptionKeyVaultProperties); + .isEqualTo(encryptionKeyVaultProperties); assertThat(storageAccountEncryption.getRequireInfrastructureEncryption()) - .isEqualTo(encryptionRequireInfrastructureEncryption); + .isEqualTo(encryptionRequireInfrastructureEncryption); assertThat(storageAccountEncryption.getServices()) - .isEqualTo(encryptionServices); + .isEqualTo(encryptionServices); assertThat(storageAccountEncryptionIdentity.getFederatedIdentityClientId()) - .isEqualTo(encryptionIdentityFederatedIdentityClientId); + .isEqualTo(encryptionIdentityFederatedIdentityClientId); assertThat(storageAccountEncryptionIdentity.getUserAssignedIdentity()) - .isEqualTo(encryptionIdentityUserAssignedIdentity); + .isEqualTo(encryptionIdentityUserAssignedIdentity); assertThat(storageAccountEncryptionKeyVaultProperties.getKeyName()) - .isEqualTo(encryptionKeyVaultPropertiesKeyName); + .isEqualTo(encryptionKeyVaultPropertiesKeyName); assertThat(storageAccountEncryptionKeyVaultProperties.getKeyVaultUri()) - .isEqualTo(encryptionKeyVaultPropertiesKeyVaultUri); + .isEqualTo(encryptionKeyVaultPropertiesKeyVaultUri); assertThat(storageAccountEncryptionKeyVaultProperties.getKeyVersion()) - .isEqualTo(encryptionKeyVaultPropertiesKeyVersion); + .isEqualTo(encryptionKeyVaultPropertiesKeyVersion); assertThat(storageAccountEncryptionServices.getBlob()) - .isEqualTo(blobEncryptionService); + .isEqualTo(blobEncryptionService); assertThat(storageAccountEncryptionServices.getFile()) - .isEqualTo(fileEncryptionService); + .isEqualTo(fileEncryptionService); assertThat(storageAccountEncryptionServices.getQueue()) - .isEqualTo(queueEncryptionService); + .isEqualTo(queueEncryptionService); assertThat(storageAccountEncryptionServices.getTable()) - .isEqualTo(tableEncryptionService); + .isEqualTo(tableEncryptionService); assertThat(storageAccountBlobEncryptionService.getEnabled()) - .isEqualTo(blobEncryptionServiceEnabled); + .isEqualTo(blobEncryptionServiceEnabled); assertThat(storageAccountBlobEncryptionService.getKeyType()) - .isEqualTo(blobEncryptionServiceKeyType); + .isEqualTo(blobEncryptionServiceKeyType); assertThat(storageAccountFileEncryptionService.getEnabled()) - .isEqualTo(fileEncryptionServiceEnabled); + .isEqualTo(fileEncryptionServiceEnabled); assertThat(storageAccountFileEncryptionService.getKeyType()) - .isEqualTo(fileEncryptionServiceKeyType); + .isEqualTo(fileEncryptionServiceKeyType); assertThat(storageAccountQueueEncryptionService.getEnabled()) - .isEqualTo(queueEncryptionServiceEnabled); + .isEqualTo(queueEncryptionServiceEnabled); assertThat(storageAccountQueueEncryptionService.getKeyType()) - .isEqualTo(queueEncryptionServiceKeyType); + .isEqualTo(queueEncryptionServiceKeyType); assertThat(storageAccountTableEncryptionService.getEnabled()) - .isEqualTo(tableEncryptionServiceEnabled); + .isEqualTo(tableEncryptionServiceEnabled); assertThat(storageAccountTableEncryptionService.getKeyType()) - .isEqualTo(tableEncryptionServiceKeyType); + .isEqualTo(tableEncryptionServiceKeyType); assertThat(storageAccount.getImmutableStorageWithVersioning()) - .isEqualTo(storageAccountImmutableStorage); + .isEqualTo(storageAccountImmutableStorage); assertThat(storageAccountImmutableStorage.getEnabled()) - .isEqualTo(immutableStorageEnabled); + .isEqualTo(immutableStorageEnabled); assertThat(storageAccountImmutableStorage.getImmutabilityPolicy()) - .isEqualTo(storageAccountImmutableStoragePolicy); + .isEqualTo(storageAccountImmutableStoragePolicy); assertThat(storageAccountImmutableStoragePolicy.getAllowProtectedAppendWrites()) - .isEqualTo(immutabilityPolicyAllowProtectedAppendWrites); + .isEqualTo(immutabilityPolicyAllowProtectedAppendWrites); assertThat(storageAccountImmutableStoragePolicy.getImmutabilityPeriodSinceCreationInDays()) - .isEqualTo(immutabilityPolicyImmutabilityPeriodSinceCreationInDays); + .isEqualTo(immutabilityPolicyImmutabilityPeriodSinceCreationInDays); assertThat(storageAccount.getIsLocalUserEnabled()) - .isEqualTo(isLocalUserEnabled); + .isEqualTo(isLocalUserEnabled); assertThat(storageAccount.getIsNfsV3Enabled()) - .isEqualTo(isNfsV3Enabled); + .isEqualTo(isNfsV3Enabled); assertThat(storageAccount.getIsSftpEnabled()) - .isEqualTo(isSftpEnabled); + .isEqualTo(isSftpEnabled); assertThat(storageAccount.getKeyPolicy()) - .isEqualTo(keyPolicy); + .isEqualTo(keyPolicy); assertThat(storageAccountKeyPolicy.getKeyExpirationPeriodInDays()) - .isEqualTo(keyPolicyExpirationPeriodInDays); + .isEqualTo(keyPolicyExpirationPeriodInDays); assertThat(storageAccount.getLargeFileSharesState()) - .isEqualTo(largeFileSharesState); + .isEqualTo(largeFileSharesState); assertThat(storageAccount.getMinimumTlsVersion()) - .isEqualTo(minimumTlsVersion); + .isEqualTo(minimumTlsVersion); assertThat(storageAccount.getNetworkRuleSet()) - .isEqualTo(networkRuleSet); + .isEqualTo(networkRuleSet); assertThat(storageAccountNetworkRuleSet.getBypass()) - .isEqualTo(networkRuleSetBypass); + .isEqualTo(networkRuleSetBypass); assertThat(storageAccountNetworkRuleSet.getDefaultAction()) - .isEqualTo(networkRuleSetDefaultAction); + .isEqualTo(networkRuleSetDefaultAction); assertThat(storageAccountNetworkRuleSet.getIpRules()) - .hasSize(1); + .hasSize(1); assertThat(storageAccountNetworkRuleSetIpRule.getAction()) - .isEqualTo(networkRuleSetIpRuleAction); + .isEqualTo(networkRuleSetIpRuleAction); assertThat(storageAccountNetworkRuleSetIpRule.getIpAddressOrRange()) - .isEqualTo(networkRuleSetIpRuleIpAddressOrRange); + .isEqualTo(networkRuleSetIpRuleIpAddressOrRange); assertThat(storageAccountNetworkRuleSet.getResourceAccessRules()) - .hasSize(1); + .hasSize(1); assertThat(storageAccountNetworkRuleSetResourceAccessRule.getResourceId()) - .isEqualTo(networkRuleSetResourceAccessRuleResourceId); + .isEqualTo(networkRuleSetResourceAccessRuleResourceId); assertThat(storageAccountNetworkRuleSetResourceAccessRule.getTenantId()) - .isEqualTo(networkRuleSetResourceAccessRuleTenantId); + .isEqualTo(networkRuleSetResourceAccessRuleTenantId); assertThat(storageAccountNetworkRuleSet.getVirtualNetworkRules()) - .hasSize(1); + .hasSize(1); assertThat(storageAccountNetworkRuleSetVirtualNetworkRule.getAction()) - .isEqualTo(networkRuleSetVirtualNetworkRuleAction); + .isEqualTo(networkRuleSetVirtualNetworkRuleAction); assertThat(storageAccountNetworkRuleSetVirtualNetworkRule.getVirtualNetworkResourceId()) - .isEqualTo(networkRuleSetVirtualNetworkRuleResourceId); + .isEqualTo(networkRuleSetVirtualNetworkRuleResourceId); assertThat(storageAccountNetworkRuleSetVirtualNetworkRule.getState()) - .isEqualTo(networkRuleSetVirtualNetworkRuleState); + .isEqualTo(networkRuleSetVirtualNetworkRuleState); assertThat(storageAccount.getPublicNetworkAccess()) - .isEqualTo(publicNetworkAccess); + .isEqualTo(publicNetworkAccess); assertThat(storageAccount.getRoutingPreference()) - .isEqualTo(routingPreference); + .isEqualTo(routingPreference); assertThat(storageAccountRoutingPreference.getPublishInternetEndpoints()) - .isEqualTo(routingPreferencePublishInternetEndpoints); + .isEqualTo(routingPreferencePublishInternetEndpoints); assertThat(storageAccountRoutingPreference.getPublishMicrosoftEndpoints()) - .isEqualTo(routingPreferencePublishMicrosoftEndpoints); + .isEqualTo(routingPreferencePublishMicrosoftEndpoints); assertThat(storageAccountRoutingPreference.getRoutingChoice()) - .isEqualTo(routingPreferenceRoutingChoice); + .isEqualTo(routingPreferenceRoutingChoice); assertThat(storageAccount.getSasPolicy()) - .isEqualTo(sasPolicy); + .isEqualTo(sasPolicy); assertThat(storageAccountSasPolicy.getExpirationAction()) - .isEqualTo(sasPolicyExpirationAction); + .isEqualTo(sasPolicyExpirationAction); assertThat(storageAccountSasPolicy.getSasExpirationPeriod()) - .isEqualTo(sasPolicyExpirationPeriod); + .isEqualTo(sasPolicyExpirationPeriod); assertThat(storageAccount.getSupportsHttpsTrafficOnly()) - .isEqualTo(supportsHttpsTrafficOnly); + .isEqualTo(supportsHttpsTrafficOnly); } @@ -833,78 +836,78 @@ public void storageAccountIsValid_when_EverythingIsSet() { @Test public void booleanWithValueArePresent_when_serialisingTheComponent() { var storageAccount = generateBuilder() - .withEncryption(AzureStorageAccountEncryption.builder() - .withServices(AzureStorageAccountEncryptionServices.builder() - .withBlob(AzureStorageAccountEncryptionService.builder() - .withEnabled(true) - .withKeyType(AzureStorageKeyType.SERVICE) - .build()) - .build()) + .withEncryption(AzureStorageAccountEncryption.builder() + .withServices(AzureStorageAccountEncryptionServices.builder() + .withBlob(AzureStorageAccountEncryptionService.builder() + .withEnabled(true) + .withKeyType(AzureStorageKeyType.SERVICE) .build()) - .build(); + .build()) + .build()) + .build(); String result = TestUtils.getJsonRepresentation(storageAccount.getEncryption() - .getServices() - .getBlob()); - + .getServices() + .getBlob()); + var expectedResult = """ - { - "enabled" : true, - "keyType" : "Service" - }"""; - + { + "enabled" : true, + "keyType" : "Service" + }"""; + assertThat(result).isEqualTo(expectedResult); } @Test public void storageAccountBuildShouldFail_when_tooShortName() { assertThatThrownBy(() -> generateBuilder() - .withName(aLowerCaseAlphanumericString(2, true, "-")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(NAME_IS_NOT_VALID); + .withName(aLowerCaseAlphanumericString(2, true, "-")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(NAME_IS_NOT_VALID); } @Test public void storageAccountBuildShouldFail_when_tooLongName() { assertThatThrownBy(() -> generateBuilder() - .withName(aLowerCaseAlphanumericString(25, true, "-")) - .build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(NAME_IS_NOT_VALID); + .withName(aLowerCaseAlphanumericString(25, true, "-")) + .build()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(NAME_IS_NOT_VALID); } @Test public void storageAccountBuildShouldFail_when_HyphensOrUnderscoreInName() { assertThatThrownBy(() -> generateBuilder().withName("this-is-a-test").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(NAME_IS_NOT_VALID); assertThatThrownBy(() -> generateBuilder().withName("this_is_a_test").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(NAME_IS_NOT_VALID); } @Test public void storageAccountBuildShouldFail_when_UppercaseCharactersInName() { assertThatThrownBy(() -> generateBuilder().withName("thisIsATest").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(NAME_IS_NOT_VALID); assertThatThrownBy(() -> generateBuilder().withName("Thisisatest").build()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining(NAME_IS_NOT_VALID); + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(NAME_IS_NOT_VALID); } private AzureLegacyStorageAccount.AzureLegacyStorageAccountBuilder generateBuilder() { return new AzureLegacyStorageAccount.AzureLegacyStorageAccountBuilder() - .withId(aComponentId()) + .withId(aComponentId()) + .withName(aLowerCaseAlphanumericString(24)) + .withDisplayName(aAlphanumericString(50)) + .withRegion(a(AzureRegion.class)) + .withResourceGroup(AzureResourceGroup.builder() .withName(aLowerCaseAlphanumericString(24)) - .withDisplayName(aAlphanumericString(50)) .withRegion(a(AzureRegion.class)) - .withResourceGroup(AzureResourceGroup.builder() - .withName(aLowerCaseAlphanumericString(24)) - .withRegion(a(AzureRegion.class)) - .build()); + .build()); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoiceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoiceTest.java index 2691ca14..a14bb3cb 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoiceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureRoutingChoiceTest.java @@ -10,23 +10,23 @@ public class AzureRoutingChoiceTest { @Test public void azureRoutingChoiceConstants_shouldNotBeNull() { assertThat(AzureRoutingChoice.MICROSOFT_ROUTING) - .as("MICROSOFT_ROUTING constant should not be null") - .isNotNull(); + .as("MICROSOFT_ROUTING constant should not be null") + .isNotNull(); assertThat(AzureRoutingChoice.INTERNET_ROUTING) - .as("INTERNET_ROUTING constant should not be null") - .isNotNull(); + .as("INTERNET_ROUTING constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureRoutingChoice() { assertThat(AzureRoutingChoice.fromString("MicrosoftRouting")) - .as("fromString should return MICROSOFT_ROUTING for 'MicrosoftRouting'") - .isEqualTo(AzureRoutingChoice.MICROSOFT_ROUTING); - + .as("fromString should return MICROSOFT_ROUTING for 'MicrosoftRouting'") + .isEqualTo(AzureRoutingChoice.MICROSOFT_ROUTING); + assertThat(AzureRoutingChoice.fromString("InternetRouting")) - .as("fromString should return INTERNET_ROUTING for 'InternetRouting'") - .isEqualTo(AzureRoutingChoice.INTERNET_ROUTING); + .as("fromString should return INTERNET_ROUTING for 'InternetRouting'") + .isEqualTo(AzureRoutingChoice.INTERNET_ROUTING); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAllAzureRoutingChoicesWithCorrectSize() { Collection values = AzureRoutingChoice.values(); assertThat(values) - .as("Values should contain MICROSOFT_ROUTING, and INTERNET_ROUTING and have exactly 2 values") - .containsExactlyInAnyOrder(AzureRoutingChoice.MICROSOFT_ROUTING, AzureRoutingChoice.INTERNET_ROUTING); + .as("Values should contain MICROSOFT_ROUTING, and INTERNET_ROUTING and have exactly 2 values") + .containsExactlyInAnyOrder(AzureRoutingChoice.MICROSOFT_ROUTING, AzureRoutingChoice.INTERNET_ROUTING); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountExtendedLocationTypesTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountExtendedLocationTypesTest.java index 82cfb329..8e5322b7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountExtendedLocationTypesTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountExtendedLocationTypesTest.java @@ -10,15 +10,15 @@ public class AzureStorageAccountExtendedLocationTypesTest { @Test public void azureStorageAccountExtendedLocationTypesConstants_shouldNotBeNull() { assertThat(AzureStorageAccountExtendedLocationTypes.EDGE_ZONE) - .as("EDGE_ZONE constant should not be null") - .isNotNull(); + .as("EDGE_ZONE constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureStorageAccountExtendedLocationTypes() { assertThat(AzureStorageAccountExtendedLocationTypes.fromString("EdgeZone")) - .as("fromString should return EDGE_ZONE for 'EdgeZone'") - .isEqualTo(AzureStorageAccountExtendedLocationTypes.EDGE_ZONE); + .as("fromString should return EDGE_ZONE for 'EdgeZone'") + .isEqualTo(AzureStorageAccountExtendedLocationTypes.EDGE_ZONE); } @Test @@ -26,7 +26,7 @@ public void valuesMethod_shouldContainAllAzureStorageAccountExtendedLocationType Collection values = AzureStorageAccountExtendedLocationTypes.values(); assertThat(values) - .as("Values should contain EDGE_ZONE and have exactly 1 value") - .containsExactlyInAnyOrder(AzureStorageAccountExtendedLocationTypes.EDGE_ZONE); + .as("Values should contain EDGE_ZONE and have exactly 1 value") + .containsExactlyInAnyOrder(AzureStorageAccountExtendedLocationTypes.EDGE_ZONE); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeySourceTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeySourceTest.java index 8bf16017..afadbb38 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeySourceTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountKeySourceTest.java @@ -10,23 +10,23 @@ public class AzureStorageAccountKeySourceTest { @Test public void azureStorageAccountKeySourceConstants_shouldNotBeNull() { assertThat(AzureStorageAccountKeySource.MICROSOFT_STORAGE) - .as("MICROSOFT_STORAGE constant should not be null") - .isNotNull(); + .as("MICROSOFT_STORAGE constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountKeySource.MICROSOFT_KEYVAULT) - .as("MICROSOFT_KEYVAULT constant should not be null") - .isNotNull(); + .as("MICROSOFT_KEYVAULT constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureStorageAccountKeySource() { assertThat(AzureStorageAccountKeySource.fromString("Microsoft.Storage")) - .as("fromString should return MICROSOFT_STORAGE for 'Microsoft.Storage'") - .isEqualTo(AzureStorageAccountKeySource.MICROSOFT_STORAGE); + .as("fromString should return MICROSOFT_STORAGE for 'Microsoft.Storage'") + .isEqualTo(AzureStorageAccountKeySource.MICROSOFT_STORAGE); assertThat(AzureStorageAccountKeySource.fromString("Microsoft.Keyvault")) - .as("fromString should return MICROSOFT_KEYVAULT for 'Microsoft.Keyvault'") - .isEqualTo(AzureStorageAccountKeySource.MICROSOFT_KEYVAULT); + .as("fromString should return MICROSOFT_KEYVAULT for 'Microsoft.Keyvault'") + .isEqualTo(AzureStorageAccountKeySource.MICROSOFT_KEYVAULT); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAlAzureStorageAccountKeySourcesWithCorrect Collection values = AzureStorageAccountKeySource.values(); assertThat(values) - .as("Values should contain MICROSOFT_STORAGE, and MICROSOFT_KEYVAULT and have exactly 2 values") - .containsExactlyInAnyOrder(AzureStorageAccountKeySource.MICROSOFT_STORAGE, - AzureStorageAccountKeySource.MICROSOFT_KEYVAULT); + .as("Values should contain MICROSOFT_STORAGE, and MICROSOFT_KEYVAULT and have exactly 2 values") + .containsExactlyInAnyOrder(AzureStorageAccountKeySource.MICROSOFT_STORAGE, + AzureStorageAccountKeySource.MICROSOFT_KEYVAULT); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountTest.java index f78e0854..71070040 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/AzureStorageAccountTest.java @@ -15,15 +15,15 @@ public class AzureStorageAccountTest { @Test public void kindIsValid_when_ValidationPasses() throws JsonProcessingException { var storage = AzureStorageAccount.builder() - .withId("storage-account") - .withName("a23456789012345678901234") + .withId("storage-account") + .withName("a23456789012345678901234") + .withRegion(AzureRegion.WEST_EUROPE) + .withResourceGroup(AzureResourceGroup.builder() + .withName("validName123") .withRegion(AzureRegion.WEST_EUROPE) - .withResourceGroup(AzureResourceGroup.builder() - .withName("validName123") - .withRegion(AzureRegion.WEST_EUROPE) - .build()) - .withTag("key1", "value1") - .build(); + .build()) + .withTag("key1", "value1") + .build(); assertTrue(storage.validate().isEmpty()); var json = TestUtils.getJsonRepresentation(storage); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyStateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyStateTest.java index 17ba9d0c..1f2d0acf 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyStateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureAccountImmutabilityPolicyStateTest.java @@ -10,31 +10,31 @@ public class AzureAccountImmutabilityPolicyStateTest { @Test public void azureAccountImmutabilityPolicyStateConstants_shouldNotBeNull() { assertThat(AzureAccountImmutabilityPolicyState.UNLOCKED) - .as("UNLOCKED constant should not be null") - .isNotNull(); + .as("UNLOCKED constant should not be null") + .isNotNull(); assertThat(AzureAccountImmutabilityPolicyState.LOCKED) - .as("LOCKED constant should not be null") - .isNotNull(); + .as("LOCKED constant should not be null") + .isNotNull(); assertThat(AzureAccountImmutabilityPolicyState.DISABLED) - .as("DISABLED constant should not be null") - .isNotNull(); + .as("DISABLED constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureAccountImmutabilityPolicyState() { assertThat(AzureAccountImmutabilityPolicyState.fromString("Unlocked")) - .as("fromString should return UNLOCKED for 'Unlocked'") - .isEqualTo(AzureAccountImmutabilityPolicyState.UNLOCKED); + .as("fromString should return UNLOCKED for 'Unlocked'") + .isEqualTo(AzureAccountImmutabilityPolicyState.UNLOCKED); assertThat(AzureAccountImmutabilityPolicyState.fromString("Locked")) - .as("fromString should return LOCKED for 'Locked'") - .isEqualTo(AzureAccountImmutabilityPolicyState.LOCKED); + .as("fromString should return LOCKED for 'Locked'") + .isEqualTo(AzureAccountImmutabilityPolicyState.LOCKED); assertThat(AzureAccountImmutabilityPolicyState.fromString("Disabled")) - .as("fromString should return DISABLED for 'Disabled'") - .isEqualTo(AzureAccountImmutabilityPolicyState.DISABLED); + .as("fromString should return DISABLED for 'Disabled'") + .isEqualTo(AzureAccountImmutabilityPolicyState.DISABLED); } @Test @@ -42,10 +42,10 @@ public void valuesMethod_shouldContainAllAzureAccountImmutabilityPolicyStatesWit Collection values = AzureAccountImmutabilityPolicyState.values(); assertThat(values) - .as("Values should contain UNLOCKED, LOCKED, and DISABLED and have exactly 3 values") - .containsExactlyInAnyOrder( - AzureAccountImmutabilityPolicyState.UNLOCKED, - AzureAccountImmutabilityPolicyState.LOCKED, - AzureAccountImmutabilityPolicyState.DISABLED); + .as("Values should contain UNLOCKED, LOCKED, and DISABLED and have exactly 3 values") + .containsExactlyInAnyOrder( + AzureAccountImmutabilityPolicyState.UNLOCKED, + AzureAccountImmutabilityPolicyState.LOCKED, + AzureAccountImmutabilityPolicyState.DISABLED); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountTypeTest.java index 99bb43a2..260c209e 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureActiveDirectoryAccountTypeTest.java @@ -10,23 +10,23 @@ public class AzureActiveDirectoryAccountTypeTest { @Test public void azureActiveDirectoryAccountTypeConstants_shouldNotBeNull() { assertThat(AzureActiveDirectoryAccountType.USER) - .as("USER constant should not be null") - .isNotNull(); + .as("USER constant should not be null") + .isNotNull(); assertThat(AzureActiveDirectoryAccountType.COMPUTER) - .as("COMPUTER constant should not be null") - .isNotNull(); + .as("COMPUTER constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureActiveDirectoryAccountType() { assertThat(AzureActiveDirectoryAccountType.fromString("User")) - .as("fromString should return USER for 'User'") - .isEqualTo(AzureActiveDirectoryAccountType.USER); + .as("fromString should return USER for 'User'") + .isEqualTo(AzureActiveDirectoryAccountType.USER); assertThat(AzureActiveDirectoryAccountType.fromString("Computer")) - .as("fromString should return COMPUTER for 'Computer'") - .isEqualTo(AzureActiveDirectoryAccountType.COMPUTER); + .as("fromString should return COMPUTER for 'Computer'") + .isEqualTo(AzureActiveDirectoryAccountType.COMPUTER); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAllAzureActiveDirectoryAccountTypesWithCor Collection values = AzureActiveDirectoryAccountType.values(); assertThat(values) - .as("Values should contain USER, and COMPUTER and have exactly 2 values") - .containsExactlyInAnyOrder(AzureActiveDirectoryAccountType.USER, - AzureActiveDirectoryAccountType.COMPUTER); + .as("Values should contain USER, and COMPUTER and have exactly 2 values") + .containsExactlyInAnyOrder(AzureActiveDirectoryAccountType.USER, + AzureActiveDirectoryAccountType.COMPUTER); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermissionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermissionTest.java index 2e22a1c9..1c621635 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermissionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDefaultSharePermissionTest.java @@ -10,39 +10,40 @@ public class AzureDefaultSharePermissionTest { @Test public void azureDefaultSharePermissionConstants_shouldNotBeNull() { assertThat(AzureDefaultSharePermission.NONE) - .as("NONE constant should not be null") - .isNotNull(); + .as("NONE constant should not be null") + .isNotNull(); assertThat(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_READER) - .as("STORAGE_FILE_DATA_SMB_SHARE_READER constant should not be null") - .isNotNull(); + .as("STORAGE_FILE_DATA_SMB_SHARE_READER constant should not be null") + .isNotNull(); assertThat(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR) - .as("STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR constant should not be null") - .isNotNull(); + .as("STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR constant should not be null") + .isNotNull(); assertThat(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR) - .as("STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR constant should not be null") - .isNotNull(); + .as("STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureDefaultSharePermission() { assertThat(AzureDefaultSharePermission.fromString("None")) - .as("fromString should return NONE for 'None'") - .isEqualTo(AzureDefaultSharePermission.NONE); + .as("fromString should return NONE for 'None'") + .isEqualTo(AzureDefaultSharePermission.NONE); assertThat(AzureDefaultSharePermission.fromString("StorageFileDataSmbShareReader")) - .as("fromString should return STORAGE_FILE_DATA_SMB_SHARE_READER for 'StorageFileDataSmbShareReader'") - .isEqualTo(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_READER); + .as("fromString should return STORAGE_FILE_DATA_SMB_SHARE_READER for 'StorageFileDataSmbShareReader'") + .isEqualTo(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_READER); assertThat(AzureDefaultSharePermission.fromString("StorageFileDataSmbShareContributor")) - .as("fromString should return STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR for 'StorageFileDataSmbShareContributor'") - .isEqualTo(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR); + .as("fromString should return STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR for 'StorageFileDataSmbShareContributor'") + .isEqualTo(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR); assertThat(AzureDefaultSharePermission.fromString("StorageFileDataSmbShareElevatedContributor")) - .as("fromString should return STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR for 'StorageFileDataSmbShareElevatedContributor'") - .isEqualTo(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR); + .as("fromString should return STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR for " + + "'StorageFileDataSmbShareElevatedContributor'") + .isEqualTo(AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR); } @Test @@ -50,13 +51,13 @@ public void valuesMethod_shouldContainAllAzureDefaultSharePermissionsWithCorrect Collection values = AzureDefaultSharePermission.values(); assertThat(values) - .as("Values should contain NONE, STORAGE_FILE_DATA_SMB_SHARE_READER, " + - "STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR, and STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR " + - "and have exactly 4 values") - .containsExactlyInAnyOrder( - AzureDefaultSharePermission.NONE, - AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_READER, - AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR, - AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR); + .as("Values should contain NONE, STORAGE_FILE_DATA_SMB_SHARE_READER, " + + "STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR, and STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR " + + "and have exactly 4 values") + .containsExactlyInAnyOrder( + AzureDefaultSharePermission.NONE, + AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_READER, + AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR, + AzureDefaultSharePermission.STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDirectoryServiceOptionsTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDirectoryServiceOptionsTest.java index dd76a303..da8df14e 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDirectoryServiceOptionsTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDirectoryServiceOptionsTest.java @@ -10,39 +10,39 @@ public class AzureDirectoryServiceOptionsTest { @Test public void azureDirectoryServiceOptionsConstants_shouldNotBeNull() { assertThat(AzureDirectoryServiceOptions.NONE) - .as("NONE constant should not be null") - .isNotNull(); + .as("NONE constant should not be null") + .isNotNull(); assertThat(AzureDirectoryServiceOptions.AADDS) - .as("AADDS constant should not be null") - .isNotNull(); + .as("AADDS constant should not be null") + .isNotNull(); assertThat(AzureDirectoryServiceOptions.AD) - .as("AD constant should not be null") - .isNotNull(); + .as("AD constant should not be null") + .isNotNull(); assertThat(AzureDirectoryServiceOptions.AADKERB) - .as("AADKERB constant should not be null") - .isNotNull(); + .as("AADKERB constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureDirectoryServiceOptions() { assertThat(AzureDirectoryServiceOptions.fromString("None")) - .as("fromString should return NONE for 'None'") - .isEqualTo(AzureDirectoryServiceOptions.NONE); + .as("fromString should return NONE for 'None'") + .isEqualTo(AzureDirectoryServiceOptions.NONE); assertThat(AzureDirectoryServiceOptions.fromString("AADDS")) - .as("fromString should return AADDS for 'AADDS'") - .isEqualTo(AzureDirectoryServiceOptions.AADDS); - + .as("fromString should return AADDS for 'AADDS'") + .isEqualTo(AzureDirectoryServiceOptions.AADDS); + assertThat(AzureDirectoryServiceOptions.fromString("AD")) - .as("fromString should return AD for 'AD'") - .isEqualTo(AzureDirectoryServiceOptions.AD); + .as("fromString should return AD for 'AD'") + .isEqualTo(AzureDirectoryServiceOptions.AD); assertThat(AzureDirectoryServiceOptions.fromString("AADKERB")) - .as("fromString should return AADKERB for 'AADKERB'") - .isEqualTo(AzureDirectoryServiceOptions.AADKERB); + .as("fromString should return AADKERB for 'AADKERB'") + .isEqualTo(AzureDirectoryServiceOptions.AADKERB); } @Test @@ -50,10 +50,10 @@ public void valuesMethod_shouldContainAllAzureDirectoryServiceOptionsWithCorrect Collection values = AzureDirectoryServiceOptions.values(); assertThat(values) - .as("Values should contain NONE, AADDS, AD, and AADKERB and have exactly 4 values") - .containsExactlyInAnyOrder(AzureDirectoryServiceOptions.NONE, - AzureDirectoryServiceOptions.AADDS, - AzureDirectoryServiceOptions.AD, - AzureDirectoryServiceOptions.AADKERB); + .as("Values should contain NONE, AADDS, AD, and AADKERB and have exactly 4 values") + .containsExactlyInAnyOrder(AzureDirectoryServiceOptions.NONE, + AzureDirectoryServiceOptions.AADDS, + AzureDirectoryServiceOptions.AD, + AzureDirectoryServiceOptions.AADKERB); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointTypeTest.java index be4dd3d6..89a4af86 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureDnsEndpointTypeTest.java @@ -10,23 +10,23 @@ public class AzureDnsEndpointTypeTest { @Test public void azureDnsEndpointTypeConstants_shouldNotBeNull() { assertThat(AzureDnsEndpointType.STANDARD) - .as("STANDARD constant should not be null") - .isNotNull(); + .as("STANDARD constant should not be null") + .isNotNull(); assertThat(AzureDnsEndpointType.AZURE_DNS_ZONE) - .as("AZURE_DNS_ZONE constant should not be null") - .isNotNull(); + .as("AZURE_DNS_ZONE constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureDnsEndpointType() { assertThat(AzureDnsEndpointType.fromString("Standard")) - .as("fromString should return STANDARD for 'Standard'") - .isEqualTo(AzureDnsEndpointType.STANDARD); + .as("fromString should return STANDARD for 'Standard'") + .isEqualTo(AzureDnsEndpointType.STANDARD); assertThat(AzureDnsEndpointType.fromString("AzureDnsZone")) - .as("fromString should return STANDARD for 'Standard'") - .isEqualTo(AzureDnsEndpointType.AZURE_DNS_ZONE); + .as("fromString should return STANDARD for 'Standard'") + .isEqualTo(AzureDnsEndpointType.AZURE_DNS_ZONE); } @Test @@ -34,7 +34,7 @@ public void valuesMethod_shouldContainAllAzureDnsEndpointTypesWithCorrectSize() Collection values = AzureDnsEndpointType.values(); assertThat(values) - .as("Values should contain STANDARD, and AZURE_DNS_ZONE and have exactly 2 values") - .containsExactlyInAnyOrder(AzureDnsEndpointType.STANDARD, AzureDnsEndpointType.AZURE_DNS_ZONE); + .as("Values should contain STANDARD, and AZURE_DNS_ZONE and have exactly 2 values") + .containsExactlyInAnyOrder(AzureDnsEndpointType.STANDARD, AzureDnsEndpointType.AZURE_DNS_ZONE); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureIdentityTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureIdentityTypeTest.java index 18bbcd7e..736b51b7 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureIdentityTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureIdentityTypeTest.java @@ -11,39 +11,39 @@ public class AzureIdentityTypeTest { @Test public void azureIdentityTypeConstants_shouldNotBeNull() { assertThat(AzureIdentityType.NONE) - .as("NONE constant should not be null") - .isNotNull(); + .as("NONE constant should not be null") + .isNotNull(); assertThat(AzureIdentityType.SYSTEM_ASSIGNED) - .as("SYSTEM_ASSIGNED constant should not be null") - .isNotNull(); + .as("SYSTEM_ASSIGNED constant should not be null") + .isNotNull(); assertThat(AzureIdentityType.USER_ASSIGNED) - .as("USER_ASSIGNED constant should not be null") - .isNotNull(); + .as("USER_ASSIGNED constant should not be null") + .isNotNull(); assertThat(AzureIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED) - .as("SYSTEM_ASSIGNED_USER_ASSIGNED constant should not be null") - .isNotNull(); + .as("SYSTEM_ASSIGNED_USER_ASSIGNED constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureIdentityType() { assertThat(AzureIdentityType.fromString("None")) - .as("fromString should return NONE for 'None'") - .isEqualTo(AzureIdentityType.NONE); + .as("fromString should return NONE for 'None'") + .isEqualTo(AzureIdentityType.NONE); assertThat(AzureIdentityType.fromString("SystemAssigned")) - .as("fromString should return SYSTEM_ASSIGNED for 'SystemAssigned'") - .isEqualTo(AzureIdentityType.SYSTEM_ASSIGNED); + .as("fromString should return SYSTEM_ASSIGNED for 'SystemAssigned'") + .isEqualTo(AzureIdentityType.SYSTEM_ASSIGNED); assertThat(AzureIdentityType.fromString("UserAssigned")) - .as("fromString should return USER_ASSIGNED for 'UserAssigned'") - .isEqualTo(AzureIdentityType.USER_ASSIGNED); + .as("fromString should return USER_ASSIGNED for 'UserAssigned'") + .isEqualTo(AzureIdentityType.USER_ASSIGNED); assertThat(AzureIdentityType.fromString("SystemAssigned,UserAssigned")) - .as("fromString should return SYSTEM_ASSIGNED_USER_ASSIGNED for 'SystemAssigned,UserAssigned'") - .isEqualTo(AzureIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED); + .as("fromString should return SYSTEM_ASSIGNED_USER_ASSIGNED for 'SystemAssigned,UserAssigned'") + .isEqualTo(AzureIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED); } @Test @@ -51,10 +51,11 @@ public void valuesMethod_shouldContainAllAzureIdentityTypesWithCorrectSize() { Collection values = AzureIdentityType.values(); assertThat(values) - .as("Values should contain NONE, SYSTEM_ASSIGNED, USER_ASSIGNED, and SYSTEM_ASSIGNED_USER_ASSIGNED and have exactly 4 values") - .containsExactlyInAnyOrder(AzureIdentityType.NONE, - AzureIdentityType.SYSTEM_ASSIGNED, - AzureIdentityType.USER_ASSIGNED, - AzureIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED); + .as("Values should contain NONE, SYSTEM_ASSIGNED, USER_ASSIGNED, and SYSTEM_ASSIGNED_USER_ASSIGNED and have " + + "exactly 4 values") + .containsExactlyInAnyOrder(AzureIdentityType.NONE, + AzureIdentityType.SYSTEM_ASSIGNED, + AzureIdentityType.USER_ASSIGNED, + AzureIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesStateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesStateTest.java index daa96e16..4261b09a 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesStateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureLargeFileSharesStateTest.java @@ -10,23 +10,23 @@ public class AzureLargeFileSharesStateTest { @Test public void azureLargeFileSharesStateConstants_shouldNotBeNull() { assertThat(AzureLargeFileSharesState.DISABLED) - .as("DISABLED constant should not be null") - .isNotNull(); - + .as("DISABLED constant should not be null") + .isNotNull(); + assertThat(AzureLargeFileSharesState.ENABLED) - .as("ENABLED constant should not be null") - .isNotNull(); + .as("ENABLED constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureAction() { assertThat(AzureLargeFileSharesState.fromString("Disabled")) - .as("fromString should return DISABLED for 'Disabled'") - .isEqualTo(AzureLargeFileSharesState.DISABLED); + .as("fromString should return DISABLED for 'Disabled'") + .isEqualTo(AzureLargeFileSharesState.DISABLED); assertThat(AzureLargeFileSharesState.fromString("Enabled")) - .as("fromString should return ENABLED for 'Enabled'") - .isEqualTo(AzureLargeFileSharesState.ENABLED); + .as("fromString should return ENABLED for 'Enabled'") + .isEqualTo(AzureLargeFileSharesState.ENABLED); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAllAzureActionsWithCorrectSize() { Collection values = AzureLargeFileSharesState.values(); assertThat(values) - .as("Values should contain DISABLED, ENABLED and have exactly 2 values") - .containsExactlyInAnyOrder(AzureLargeFileSharesState.DISABLED, - AzureLargeFileSharesState.ENABLED); + .as("Values should contain DISABLED, ENABLED and have exactly 2 values") + .containsExactlyInAnyOrder(AzureLargeFileSharesState.DISABLED, + AzureLargeFileSharesState.ENABLED); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccessTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccessTest.java index fdf06146..851b8ecc 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccessTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzurePublicNetworkAccessTest.java @@ -10,23 +10,23 @@ public class AzurePublicNetworkAccessTest { @Test public void azurePublicNetworkAccessConstants_shouldNotBeNull() { assertThat(AzurePublicNetworkAccess.ENABLED) - .as("ENABLED constant should not be null") - .isNotNull(); + .as("ENABLED constant should not be null") + .isNotNull(); assertThat(AzurePublicNetworkAccess.DISABLED) - .as("DISABLED constant should not be null") - .isNotNull(); + .as("DISABLED constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzurePublicNetworkAccess() { assertThat(AzurePublicNetworkAccess.fromString("Enabled")) - .as("fromString should return ENABLED for 'Enabled'") - .isEqualTo(AzurePublicNetworkAccess.ENABLED); - + .as("fromString should return ENABLED for 'Enabled'") + .isEqualTo(AzurePublicNetworkAccess.ENABLED); + assertThat(AzurePublicNetworkAccess.fromString("Disabled")) - .as("fromString should return DISABLED for 'Disabled'") - .isEqualTo(AzurePublicNetworkAccess.DISABLED); + .as("fromString should return DISABLED for 'Disabled'") + .isEqualTo(AzurePublicNetworkAccess.DISABLED); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAllAzurePublicNetworkAccessesWithCorrectSi Collection values = AzurePublicNetworkAccess.values(); assertThat(values) - .as("Values should contain ENABLED, and DISABLED and have exactly 2 values") - .containsExactlyInAnyOrder(AzurePublicNetworkAccess.ENABLED, - AzurePublicNetworkAccess.DISABLED); + .as("Values should contain ENABLED, and DISABLED and have exactly 2 values") + .containsExactlyInAnyOrder(AzurePublicNetworkAccess.ENABLED, + AzurePublicNetworkAccess.DISABLED); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStateTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStateTest.java index 3d3b8365..74c3cad3 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStateTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStateTest.java @@ -10,47 +10,47 @@ public class AzureStateTest { @Test public void azureStateConstants_shouldNotBeNull() { assertThat(AzureState.PROVISIONING) - .as("PROVISIONING constant should not be null") - .isNotNull(); + .as("PROVISIONING constant should not be null") + .isNotNull(); assertThat(AzureState.DEPROVISIONING) - .as("DEPROVISIONING constant should not be null") - .isNotNull(); + .as("DEPROVISIONING constant should not be null") + .isNotNull(); assertThat(AzureState.SUCCEEDED) - .as("SUCCEEDED constant should not be null") - .isNotNull(); + .as("SUCCEEDED constant should not be null") + .isNotNull(); assertThat(AzureState.FAILED) - .as("FAILED constant should not be null") - .isNotNull(); + .as("FAILED constant should not be null") + .isNotNull(); assertThat(AzureState.NETWORK_SOURCE_DELETED) - .as("NETWORK_SOURCE_DELETED constant should not be null") - .isNotNull(); + .as("NETWORK_SOURCE_DELETED constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureState() { assertThat(AzureState.fromString("Provisioning")) - .as("fromString should return PROVISIONING for 'Provisioning'") - .isEqualTo(AzureState.PROVISIONING); - + .as("fromString should return PROVISIONING for 'Provisioning'") + .isEqualTo(AzureState.PROVISIONING); + assertThat(AzureState.fromString("Deprovisioning")) - .as("fromString should return DEPROVISIONING for 'Deprovisioning'") - .isEqualTo(AzureState.DEPROVISIONING); + .as("fromString should return DEPROVISIONING for 'Deprovisioning'") + .isEqualTo(AzureState.DEPROVISIONING); assertThat(AzureState.fromString("Succeeded")) - .as("fromString should return SUCCEEDED for 'Succeeded'") - .isEqualTo(AzureState.SUCCEEDED); - + .as("fromString should return SUCCEEDED for 'Succeeded'") + .isEqualTo(AzureState.SUCCEEDED); + assertThat(AzureState.fromString("Failed")) - .as("fromString should return FAILED for 'Failed'") - .isEqualTo(AzureState.FAILED); + .as("fromString should return FAILED for 'Failed'") + .isEqualTo(AzureState.FAILED); assertThat(AzureState.fromString("NetworkSourceDeleted")) - .as("fromString should return NETWORK_SOURCE_DELETED for 'NetworkSourceDeleted'") - .isEqualTo(AzureState.NETWORK_SOURCE_DELETED); + .as("fromString should return NETWORK_SOURCE_DELETED for 'NetworkSourceDeleted'") + .isEqualTo(AzureState.NETWORK_SOURCE_DELETED); } @Test @@ -58,11 +58,12 @@ public void valuesMethod_shouldContainAllAzureStatesWithCorrectSize() { Collection values = AzureState.values(); assertThat(values) - .as("Values should contain PROVISIONING, DEPROVISIONING, SUCCEEDED, FAILED, and NETWORK_SOURCE_DELETED and have exactly 5 values") - .containsExactlyInAnyOrder(AzureState.PROVISIONING, - AzureState.DEPROVISIONING, - AzureState.SUCCEEDED, - AzureState.FAILED, - AzureState.NETWORK_SOURCE_DELETED); + .as("Values should contain PROVISIONING, DEPROVISIONING, SUCCEEDED, FAILED, and NETWORK_SOURCE_DELETED and have" + + " exactly 5 values") + .containsExactlyInAnyOrder(AzureState.PROVISIONING, + AzureState.DEPROVISIONING, + AzureState.SUCCEEDED, + AzureState.FAILED, + AzureState.NETWORK_SOURCE_DELETED); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAllowedCopyScopeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAllowedCopyScopeTest.java index 7278dcdd..bad34b2c 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAllowedCopyScopeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageAccountAllowedCopyScopeTest.java @@ -10,23 +10,23 @@ public class AzureStorageAccountAllowedCopyScopeTest { @Test public void azureStorageAccountAllowedCopyScopeConstants_shouldNotBeNull() { assertThat(AzureStorageAccountAllowedCopyScope.PRIVATE_LINK) - .as("PRIVATE_LINK constant should not be null") - .isNotNull(); + .as("PRIVATE_LINK constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountAllowedCopyScope.AAD) - .as("AAD constant should not be null") - .isNotNull(); + .as("AAD constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureStorageAccountAllowedCopyScope() { assertThat(AzureStorageAccountAllowedCopyScope.fromString("PrivateLink")) - .as("fromString should return PRIVATE_LINK for 'PrivateLink'") - .isEqualTo(AzureStorageAccountAllowedCopyScope.PRIVATE_LINK); - + .as("fromString should return PRIVATE_LINK for 'PrivateLink'") + .isEqualTo(AzureStorageAccountAllowedCopyScope.PRIVATE_LINK); + assertThat(AzureStorageAccountAllowedCopyScope.fromString("AAD")) - .as("fromString should return AAD for 'AAD'") - .isEqualTo(AzureStorageAccountAllowedCopyScope.AAD); + .as("fromString should return AAD for 'AAD'") + .isEqualTo(AzureStorageAccountAllowedCopyScope.AAD); } @Test @@ -34,8 +34,8 @@ public void valuesMethod_shouldContainAllAzureStorageAccountAllowedCopyScopesWit Collection values = AzureStorageAccountAllowedCopyScope.values(); assertThat(values) - .as("Values should contain PRIVATE_LINK, and AAD and have exactly 2 values") - .containsExactlyInAnyOrder(AzureStorageAccountAllowedCopyScope.PRIVATE_LINK, - AzureStorageAccountAllowedCopyScope.AAD); + .as("Values should contain PRIVATE_LINK, and AAD and have exactly 2 values") + .containsExactlyInAnyOrder(AzureStorageAccountAllowedCopyScope.PRIVATE_LINK, + AzureStorageAccountAllowedCopyScope.AAD); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageKeyTypeTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageKeyTypeTest.java index 3b49e22e..1661c558 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageKeyTypeTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageKeyTypeTest.java @@ -10,23 +10,23 @@ public class AzureStorageKeyTypeTest { @Test public void azureStorageKeyTypeConstants_shouldNotBeNull() { assertThat(AzureStorageKeyType.SERVICE) - .as("SERVICE constant should not be null") - .isNotNull(); + .as("SERVICE constant should not be null") + .isNotNull(); assertThat(AzureStorageKeyType.ACCOUNT) - .as("ACCOUNT constant should not be null") - .isNotNull(); + .as("ACCOUNT constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureStorageKeyType() { assertThat(AzureStorageKeyType.fromString("Service")) - .as("fromString should return SERVICE for 'Service'") - .isEqualTo(AzureStorageKeyType.SERVICE); - + .as("fromString should return SERVICE for 'Service'") + .isEqualTo(AzureStorageKeyType.SERVICE); + assertThat(AzureStorageKeyType.fromString("Account")) - .as("fromString should return ACCOUNT for 'Account'") - .isEqualTo(AzureStorageKeyType.ACCOUNT); + .as("fromString should return ACCOUNT for 'Account'") + .isEqualTo(AzureStorageKeyType.ACCOUNT); } @Test @@ -34,7 +34,7 @@ public void valuesMethod_shouldContainAllAzureStorageKeyTypesWithCorrectSize() { Collection values = AzureStorageKeyType.values(); assertThat(values) - .as("Values should contain SERVICE, and ACCOUNT and have exactly 2 values") - .containsExactlyInAnyOrder(AzureStorageKeyType.SERVICE, AzureStorageKeyType.ACCOUNT); + .as("Values should contain SERVICE, and ACCOUNT and have exactly 2 values") + .containsExactlyInAnyOrder(AzureStorageKeyType.SERVICE, AzureStorageKeyType.ACCOUNT); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageSkuNameTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageSkuNameTest.java index d4dde3e0..802f332f 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageSkuNameTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/azure/storageaccount/valueobjects/AzureStorageSkuNameTest.java @@ -10,71 +10,71 @@ public class AzureStorageSkuNameTest { @Test public void azureStorageAccountSkuNameConstants_shouldNotBeNull() { assertThat(AzureStorageAccountSkuName.STANDARD_LRS) - .as("STANDARD_LRS constant should not be null") - .isNotNull(); + .as("STANDARD_LRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.STANDARD_GRS) - .as("STANDARD_GRS constant should not be null") - .isNotNull(); + .as("STANDARD_GRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.STANDARD_RAGRS) - .as("STANDARD_RAGRS constant should not be null") - .isNotNull(); + .as("STANDARD_RAGRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.STANDARD_ZRS) - .as("STANDARD_ZRS constant should not be null") - .isNotNull(); + .as("STANDARD_ZRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.PREMIUM_LRS) - .as("PREMIUM_LRS constant should not be null") - .isNotNull(); + .as("PREMIUM_LRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.PREMIUM_ZRS) - .as("PREMIUM_ZRS constant should not be null") - .isNotNull(); + .as("PREMIUM_ZRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.STANDARD_GZRS) - .as("STANDARD_GZRS constant should not be null") - .isNotNull(); + .as("STANDARD_GZRS constant should not be null") + .isNotNull(); assertThat(AzureStorageAccountSkuName.STANDARD_RAGZRS) - .as("STANDARD_RAGZRS constant should not be null") - .isNotNull(); + .as("STANDARD_RAGZRS constant should not be null") + .isNotNull(); } @Test public void fromString_shouldReturnCorrespondingAzureStorageAccountSkuName() { assertThat(AzureStorageAccountSkuName.fromString("Standard_LRS")) - .as("fromString should return STANDARD_LRS for 'Standard_LRS'") - .isEqualTo(AzureStorageAccountSkuName.STANDARD_LRS); + .as("fromString should return STANDARD_LRS for 'Standard_LRS'") + .isEqualTo(AzureStorageAccountSkuName.STANDARD_LRS); assertThat(AzureStorageAccountSkuName.fromString("Standard_GRS")) - .as("fromString should return STANDARD_GRS for 'Standard_GRS'") - .isEqualTo(AzureStorageAccountSkuName.STANDARD_GRS); - + .as("fromString should return STANDARD_GRS for 'Standard_GRS'") + .isEqualTo(AzureStorageAccountSkuName.STANDARD_GRS); + assertThat(AzureStorageAccountSkuName.fromString("Standard_RAGRS")) - .as("fromString should return STANDARD_RAGRS for 'Standard_RAGRS'") - .isEqualTo(AzureStorageAccountSkuName.STANDARD_RAGRS); + .as("fromString should return STANDARD_RAGRS for 'Standard_RAGRS'") + .isEqualTo(AzureStorageAccountSkuName.STANDARD_RAGRS); assertThat(AzureStorageAccountSkuName.fromString("Standard_ZRS")) - .as("fromString should return STANDARD_ZRS for 'Standard_ZRS'") - .isEqualTo(AzureStorageAccountSkuName.STANDARD_ZRS); + .as("fromString should return STANDARD_ZRS for 'Standard_ZRS'") + .isEqualTo(AzureStorageAccountSkuName.STANDARD_ZRS); assertThat(AzureStorageAccountSkuName.fromString("Premium_LRS")) - .as("fromString should return PREMIUM_LRS for 'Premium_LRS'") - .isEqualTo(AzureStorageAccountSkuName.PREMIUM_LRS); + .as("fromString should return PREMIUM_LRS for 'Premium_LRS'") + .isEqualTo(AzureStorageAccountSkuName.PREMIUM_LRS); assertThat(AzureStorageAccountSkuName.fromString("Premium_ZRS")) - .as("fromString should return PREMIUM_ZRS for 'Premium_ZRS'") - .isEqualTo(AzureStorageAccountSkuName.PREMIUM_ZRS); + .as("fromString should return PREMIUM_ZRS for 'Premium_ZRS'") + .isEqualTo(AzureStorageAccountSkuName.PREMIUM_ZRS); assertThat(AzureStorageAccountSkuName.fromString("Standard_GZRS")) - .as("fromString should return STANDARD_GZRS for 'Standard_GZRS'") - .isEqualTo(AzureStorageAccountSkuName.STANDARD_GZRS); + .as("fromString should return STANDARD_GZRS for 'Standard_GZRS'") + .isEqualTo(AzureStorageAccountSkuName.STANDARD_GZRS); assertThat(AzureStorageAccountSkuName.fromString("Standard_RAGZRS")) - .as("fromString should return STANDARD_RAGZRS for 'Standard_RAGZRS'") - .isEqualTo(AzureStorageAccountSkuName.STANDARD_RAGZRS); + .as("fromString should return STANDARD_RAGZRS for 'Standard_RAGZRS'") + .isEqualTo(AzureStorageAccountSkuName.STANDARD_RAGZRS); } @Test @@ -82,15 +82,15 @@ public void valuesMethod_shouldContainAllAzureStorageAccountSkuNamesWithCorrectS Collection values = AzureStorageAccountSkuName.values(); assertThat(values) - .as("Values should contain STANDARD_LRS, STANDARD_GRS, STANDARD_RAGRS, STANDARD_ZRS, PREMIUM_LRS, " + - "PREMIUM_ZRS, STANDARD_GZRS and STANDARD_RAGZRS and have exactly 8 values") - .containsExactlyInAnyOrder(AzureStorageAccountSkuName.STANDARD_LRS, - AzureStorageAccountSkuName.STANDARD_GRS, - AzureStorageAccountSkuName.STANDARD_RAGRS, - AzureStorageAccountSkuName.STANDARD_ZRS, - AzureStorageAccountSkuName.PREMIUM_LRS, - AzureStorageAccountSkuName.PREMIUM_ZRS, - AzureStorageAccountSkuName.STANDARD_GZRS, - AzureStorageAccountSkuName.STANDARD_RAGZRS); + .as("Values should contain STANDARD_LRS, STANDARD_GRS, STANDARD_RAGRS, STANDARD_ZRS, PREMIUM_LRS, " + + "PREMIUM_ZRS, STANDARD_GZRS and STANDARD_RAGZRS and have exactly 8 values") + .containsExactlyInAnyOrder(AzureStorageAccountSkuName.STANDARD_LRS, + AzureStorageAccountSkuName.STANDARD_GRS, + AzureStorageAccountSkuName.STANDARD_RAGRS, + AzureStorageAccountSkuName.STANDARD_ZRS, + AzureStorageAccountSkuName.PREMIUM_LRS, + AzureStorageAccountSkuName.PREMIUM_ZRS, + AzureStorageAccountSkuName.STANDARD_GZRS, + AzureStorageAccountSkuName.STANDARD_RAGZRS); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpNodePoolTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpNodePoolTest.java index f438ae02..a0d31bc2 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpNodePoolTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpNodePoolTest.java @@ -6,27 +6,30 @@ public class GcpNodePoolTest { - @Test - public void validationError_when_gcpNodePoolWithNullName() { - assertThat(buildGcpNodePool(null).validate()).contains("[GcpNodePool Validation] Name has not been defined and it is required"); - } - - @Test - public void validationError_when_gcpNodePoolWithEmptyName() { - assertThat(buildGcpNodePool("").validate()).contains("[GcpNodePool Validation] Name has not been defined and it is required"); - } - - @Test - public void validationError_when_gcpNodePoolWithBlankName() { - assertThat(buildGcpNodePool(" ").validate()).contains("[GcpNodePool Validation] Name has not been defined and it is required"); - } - - @Test - public void noValidationErrors_when_gcpNodePoolWithValidFields() { - assertThat(buildGcpNodePool("gcp-node").validate()).isEmpty(); - } - - private GcpNodePool buildGcpNodePool(String name) { - return GcpNodePool.builder().withName(name).build(); - } + @Test + public void validationError_when_gcpNodePoolWithNullName() { + assertThat(buildGcpNodePool(null).validate()).contains("[GcpNodePool Validation] Name has not been defined and it" + + " is required"); + } + + @Test + public void validationError_when_gcpNodePoolWithEmptyName() { + assertThat(buildGcpNodePool("").validate()).contains("[GcpNodePool Validation] Name has not been defined and it " + + "is required"); + } + + @Test + public void validationError_when_gcpNodePoolWithBlankName() { + assertThat(buildGcpNodePool(" ").validate()).contains("[GcpNodePool Validation] Name has not been defined and it" + + " is required"); + } + + @Test + public void noValidationErrors_when_gcpNodePoolWithValidFields() { + assertThat(buildGcpNodePool("gcp-node").validate()).isEmpty(); + } + + private GcpNodePool buildGcpNodePool(String name) { + return GcpNodePool.builder().withName(name).build(); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpProgreSqlTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpProgreSqlTest.java index 8a4a79ed..46873721 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpProgreSqlTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpProgreSqlTest.java @@ -9,116 +9,116 @@ class GcpProgreSqlTest { - @Test - public void exceptionThrown_when_gcpPgCreatedWithNoIdNoRegionNoNetwork() { - var postgres = GcpPostgreSqlDbms.builder(); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "Component id has not been defined and it is required", - "[GcpProgreSQL Validation] Region has not been defined and it is required", - "[GcpProgreSQL Validation] Network has not been defined and it is required]" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithNoRegionNoNetwork() { - var postgres = GcpPostgreSqlDbms.builder().withId(ComponentId.from("postg")); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Region has not been defined and it is required", - "[GcpProgreSQL Validation] Network has not been defined and it is required]" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithNoNetwork() { - var postgres = GcpPostgreSqlDbms.builder() - .withId(ComponentId.from("postg")) - .withRegion(ASIA_SOUTH1); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Network has not been defined and it is required]" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkAddress() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkAddress(""); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network address is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkAddress() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkAddress(" "); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network address is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkAddressDescription() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkAddressDescription(""); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network address description is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkAddressDescription() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkAddressDescription(" "); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network address description is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkName() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkName(""); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network name is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkName() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkName(" "); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network name is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkPrefix() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkPrefix(""); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network prefix is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkPrefix() { - var postgres = getGcpPostgresBuilder() - .withPeeringNetworkPrefix(" "); - assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( - "[GcpProgreSQL Validation] Peering network prefix is empty" - ); - } - - @Test - public void exceptionThrown_when_gcpPgCreated() { - assertThat(getGcpPostgresBuilder().build().validate()).isEmpty(); - } - - private GcpPostgreSqlDbms.GcpPostgreSqlBuilder getGcpPostgresBuilder() { - return GcpPostgreSqlDbms.builder() - .withId(ComponentId.from("postg")) - .withRegion(ASIA_SOUTH1) - .withNetwork("network"); - } + @Test + public void exceptionThrown_when_gcpPgCreatedWithNoIdNoRegionNoNetwork() { + var postgres = GcpPostgreSqlDbms.builder(); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "Component id has not been defined and it is required", + "[GcpProgreSQL Validation] Region has not been defined and it is required", + "[GcpProgreSQL Validation] Network has not been defined and it is required]" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithNoRegionNoNetwork() { + var postgres = GcpPostgreSqlDbms.builder().withId(ComponentId.from("postg")); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Region has not been defined and it is required", + "[GcpProgreSQL Validation] Network has not been defined and it is required]" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithNoNetwork() { + var postgres = GcpPostgreSqlDbms.builder() + .withId(ComponentId.from("postg")) + .withRegion(ASIA_SOUTH1); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Network has not been defined and it is required]" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkAddress() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkAddress(""); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network address is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkAddress() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkAddress(" "); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network address is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkAddressDescription() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkAddressDescription(""); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network address description is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkAddressDescription() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkAddressDescription(" "); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network address description is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkName() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkName(""); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network name is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkName() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkName(" "); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network name is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithEmptyPeeringNetworkPrefix() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkPrefix(""); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network prefix is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreatedWithBlankPeeringNetworkPrefix() { + var postgres = getGcpPostgresBuilder() + .withPeeringNetworkPrefix(" "); + assertThatThrownBy(postgres::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll( + "[GcpProgreSQL Validation] Peering network prefix is empty" + ); + } + + @Test + public void exceptionThrown_when_gcpPgCreated() { + assertThat(getGcpPostgresBuilder().build().validate()).isEmpty(); + } + + private GcpPostgreSqlDbms.GcpPostgreSqlBuilder getGcpPostgresBuilder() { + return GcpPostgreSqlDbms.builder() + .withId(ComponentId.from("postg")) + .withRegion(ASIA_SOUTH1) + .withNetwork("network"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegionTest.java index 2635ec52..a0543e0b 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GcpRegionTest.java @@ -11,224 +11,224 @@ public class GcpRegionTest { @Test public void gcpActionConstants_shouldNotBeBlank() { GcpRegion.values().forEach(x -> - assertThat(x.toString()).isNotBlank()); + assertThat(x.toString()).isNotBlank()); } @Test public void fromString_shouldReturnCorrespondingGcpAction() { assertThat(GcpRegion.fromString("africa-south1")) - .as("fromString should return AFRICA_SOUTH1 for 'africa-south1'") - .isEqualTo(GcpRegion.AFRICA_SOUTH1); + .as("fromString should return AFRICA_SOUTH1 for 'africa-south1'") + .isEqualTo(GcpRegion.AFRICA_SOUTH1); assertThat(GcpRegion.fromString("asia-east1")) - .as("fromString should return ASIA_EAST1 for 'asia-east1'") - .isEqualTo(GcpRegion.ASIA_EAST1); + .as("fromString should return ASIA_EAST1 for 'asia-east1'") + .isEqualTo(GcpRegion.ASIA_EAST1); assertThat(GcpRegion.fromString("asia-east2")) - .as("fromString should return ASIA_EAST2 for 'asia-east2'") - .isEqualTo(GcpRegion.ASIA_EAST2); + .as("fromString should return ASIA_EAST2 for 'asia-east2'") + .isEqualTo(GcpRegion.ASIA_EAST2); assertThat(GcpRegion.fromString("asia-northeast1-b")) - .as("fromString should return ASIA_NORTHEAST1 for 'asia-northeast1-b'") - .isEqualTo(GcpRegion.ASIA_NORTHEAST1); + .as("fromString should return ASIA_NORTHEAST1 for 'asia-northeast1-b'") + .isEqualTo(GcpRegion.ASIA_NORTHEAST1); assertThat(GcpRegion.fromString("asia-northeast2")) - .as("fromString should return ASIA_NORTHEAST2 for 'asia-northeast2'") - .isEqualTo(GcpRegion.ASIA_NORTHEAST2); + .as("fromString should return ASIA_NORTHEAST2 for 'asia-northeast2'") + .isEqualTo(GcpRegion.ASIA_NORTHEAST2); assertThat(GcpRegion.fromString("asia-northeast3")) - .as("fromString should return ASIA_NORTHEAST3 for 'asia-northeast3'") - .isEqualTo(GcpRegion.ASIA_NORTHEAST3); + .as("fromString should return ASIA_NORTHEAST3 for 'asia-northeast3'") + .isEqualTo(GcpRegion.ASIA_NORTHEAST3); assertThat(GcpRegion.fromString("asia-south1")) - .as("fromString should return ASIA_SOUTH1 for 'asia-south1'") - .isEqualTo(GcpRegion.ASIA_SOUTH1); + .as("fromString should return ASIA_SOUTH1 for 'asia-south1'") + .isEqualTo(GcpRegion.ASIA_SOUTH1); assertThat(GcpRegion.fromString("asia-south2")) - .as("fromString should return ASIA_SOUTH2 for 'asia-south2'") - .isEqualTo(GcpRegion.ASIA_SOUTH2); + .as("fromString should return ASIA_SOUTH2 for 'asia-south2'") + .isEqualTo(GcpRegion.ASIA_SOUTH2); assertThat(GcpRegion.fromString("asia-southeast1")) - .as("fromString should return ASIA_SOUTHEAST1 for 'asia-southeast1'") - .isEqualTo(GcpRegion.ASIA_SOUTHEAST1); + .as("fromString should return ASIA_SOUTHEAST1 for 'asia-southeast1'") + .isEqualTo(GcpRegion.ASIA_SOUTHEAST1); assertThat(GcpRegion.fromString("asia-southeast2")) - .as("fromString should return ASIA_SOUTHEAST2 for 'asia-southeast2'") - .isEqualTo(GcpRegion.ASIA_SOUTHEAST2); + .as("fromString should return ASIA_SOUTHEAST2 for 'asia-southeast2'") + .isEqualTo(GcpRegion.ASIA_SOUTHEAST2); assertThat(GcpRegion.fromString("australia-southeast1")) - .as("fromString should return AUSTRALIA_SOUTHEAST1 for 'australia-southeast1'") - .isEqualTo(GcpRegion.AUSTRALIA_SOUTHEAST1); + .as("fromString should return AUSTRALIA_SOUTHEAST1 for 'australia-southeast1'") + .isEqualTo(GcpRegion.AUSTRALIA_SOUTHEAST1); assertThat(GcpRegion.fromString("australia-southeast2")) - .as("fromString should return AUSTRALIA_SOUTHEAST2 for 'australia-southeast2'") - .isEqualTo(GcpRegion.AUSTRALIA_SOUTHEAST2); + .as("fromString should return AUSTRALIA_SOUTHEAST2 for 'australia-southeast2'") + .isEqualTo(GcpRegion.AUSTRALIA_SOUTHEAST2); assertThat(GcpRegion.fromString("europe-central2")) - .as("fromString should return EUROPE_CENTRAL2 for 'europe-central2'") - .isEqualTo(GcpRegion.EUROPE_CENTRAL2); + .as("fromString should return EUROPE_CENTRAL2 for 'europe-central2'") + .isEqualTo(GcpRegion.EUROPE_CENTRAL2); assertThat(GcpRegion.fromString("europe-north1")) - .as("fromString should return EUROPE_NORTH1 for 'europe-north1'") - .isEqualTo(GcpRegion.EUROPE_NORTH1); + .as("fromString should return EUROPE_NORTH1 for 'europe-north1'") + .isEqualTo(GcpRegion.EUROPE_NORTH1); assertThat(GcpRegion.fromString("europe-southwest1")) - .as("fromString should return EUROPE_SOUTHWEST1 for 'europe-southwest1'") - .isEqualTo(GcpRegion.EUROPE_SOUTHWEST1); + .as("fromString should return EUROPE_SOUTHWEST1 for 'europe-southwest1'") + .isEqualTo(GcpRegion.EUROPE_SOUTHWEST1); assertThat(GcpRegion.fromString("europe-west1")) - .as("fromString should return EUROPE_WEST1 for 'europe-west1'") - .isEqualTo(GcpRegion.EUROPE_WEST1); + .as("fromString should return EUROPE_WEST1 for 'europe-west1'") + .isEqualTo(GcpRegion.EUROPE_WEST1); assertThat(GcpRegion.fromString("europe-west10")) - .as("fromString should return EUROPE_WEST10 for 'europe-west10'") - .isEqualTo(GcpRegion.EUROPE_WEST10); + .as("fromString should return EUROPE_WEST10 for 'europe-west10'") + .isEqualTo(GcpRegion.EUROPE_WEST10); assertThat(GcpRegion.fromString("europe-west12")) - .as("fromString should return EUROPE_WEST12 for 'europe-west12'") - .isEqualTo(GcpRegion.EUROPE_WEST12); + .as("fromString should return EUROPE_WEST12 for 'europe-west12'") + .isEqualTo(GcpRegion.EUROPE_WEST12); assertThat(GcpRegion.fromString("europe-west2")) - .as("fromString should return EUROPE_WEST2 for 'europe-west2'") - .isEqualTo(GcpRegion.EUROPE_WEST2); + .as("fromString should return EUROPE_WEST2 for 'europe-west2'") + .isEqualTo(GcpRegion.EUROPE_WEST2); assertThat(GcpRegion.fromString("europe-west3")) - .as("fromString should return EUROPE_WEST3 for 'europe-west3'") - .isEqualTo(GcpRegion.EUROPE_WEST3); + .as("fromString should return EUROPE_WEST3 for 'europe-west3'") + .isEqualTo(GcpRegion.EUROPE_WEST3); assertThat(GcpRegion.fromString("europe-west4")) - .as("fromString should return EUROPE_WEST4 for 'europe-west4'") - .isEqualTo(GcpRegion.EUROPE_WEST4); + .as("fromString should return EUROPE_WEST4 for 'europe-west4'") + .isEqualTo(GcpRegion.EUROPE_WEST4); assertThat(GcpRegion.fromString("europe-west6")) - .as("fromString should return EUROPE_WEST6 for 'europe-west6'") - .isEqualTo(GcpRegion.EUROPE_WEST6); + .as("fromString should return EUROPE_WEST6 for 'europe-west6'") + .isEqualTo(GcpRegion.EUROPE_WEST6); assertThat(GcpRegion.fromString("europe-west8")) - .as("fromString should return EUROPE_WEST8 for 'europe-west8'") - .isEqualTo(GcpRegion.EUROPE_WEST8); + .as("fromString should return EUROPE_WEST8 for 'europe-west8'") + .isEqualTo(GcpRegion.EUROPE_WEST8); assertThat(GcpRegion.fromString("europe-west9")) - .as("fromString should return EUROPE_WEST9 for 'europe-west9'") - .isEqualTo(GcpRegion.EUROPE_WEST9); + .as("fromString should return EUROPE_WEST9 for 'europe-west9'") + .isEqualTo(GcpRegion.EUROPE_WEST9); assertThat(GcpRegion.fromString("me-central1")) - .as("fromString should return ME_CENTRAL1 for 'me-central1'") - .isEqualTo(GcpRegion.ME_CENTRAL1); + .as("fromString should return ME_CENTRAL1 for 'me-central1'") + .isEqualTo(GcpRegion.ME_CENTRAL1); assertThat(GcpRegion.fromString("me-central2")) - .as("fromString should return ME_CENTRAL2 for 'me-central2'") - .isEqualTo(GcpRegion.ME_CENTRAL2); + .as("fromString should return ME_CENTRAL2 for 'me-central2'") + .isEqualTo(GcpRegion.ME_CENTRAL2); assertThat(GcpRegion.fromString("me-west1")) - .as("fromString should return ME_WEST1 for 'me-west1'") - .isEqualTo(GcpRegion.ME_WEST1); + .as("fromString should return ME_WEST1 for 'me-west1'") + .isEqualTo(GcpRegion.ME_WEST1); assertThat(GcpRegion.fromString("northamerica-northeast1")) - .as("fromString should return NORTHAMERICA_NORTHEAST1 for 'northamerica-northeast1'") - .isEqualTo(GcpRegion.NORTHAMERICA_NORTHEAST1); + .as("fromString should return NORTHAMERICA_NORTHEAST1 for 'northamerica-northeast1'") + .isEqualTo(GcpRegion.NORTHAMERICA_NORTHEAST1); assertThat(GcpRegion.fromString("northamerica-northeast2")) - .as("fromString should return NORTHAMERICA_NORTHEAST2 for 'northamerica-northeast2'") - .isEqualTo(GcpRegion.NORTHAMERICA_NORTHEAST2); + .as("fromString should return NORTHAMERICA_NORTHEAST2 for 'northamerica-northeast2'") + .isEqualTo(GcpRegion.NORTHAMERICA_NORTHEAST2); assertThat(GcpRegion.fromString("northamerica-south1")) - .as("fromString should return NORTHAMERICA_SOUTH1 for 'northamerica-south1'") - .isEqualTo(GcpRegion.NORTHAMERICA_SOUTH1); + .as("fromString should return NORTHAMERICA_SOUTH1 for 'northamerica-south1'") + .isEqualTo(GcpRegion.NORTHAMERICA_SOUTH1); assertThat(GcpRegion.fromString("southamerica-east1")) - .as("fromString should return SOUTHAMERICA_EAST1 for 'southamerica-east1'") - .isEqualTo(GcpRegion.SOUTHAMERICA_EAST1); + .as("fromString should return SOUTHAMERICA_EAST1 for 'southamerica-east1'") + .isEqualTo(GcpRegion.SOUTHAMERICA_EAST1); assertThat(GcpRegion.fromString("southamerica-west1")) - .as("fromString should return SOUTHAMERICA_WEST1 for 'southamerica-west1'") - .isEqualTo(GcpRegion.SOUTHAMERICA_WEST1); + .as("fromString should return SOUTHAMERICA_WEST1 for 'southamerica-west1'") + .isEqualTo(GcpRegion.SOUTHAMERICA_WEST1); assertThat(GcpRegion.fromString("us-central1")) - .as("fromString should return US_CENTRAL1 for 'us-central1'") - .isEqualTo(GcpRegion.US_CENTRAL1); + .as("fromString should return US_CENTRAL1 for 'us-central1'") + .isEqualTo(GcpRegion.US_CENTRAL1); assertThat(GcpRegion.fromString("us-east1")) - .as("fromString should return US_EAST1 for 'us-east1'") - .isEqualTo(GcpRegion.US_EAST1); + .as("fromString should return US_EAST1 for 'us-east1'") + .isEqualTo(GcpRegion.US_EAST1); assertThat(GcpRegion.fromString("us-east4")) - .as("fromString should return US_EAST4 for 'us-east4'") - .isEqualTo(GcpRegion.US_EAST4); + .as("fromString should return US_EAST4 for 'us-east4'") + .isEqualTo(GcpRegion.US_EAST4); assertThat(GcpRegion.fromString("us-east5")) - .as("fromString should return US_EAST5 for 'us-east5'") - .isEqualTo(GcpRegion.US_EAST5); + .as("fromString should return US_EAST5 for 'us-east5'") + .isEqualTo(GcpRegion.US_EAST5); assertThat(GcpRegion.fromString("us-south1")) - .as("fromString should return US_SOUTH5 for 'us-south1'") - .isEqualTo(GcpRegion.US_SOUTH1); + .as("fromString should return US_SOUTH5 for 'us-south1'") + .isEqualTo(GcpRegion.US_SOUTH1); assertThat(GcpRegion.fromString("us-west1")) - .as("fromString should return US_WEST1 for 'us-west1'") - .isEqualTo(GcpRegion.US_WEST1); + .as("fromString should return US_WEST1 for 'us-west1'") + .isEqualTo(GcpRegion.US_WEST1); assertThat(GcpRegion.fromString("us-west2")) - .as("fromString should return US_WEST2 for 'us-west2'") - .isEqualTo(GcpRegion.US_WEST2); + .as("fromString should return US_WEST2 for 'us-west2'") + .isEqualTo(GcpRegion.US_WEST2); assertThat(GcpRegion.fromString("us-west3")) - .as("fromString should return US_WEST3 for 'us-west3'") - .isEqualTo(GcpRegion.US_WEST3); + .as("fromString should return US_WEST3 for 'us-west3'") + .isEqualTo(GcpRegion.US_WEST3); assertThat(GcpRegion.fromString("us-west4")) - .as("fromString should return US_WEST4 for 'us-west4'") - .isEqualTo(GcpRegion.US_WEST4); + .as("fromString should return US_WEST4 for 'us-west4'") + .isEqualTo(GcpRegion.US_WEST4); } @Test public void valuesMethod_shouldContainAllGcpActionsWithCorrectSize() { Collection values = GcpRegion.values(); - + assertThat(values) - .as("Values should contain all specified GcpRegions") - .contains( - GcpRegion.AFRICA_SOUTH1, - GcpRegion.AFRICA_SOUTH1, - GcpRegion.ASIA_EAST1, - GcpRegion.ASIA_EAST2, - GcpRegion.ASIA_NORTHEAST1, - GcpRegion.ASIA_NORTHEAST2, - GcpRegion.ASIA_NORTHEAST3, - GcpRegion.ASIA_SOUTH1, - GcpRegion.ASIA_SOUTH2, - GcpRegion.ASIA_SOUTHEAST1, - GcpRegion.ASIA_SOUTHEAST2, - GcpRegion.AUSTRALIA_SOUTHEAST1, - GcpRegion.AUSTRALIA_SOUTHEAST2, - GcpRegion.EUROPE_CENTRAL2, - GcpRegion.EUROPE_NORTH1, - GcpRegion.EUROPE_SOUTHWEST1, - GcpRegion.EUROPE_WEST1, - GcpRegion.EUROPE_WEST10, - GcpRegion.EUROPE_WEST12, - GcpRegion.EUROPE_WEST2, - GcpRegion.EUROPE_WEST3, - GcpRegion.EUROPE_WEST4, - GcpRegion.EUROPE_WEST6, - GcpRegion.EUROPE_WEST8, - GcpRegion.EUROPE_WEST9, - GcpRegion.ME_CENTRAL1, - GcpRegion.ME_CENTRAL2, - GcpRegion.ME_WEST1, - GcpRegion.NORTHAMERICA_NORTHEAST1, - GcpRegion.NORTHAMERICA_NORTHEAST2, - GcpRegion.NORTHAMERICA_SOUTH1, - GcpRegion.SOUTHAMERICA_EAST1, - GcpRegion.SOUTHAMERICA_WEST1, - GcpRegion.US_CENTRAL1, - GcpRegion.US_EAST1, - GcpRegion.US_EAST4, - GcpRegion.US_EAST5, - GcpRegion.US_SOUTH1, - GcpRegion.US_WEST1, - GcpRegion.US_WEST2, - GcpRegion.US_WEST3, - GcpRegion.US_WEST4); + .as("Values should contain all specified GcpRegions") + .contains( + GcpRegion.AFRICA_SOUTH1, + GcpRegion.AFRICA_SOUTH1, + GcpRegion.ASIA_EAST1, + GcpRegion.ASIA_EAST2, + GcpRegion.ASIA_NORTHEAST1, + GcpRegion.ASIA_NORTHEAST2, + GcpRegion.ASIA_NORTHEAST3, + GcpRegion.ASIA_SOUTH1, + GcpRegion.ASIA_SOUTH2, + GcpRegion.ASIA_SOUTHEAST1, + GcpRegion.ASIA_SOUTHEAST2, + GcpRegion.AUSTRALIA_SOUTHEAST1, + GcpRegion.AUSTRALIA_SOUTHEAST2, + GcpRegion.EUROPE_CENTRAL2, + GcpRegion.EUROPE_NORTH1, + GcpRegion.EUROPE_SOUTHWEST1, + GcpRegion.EUROPE_WEST1, + GcpRegion.EUROPE_WEST10, + GcpRegion.EUROPE_WEST12, + GcpRegion.EUROPE_WEST2, + GcpRegion.EUROPE_WEST3, + GcpRegion.EUROPE_WEST4, + GcpRegion.EUROPE_WEST6, + GcpRegion.EUROPE_WEST8, + GcpRegion.EUROPE_WEST9, + GcpRegion.ME_CENTRAL1, + GcpRegion.ME_CENTRAL2, + GcpRegion.ME_WEST1, + GcpRegion.NORTHAMERICA_NORTHEAST1, + GcpRegion.NORTHAMERICA_NORTHEAST2, + GcpRegion.NORTHAMERICA_SOUTH1, + GcpRegion.SOUTHAMERICA_EAST1, + GcpRegion.SOUTHAMERICA_WEST1, + GcpRegion.US_CENTRAL1, + GcpRegion.US_EAST1, + GcpRegion.US_EAST4, + GcpRegion.US_EAST5, + GcpRegion.US_SOUTH1, + GcpRegion.US_WEST1, + GcpRegion.US_WEST2, + GcpRegion.US_WEST3, + GcpRegion.US_WEST4); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngineTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngineTest.java index 97fdb889..d6b605b9 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngineTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/gcp/GoogleKubernetesEngineTest.java @@ -13,58 +13,61 @@ public class GoogleKubernetesEngineTest { - @Test - public void noValidationErrors_when_basicGke() { - assertThat(getDefaultGke().build().validate()).isEmpty(); - } + @Test + public void noValidationErrors_when_basicGke() { + assertThat(getDefaultGke().build().validate()).isEmpty(); + } - @Test - public void typeIsKubernetes_when_gkeIsBuilt() { - assertThat(getDefaultGke().build().getType()).isEqualTo(PAAS_KUBERNETES); - } + @Test + public void typeIsKubernetes_when_gkeIsBuilt() { + assertThat(getDefaultGke().build().getType()).isEqualTo(PAAS_KUBERNETES); + } - @Test - public void exceptionThrown_when_gkeCreatedWithNullId() { - assertThatThrownBy(() -> getDefaultGke().withId("").build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("A valid component id cannot be null, empty or contain spaces"); - } + @Test + public void exceptionThrown_when_gkeCreatedWithNullId() { + assertThatThrownBy(() -> getDefaultGke().withId("").build()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("A valid component id cannot be null, empty or contain spaces"); + } - @Test - public void typeIsKubernetes_when_gkeIsBuiltWithoutSpecifyType() { - var gkeBuilder = getDefaultGke(); - assertThatCode(gkeBuilder::build).doesNotThrowAnyException(); - assertThat(gkeBuilder.build().getType()).isEqualTo(PAAS_KUBERNETES); - } + @Test + public void typeIsKubernetes_when_gkeIsBuiltWithoutSpecifyType() { + var gkeBuilder = getDefaultGke(); + assertThatCode(gkeBuilder::build).doesNotThrowAnyException(); + assertThat(gkeBuilder.build().getType()).isEqualTo(PAAS_KUBERNETES); + } - @Test - public void exceptionThrown_when_gkeCreatedWithNullNodePools() { - var gke = GoogleKubernetesEngine.builder() - .withId("test"); - assertThatThrownBy(gke::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list is null or empty"); - } + @Test + public void exceptionThrown_when_gkeCreatedWithNullNodePools() { + var gke = GoogleKubernetesEngine.builder() + .withId("test"); + assertThatThrownBy(gke::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list " + + "is null or empty"); + } - @Test - public void exceptionThrown_when_gkeCreatedWithEmptyNodePools() { - var gke = GoogleKubernetesEngine.builder() - .withId("test") - .withNodePools(emptyList()); - assertThatThrownBy(gke::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list is null or empty"); - } + @Test + public void exceptionThrown_when_gkeCreatedWithEmptyNodePools() { + var gke = GoogleKubernetesEngine.builder() + .withId("test") + .withNodePools(emptyList()); + assertThatThrownBy(gke::build).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Node pool list " + + "is null or empty"); + } - @Test - public void exceptionThrown_when_gkeCreatedWithPodIdentityAndPriorityClasses() { - var gke = getDefaultGke() - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("azure-pod-identity") - .withNamespace("kube-system") - .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) - .withEnable(true) - .withAllowNetworkPluginKubeNet(true) - .build()) - .withPriorityClass(PriorityClass.builder() - .withName("test") - .withValue(200) - .build()); - assertThatThrownBy(gke::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll("Priority classes are not fully supported yet for GCP", "Pod Managed Identity is not fully supported yet for GCP"); - } + @Test + public void exceptionThrown_when_gkeCreatedWithPodIdentityAndPriorityClasses() { + var gke = getDefaultGke() + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("azure-pod-identity") + .withNamespace("kube-system") + .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) + .withEnable(true) + .withAllowNetworkPluginKubeNet(true) + .build()) + .withPriorityClass(PriorityClass.builder() + .withName("test") + .withValue(200) + .build()); + assertThatThrownBy(gke::build).isInstanceOf(IllegalArgumentException.class).hasMessageContainingAll("Priority " + + "classes are not fully supported yet for GCP", "Pod Managed Identity is not fully supported yet for GCP"); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciRegionTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciRegionTest.java index 6f53f58f..d403eb30 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciRegionTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/paas/providers/oci/OciRegionTest.java @@ -11,218 +11,218 @@ public class OciRegionTest { @Test public void ociActionConstants_shouldNotBeBlank() { OciRegion.values().forEach(x -> - assertThat(x.toString()).isNotBlank()); + assertThat(x.toString()).isNotBlank()); } @Test public void fromString_shouldReturnCorrespondingOciAction() { assertThat(OciRegion.fromString("ap-sydney-1")) - .as("fromString should return AP_SYDNEY_1 for 'ap-sydney-1'") - .isEqualTo(OciRegion.AP_SYDNEY_1); + .as("fromString should return AP_SYDNEY_1 for 'ap-sydney-1'") + .isEqualTo(OciRegion.AP_SYDNEY_1); assertThat(OciRegion.fromString("ap-melbourne-1")) - .as("fromString should return AP_MELBOURNE_1 for 'ap-melbourne-1'") - .isEqualTo(OciRegion.AP_MELBOURNE_1); + .as("fromString should return AP_MELBOURNE_1 for 'ap-melbourne-1'") + .isEqualTo(OciRegion.AP_MELBOURNE_1); assertThat(OciRegion.fromString("sa-saopaulo-1")) - .as("fromString should return SA_SAOPAULO_1 for 'sa-saopaulo-1'") - .isEqualTo(OciRegion.SA_SAOPAULO_1); + .as("fromString should return SA_SAOPAULO_1 for 'sa-saopaulo-1'") + .isEqualTo(OciRegion.SA_SAOPAULO_1); assertThat(OciRegion.fromString("sa-vinhedo-1")) - .as("fromString should return SA_VINHEDO_1 for 'sa-vinhedo-1'") - .isEqualTo(OciRegion.SA_VINHEDO_1); + .as("fromString should return SA_VINHEDO_1 for 'sa-vinhedo-1'") + .isEqualTo(OciRegion.SA_VINHEDO_1); assertThat(OciRegion.fromString("ca-montreal-1")) - .as("fromString should return CA_MONTREAL_1 for 'ca-montreal-1'") - .isEqualTo(OciRegion.CA_MONTREAL_1); + .as("fromString should return CA_MONTREAL_1 for 'ca-montreal-1'") + .isEqualTo(OciRegion.CA_MONTREAL_1); assertThat(OciRegion.fromString("ca-toronto-1")) - .as("fromString should return CA_TORONTO_1 for 'ca-toronto-1'") - .isEqualTo(OciRegion.CA_TORONTO_1); + .as("fromString should return CA_TORONTO_1 for 'ca-toronto-1'") + .isEqualTo(OciRegion.CA_TORONTO_1); assertThat(OciRegion.fromString("sa-santiago-1")) - .as("fromString should return SA_SANTIAGO_1 for 'sa-santiago-1'") - .isEqualTo(OciRegion.SA_SANTIAGO_1); + .as("fromString should return SA_SANTIAGO_1 for 'sa-santiago-1'") + .isEqualTo(OciRegion.SA_SANTIAGO_1); assertThat(OciRegion.fromString("sa-valparaiso-1")) - .as("fromString should return SA_VALPARAISO_1 for 'sa-valparaiso-1'") - .isEqualTo(OciRegion.SA_VALPARAISO_1); + .as("fromString should return SA_VALPARAISO_1 for 'sa-valparaiso-1'") + .isEqualTo(OciRegion.SA_VALPARAISO_1); assertThat(OciRegion.fromString("sa-bogota-1")) - .as("fromString should return SA_BOGOTA_1 for 'sa-bogota-1'") - .isEqualTo(OciRegion.SA_BOGOTA_1); + .as("fromString should return SA_BOGOTA_1 for 'sa-bogota-1'") + .isEqualTo(OciRegion.SA_BOGOTA_1); assertThat(OciRegion.fromString("eu-paris-1")) - .as("fromString should return EU_PARIS_1 for 'eu-paris-1'") - .isEqualTo(OciRegion.EU_PARIS_1); + .as("fromString should return EU_PARIS_1 for 'eu-paris-1'") + .isEqualTo(OciRegion.EU_PARIS_1); assertThat(OciRegion.fromString("eu-marseille-1")) - .as("fromString should return EU_MARSEILLE_1 for 'eu-marseille-1'") - .isEqualTo(OciRegion.EU_MARSEILLE_1); + .as("fromString should return EU_MARSEILLE_1 for 'eu-marseille-1'") + .isEqualTo(OciRegion.EU_MARSEILLE_1); assertThat(OciRegion.fromString("eu-frankfurt-1")) - .as("fromString should return EU_FRANKFURT_1 for 'eu-frankfurt-1'") - .isEqualTo(OciRegion.EU_FRANKFURT_1); + .as("fromString should return EU_FRANKFURT_1 for 'eu-frankfurt-1'") + .isEqualTo(OciRegion.EU_FRANKFURT_1); assertThat(OciRegion.fromString("ap-hyderabad-1")) - .as("fromString should return AP_HYDERABAD_1 for 'ap-hyderabad-1'") - .isEqualTo(OciRegion.AP_HYDERABAD_1); + .as("fromString should return AP_HYDERABAD_1 for 'ap-hyderabad-1'") + .isEqualTo(OciRegion.AP_HYDERABAD_1); assertThat(OciRegion.fromString("ap-mumbai-1")) - .as("fromString should return AP_MUMBAI_1 for 'ap-mumbai-1'") - .isEqualTo(OciRegion.AP_MUMBAI_1); + .as("fromString should return AP_MUMBAI_1 for 'ap-mumbai-1'") + .isEqualTo(OciRegion.AP_MUMBAI_1); assertThat(OciRegion.fromString("il-jerusalem-1")) - .as("fromString should return IL_JERUSALEM_1 for 'il-jerusalem-1'") - .isEqualTo(OciRegion.IL_JERUSALEM_1); + .as("fromString should return IL_JERUSALEM_1 for 'il-jerusalem-1'") + .isEqualTo(OciRegion.IL_JERUSALEM_1); assertThat(OciRegion.fromString("eu-milan-1")) - .as("fromString should return EU_MILAN_1 for 'eu-milan-1'") - .isEqualTo(OciRegion.EU_MILAN_1); + .as("fromString should return EU_MILAN_1 for 'eu-milan-1'") + .isEqualTo(OciRegion.EU_MILAN_1); assertThat(OciRegion.fromString("ap-osaka-1")) - .as("fromString should return AP_OSAKA_1 for 'ap-osaka-1'") - .isEqualTo(OciRegion.AP_OSAKA_1); + .as("fromString should return AP_OSAKA_1 for 'ap-osaka-1'") + .isEqualTo(OciRegion.AP_OSAKA_1); assertThat(OciRegion.fromString("ap-tokyo-1")) - .as("fromString should return AP_TOKYO_1 for 'ap-tokyo-1'") - .isEqualTo(OciRegion.AP_TOKYO_1); + .as("fromString should return AP_TOKYO_1 for 'ap-tokyo-1'") + .isEqualTo(OciRegion.AP_TOKYO_1); assertThat(OciRegion.fromString("mx-queretaro-1")) - .as("fromString should return MX_QUERETARO_1 for 'mx-queretaro-1'") - .isEqualTo(OciRegion.MX_QUERETARO_1); + .as("fromString should return MX_QUERETARO_1 for 'mx-queretaro-1'") + .isEqualTo(OciRegion.MX_QUERETARO_1); assertThat(OciRegion.fromString("mx-monterrey-1")) - .as("fromString should return MX_MONTERREY_1 for 'mx-monterrey-1'") - .isEqualTo(OciRegion.MX_MONTERREY_1); + .as("fromString should return MX_MONTERREY_1 for 'mx-monterrey-1'") + .isEqualTo(OciRegion.MX_MONTERREY_1); assertThat(OciRegion.fromString("eu-amsterdam-1")) - .as("fromString should return EU_AMSTERDAM_1 for 'eu-amsterdam-1'") - .isEqualTo(OciRegion.EU_AMSTERDAM_1); + .as("fromString should return EU_AMSTERDAM_1 for 'eu-amsterdam-1'") + .isEqualTo(OciRegion.EU_AMSTERDAM_1); assertThat(OciRegion.fromString("me-riyadh-1")) - .as("fromString should return ME_RIYADH_1 for 'me-riyadh-1'") - .isEqualTo(OciRegion.ME_RIYADH_1); + .as("fromString should return ME_RIYADH_1 for 'me-riyadh-1'") + .isEqualTo(OciRegion.ME_RIYADH_1); assertThat(OciRegion.fromString("me-jeddah-1")) - .as("fromString should return ME_JEDDAH_1 for 'me-jeddah-1'") - .isEqualTo(OciRegion.ME_JEDDAH_1); + .as("fromString should return ME_JEDDAH_1 for 'me-jeddah-1'") + .isEqualTo(OciRegion.ME_JEDDAH_1); assertThat(OciRegion.fromString("eu-jovanovac-1")) - .as("fromString should return EU_JOVANOVAC_1 for 'eu-jovanovac-1'") - .isEqualTo(OciRegion.EU_JOVANOVAC_1); + .as("fromString should return EU_JOVANOVAC_1 for 'eu-jovanovac-1'") + .isEqualTo(OciRegion.EU_JOVANOVAC_1); assertThat(OciRegion.fromString("singapore-1")) - .as("fromString should return SINGAPORE_1 for 'singapore-1'") - .isEqualTo(OciRegion.SINGAPORE_1); + .as("fromString should return SINGAPORE_1 for 'singapore-1'") + .isEqualTo(OciRegion.SINGAPORE_1); assertThat(OciRegion.fromString("ap-singapore-2")) - .as("fromString should return AP_SINGAPORE_2 for 'ap-singapore-2'") - .isEqualTo(OciRegion.AP_SINGAPORE_2); + .as("fromString should return AP_SINGAPORE_2 for 'ap-singapore-2'") + .isEqualTo(OciRegion.AP_SINGAPORE_2); assertThat(OciRegion.fromString("af-johannesburg-1")) - .as("fromString should return AF_JOHANNESBURG_1 for 'af-johannesburg-1'") - .isEqualTo(OciRegion.AF_JOHANNESBURG_1); + .as("fromString should return AF_JOHANNESBURG_1 for 'af-johannesburg-1'") + .isEqualTo(OciRegion.AF_JOHANNESBURG_1); assertThat(OciRegion.fromString("ap-seoul-1")) - .as("fromString should return AP_SEOUL_1 for 'ap-seoul-1'") - .isEqualTo(OciRegion.AP_SEOUL_1); + .as("fromString should return AP_SEOUL_1 for 'ap-seoul-1'") + .isEqualTo(OciRegion.AP_SEOUL_1); assertThat(OciRegion.fromString("ap-chuncheon-1")) - .as("fromString should return AP_CHUNCHEON_1 for 'ap-chuncheon-1'") - .isEqualTo(OciRegion.AP_CHUNCHEON_1); + .as("fromString should return AP_CHUNCHEON_1 for 'ap-chuncheon-1'") + .isEqualTo(OciRegion.AP_CHUNCHEON_1); assertThat(OciRegion.fromString("eu-madrid-1")) - .as("fromString should return EU_MADRID_1 for 'eu-madrid-1'") - .isEqualTo(OciRegion.EU_MADRID_1); + .as("fromString should return EU_MADRID_1 for 'eu-madrid-1'") + .isEqualTo(OciRegion.EU_MADRID_1); assertThat(OciRegion.fromString("eu-stockholm-1")) - .as("fromString should return EU_STOCKHOLM_1 for 'eu-stockholm-1'") - .isEqualTo(OciRegion.EU_STOCKHOLM_1); + .as("fromString should return EU_STOCKHOLM_1 for 'eu-stockholm-1'") + .isEqualTo(OciRegion.EU_STOCKHOLM_1); assertThat(OciRegion.fromString("eu-zurich-1")) - .as("fromString should return EU_ZURICH_1 for 'eu-zurich-1'") - .isEqualTo(OciRegion.EU_ZURICH_1); + .as("fromString should return EU_ZURICH_1 for 'eu-zurich-1'") + .isEqualTo(OciRegion.EU_ZURICH_1); assertThat(OciRegion.fromString("me-abudhabi-1")) - .as("fromString should return ME_ABUDHABI_1 for 'me-abudhabi-1'") - .isEqualTo(OciRegion.ME_ABUDHABI_1); + .as("fromString should return ME_ABUDHABI_1 for 'me-abudhabi-1'") + .isEqualTo(OciRegion.ME_ABUDHABI_1); assertThat(OciRegion.fromString("me-dubai-1")) - .as("fromString should return ME_DUBAI_1 for 'me-dubai-1'") - .isEqualTo(OciRegion.ME_DUBAI_1); + .as("fromString should return ME_DUBAI_1 for 'me-dubai-1'") + .isEqualTo(OciRegion.ME_DUBAI_1); assertThat(OciRegion.fromString("uk-london-1")) - .as("fromString should return UK_LONDON_1 for 'uk-london-1'") - .isEqualTo(OciRegion.UK_LONDON_1); + .as("fromString should return UK_LONDON_1 for 'uk-london-1'") + .isEqualTo(OciRegion.UK_LONDON_1); assertThat(OciRegion.fromString("uk-cardiff-1")) - .as("fromString should return UK_CARDIFF_1 for 'uk-cardiff-1'") - .isEqualTo(OciRegion.UK_CARDIFF_1); + .as("fromString should return UK_CARDIFF_1 for 'uk-cardiff-1'") + .isEqualTo(OciRegion.UK_CARDIFF_1); assertThat(OciRegion.fromString("us-ashburn-1")) - .as("fromString should return US_ASHBURN_1 for 'us-ashburn-1'") - .isEqualTo(OciRegion.US_ASHBURN_1); + .as("fromString should return US_ASHBURN_1 for 'us-ashburn-1'") + .isEqualTo(OciRegion.US_ASHBURN_1); assertThat(OciRegion.fromString("us-chicago-1")) - .as("fromString should return US_CHICAGO_1 for 'us-chicago-1'") - .isEqualTo(OciRegion.US_CHICAGO_1); + .as("fromString should return US_CHICAGO_1 for 'us-chicago-1'") + .isEqualTo(OciRegion.US_CHICAGO_1); assertThat(OciRegion.fromString("us-phoenix-1")) - .as("fromString should return US_PHOENIX_1 for 'us-phoenix-1'") - .isEqualTo(OciRegion.US_PHOENIX_1); + .as("fromString should return US_PHOENIX_1 for 'us-phoenix-1'") + .isEqualTo(OciRegion.US_PHOENIX_1); assertThat(OciRegion.fromString("us-sanjose-1")) - .as("fromString should return US_SANJOSE_1 for 'us-sanjose-1'") - .isEqualTo(OciRegion.US_SANJOSE_1); + .as("fromString should return US_SANJOSE_1 for 'us-sanjose-1'") + .isEqualTo(OciRegion.US_SANJOSE_1); } @Test public void valuesMethod_shouldContainAllOciActionsWithCorrectSize() { Collection values = OciRegion.values(); - + assertThat(values) - .as("Values should contain all specified OciRegions") - .contains( - OciRegion.AP_SYDNEY_1, - OciRegion.AP_MELBOURNE_1, - OciRegion.SA_SAOPAULO_1, - OciRegion.SA_VINHEDO_1, - OciRegion.CA_MONTREAL_1, - OciRegion.CA_TORONTO_1, - OciRegion.SA_SANTIAGO_1, - OciRegion.SA_VALPARAISO_1, - OciRegion.SA_BOGOTA_1, - OciRegion.EU_PARIS_1, - OciRegion.EU_MARSEILLE_1, - OciRegion.EU_FRANKFURT_1, - OciRegion.AP_HYDERABAD_1, - OciRegion.AP_MUMBAI_1, - OciRegion.IL_JERUSALEM_1, - OciRegion.EU_MILAN_1, - OciRegion.AP_OSAKA_1, - OciRegion.AP_TOKYO_1, - OciRegion.MX_QUERETARO_1, - OciRegion.MX_MONTERREY_1, - OciRegion.EU_AMSTERDAM_1, - OciRegion.ME_RIYADH_1, - OciRegion.ME_JEDDAH_1, - OciRegion.EU_JOVANOVAC_1, - OciRegion.SINGAPORE_1, - OciRegion.AP_SINGAPORE_2, - OciRegion.AF_JOHANNESBURG_1, - OciRegion.AP_SEOUL_1, - OciRegion.AP_CHUNCHEON_1, - OciRegion.EU_MADRID_1, - OciRegion.EU_STOCKHOLM_1, - OciRegion.EU_ZURICH_1, - OciRegion.ME_ABUDHABI_1, - OciRegion.ME_DUBAI_1, - OciRegion.UK_LONDON_1, - OciRegion.UK_CARDIFF_1, - OciRegion.US_ASHBURN_1, - OciRegion.US_CHICAGO_1, - OciRegion.US_PHOENIX_1, - OciRegion.US_SANJOSE_1); + .as("Values should contain all specified OciRegions") + .contains( + OciRegion.AP_SYDNEY_1, + OciRegion.AP_MELBOURNE_1, + OciRegion.SA_SAOPAULO_1, + OciRegion.SA_VINHEDO_1, + OciRegion.CA_MONTREAL_1, + OciRegion.CA_TORONTO_1, + OciRegion.SA_SANTIAGO_1, + OciRegion.SA_VALPARAISO_1, + OciRegion.SA_BOGOTA_1, + OciRegion.EU_PARIS_1, + OciRegion.EU_MARSEILLE_1, + OciRegion.EU_FRANKFURT_1, + OciRegion.AP_HYDERABAD_1, + OciRegion.AP_MUMBAI_1, + OciRegion.IL_JERUSALEM_1, + OciRegion.EU_MILAN_1, + OciRegion.AP_OSAKA_1, + OciRegion.AP_TOKYO_1, + OciRegion.MX_QUERETARO_1, + OciRegion.MX_MONTERREY_1, + OciRegion.EU_AMSTERDAM_1, + OciRegion.ME_RIYADH_1, + OciRegion.ME_JEDDAH_1, + OciRegion.EU_JOVANOVAC_1, + OciRegion.SINGAPORE_1, + OciRegion.AP_SINGAPORE_2, + OciRegion.AF_JOHANNESBURG_1, + OciRegion.AP_SEOUL_1, + OciRegion.AP_CHUNCHEON_1, + OciRegion.EU_MADRID_1, + OciRegion.EU_STOCKHOLM_1, + OciRegion.EU_ZURICH_1, + OciRegion.ME_ABUDHABI_1, + OciRegion.ME_DUBAI_1, + OciRegion.UK_LONDON_1, + OciRegion.UK_CARDIFF_1, + OciRegion.US_ASHBURN_1, + OciRegion.US_CHICAGO_1, + OciRegion.US_PHOENIX_1, + OciRegion.US_SANJOSE_1); } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedMessageBrokerTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedMessageBrokerTest.java index 2a4aad1e..177b81b1 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedMessageBrokerTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedMessageBrokerTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.saas; import org.junit.jupiter.api.Test; @@ -10,23 +9,23 @@ class UnmanagedMessageBrokerTest { @Test public void exceptionThrown_when_componentBuiltWithNullId() { assertThatThrownBy(() -> UnmanagedBrokerComponent.builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); } @Test public void exceptionThrown_when_componentBuiltWithEmptyValues() { assertThatThrownBy(() -> UnmanagedBrokerComponent.builder().withId("unmanaged-storage").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Secret Value has not been defined and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Secret Value has not been defined and it is required"); } @Test public void typeIsUnmanagedBrokerComponent_when_BuiltWithAllRequiredValues() { var secretValue = "aSecretValue"; var builder = UnmanagedBrokerComponent.builder() - .withId("unmanaged-storage") - .withSecretValue(secretValue); + .withId("unmanaged-storage") + .withSecretValue(secretValue); assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_BROKER); assertThat(builder.build().getSecretName()).isBlank(); @@ -38,15 +37,15 @@ public void secretName_IsNotEmpty_when_BuiltWithAllRequiredValues() { var secretName = "aSecretName"; var secretValue = "aSecretValue"; var builder = UnmanagedBrokerComponent.builder() - .withId("unmanaged-storage") - .withSecretName(secretName) - .withSecretValue(secretValue); + .withId("unmanaged-storage") + .withSecretName(secretName) + .withSecretValue(secretValue); assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_BROKER); assertThat(builder.build().getSecretName()).isNotBlank(); assertThat(builder.build().getSecretName()).isEqualTo(secretName); assertThat(builder.build().getSecretValue()).isEqualTo(secretValue); } - - + + } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponentTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponentTest.java index 18ae046f..018c5462 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponentTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedSecurityComponentTest.java @@ -9,23 +9,23 @@ class UnmanagedSecurityComponentTest { @Test public void exceptionThrown_when_componentBuiltWithNullId() { assertThatThrownBy(() -> UnmanagedSecurityComponent.builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); } @Test public void exceptionThrown_when_componentBuiltWithEmptyValues() { assertThatThrownBy(() -> UnmanagedSecurityComponent.builder().withId("external-security").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Secret Value has not been defined and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Secret Value has not been defined and it is required"); } @Test public void typeIsExternalSecurityComponent_when_BuiltWithAllRequiredValues() { var secretValue = "aSecretValue"; var builder = UnmanagedSecurityComponent.builder() - .withId("external-security") - .withSecretValue(secretValue); + .withId("external-security") + .withSecretValue(secretValue); assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_SECURITY); assertThat(builder.build().getSecretName()).isBlank(); @@ -37,10 +37,10 @@ public void secretName_IsNotEmpty_when_BuiltWithAllRequiredValues() { var secretName = "aSecretName"; var secretValue = "aSecretValue"; var builder = UnmanagedSecurityComponent.builder() - .withId("external-security") - .withSecretName(secretName) - .withSecretValue(secretValue); - + .withId("external-security") + .withSecretName(secretName) + .withSecretValue(secretValue); + assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_SECURITY); assertThat(builder.build().getSecretName()).isNotBlank(); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageAccountTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageAccountTest.java index 65e58691..abd47cd9 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageAccountTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/saas/UnmanagedStorageAccountTest.java @@ -1,4 +1,3 @@ - package com.yanchware.fractal.sdk.domain.livesystem.saas; import com.yanchware.fractal.sdk.utils.TestUtils; @@ -11,23 +10,23 @@ class UnmanagedStorageAccountTest { @Test public void exceptionThrown_when_componentBuiltWithNullId() { assertThatThrownBy(() -> UnmanagedStorageComponent.builder().withId("").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Component Id is illegal"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Component Id is illegal"); } @Test public void exceptionThrown_when_componentBuiltWithEmptyValues() { assertThatThrownBy(() -> UnmanagedStorageComponent.builder().withId("unmanaged-storage").build()). - isInstanceOf(IllegalArgumentException.class). - hasMessageContaining("Secret Value has not been defined and it is required"); + isInstanceOf(IllegalArgumentException.class). + hasMessageContaining("Secret Value has not been defined and it is required"); } @Test public void typeIsUnmanagedStorageComponent_when_BuiltWithAllRequiredValues() { var secretValue = "aSecretValue"; var builder = UnmanagedStorageComponent.builder() - .withId("unmanaged-storage") - .withSecretValue(secretValue); + .withId("unmanaged-storage") + .withSecretValue(secretValue); assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_STORAGE); assertThat(builder.build().getSecretName()).isBlank(); @@ -39,10 +38,10 @@ public void secretName_IsNotEmpty_when_componentBuiltWithSecretName() { var secretName = "aSecretName"; var secretValue = "aSecretValue"; var builder = UnmanagedStorageComponent.builder() - .withId("unmanaged-storage") - .withSecretName(secretName) - .withSecretValue(secretValue); - + .withId("unmanaged-storage") + .withSecretName(secretName) + .withSecretValue(secretValue); + assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_STORAGE); assertThat(builder.build().getSecretName()).isNotBlank(); @@ -55,12 +54,12 @@ public void json_IsNotEmpty_when_componentBuilt() { var secretName = "aSecretName"; var secretValue = "aSecretValue"; var builder = UnmanagedStorageComponent.builder() - .withId("unmanaged-storage") - .withSecretName(secretName) - .withSecretValue(secretValue); + .withId("unmanaged-storage") + .withSecretName(secretName) + .withSecretValue(secretValue); var json = TestUtils.getJsonRepresentation(builder.build()); - + assertThatCode(builder::build).doesNotThrowAnyException(); assertThat(builder.build().getType()).isEqualTo(SAAS_UNMANAGED_STORAGE); assertThat(json).isNotBlank(); diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemKubernetesComponentDtoTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemKubernetesComponentDtoTest.java index 484e5fa4..f6afdd97 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemKubernetesComponentDtoTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/livesystem/service/dtos/LiveSystemKubernetesComponentDtoTest.java @@ -10,123 +10,148 @@ import static org.assertj.core.api.Assertions.assertThat; public class LiveSystemKubernetesComponentDtoTest { - protected void assertCaaSComponents(KubernetesCluster k8sCluster, Map lsDtoMap) { - ProviderType provider = k8sCluster.getProvider(); - k8sCluster.getMonitoringInstances().forEach(component -> asserMonitoringComponent(lsDtoMap, (CaaSPrometheus) component, provider)); - k8sCluster.getApiGatewayInstances().forEach(component -> assertApiGatewayComponent(lsDtoMap, (CaaSAmbassador) component, provider)); - k8sCluster.getK8sWorkloadInstances().forEach(component -> assertK8sWorkloadComponent(lsDtoMap, component, provider)); - k8sCluster.getServiceMeshSecurityInstances().forEach(component -> assertSericeMeshSecurityComponent(lsDtoMap, component, provider)); - k8sCluster.getLoggingInstances().forEach(component -> assertLoggingComponent(lsDtoMap, (CaaSElasticLogging) component, provider)); - } + protected void assertCaaSComponents(KubernetesCluster k8sCluster, Map lsDtoMap) { + ProviderType provider = k8sCluster.getProvider(); + k8sCluster.getMonitoringInstances().forEach(component -> asserMonitoringComponent(lsDtoMap, + (CaaSPrometheus) component, provider)); + k8sCluster.getApiGatewayInstances().forEach(component -> assertApiGatewayComponent(lsDtoMap, + (CaaSAmbassador) component, provider)); + k8sCluster.getK8sWorkloadInstances().forEach(component -> assertK8sWorkloadComponent(lsDtoMap, component, + provider)); + k8sCluster.getServiceMeshSecurityInstances().forEach(component -> assertSericeMeshSecurityComponent(lsDtoMap, + component, provider)); + k8sCluster.getLoggingInstances().forEach(component -> assertLoggingComponent(lsDtoMap, + (CaaSElasticLogging) component, provider)); + } - private void assertLoggingComponent(Map lsDtoMap, CaaSElasticLogging component, ProviderType provider) { - var dto = lsDtoMap.get(component.getId().getValue()); - assertGenericComponent(dto, component, ComponentType.CAAS_ELASTIC_LOGGING.getId()); - assertThat(dto.getProvider()).isEqualTo(provider); - assertThat(dto.getParameters()) - .extracting( - "containerPlatform", - "cpu", - "elasticInstances", - "elasticVersion", - "isApmRequired", - "isKibanaRequired", - "memory", - "namespace", - "storage", - "storageClassName") - .containsExactly( - component.getContainerPlatform(), - component.getCpu(), - component.getElasticInstances(), - component.getElasticVersion(), - component.isApmRequired(), - component.isKibanaRequired(), - component.getMemory(), - component.getNamespace(), - component.getStorage(), - component.getStorageClassName()); - } + private void assertLoggingComponent( + Map lsDtoMap, + CaaSElasticLogging component, + ProviderType provider) + { + var dto = lsDtoMap.get(component.getId().getValue()); + assertGenericComponent(dto, component, ComponentType.CAAS_ELASTIC_LOGGING.getId()); + assertThat(dto.getProvider()).isEqualTo(provider); + assertThat(dto.getParameters()) + .extracting( + "containerPlatform", + "cpu", + "elasticInstances", + "elasticVersion", + "isApmRequired", + "isKibanaRequired", + "memory", + "namespace", + "storage", + "storageClassName") + .containsExactly( + component.getContainerPlatform(), + component.getCpu(), + component.getElasticInstances(), + component.getElasticVersion(), + component.isApmRequired(), + component.isKibanaRequired(), + component.getMemory(), + component.getNamespace(), + component.getStorage(), + component.getStorageClassName()); + } - private void assertSericeMeshSecurityComponent(Map lsDtoMap, CaaSServiceMeshSecurityImpl component, ProviderType provider) { - var dto = lsDtoMap.get(component.getId().getValue()); - assertGenericComponent(dto, component, ComponentType.CAAS_OCELOT.getId()); - assertThat(dto.getProvider()).isEqualTo(provider); - assertThat(dto.getParameters()) - .extracting( - "containerPlatform", - "cookieMaxAgeSec", - "corsOrigins", - "host", - "hostOwnerEmail", - "namespace", - "pathPrefix") - .containsExactly( - component.getContainerPlatform(), - component.getCookieMaxAgeSec(), - component.getCorsOrigins(), - component.getHost(), - component.getHostOwnerEmail(), - component.getNamespace(), - component.getPathPrefix()); - } + private void assertSericeMeshSecurityComponent( + Map lsDtoMap, + CaaSServiceMeshSecurityImpl component, + ProviderType provider) + { + var dto = lsDtoMap.get(component.getId().getValue()); + assertGenericComponent(dto, component, ComponentType.CAAS_OCELOT.getId()); + assertThat(dto.getProvider()).isEqualTo(provider); + assertThat(dto.getParameters()) + .extracting( + "containerPlatform", + "cookieMaxAgeSec", + "corsOrigins", + "host", + "hostOwnerEmail", + "namespace", + "pathPrefix") + .containsExactly( + component.getContainerPlatform(), + component.getCookieMaxAgeSec(), + component.getCorsOrigins(), + component.getHost(), + component.getHostOwnerEmail(), + component.getNamespace(), + component.getPathPrefix()); + } - private void assertK8sWorkloadComponent(Map lsDtoMap, CaaSKubernetesWorkload component, ProviderType provider) { - var dto = lsDtoMap.get(component.getId().getValue()); - assertGenericComponent(dto, component, ComponentType.CAAS_K8S_WORKLOAD.getId()); - assertThat(dto.getProvider()).isEqualTo(provider); - assertThat(dto.getParameters()) - .extracting( - "branchName", - "containerPlatform", - "namespace", - "privateSSHKeyPassphraseEnvironmentSecretShortName", - "privateSSHKeyEnvironmentSecretShortName", - "repoId", - "roles") - .containsExactly( - component.getBranchName(), - component.getContainerPlatform(), - component.getNamespace(), - component.getPrivateSSHKeyPassphraseEnvironmentSecretShortName(), - component.getPrivateSSHKeyEnvironmentSecretShortName(), - component.getRepoId(), - component.getRoles()); - } + private void assertK8sWorkloadComponent( + Map lsDtoMap, + CaaSKubernetesWorkload component, + ProviderType provider) + { + var dto = lsDtoMap.get(component.getId().getValue()); + assertGenericComponent(dto, component, ComponentType.CAAS_K8S_WORKLOAD.getId()); + assertThat(dto.getProvider()).isEqualTo(provider); + assertThat(dto.getParameters()) + .extracting( + "branchName", + "containerPlatform", + "namespace", + "privateSSHKeyPassphraseEnvironmentSecretShortName", + "privateSSHKeyEnvironmentSecretShortName", + "repoId", + "roles") + .containsExactly( + component.getBranchName(), + component.getContainerPlatform(), + component.getNamespace(), + component.getPrivateSSHKeyPassphraseEnvironmentSecretShortName(), + component.getPrivateSSHKeyEnvironmentSecretShortName(), + component.getRepoId(), + component.getRoles()); + } - private void assertApiGatewayComponent(Map lsDtoMap, CaaSAmbassador component, ProviderType provider) { - var dto = lsDtoMap.get(component.getId().getValue()); - assertGenericComponent(dto, component, ComponentType.CAAS_AMBASSADOR.getId()); - assertThat(dto.getProvider()).isEqualTo(provider); - assertThat(dto.getParameters()) - .extracting( - "acmeProviderAuthority", - "containerPlatform", - "host", - "hostOwnerEmail", - "namespace", - "tlsSecretName") - .containsExactly( - component.getAcmeProviderAuthority(), - component.getContainerPlatform(), - component.getHost(), - component.getHostOwnerEmail(), - component.getNamespace(), - component.getTlsSecretName()); - } + private void assertApiGatewayComponent( + Map lsDtoMap, + CaaSAmbassador component, + ProviderType provider) + { + var dto = lsDtoMap.get(component.getId().getValue()); + assertGenericComponent(dto, component, ComponentType.CAAS_AMBASSADOR.getId()); + assertThat(dto.getProvider()).isEqualTo(provider); + assertThat(dto.getParameters()) + .extracting( + "acmeProviderAuthority", + "containerPlatform", + "host", + "hostOwnerEmail", + "namespace", + "tlsSecretName") + .containsExactly( + component.getAcmeProviderAuthority(), + component.getContainerPlatform(), + component.getHost(), + component.getHostOwnerEmail(), + component.getNamespace(), + component.getTlsSecretName()); + } - private void asserMonitoringComponent(Map lsDtoMap, CaaSPrometheus component, ProviderType provider) { - var dto = lsDtoMap.get(component.getId().getValue()); - assertGenericComponent(dto, component, ComponentType.CAAS_PROMETHEUS.getId()); - assertThat(dto.getProvider()).isEqualTo(provider); - assertThat(dto.getParameters()) - .extracting( - "apiGatewayUrl", - "containerPlatform", - "namespace") - .containsExactly( - component.getApiGatewayUrl(), - component.getContainerPlatform(), - component.getNamespace()); - } + private void asserMonitoringComponent( + Map lsDtoMap, + CaaSPrometheus component, + ProviderType provider) + { + var dto = lsDtoMap.get(component.getId().getValue()); + assertGenericComponent(dto, component, ComponentType.CAAS_PROMETHEUS.getId()); + assertThat(dto.getProvider()).isEqualTo(provider); + assertThat(dto.getParameters()) + .extracting( + "apiGatewayUrl", + "containerPlatform", + "namespace") + .containsExactly( + component.getApiGatewayUrl(), + component.getContainerPlatform(), + component.getNamespace()); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdNegativeTests.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdNegativeTests.java index 0161bace..f79c372f 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdNegativeTests.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdNegativeTests.java @@ -19,21 +19,22 @@ public static Stream badInput() { var toLongBadComponentId = getRandomString(MAX_LENGTH + 2, "--"); return Stream.of( - Arguments.of(null, List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "null"))), - Arguments.of("", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, ""))), - Arguments.of(" ", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, " "))), - Arguments.of("\t", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "\t"))), - Arguments.of("\n", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "\n"))), - Arguments.of("\r", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "\r"))), - Arguments.of("1test-compo", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "1test-compo"))), - Arguments.of("1test\ncompo", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "1test\ncompo"))), - Arguments.of(toLongComponentId, List.of(String.format(ComponentId.ID_LENGTH_MISMATCH_TEMPLATE, toLongComponentId))), - Arguments.of(toLongBadComponentId, List.of( - String.format(ComponentId.ILLEGAL_ID_TEMPLATE, toLongBadComponentId), - String.format(ComponentId.ID_LENGTH_MISMATCH_TEMPLATE, toLongBadComponentId))), - Arguments.of("a-", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "a-"), - String.format(ComponentId.ID_LENGTH_MISMATCH_TEMPLATE, "a-"))), - Arguments.of("a-strange--id", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "a-strange--id")))); + Arguments.of(null, List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "null"))), + Arguments.of("", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, ""))), + Arguments.of(" ", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, " "))), + Arguments.of("\t", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "\t"))), + Arguments.of("\n", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "\n"))), + Arguments.of("\r", List.of(String.format(ComponentId.ID_NULL_OR_EMPTY_TEMPLATE, "\r"))), + Arguments.of("1test-compo", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "1test-compo"))), + Arguments.of("1test\ncompo", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "1test\ncompo"))), + Arguments.of(toLongComponentId, List.of(String.format(ComponentId.ID_LENGTH_MISMATCH_TEMPLATE, + toLongComponentId))), + Arguments.of(toLongBadComponentId, List.of( + String.format(ComponentId.ILLEGAL_ID_TEMPLATE, toLongBadComponentId), + String.format(ComponentId.ID_LENGTH_MISMATCH_TEMPLATE, toLongBadComponentId))), + Arguments.of("a-", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "a-"), + String.format(ComponentId.ID_LENGTH_MISMATCH_TEMPLATE, "a-"))), + Arguments.of("a-strange--id", List.of(String.format(ComponentId.ILLEGAL_ID_TEMPLATE, "a-strange--id")))); } @ParameterizedTest @@ -45,7 +46,7 @@ public void validationFails_when_badInput(String value, Collection expec private static String getRandomString(Integer length, String append) { return StringUtils.isBlank(append) - ? RandomStringUtils.randomAlphabetic(length).toLowerCase() - : String.format("%s%s", RandomStringUtils.randomAlphabetic(length), append).toLowerCase(); + ? RandomStringUtils.randomAlphabetic(length).toLowerCase() + : String.format("%s%s", RandomStringUtils.randomAlphabetic(length), append).toLowerCase(); } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdPositiveTests.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdPositiveTests.java index 4a08c92e..d12a5a02 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdPositiveTests.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/domain/values/ComponentIdPositiveTests.java @@ -9,23 +9,22 @@ import static org.assertj.core.api.Assertions.assertThat; -public class ComponentIdPositiveTests -{ - public static Stream positiveInput() { - return Stream.of( - Arguments.of("abcd"), - Arguments.of("a-c-d"), - Arguments.of("a-nice-id"), - Arguments.of("id2"), - Arguments.of("a2-id"), - Arguments.of("a2-2")); - } +public class ComponentIdPositiveTests { + public static Stream positiveInput() { + return Stream.of( + Arguments.of("abcd"), + Arguments.of("a-c-d"), + Arguments.of("a-nice-id"), + Arguments.of("id2"), + Arguments.of("a2-id"), + Arguments.of("a2-2")); + } - @ParameterizedTest - @MethodSource("positiveInput") - public void validationFails_when_badInput(String value) - { - Collection errors = ComponentId.validate(value); - assertThat(errors).isEmpty(); - } + @ParameterizedTest + @MethodSource("positiveInput") + public void validationFails_when_badInput(String value) + { + Collection errors = ComponentId.validate(value); + assertThat(errors).isEmpty(); + } } diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/CollectionUtilsTest.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/CollectionUtilsTest.java index 14351e6d..601922e5 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/CollectionUtilsTest.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/CollectionUtilsTest.java @@ -9,13 +9,13 @@ class CollectionUtilsTest { - @Test - public void isBlank_when_collectionIsNull() { - assertThat(isBlank(null)).isTrue(); - } + @Test + public void isBlank_when_collectionIsNull() { + assertThat(isBlank(null)).isTrue(); + } - @Test - public void isBlank_when_collectionIsEmpty() { - assertThat(isBlank(new ArrayList<>())).isTrue(); - } + @Test + public void isBlank_when_collectionIsEmpty() { + assertThat(isBlank(new ArrayList<>())).isTrue(); + } } \ No newline at end of file diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/LocalSdkConfiguration.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/LocalSdkConfiguration.java index c4314f58..17869aa8 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/LocalSdkConfiguration.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/LocalSdkConfiguration.java @@ -47,7 +47,9 @@ public URI getLiveSystemEndpoint() { @SneakyThrows @Override - public URI getEnvironmentsEndpoint() { return new URI(httpBaseUrl + "/environments"); } + public URI getEnvironmentsEndpoint() { + return new URI(httpBaseUrl + "/environments"); + } @Override public String getAwsAccessKeyId() { diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/StringHandler.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/StringHandler.java index 6278e31c..0cbf045a 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/StringHandler.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/StringHandler.java @@ -8,7 +8,7 @@ public class StringHandler { public static String getStringFromInputStream(InputStream inputStream, String delimiter) { return new BufferedReader(new InputStreamReader(inputStream)) - .lines().parallel().collect(Collectors.joining(delimiter)); + .lines().parallel().collect(Collectors.joining(delimiter)); } public static String getStringFromInputStream(InputStream inputStream) { diff --git a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/TestUtils.java b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/TestUtils.java index 8b95a335..f67ac4a2 100644 --- a/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/TestUtils.java +++ b/fractal.sdk/src/test/java/com/yanchware/fractal/sdk/utils/TestUtils.java @@ -6,11 +6,11 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.yanchware.fractal.sdk.domain.Component; import com.yanchware.fractal.sdk.domain.ComponentLink; -import com.yanchware.fractal.sdk.domain.blueprint.FractalIdValue; import com.yanchware.fractal.sdk.domain.environment.Environment; import com.yanchware.fractal.sdk.domain.environment.EnvironmentIdValue; import com.yanchware.fractal.sdk.domain.environment.EnvironmentType; import com.yanchware.fractal.sdk.domain.environment.ManagementEnvironment; +import com.yanchware.fractal.sdk.domain.fractal.FractalIdValue; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemAggregate; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemIdValue; import com.yanchware.fractal.sdk.domain.livesystem.LiveSystemsFactory; @@ -68,101 +68,101 @@ public class TestUtils { public static AzureKubernetesServiceBuilder getAksBuilder() { return AzureKubernetesService.builder() - .withId("aks-1") - .withDescription("Test AKS cluster") - .withDisplayName("AKS #1") - .withRegion(WEST_EUROPE) - .withServiceIpRange("10.2.0.0/16") - .withPodIpRange("10.3.0.0/16") - .withVnetAddressSpaceIpRange("10.1.0.0/22") - .withVnetSubnetAddressIpRange("10.1.0.0/22") - .withExternalWorkspaceResourceId("workplaceResourceId") - .withOutboundIp(AzureOutboundIp.builder() - .withName("fractal") - .withAzureResourceGroup(AzureResourceGroup.builder() - .withName("group") - .withRegion(WEST_EUROPE) - .build()) - .build()) - .withAddonProfiles(List.of( - AzureKubernetesAddonProfile.builder() - .withAddonToEnable(AzureKubernetesAddon.AZURE_POLICY) - .build(), - AzureKubernetesAddonProfile.builder() - .withAddonToEnable(AzureKubernetesAddon.AZURE_KEYVAULT_SECRETS_PROVIDER) - .build())) - .withNodePool(AzureNodePool.builder() - .withName("akslinux") - .withDiskSizeGb(35) - .withMachineType(STANDARD_B2S) - .withMaxNodeCount(3) - .withInitialNodeCount(1) - .withMaxSurge(1) - .withMinNodeCount(1) - .withMaxPodsPerNode(100) - .withOsType(LINUX) - .withOsSku(AzureOsSku.AZURE_LINUX) - .withAutoscalingEnabled(true) - .withLabels(Map.of("env", "test")) - .build()) - .withPriorityClass(PriorityClass.builder() - .withName("fractal-critical") - .withDescription("Used for Fractal Components") - .withPreemptionPolicy(PREEMPT_LOWER_PRIORITY) - .withValue(1_000_000_000) - .build()) - .withPriorityClass(PriorityClass.builder() - .withName("fractal-critical.2") - .withDescription("Used for Fractal Components") - .withPreemptionPolicy(NEVER) - .withValue(999_999_000) - .build()) - .withPodManagedIdentity(PodManagedIdentity.builder() - .withName("azure-pod-identity") - .withNamespace("kube-system") - .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) - .withEnable(true) - .withAllowNetworkPluginKubeNet(true) - .build()) - .withRole(RoleAssignment.builder() - .withRoleName("AcrPull") - .withScope("Role scope to ACR") - .build()) - .withAddonProfile(AzureKubernetesAddonProfile.builder() - .withAddonToEnable(AzureKubernetesAddon.MONITORING) - .build()) - .withKubernetesVersion("1.1.1") - .withActiveDirectoryProfile(AzureActiveDirectoryProfile.builder() - .withAdminGroupObjectIDs(List.of(UUID.randomUUID().toString())) - .build()) - .withWindowsAdminUsername("unit-test") - .withWorkloadIdentityEnabled(true) - .withTag("tag1", "tag1Value") - .withTag("tag2", "tag2Value"); + .withId("aks-1") + .withDescription("Test AKS cluster") + .withDisplayName("AKS #1") + .withRegion(WEST_EUROPE) + .withServiceIpRange("10.2.0.0/16") + .withPodIpRange("10.3.0.0/16") + .withVnetAddressSpaceIpRange("10.1.0.0/22") + .withVnetSubnetAddressIpRange("10.1.0.0/22") + .withExternalWorkspaceResourceId("workplaceResourceId") + .withOutboundIp(AzureOutboundIp.builder() + .withName("fractal") + .withAzureResourceGroup(AzureResourceGroup.builder() + .withName("group") + .withRegion(WEST_EUROPE) + .build()) + .build()) + .withAddonProfiles(List.of( + AzureKubernetesAddonProfile.builder() + .withAddonToEnable(AzureKubernetesAddon.AZURE_POLICY) + .build(), + AzureKubernetesAddonProfile.builder() + .withAddonToEnable(AzureKubernetesAddon.AZURE_KEYVAULT_SECRETS_PROVIDER) + .build())) + .withNodePool(AzureNodePool.builder() + .withName("akslinux") + .withDiskSizeGb(35) + .withMachineType(STANDARD_B2S) + .withMaxNodeCount(3) + .withInitialNodeCount(1) + .withMaxSurge(1) + .withMinNodeCount(1) + .withMaxPodsPerNode(100) + .withOsType(LINUX) + .withOsSku(AzureOsSku.AZURE_LINUX) + .withAutoscalingEnabled(true) + .withLabels(Map.of("env", "test")) + .build()) + .withPriorityClass(PriorityClass.builder() + .withName("fractal-critical") + .withDescription("Used for Fractal Components") + .withPreemptionPolicy(PREEMPT_LOWER_PRIORITY) + .withValue(1_000_000_000) + .build()) + .withPriorityClass(PriorityClass.builder() + .withName("fractal-critical.2") + .withDescription("Used for Fractal Components") + .withPreemptionPolicy(NEVER) + .withValue(999_999_000) + .build()) + .withPodManagedIdentity(PodManagedIdentity.builder() + .withName("azure-pod-identity") + .withNamespace("kube-system") + .withExceptionPodLabels(Map.of("app", "mic", "component", "mic")) + .withEnable(true) + .withAllowNetworkPluginKubeNet(true) + .build()) + .withRole(RoleAssignment.builder() + .withRoleName("AcrPull") + .withScope("Role scope to ACR") + .build()) + .withAddonProfile(AzureKubernetesAddonProfile.builder() + .withAddonToEnable(AzureKubernetesAddon.MONITORING) + .build()) + .withKubernetesVersion("1.1.1") + .withActiveDirectoryProfile(AzureActiveDirectoryProfile.builder() + .withAdminGroupObjectIDs(List.of(UUID.randomUUID().toString())) + .build()) + .withWindowsAdminUsername("unit-test") + .withWorkloadIdentityEnabled(true) + .withTag("tag1", "tag1Value") + .withTag("tag2", "tag2Value"); } public static GoogleKubernetesEngineBuilder getGkeBuilder() { return GoogleKubernetesEngine.builder() - .withId("gke-1") - .withDescription("Test GKE cluster") - .withDisplayName("GKE #1") - .withRegion(EUROPE_WEST1) - .withNetworkName("network-host") - .withSubnetworkName("compute-tier-1") - .withPodsRangeName("tier-1-pods") - .withPodIpRange("10.3.0.0/16") - .withServicesRangeName("tier-1-services") - .withServiceIpRange("10.2.0.0/16") - .withSubnetworkIpRange("10.0.4.0/22") - .withNodePool(GcpNodePool.builder() - .withName("gcpnode") - .withDiskSizeGb(35) - .withInitialNodeCount(1) - .withMachineType(E2_STANDARD2) - .withMaxNodeCount(3) - .withMaxSurge(1) - .withMinNodeCount(1) - .build()); + .withId("gke-1") + .withDescription("Test GKE cluster") + .withDisplayName("GKE #1") + .withRegion(EUROPE_WEST1) + .withNetworkName("network-host") + .withSubnetworkName("compute-tier-1") + .withPodsRangeName("tier-1-pods") + .withPodIpRange("10.3.0.0/16") + .withServicesRangeName("tier-1-services") + .withServiceIpRange("10.2.0.0/16") + .withSubnetworkIpRange("10.0.4.0/22") + .withNodePool(GcpNodePool.builder() + .withName("gcpnode") + .withDiskSizeGb(35) + .withInitialNodeCount(1) + .withMachineType(E2_STANDARD2) + .withMaxNodeCount(3) + .withMaxSurge(1) + .withMinNodeCount(1) + .build()); } public static AwsElasticKubernetesServiceBuilder getEksBuilder() { @@ -197,24 +197,24 @@ public static OciContainerEngineForKubernetesBuilder getOkeBuilder() { public static AzureKubernetesService getAksExample() { return getAksBuilder() - .withK8sWorkload(getK8sWorkloadExample()) - .withMonitoring(getPrometheusExample()) - .withAPIGateway(getAmbassadorExample()) - .withServiceMeshSecurity(getOcelotExample()) - .withLogging(getElasticLoggingExample()) - .withDocumentDB(getElasticDataStoreExample()) - .build(); + .withK8sWorkload(getK8sWorkloadExample()) + .withMonitoring(getPrometheusExample()) + .withAPIGateway(getAmbassadorExample()) + .withServiceMeshSecurity(getOcelotExample()) + .withLogging(getElasticLoggingExample()) + .withDocumentDB(getElasticDataStoreExample()) + .build(); } public static GoogleKubernetesEngine getGkeExample() { return getGkeBuilder() - .withK8sWorkload(getK8sWorkloadExample()) - .withMonitoring(getPrometheusExample()) - .withAPIGateway(getAmbassadorExample()) - .withServiceMeshSecurity(getOcelotExample()) - .withLogging(getElasticLoggingExample()) - .withDocumentDB(getElasticDataStoreExample()) - .build(); + .withK8sWorkload(getK8sWorkloadExample()) + .withMonitoring(getPrometheusExample()) + .withAPIGateway(getAmbassadorExample()) + .withServiceMeshSecurity(getOcelotExample()) + .withLogging(getElasticLoggingExample()) + .withDocumentDB(getElasticDataStoreExample()) + .build(); } public static OciContainerEngineForKubernetes getOkeExample() { @@ -252,180 +252,180 @@ public static AwsElasticKubernetesService getEksExample() { public static CaaSKubernetesWorkload getK8sWorkloadExample() { return CaaSKubernetesWorkload.builder() - .withId("fractal-svc") - .withDescription("Fractal Service on K8S") - .withDisplayName("Fractal SVC") - .withNamespace("fractal") - .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("fractal-private-passphrase") - .withPrivateSSHKeyEnvironmentSecretShortName("fractal-private-ssh") - .withSSHRepositoryURI("ssh-uri") - .withRepoId("fractal-svc-id") - .withBranchName("env/fractal-test") - .withRoles(List.of( - CustomWorkloadRole.builder().withName("datastore").withScope("user").build(), - CustomWorkloadRole.builder().withName("pubsub").withScope("editor").build(), - CustomWorkloadRole.builder().withName("ocelot").withScope("user").withRoleType(RoleType.OCELOT_ROLE).build())) - .build(); + .withId("fractal-svc") + .withDescription("Fractal Service on K8S") + .withDisplayName("Fractal SVC") + .withNamespace("fractal") + .withPrivateSSHKeyPassphraseEnvironmentSecretShortName("fractal-private-passphrase") + .withPrivateSSHKeyEnvironmentSecretShortName("fractal-private-ssh") + .withSSHRepositoryURI("ssh-uri") + .withRepoId("fractal-svc-id") + .withBranchName("env/fractal-test") + .withRoles(List.of( + CustomWorkloadRole.builder().withName("datastore").withScope("user").build(), + CustomWorkloadRole.builder().withName("pubsub").withScope("editor").build(), + CustomWorkloadRole.builder().withName("ocelot").withScope("user").withRoleType(RoleType.OCELOT_ROLE).build())) + .build(); } public static CaaSPrometheus getPrometheusExample() { return CaaSPrometheus.builder() - .withId("prometheus") - .withDescription("Prometheus monitoring") - .withDisplayName("Prometheus") - .withNamespace("monitoring") - .withApiGatewayUrl("apiGatewayUrl") - .build(); + .withId("prometheus") + .withDescription("Prometheus monitoring") + .withDisplayName("Prometheus") + .withNamespace("monitoring") + .withApiGatewayUrl("apiGatewayUrl") + .build(); } public static CaaSAmbassador getAmbassadorExample() { return CaaSAmbassador.builder() - .withId("ambassador") - .withDescription("Ambassador") - .withDisplayName("Ambassador") - .withNamespace("ambassador") - .withHost("host") - .withHostOwnerEmail("hostOwnerEmail") - .withAcmeProviderAuthority("authority") - .withTlsSecretName("tls") - .build(); + .withId("ambassador") + .withDescription("Ambassador") + .withDisplayName("Ambassador") + .withNamespace("ambassador") + .withHost("host") + .withHostOwnerEmail("hostOwnerEmail") + .withAcmeProviderAuthority("authority") + .withTlsSecretName("tls") + .build(); } public static CaaSOcelot getOcelotExample() { return CaaSOcelot.builder() - .withId("ocelot") - .withDescription("Security with Ocelot") - .withDisplayName("Ocelot") - .withNamespace("security") - .withHost("api.fractal-arch.org") - .withHostOwnerEmail("hello@fractal-arch.org") - .withCookieMaxAgeSec(3600) - .withCorsOrigins("https://fractal-arch.org") - .withPathPrefix("/api/*") - .withLink(ComponentLink.builder() - .withComponentId("db-1") - .build()) - .build(); + .withId("ocelot") + .withDescription("Security with Ocelot") + .withDisplayName("Ocelot") + .withNamespace("security") + .withHost("api.fractal-arch.org") + .withHostOwnerEmail("hello@fractal-arch.org") + .withCookieMaxAgeSec(3600) + .withCorsOrigins("https://fractal-arch.org") + .withPathPrefix("/api/*") + .withLink(ComponentLink.builder() + .withComponentId("db-1") + .build()) + .build(); } public static CaaSElasticLogging getElasticLoggingExample() { return CaaSElasticLogging.builder() - .withId("elastic-logging") - .withDescription("Elastic Logging") - .withDisplayName("Elastic Logging") - .withNamespace("logging") - .withAPM(true) - .withKibana(true) - .withElasticVersion("1") - .withInstances(3) - .withStorage("250Gi") - .withStorageClassName("standard") - .withMemory(3) - .withCpu(3) - .build(); + .withId("elastic-logging") + .withDescription("Elastic Logging") + .withDisplayName("Elastic Logging") + .withNamespace("logging") + .withAPM(true) + .withKibana(true) + .withElasticVersion("1") + .withInstances(3) + .withStorage("250Gi") + .withStorageClassName("standard") + .withMemory(3) + .withCpu(3) + .build(); } public static CaaSElasticDataStore getElasticDataStoreExample() { return CaaSElasticDataStore.builder() - .withId("elastic-data") - .withDescription("Elastic Data Store") - .withDisplayName("Elastic Data Store") - .withNamespace("elastic-data") - .withKibana(false) - .withElasticVersion("1") - .withInstances(3) - .withStorage("250Gi") - .withStorageClassName("ssd") - .withMemory(3) - .withCpu(3) - .build(); + .withId("elastic-data") + .withDescription("Elastic Data Store") + .withDisplayName("Elastic Data Store") + .withNamespace("elastic-data") + .withKibana(false) + .withElasticVersion("1") + .withInstances(3) + .withStorage("250Gi") + .withStorageClassName("ssd") + .withMemory(3) + .withCpu(3) + .build(); } public static AzurePostgreSqlDbms getAzurePostgresExample() { var postgreSqlDatabase = AzurePostgreSqlDatabase.builder() - .withId("db-1") - .withDisplayName("db-1") - .withName("db") - .withSchema("test") - .build(); + .withId("db-1") + .withDisplayName("db-1") + .withName("db") + .withSchema("test") + .build(); return AzurePostgreSqlDbms.builder() - .withId("dbpg") - .withName("db-name") - .withDescription("PostgreSQL") - .withDisplayName("PostgreSQL") - .withRegion(WEST_EUROPE) - .withRootUser("rootUser") - .withSkuName(B_GEN5_1) - .withStorageAutoGrow(ENABLED) - .withStorageGb(5) - .withBackupRetentionDays(12) - .withDatabase(postgreSqlDatabase) - .withDatabase(getAzurePostgresDbExample()) - .build(); + .withId("dbpg") + .withName("db-name") + .withDescription("PostgreSQL") + .withDisplayName("PostgreSQL") + .withRegion(WEST_EUROPE) + .withRootUser("rootUser") + .withSkuName(B_GEN5_1) + .withStorageAutoGrow(ENABLED) + .withStorageGb(5) + .withBackupRetentionDays(12) + .withDatabase(postgreSqlDatabase) + .withDatabase(getAzurePostgresDbExample()) + .build(); } public static GcpPostgreSqlDbms getGcpPostgresExample() { return GcpPostgreSqlDbms.builder() - .withId("dbpg") - .withDescription("PostgreSQL") - .withDisplayName("PostgreSQL") - .withRegion(EUROPE_WEST1) - .withNetwork("network") - .withPeeringNetworkAddress("address") - .withPeeringNetworkAddressDescription("address-desc") - .withPeeringNetworkName("network-name") - .withPeeringNetworkPrefix("network-prefix") - .withDatabase(getGcpPostgresDbExample()) - .lock() - .build(); + .withId("dbpg") + .withDescription("PostgreSQL") + .withDisplayName("PostgreSQL") + .withRegion(EUROPE_WEST1) + .withNetwork("network") + .withPeeringNetworkAddress("address") + .withPeeringNetworkAddressDescription("address-desc") + .withPeeringNetworkName("network-name") + .withPeeringNetworkPrefix("network-prefix") + .withDatabase(getGcpPostgresDbExample()) + .lock() + .build(); } public static AzurePostgreSqlDatabase getAzurePostgresDbExample() { return AzurePostgreSqlDatabase.builder() - .withId("db-2") - .withDisplayName("db-2") - .withName("db2") - .withSchema("test") - .withLink(getComponentLink()) - .build(); + .withId("db-2") + .withDisplayName("db-2") + .withName("db2") + .withSchema("test") + .withLink(getComponentLink()) + .build(); } public static GcpPostgreSqlDatabase getGcpPostgresDbExample() { return GcpPostgreSqlDatabase.builder() - .withId("db-2") - .withDisplayName("db-2") - .withName("db2") - .withSchema("test") - .withLink(getComponentLink()) - .build(); + .withId("db-2") + .withDisplayName("db-2") + .withName("db2") + .withSchema("test") + .withLink(getComponentLink()) + .build(); } public static Environment getEnvExample() { return ManagementEnvironment.builder() - .withId(new EnvironmentIdValue( - EnvironmentType.PERSONAL, - UUID.fromString("2e114308-14ec-4d77-b610-490324fa1844"), - "test")) - .withResourceGroup(ResourceGroupId.fromString("Personal/2e114308-14ec-4d77-b610-490324fa1844/rg")) - .build(); + .withId(new EnvironmentIdValue( + EnvironmentType.PERSONAL, + UUID.fromString("2e114308-14ec-4d77-b610-490324fa1844"), + "test")) + .withResourceGroup(ResourceGroupId.fromString("Personal/2e114308-14ec-4d77-b610-490324fa1844/rg")) + .build(); } public static LiveSystemAggregate getLiveSystemExample() { var resourceGroupId = new ResourceGroupId(ResourceGroupType.PERSONAL, UUID.randomUUID(), "rg"); var liveSystemsFactory = new LiveSystemsFactory( - HttpClient.newBuilder().build(), - new LocalSdkConfiguration(""), - RetryRegistry.ofDefaults()); + HttpClient.newBuilder().build(), + new LocalSdkConfiguration(""), + RetryRegistry.ofDefaults()); return liveSystemsFactory.builder() - .withId(new LiveSystemIdValue(resourceGroupId, "business-platform-test")) - .withFractalId(new FractalIdValue(resourceGroupId, "business-platform-test", "v1.0")) - .withDescription("Business platform") - .withStandardProvider(ProviderType.AZURE) - .withComponent(getAksExample()) - .withComponent(getAzurePostgresExample()) - .withEnvironmentId(getEnvExample().getId()) - .build(); + .withId(new LiveSystemIdValue(resourceGroupId, "business-platform-test")) + .withFractalId(new FractalIdValue(resourceGroupId, "business-platform-test", "v1.0")) + .withDescription("Business platform") + .withStandardProvider(ProviderType.AZURE) + .withComponent(getAksExample()) + .withComponent(getAzurePostgresExample()) + .withEnvironmentId(getEnvExample().getId()) + .build(); } public static ComponentLink getComponentLink() { @@ -434,66 +434,66 @@ public static ComponentLink getComponentLink() { linkSettings.put("subscribe", true); return ComponentLink.builder() - .withComponentId("microservices") - .withSettings(linkSettings) - .build(); + .withComponentId("microservices") + .withSettings(linkSettings) + .build(); } public static AzureKubernetesServiceBuilder getDefaultAks() { return AzureKubernetesService.builder() - .withId(ComponentId.from("test")) - .withRegion(WEST_EUROPE) - .withNodePool(AzureNodePool.builder() - .withMachineType(STANDARD_B2S) - .withName("azure") - .withDiskSizeGb(30) - .withInitialNodeCount(1) - .withAutoscalingEnabled(false) - .build()); + .withId(ComponentId.from("test")) + .withRegion(WEST_EUROPE) + .withNodePool(AzureNodePool.builder() + .withMachineType(STANDARD_B2S) + .withName("azure") + .withDiskSizeGb(30) + .withInitialNodeCount(1) + .withAutoscalingEnabled(false) + .build()); } public static GoogleKubernetesEngineBuilder getDefaultGke() { return GoogleKubernetesEngine.builder() - .withId(ComponentId.from("test")) - .withRegion(EUROPE_WEST1) - .withNodePool(GcpNodePool.builder() - .withName("gke") - .withMachineType(E2_STANDARD2) - .build()); + .withId(ComponentId.from("test")) + .withRegion(EUROPE_WEST1) + .withNodePool(GcpNodePool.builder() + .withName("gke") + .withMachineType(E2_STANDARD2) + .build()); } public static OciContainerEngineForKubernetesBuilder getDefaultOke() { return OciContainerEngineForKubernetes.builder() - .withId(ComponentId.from("test")) - .withRegion(EU_ZURICH_1); + .withId(ComponentId.from("test")) + .withRegion(EU_ZURICH_1); } public static AwsElasticKubernetesServiceBuilder getDefaultEks() { return AwsElasticKubernetesService.builder() - .withId(ComponentId.from("test")) - .withRegion(EU_NORTH_1); + .withId(ComponentId.from("test")) + .withRegion(EU_NORTH_1); } public static void assertGenericComponent(ComponentDto componentDto, Component comp, String type) { SoftAssertions.assertSoftly(softly -> softly.assertThat(componentDto) - .extracting( - ComponentDto::getId, - ComponentDto::getDisplayName, - ComponentDto::getDescription, - ComponentDto::getType, - ComponentDto::getVersion, - ComponentDto::isLocked, - ComponentDto::getDependencies, - ComponentDto::getLinks) - .containsExactly( - comp.getId().getValue(), - comp.getDisplayName(), - comp.getDescription(), - type, - DEFAULT_VERSION, - comp.isLocked(), - comp.getDependencies().stream().map(ComponentId::getValue).collect(toSet()), - comp.getLinks())); + .extracting( + ComponentDto::getId, + ComponentDto::getDisplayName, + ComponentDto::getDescription, + ComponentDto::getType, + ComponentDto::getVersion, + ComponentDto::isLocked, + ComponentDto::getDependencies, + ComponentDto::getLinks) + .containsExactly( + comp.getId().getValue(), + comp.getDisplayName(), + comp.getDescription(), + type, + DEFAULT_VERSION, + comp.isLocked(), + comp.getDependencies().stream().map(ComponentId::getValue).collect(toSet()), + comp.getLinks())); } public static String getJsonRepresentation(Object obj) {