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

package com.azure.resourcemanager.datalakeanalytics.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.datalakeanalytics.models.AddDataLakeStoreWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.AddStorageAccountWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.CreateComputePolicyWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.CreateDataLakeAnalyticsAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.CreateFirewallRuleWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.FirewallAllowAzureIpsState;
import com.azure.resourcemanager.datalakeanalytics.models.FirewallState;
import com.azure.resourcemanager.datalakeanalytics.models.TierType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class CreateDataLakeAnalyticsAccountParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CreateDataLakeAnalyticsAccountParameters model =
            BinaryData
                .fromString(
                    "{\"location\":\"cnyejhkryhtnapcz\",\"tags\":{\"ni\":\"kjyemkk\",\"ilzyd\":\"joxzjnchgejspodm\"},\"properties\":{\"defaultDataLakeStoreAccount\":\"h\",\"dataLakeStoreAccounts\":[{\"name\":\"wyahuxinpmqnja\"},{\"name\":\"ixjsprozvcputeg\"},{\"name\":\"wmfdatscmdvpjhul\"},{\"name\":\"uvm\"}],\"storageAccounts\":[{\"name\":\"k\"},{\"name\":\"wfndiodjpsl\"}],\"computePolicies\":[{\"name\":\"dpvwryoqpsoaccta\"},{\"name\":\"akl\"}],\"firewallRules\":[{\"name\":\"hbcryffdfdosyge\"}],\"firewallState\":\"Disabled\",\"firewallAllowAzureIps\":\"Disabled\",\"newTier\":\"Commitment_500AUHours\",\"maxJobCount\":21740307,\"maxDegreeOfParallelism\":718519788,\"maxDegreeOfParallelismPerJob\":1079537419,\"minPriorityPerJob\":510394239,\"queryStoreRetention\":1969349443}}")
                .toObject(CreateDataLakeAnalyticsAccountParameters.class);
        Assertions.assertEquals("cnyejhkryhtnapcz", model.location());
        Assertions.assertEquals("kjyemkk", model.tags().get("ni"));
        Assertions.assertEquals("h", model.defaultDataLakeStoreAccount());
        Assertions.assertEquals("wyahuxinpmqnja", model.dataLakeStoreAccounts().get(0).name());
        Assertions.assertEquals("k", model.storageAccounts().get(0).name());
        Assertions.assertEquals("dpvwryoqpsoaccta", model.computePolicies().get(0).name());
        Assertions.assertEquals("hbcryffdfdosyge", model.firewallRules().get(0).name());
        Assertions.assertEquals(FirewallState.DISABLED, model.firewallState());
        Assertions.assertEquals(FirewallAllowAzureIpsState.DISABLED, model.firewallAllowAzureIps());
        Assertions.assertEquals(TierType.COMMITMENT_500AUHOURS, model.newTier());
        Assertions.assertEquals(21740307, model.maxJobCount());
        Assertions.assertEquals(718519788, model.maxDegreeOfParallelism());
        Assertions.assertEquals(1079537419, model.maxDegreeOfParallelismPerJob());
        Assertions.assertEquals(510394239, model.minPriorityPerJob());
        Assertions.assertEquals(1969349443, model.queryStoreRetention());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CreateDataLakeAnalyticsAccountParameters model =
            new CreateDataLakeAnalyticsAccountParameters()
                .withLocation("cnyejhkryhtnapcz")
                .withTags(mapOf("ni", "kjyemkk", "ilzyd", "joxzjnchgejspodm"))
                .withDefaultDataLakeStoreAccount("h")
                .withDataLakeStoreAccounts(
                    Arrays
                        .asList(
                            new AddDataLakeStoreWithAccountParameters().withName("wyahuxinpmqnja"),
                            new AddDataLakeStoreWithAccountParameters().withName("ixjsprozvcputeg"),
                            new AddDataLakeStoreWithAccountParameters().withName("wmfdatscmdvpjhul"),
                            new AddDataLakeStoreWithAccountParameters().withName("uvm")))
                .withStorageAccounts(
                    Arrays
                        .asList(
                            new AddStorageAccountWithAccountParameters().withName("k"),
                            new AddStorageAccountWithAccountParameters().withName("wfndiodjpsl")))
                .withComputePolicies(
                    Arrays
                        .asList(
                            new CreateComputePolicyWithAccountParameters().withName("dpvwryoqpsoaccta"),
                            new CreateComputePolicyWithAccountParameters().withName("akl")))
                .withFirewallRules(
                    Arrays.asList(new CreateFirewallRuleWithAccountParameters().withName("hbcryffdfdosyge")))
                .withFirewallState(FirewallState.DISABLED)
                .withFirewallAllowAzureIps(FirewallAllowAzureIpsState.DISABLED)
                .withNewTier(TierType.COMMITMENT_500AUHOURS)
                .withMaxJobCount(21740307)
                .withMaxDegreeOfParallelism(718519788)
                .withMaxDegreeOfParallelismPerJob(1079537419)
                .withMinPriorityPerJob(510394239)
                .withQueryStoreRetention(1969349443);
        model = BinaryData.fromObject(model).toObject(CreateDataLakeAnalyticsAccountParameters.class);
        Assertions.assertEquals("cnyejhkryhtnapcz", model.location());
        Assertions.assertEquals("kjyemkk", model.tags().get("ni"));
        Assertions.assertEquals("h", model.defaultDataLakeStoreAccount());
        Assertions.assertEquals("wyahuxinpmqnja", model.dataLakeStoreAccounts().get(0).name());
        Assertions.assertEquals("k", model.storageAccounts().get(0).name());
        Assertions.assertEquals("dpvwryoqpsoaccta", model.computePolicies().get(0).name());
        Assertions.assertEquals("hbcryffdfdosyge", model.firewallRules().get(0).name());
        Assertions.assertEquals(FirewallState.DISABLED, model.firewallState());
        Assertions.assertEquals(FirewallAllowAzureIpsState.DISABLED, model.firewallAllowAzureIps());
        Assertions.assertEquals(TierType.COMMITMENT_500AUHOURS, model.newTier());
        Assertions.assertEquals(21740307, model.maxJobCount());
        Assertions.assertEquals(718519788, model.maxDegreeOfParallelism());
        Assertions.assertEquals(1079537419, model.maxDegreeOfParallelismPerJob());
        Assertions.assertEquals(510394239, model.minPriorityPerJob());
        Assertions.assertEquals(1969349443, model.queryStoreRetention());
    }

    @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;
    }
}
