// 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.fluent.models.ServerProperties;
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.ServerState;
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 java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ServerPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServerProperties model =
            BinaryData
                .fromString(
                    "{\"administratorLogin\":\"scnpqxuhivy\",\"version\":\"10.3\",\"sslEnforcement\":\"Enabled\",\"minimalTlsVersion\":\"TLS1_0\",\"userVisibleState\":\"Dropping\",\"fullyQualifiedDomainName\":\"vd\",\"earliestRestoreDate\":\"2021-10-25T02:57:36Z\",\"storageProfile\":{\"backupRetentionDays\":1041852302,\"geoRedundantBackup\":\"Enabled\",\"storageMB\":1656802567,\"storageAutogrow\":\"Enabled\"},\"replicationRole\":\"audccsnhs\",\"masterServerId\":\"nyejhkryhtnap\",\"replicaCapacity\":1978797807,\"publicNetworkAccess\":\"Enabled\",\"privateEndpointConnections\":[{\"id\":\"emkkvnipjox\",\"properties\":{\"provisioningState\":\"Ready\"}}]}")
                .toObject(ServerProperties.class);
        Assertions.assertEquals("scnpqxuhivy", model.administratorLogin());
        Assertions.assertEquals(ServerVersion.ONE_ZERO_THREE, model.version());
        Assertions.assertEquals(SslEnforcementEnum.ENABLED, model.sslEnforcement());
        Assertions.assertEquals(MinimalTlsVersionEnum.TLS1_0, model.minimalTlsVersion());
        Assertions.assertEquals(ServerState.DROPPING, model.userVisibleState());
        Assertions.assertEquals("vd", model.fullyQualifiedDomainName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-25T02:57:36Z"), model.earliestRestoreDate());
        Assertions.assertEquals(1041852302, model.storageProfile().backupRetentionDays());
        Assertions.assertEquals(GeoRedundantBackup.ENABLED, model.storageProfile().geoRedundantBackup());
        Assertions.assertEquals(1656802567, model.storageProfile().storageMB());
        Assertions.assertEquals(StorageAutogrow.ENABLED, model.storageProfile().storageAutogrow());
        Assertions.assertEquals("audccsnhs", model.replicationRole());
        Assertions.assertEquals("nyejhkryhtnap", model.masterServerId());
        Assertions.assertEquals(1978797807, model.replicaCapacity());
        Assertions.assertEquals(PublicNetworkAccessEnum.ENABLED, model.publicNetworkAccess());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServerProperties model =
            new ServerProperties()
                .withAdministratorLogin("scnpqxuhivy")
                .withVersion(ServerVersion.ONE_ZERO_THREE)
                .withSslEnforcement(SslEnforcementEnum.ENABLED)
                .withMinimalTlsVersion(MinimalTlsVersionEnum.TLS1_0)
                .withUserVisibleState(ServerState.DROPPING)
                .withFullyQualifiedDomainName("vd")
                .withEarliestRestoreDate(OffsetDateTime.parse("2021-10-25T02:57:36Z"))
                .withStorageProfile(
                    new StorageProfile()
                        .withBackupRetentionDays(1041852302)
                        .withGeoRedundantBackup(GeoRedundantBackup.ENABLED)
                        .withStorageMB(1656802567)
                        .withStorageAutogrow(StorageAutogrow.ENABLED))
                .withReplicationRole("audccsnhs")
                .withMasterServerId("nyejhkryhtnap")
                .withReplicaCapacity(1978797807)
                .withPublicNetworkAccess(PublicNetworkAccessEnum.ENABLED);
        model = BinaryData.fromObject(model).toObject(ServerProperties.class);
        Assertions.assertEquals("scnpqxuhivy", model.administratorLogin());
        Assertions.assertEquals(ServerVersion.ONE_ZERO_THREE, model.version());
        Assertions.assertEquals(SslEnforcementEnum.ENABLED, model.sslEnforcement());
        Assertions.assertEquals(MinimalTlsVersionEnum.TLS1_0, model.minimalTlsVersion());
        Assertions.assertEquals(ServerState.DROPPING, model.userVisibleState());
        Assertions.assertEquals("vd", model.fullyQualifiedDomainName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-25T02:57:36Z"), model.earliestRestoreDate());
        Assertions.assertEquals(1041852302, model.storageProfile().backupRetentionDays());
        Assertions.assertEquals(GeoRedundantBackup.ENABLED, model.storageProfile().geoRedundantBackup());
        Assertions.assertEquals(1656802567, model.storageProfile().storageMB());
        Assertions.assertEquals(StorageAutogrow.ENABLED, model.storageProfile().storageAutogrow());
        Assertions.assertEquals("audccsnhs", model.replicationRole());
        Assertions.assertEquals("nyejhkryhtnap", model.masterServerId());
        Assertions.assertEquals(1978797807, model.replicaCapacity());
        Assertions.assertEquals(PublicNetworkAccessEnum.ENABLED, model.publicNetworkAccess());
    }
}
