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

package com.azure.resourcemanager.synapse.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.synapse.models.AzureSku;
import com.azure.resourcemanager.synapse.models.KustoPoolUpdate;
import com.azure.resourcemanager.synapse.models.OptimizedAutoscale;
import com.azure.resourcemanager.synapse.models.SkuName;
import com.azure.resourcemanager.synapse.models.SkuSize;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class KustoPoolUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        KustoPoolUpdate model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"qpd\":\"omacluzvxnqmhr\",\"ssffxuifmc\":\"wmkoisq\",\"zsylollgt\":\"ypobkdqzr\",\"vuaurk\":\"czzydmxzjij\"},\"sku\":{\"name\":\"Compute"
                        + " optimized\",\"capacity\":772541424,\"size\":\"Medium\"},\"properties\":{\"state\":\"Creating\",\"provisioningState\":\"Failed\",\"uri\":\"c\",\"dataIngestionUri\":\"nbkkjanurnnq\",\"stateReason\":\"q\",\"optimizedAutoscale\":{\"version\":170755995,\"isEnabled\":true,\"minimum\":1872065986,\"maximum\":1388268954},\"enableStreamingIngest\":true,\"enablePurge\":false,\"languageExtensions\":{\"value\":[]},\"workspaceUID\":\"pxrxvbfihwu\"},\"id\":\"vctafsrb\",\"name\":\"rblmli\",\"type\":\"wxihs\"}")
                .toObject(KustoPoolUpdate.class);
        Assertions.assertEquals("omacluzvxnqmhr", model.tags().get("qpd"));
        Assertions.assertEquals(SkuName.COMPUTE_OPTIMIZED, model.sku().name());
        Assertions.assertEquals(772541424, model.sku().capacity());
        Assertions.assertEquals(SkuSize.MEDIUM, model.sku().size());
        Assertions.assertEquals(170755995, model.optimizedAutoscale().version());
        Assertions.assertEquals(true, model.optimizedAutoscale().isEnabled());
        Assertions.assertEquals(1872065986, model.optimizedAutoscale().minimum());
        Assertions.assertEquals(1388268954, model.optimizedAutoscale().maximum());
        Assertions.assertEquals(true, model.enableStreamingIngest());
        Assertions.assertEquals(false, model.enablePurge());
        Assertions.assertEquals("pxrxvbfihwu", model.workspaceUid());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        KustoPoolUpdate model =
            new KustoPoolUpdate()
                .withTags(
                    mapOf(
                        "qpd",
                        "omacluzvxnqmhr",
                        "ssffxuifmc",
                        "wmkoisq",
                        "zsylollgt",
                        "ypobkdqzr",
                        "vuaurk",
                        "czzydmxzjij"))
                .withSku(
                    new AzureSku().withName(SkuName.COMPUTE_OPTIMIZED).withCapacity(772541424).withSize(SkuSize.MEDIUM))
                .withOptimizedAutoscale(
                    new OptimizedAutoscale()
                        .withVersion(170755995)
                        .withIsEnabled(true)
                        .withMinimum(1872065986)
                        .withMaximum(1388268954))
                .withEnableStreamingIngest(true)
                .withEnablePurge(false)
                .withWorkspaceUid("pxrxvbfihwu");
        model = BinaryData.fromObject(model).toObject(KustoPoolUpdate.class);
        Assertions.assertEquals("omacluzvxnqmhr", model.tags().get("qpd"));
        Assertions.assertEquals(SkuName.COMPUTE_OPTIMIZED, model.sku().name());
        Assertions.assertEquals(772541424, model.sku().capacity());
        Assertions.assertEquals(SkuSize.MEDIUM, model.sku().size());
        Assertions.assertEquals(170755995, model.optimizedAutoscale().version());
        Assertions.assertEquals(true, model.optimizedAutoscale().isEnabled());
        Assertions.assertEquals(1872065986, model.optimizedAutoscale().minimum());
        Assertions.assertEquals(1388268954, model.optimizedAutoscale().maximum());
        Assertions.assertEquals(true, model.enableStreamingIngest());
        Assertions.assertEquals(false, model.enablePurge());
        Assertions.assertEquals("pxrxvbfihwu", model.workspaceUid());
    }

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