// 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.ConfigurationInner;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ServerRole;
import com.azure.resourcemanager.cosmosdbforpostgresql.models.ServerRoleGroupConfiguration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ConfigurationInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ConfigurationInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"description\":\"aop\",\"dataType\":\"Enumeration\",\"allowedValues\":\"jcmmxdcufufsrp\",\"requiresRestart\":true,\"serverRoleGroupConfigurations\":[{\"role\":\"Worker\",\"value\":\"nsez\",\"defaultValue\":\"tbzsgfyccs\",\"source\":\"wmdwzjeiachboo\"},{\"role\":\"Worker\",\"value\":\"lnrosfqp\",\"defaultValue\":\"ehzzvypyqrim\",\"source\":\"npvswjdkirso\"},{\"role\":\"Worker\",\"value\":\"qxhcrmn\",\"defaultValue\":\"jtckwhdso\",\"source\":\"iy\"}],\"provisioningState\":\"InProgress\"},\"id\":\"sqwpgrjb\",\"name\":\"norcjxvsnbyxqab\",\"type\":\"mocpc\"}")
                .toObject(ConfigurationInner.class);
        Assertions.assertEquals(true, model.requiresRestart());
        Assertions.assertEquals(ServerRole.WORKER, model.serverRoleGroupConfigurations().get(0).role());
        Assertions.assertEquals("nsez", model.serverRoleGroupConfigurations().get(0).value());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ConfigurationInner model =
            new ConfigurationInner()
                .withRequiresRestart(true)
                .withServerRoleGroupConfigurations(
                    Arrays
                        .asList(
                            new ServerRoleGroupConfiguration().withRole(ServerRole.WORKER).withValue("nsez"),
                            new ServerRoleGroupConfiguration().withRole(ServerRole.WORKER).withValue("lnrosfqp"),
                            new ServerRoleGroupConfiguration().withRole(ServerRole.WORKER).withValue("qxhcrmn")));
        model = BinaryData.fromObject(model).toObject(ConfigurationInner.class);
        Assertions.assertEquals(true, model.requiresRestart());
        Assertions.assertEquals(ServerRole.WORKER, model.serverRoleGroupConfigurations().get(0).role());
        Assertions.assertEquals("nsez", model.serverRoleGroupConfigurations().get(0).value());
    }
}
