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

package com.azure.resourcemanager.postgresqlflexibleserver.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.postgresqlflexibleserver.models.DbServerMetadata;
import com.azure.resourcemanager.postgresqlflexibleserver.models.ServerSku;
import com.azure.resourcemanager.postgresqlflexibleserver.models.SkuTier;
import org.junit.jupiter.api.Assertions;

public final class DbServerMetadataTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DbServerMetadata model =
            BinaryData
                .fromString(
                    "{\"location\":\"kpikadrgvt\",\"version\":\"gnbuy\",\"storageMb\":850338934,\"sku\":{\"name\":\"gg\",\"tier\":\"Burstable\"}}")
                .toObject(DbServerMetadata.class);
        Assertions.assertEquals("gnbuy", model.version());
        Assertions.assertEquals(850338934, model.storageMb());
        Assertions.assertEquals("gg", model.sku().name());
        Assertions.assertEquals(SkuTier.BURSTABLE, model.sku().tier());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DbServerMetadata model =
            new DbServerMetadata()
                .withVersion("gnbuy")
                .withStorageMb(850338934)
                .withSku(new ServerSku().withName("gg").withTier(SkuTier.BURSTABLE));
        model = BinaryData.fromObject(model).toObject(DbServerMetadata.class);
        Assertions.assertEquals("gnbuy", model.version());
        Assertions.assertEquals(850338934, model.storageMb());
        Assertions.assertEquals("gg", model.sku().name());
        Assertions.assertEquals(SkuTier.BURSTABLE, model.sku().tier());
    }
}
