// 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.fluent.models.KustoPoolInner;
import com.azure.resourcemanager.synapse.models.AzureSku;
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 KustoPoolInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        KustoPoolInner model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"Storage"
                        + " optimized\",\"capacity\":882727572,\"size\":\"Large\"},\"properties\":{\"state\":\"Creating\",\"provisioningState\":\"Moving\",\"uri\":\"kdfrdbiqmrjgeihf\",\"dataIngestionUri\":\"ggwfiwz\",\"stateReason\":\"mjpb\",\"optimizedAutoscale\":{\"version\":1813948953,\"isEnabled\":true,\"minimum\":1564431663,\"maximum\":342558293},\"enableStreamingIngest\":false,\"enablePurge\":false,\"languageExtensions\":{\"value\":[]},\"workspaceUID\":\"yfqi\"},\"etag\":\"xhnpo\",\"location\":\"qwcabvnui\",\"tags\":{\"fjlrxwtoauk\":\"yaswlpaugmr\"},\"id\":\"fkvcisi\",\"name\":\"moaedsxj\",\"type\":\"uivedwcgyeewxeiq\"}")
                .toObject(KustoPoolInner.class);
        Assertions.assertEquals("qwcabvnui", model.location());
        Assertions.assertEquals("yaswlpaugmr", model.tags().get("fjlrxwtoauk"));
        Assertions.assertEquals(SkuName.STORAGE_OPTIMIZED, model.sku().name());
        Assertions.assertEquals(882727572, model.sku().capacity());
        Assertions.assertEquals(SkuSize.LARGE, model.sku().size());
        Assertions.assertEquals(1813948953, model.optimizedAutoscale().version());
        Assertions.assertEquals(true, model.optimizedAutoscale().isEnabled());
        Assertions.assertEquals(1564431663, model.optimizedAutoscale().minimum());
        Assertions.assertEquals(342558293, model.optimizedAutoscale().maximum());
        Assertions.assertEquals(false, model.enableStreamingIngest());
        Assertions.assertEquals(false, model.enablePurge());
        Assertions.assertEquals("yfqi", model.workspaceUid());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        KustoPoolInner model =
            new KustoPoolInner()
                .withLocation("qwcabvnui")
                .withTags(mapOf("fjlrxwtoauk", "yaswlpaugmr"))
                .withSku(
                    new AzureSku().withName(SkuName.STORAGE_OPTIMIZED).withCapacity(882727572).withSize(SkuSize.LARGE))
                .withOptimizedAutoscale(
                    new OptimizedAutoscale()
                        .withVersion(1813948953)
                        .withIsEnabled(true)
                        .withMinimum(1564431663)
                        .withMaximum(342558293))
                .withEnableStreamingIngest(false)
                .withEnablePurge(false)
                .withWorkspaceUid("yfqi");
        model = BinaryData.fromObject(model).toObject(KustoPoolInner.class);
        Assertions.assertEquals("qwcabvnui", model.location());
        Assertions.assertEquals("yaswlpaugmr", model.tags().get("fjlrxwtoauk"));
        Assertions.assertEquals(SkuName.STORAGE_OPTIMIZED, model.sku().name());
        Assertions.assertEquals(882727572, model.sku().capacity());
        Assertions.assertEquals(SkuSize.LARGE, model.sku().size());
        Assertions.assertEquals(1813948953, model.optimizedAutoscale().version());
        Assertions.assertEquals(true, model.optimizedAutoscale().isEnabled());
        Assertions.assertEquals(1564431663, model.optimizedAutoscale().minimum());
        Assertions.assertEquals(342558293, model.optimizedAutoscale().maximum());
        Assertions.assertEquals(false, model.enableStreamingIngest());
        Assertions.assertEquals(false, model.enablePurge());
        Assertions.assertEquals("yfqi", 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;
    }
}
