// 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.FirewallAllowAzureIpsState;
import com.azure.resourcemanager.datalakeanalytics.models.FirewallState;
import com.azure.resourcemanager.datalakeanalytics.models.TierType;
import com.azure.resourcemanager.datalakeanalytics.models.UpdateComputePolicyWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.UpdateDataLakeAnalyticsAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.UpdateDataLakeStoreWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.UpdateFirewallRuleWithAccountParameters;
import com.azure.resourcemanager.datalakeanalytics.models.UpdateStorageAccountWithAccountParameters;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class UpdateDataLakeAnalyticsAccountParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UpdateDataLakeAnalyticsAccountParameters model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"foskghsauuimj\":\"ku\",\"rfbyaosvexcso\":\"vxieduugidyj\",\"vleggzfbuhfmvfax\":\"pclhocohslk\",\"hl\":\"ffeii\"},\"properties\":{\"dataLakeStoreAccounts\":[{\"name\":\"yvshxmz\"}],\"storageAccounts\":[{\"name\":\"oggigrxwburv\"},{\"name\":\"xjnspy\"},{\"name\":\"tko\"},{\"name\":\"kouknvudwtiu\"}],\"computePolicies\":[{\"name\":\"ngkpocipazy\"}],\"firewallRules\":[{\"name\":\"ukgjnpiucgygevq\"},{\"name\":\"typmrbpizcdrqjsd\"},{\"name\":\"dnfyhxdeoejzicwi\"},{\"name\":\"jttgzf\"}],\"firewallState\":\"Disabled\",\"firewallAllowAzureIps\":\"Enabled\",\"newTier\":\"Commitment_5000AUHours\",\"maxJobCount\":558148580,\"maxDegreeOfParallelism\":1192393079,\"maxDegreeOfParallelismPerJob\":1232407744,\"minPriorityPerJob\":504162153,\"queryStoreRetention\":128550194}}")
                .toObject(UpdateDataLakeAnalyticsAccountParameters.class);
        Assertions.assertEquals("ku", model.tags().get("foskghsauuimj"));
        Assertions.assertEquals("yvshxmz", model.dataLakeStoreAccounts().get(0).name());
        Assertions.assertEquals("oggigrxwburv", model.storageAccounts().get(0).name());
        Assertions.assertEquals("ngkpocipazy", model.computePolicies().get(0).name());
        Assertions.assertEquals("ukgjnpiucgygevq", model.firewallRules().get(0).name());
        Assertions.assertEquals(FirewallState.DISABLED, model.firewallState());
        Assertions.assertEquals(FirewallAllowAzureIpsState.ENABLED, model.firewallAllowAzureIps());
        Assertions.assertEquals(TierType.COMMITMENT_5000AUHOURS, model.newTier());
        Assertions.assertEquals(558148580, model.maxJobCount());
        Assertions.assertEquals(1192393079, model.maxDegreeOfParallelism());
        Assertions.assertEquals(1232407744, model.maxDegreeOfParallelismPerJob());
        Assertions.assertEquals(504162153, model.minPriorityPerJob());
        Assertions.assertEquals(128550194, model.queryStoreRetention());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UpdateDataLakeAnalyticsAccountParameters model =
            new UpdateDataLakeAnalyticsAccountParameters()
                .withTags(
                    mapOf(
                        "foskghsauuimj",
                        "ku",
                        "rfbyaosvexcso",
                        "vxieduugidyj",
                        "vleggzfbuhfmvfax",
                        "pclhocohslk",
                        "hl",
                        "ffeii"))
                .withDataLakeStoreAccounts(
                    Arrays.asList(new UpdateDataLakeStoreWithAccountParameters().withName("yvshxmz")))
                .withStorageAccounts(
                    Arrays
                        .asList(
                            new UpdateStorageAccountWithAccountParameters().withName("oggigrxwburv"),
                            new UpdateStorageAccountWithAccountParameters().withName("xjnspy"),
                            new UpdateStorageAccountWithAccountParameters().withName("tko"),
                            new UpdateStorageAccountWithAccountParameters().withName("kouknvudwtiu")))
                .withComputePolicies(
                    Arrays.asList(new UpdateComputePolicyWithAccountParameters().withName("ngkpocipazy")))
                .withFirewallRules(
                    Arrays
                        .asList(
                            new UpdateFirewallRuleWithAccountParameters().withName("ukgjnpiucgygevq"),
                            new UpdateFirewallRuleWithAccountParameters().withName("typmrbpizcdrqjsd"),
                            new UpdateFirewallRuleWithAccountParameters().withName("dnfyhxdeoejzicwi"),
                            new UpdateFirewallRuleWithAccountParameters().withName("jttgzf")))
                .withFirewallState(FirewallState.DISABLED)
                .withFirewallAllowAzureIps(FirewallAllowAzureIpsState.ENABLED)
                .withNewTier(TierType.COMMITMENT_5000AUHOURS)
                .withMaxJobCount(558148580)
                .withMaxDegreeOfParallelism(1192393079)
                .withMaxDegreeOfParallelismPerJob(1232407744)
                .withMinPriorityPerJob(504162153)
                .withQueryStoreRetention(128550194);
        model = BinaryData.fromObject(model).toObject(UpdateDataLakeAnalyticsAccountParameters.class);
        Assertions.assertEquals("ku", model.tags().get("foskghsauuimj"));
        Assertions.assertEquals("yvshxmz", model.dataLakeStoreAccounts().get(0).name());
        Assertions.assertEquals("oggigrxwburv", model.storageAccounts().get(0).name());
        Assertions.assertEquals("ngkpocipazy", model.computePolicies().get(0).name());
        Assertions.assertEquals("ukgjnpiucgygevq", model.firewallRules().get(0).name());
        Assertions.assertEquals(FirewallState.DISABLED, model.firewallState());
        Assertions.assertEquals(FirewallAllowAzureIpsState.ENABLED, model.firewallAllowAzureIps());
        Assertions.assertEquals(TierType.COMMITMENT_5000AUHOURS, model.newTier());
        Assertions.assertEquals(558148580, model.maxJobCount());
        Assertions.assertEquals(1192393079, model.maxDegreeOfParallelism());
        Assertions.assertEquals(1232407744, model.maxDegreeOfParallelismPerJob());
        Assertions.assertEquals(504162153, model.minPriorityPerJob());
        Assertions.assertEquals(128550194, 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;
    }
}
