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

package com.azure.resourcemanager.cosmosdbforpostgresql.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.cosmosdbforpostgresql.fluent.models.ClusterServerInner;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ClusterServerListResult;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ServerRole;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ClusterServerListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ClusterServerListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"fullyQualifiedDomainName\":\"mt\",\"role\":\"Worker\",\"state\":\"ryrtihfxtijbpzv\",\"haState\":\"wzsymglzufcy\",\"availabilityZone\":\"ohdbihanufh\",\"postgresqlVersion\":\"bj\",\"citusVersion\":\"a\",\"serverEdition\":\"th\",\"storageQuotaInMb\":731883185,\"vCores\":676674728,\"enableHa\":true,\"enablePublicIpAccess\":false,\"isReadOnly\":true,\"administratorLogin\":\"czbysc\"},\"id\":\"q\",\"name\":\"uhivyqniw\",\"type\":\"ybrk\"},{\"properties\":{\"fullyQualifiedDomainName\":\"umjgrtfwvuk\",\"role\":\"Worker\",\"state\":\"dcc\",\"haState\":\"h\",\"availabilityZone\":\"cnyejhkryhtnapcz\",\"postgresqlVersion\":\"okjye\",\"citusVersion\":\"kvnipjoxz\",\"serverEdition\":\"chgejspodm\",\"storageQuotaInMb\":1543997460,\"vCores\":1345546955,\"enableHa\":false,\"enablePublicIpAccess\":false,\"isReadOnly\":true,\"administratorLogin\":\"ahuxinpm\"},\"id\":\"jaqwixjsp\",\"name\":\"ozvcput\",\"type\":\"gjvw\"}]}")
                .toObject(ClusterServerListResult.class);
        Assertions.assertEquals(ServerRole.WORKER, model.value().get(0).role());
        Assertions.assertEquals("ohdbihanufh", model.value().get(0).availabilityZone());
        Assertions.assertEquals("bj", model.value().get(0).postgresqlVersion());
        Assertions.assertEquals("a", model.value().get(0).citusVersion());
        Assertions.assertEquals("th", model.value().get(0).serverEdition());
        Assertions.assertEquals(731883185, model.value().get(0).storageQuotaInMb());
        Assertions.assertEquals(676674728, model.value().get(0).vCores());
        Assertions.assertEquals(true, model.value().get(0).enableHa());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ClusterServerListResult model =
            new ClusterServerListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ClusterServerInner()
                                .withRole(ServerRole.WORKER)
                                .withAvailabilityZone("ohdbihanufh")
                                .withPostgresqlVersion("bj")
                                .withCitusVersion("a")
                                .withServerEdition("th")
                                .withStorageQuotaInMb(731883185)
                                .withVCores(676674728)
                                .withEnableHa(true),
                            new ClusterServerInner()
                                .withRole(ServerRole.WORKER)
                                .withAvailabilityZone("cnyejhkryhtnapcz")
                                .withPostgresqlVersion("okjye")
                                .withCitusVersion("kvnipjoxz")
                                .withServerEdition("chgejspodm")
                                .withStorageQuotaInMb(1543997460)
                                .withVCores(1345546955)
                                .withEnableHa(false)));
        model = BinaryData.fromObject(model).toObject(ClusterServerListResult.class);
        Assertions.assertEquals(ServerRole.WORKER, model.value().get(0).role());
        Assertions.assertEquals("ohdbihanufh", model.value().get(0).availabilityZone());
        Assertions.assertEquals("bj", model.value().get(0).postgresqlVersion());
        Assertions.assertEquals("a", model.value().get(0).citusVersion());
        Assertions.assertEquals("th", model.value().get(0).serverEdition());
        Assertions.assertEquals(731883185, model.value().get(0).storageQuotaInMb());
        Assertions.assertEquals(676674728, model.value().get(0).vCores());
        Assertions.assertEquals(true, model.value().get(0).enableHa());
    }
}
