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

package com.azure.resourcemanager.datalakestore.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.datalakestore.models.CreateDataLakeStoreAccountParameters;
import com.azure.resourcemanager.datalakestore.models.CreateFirewallRuleWithAccountParameters;
import com.azure.resourcemanager.datalakestore.models.CreateTrustedIdProviderWithAccountParameters;
import com.azure.resourcemanager.datalakestore.models.CreateVirtualNetworkRuleWithAccountParameters;
import com.azure.resourcemanager.datalakestore.models.EncryptionConfig;
import com.azure.resourcemanager.datalakestore.models.EncryptionConfigType;
import com.azure.resourcemanager.datalakestore.models.EncryptionIdentity;
import com.azure.resourcemanager.datalakestore.models.EncryptionState;
import com.azure.resourcemanager.datalakestore.models.FirewallAllowAzureIpsState;
import com.azure.resourcemanager.datalakestore.models.FirewallState;
import com.azure.resourcemanager.datalakestore.models.TierType;
import com.azure.resourcemanager.datalakestore.models.TrustedIdProviderState;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class CreateDataLakeStoreAccountParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CreateDataLakeStoreAccountParameters model =
            BinaryData
                .fromString(
                    "{\"location\":\"kvnipjoxz\",\"tags\":{\"lzydehojwyahux\":\"hgejspodma\",\"vcputegj\":\"npmqnjaqwixjspro\",\"uuvmkjozkrwfnd\":\"wmfdatscmdvpjhul\"},\"identity\":{\"principalId\":\"d0dc0555-2478-483f-bd52-738f824e1696\",\"tenantId\":\"795441b9-fd01-44d8-859a-876e07e2fb02\"},\"properties\":{\"defaultGroup\":\"lwejdpv\",\"encryptionConfig\":{\"type\":\"ServiceManaged\"},\"encryptionState\":\"Disabled\",\"firewallRules\":[{\"name\":\"acctazakljla\"},{\"name\":\"bcryffdfd\"}],\"virtualNetworkRules\":[{\"name\":\"gexpaojakhmsbz\"},{\"name\":\"hcrzevd\"},{\"name\":\"hlxaolthqtr\"},{\"name\":\"qjbpfzfsin\"}],\"firewallState\":\"Enabled\",\"firewallAllowAzureIps\":\"Disabled\",\"trustedIdProviders\":[{\"name\":\"wzo\"},{\"name\":\"xjtfelluwfzit\"},{\"name\":\"np\"},{\"name\":\"qfpjk\"}],\"trustedIdProviderState\":\"Disabled\",\"newTier\":\"Commitment_5PB\"}}")
                .toObject(CreateDataLakeStoreAccountParameters.class);
        Assertions.assertEquals("kvnipjoxz", model.location());
        Assertions.assertEquals("hgejspodma", model.tags().get("lzydehojwyahux"));
        Assertions.assertEquals("lwejdpv", model.defaultGroup());
        Assertions.assertEquals(EncryptionConfigType.SERVICE_MANAGED, model.encryptionConfig().type());
        Assertions.assertEquals(EncryptionState.DISABLED, model.encryptionState());
        Assertions.assertEquals("acctazakljla", model.firewallRules().get(0).name());
        Assertions.assertEquals("gexpaojakhmsbz", model.virtualNetworkRules().get(0).name());
        Assertions.assertEquals(FirewallState.ENABLED, model.firewallState());
        Assertions.assertEquals(FirewallAllowAzureIpsState.DISABLED, model.firewallAllowAzureIps());
        Assertions.assertEquals("wzo", model.trustedIdProviders().get(0).name());
        Assertions.assertEquals(TrustedIdProviderState.DISABLED, model.trustedIdProviderState());
        Assertions.assertEquals(TierType.COMMITMENT_5PB, model.newTier());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CreateDataLakeStoreAccountParameters model =
            new CreateDataLakeStoreAccountParameters()
                .withLocation("kvnipjoxz")
                .withTags(
                    mapOf(
                        "lzydehojwyahux",
                        "hgejspodma",
                        "vcputegj",
                        "npmqnjaqwixjspro",
                        "uuvmkjozkrwfnd",
                        "wmfdatscmdvpjhul"))
                .withIdentity(new EncryptionIdentity())
                .withDefaultGroup("lwejdpv")
                .withEncryptionConfig(new EncryptionConfig().withType(EncryptionConfigType.SERVICE_MANAGED))
                .withEncryptionState(EncryptionState.DISABLED)
                .withFirewallRules(
                    Arrays
                        .asList(
                            new CreateFirewallRuleWithAccountParameters().withName("acctazakljla"),
                            new CreateFirewallRuleWithAccountParameters().withName("bcryffdfd")))
                .withVirtualNetworkRules(
                    Arrays
                        .asList(
                            new CreateVirtualNetworkRuleWithAccountParameters().withName("gexpaojakhmsbz"),
                            new CreateVirtualNetworkRuleWithAccountParameters().withName("hcrzevd"),
                            new CreateVirtualNetworkRuleWithAccountParameters().withName("hlxaolthqtr"),
                            new CreateVirtualNetworkRuleWithAccountParameters().withName("qjbpfzfsin")))
                .withFirewallState(FirewallState.ENABLED)
                .withFirewallAllowAzureIps(FirewallAllowAzureIpsState.DISABLED)
                .withTrustedIdProviders(
                    Arrays
                        .asList(
                            new CreateTrustedIdProviderWithAccountParameters().withName("wzo"),
                            new CreateTrustedIdProviderWithAccountParameters().withName("xjtfelluwfzit"),
                            new CreateTrustedIdProviderWithAccountParameters().withName("np"),
                            new CreateTrustedIdProviderWithAccountParameters().withName("qfpjk")))
                .withTrustedIdProviderState(TrustedIdProviderState.DISABLED)
                .withNewTier(TierType.COMMITMENT_5PB);
        model = BinaryData.fromObject(model).toObject(CreateDataLakeStoreAccountParameters.class);
        Assertions.assertEquals("kvnipjoxz", model.location());
        Assertions.assertEquals("hgejspodma", model.tags().get("lzydehojwyahux"));
        Assertions.assertEquals("lwejdpv", model.defaultGroup());
        Assertions.assertEquals(EncryptionConfigType.SERVICE_MANAGED, model.encryptionConfig().type());
        Assertions.assertEquals(EncryptionState.DISABLED, model.encryptionState());
        Assertions.assertEquals("acctazakljla", model.firewallRules().get(0).name());
        Assertions.assertEquals("gexpaojakhmsbz", model.virtualNetworkRules().get(0).name());
        Assertions.assertEquals(FirewallState.ENABLED, model.firewallState());
        Assertions.assertEquals(FirewallAllowAzureIpsState.DISABLED, model.firewallAllowAzureIps());
        Assertions.assertEquals("wzo", model.trustedIdProviders().get(0).name());
        Assertions.assertEquals(TrustedIdProviderState.DISABLED, model.trustedIdProviderState());
        Assertions.assertEquals(TierType.COMMITMENT_5PB, model.newTier());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
