// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.mariadb.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mariadb.models.GeoRedundantBackup;
import com.azure.resourcemanager.mariadb.models.MinimalTlsVersionEnum;
import com.azure.resourcemanager.mariadb.models.PublicNetworkAccessEnum;
import com.azure.resourcemanager.mariadb.models.ServerPropertiesForCreate;
import com.azure.resourcemanager.mariadb.models.ServerVersion;
import com.azure.resourcemanager.mariadb.models.SslEnforcementEnum;
import com.azure.resourcemanager.mariadb.models.StorageAutogrow;
import com.azure.resourcemanager.mariadb.models.StorageProfile;
import org.junit.jupiter.api.Assertions;

public final class ServerPropertiesForCreateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServerPropertiesForCreate model =
            BinaryData
                .fromString(
                    "{\"createMode\":\"ServerPropertiesForCreate\",\"version\":\"10.2\",\"sslEnforcement\":\"Enabled\",\"minimalTlsVersion\":\"TLSEnforcementDisabled\",\"publicNetworkAccess\":\"Enabled\",\"storageProfile\":{\"backupRetentionDays\":1604398792,\"geoRedundantBackup\":\"Disabled\",\"storageMB\":280766823,\"storageAutogrow\":\"Disabled\"}}")
                .toObject(ServerPropertiesForCreate.class);
        Assertions.assertEquals(ServerVersion.ONE_ZERO_TWO, model.version());
        Assertions.assertEquals(SslEnforcementEnum.ENABLED, model.sslEnforcement());
        Assertions.assertEquals(MinimalTlsVersionEnum.TLSENFORCEMENT_DISABLED, model.minimalTlsVersion());
        Assertions.assertEquals(PublicNetworkAccessEnum.ENABLED, model.publicNetworkAccess());
        Assertions.assertEquals(1604398792, model.storageProfile().backupRetentionDays());
        Assertions.assertEquals(GeoRedundantBackup.DISABLED, model.storageProfile().geoRedundantBackup());
        Assertions.assertEquals(280766823, model.storageProfile().storageMB());
        Assertions.assertEquals(StorageAutogrow.DISABLED, model.storageProfile().storageAutogrow());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServerPropertiesForCreate model =
            new ServerPropertiesForCreate()
                .withVersion(ServerVersion.ONE_ZERO_TWO)
                .withSslEnforcement(SslEnforcementEnum.ENABLED)
                .withMinimalTlsVersion(MinimalTlsVersionEnum.TLSENFORCEMENT_DISABLED)
                .withPublicNetworkAccess(PublicNetworkAccessEnum.ENABLED)
                .withStorageProfile(
                    new StorageProfile()
                        .withBackupRetentionDays(1604398792)
                        .withGeoRedundantBackup(GeoRedundantBackup.DISABLED)
                        .withStorageMB(280766823)
                        .withStorageAutogrow(StorageAutogrow.DISABLED));
        model = BinaryData.fromObject(model).toObject(ServerPropertiesForCreate.class);
        Assertions.assertEquals(ServerVersion.ONE_ZERO_TWO, model.version());
        Assertions.assertEquals(SslEnforcementEnum.ENABLED, model.sslEnforcement());
        Assertions.assertEquals(MinimalTlsVersionEnum.TLSENFORCEMENT_DISABLED, model.minimalTlsVersion());
        Assertions.assertEquals(PublicNetworkAccessEnum.ENABLED, model.publicNetworkAccess());
        Assertions.assertEquals(1604398792, model.storageProfile().backupRetentionDays());
        Assertions.assertEquals(GeoRedundantBackup.DISABLED, model.storageProfile().geoRedundantBackup());
        Assertions.assertEquals(280766823, model.storageProfile().storageMB());
        Assertions.assertEquals(StorageAutogrow.DISABLED, model.storageProfile().storageAutogrow());
    }
}
