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

package com.azure.resourcemanager.storagepool.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagepool.fluent.models.Sku;
import com.azure.resourcemanager.storagepool.models.Disk;
import com.azure.resourcemanager.storagepool.models.DiskPoolCreate;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DiskPoolCreateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DiskPoolCreate model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"odxobnbdxkqpxok\",\"tier\":\"ionpimexg\"},\"properties\":{\"availabilityZones\":[\"gcpo\"],\"disks\":[{\"id\":\"aajrm\"},{\"id\":\"djwzrlov\"},{\"id\":\"clwhijcoejctbz\"},{\"id\":\"qsqsy\"}],\"subnetId\":\"bkbfkgukdkex\",\"additionalCapabilities\":[\"ofmx\"]},\"managedBy\":\"c\",\"managedByExtended\":[\"gddtocj\"],\"location\":\"xhvpmoue\",\"tags\":{\"xqbzvddntwnd\":\"zxibqeoj\",\"vuhrhcffcyddgl\":\"icbtwnpzao\",\"xmqci\":\"jthjqkwpyei\",\"hkh\":\"q\"},\"id\":\"xuigdtopbobj\",\"name\":\"ghmewuam\",\"type\":\"uhrzayvvt\"}")
                .toObject(DiskPoolCreate.class);
        Assertions.assertEquals("xhvpmoue", model.location());
        Assertions.assertEquals("zxibqeoj", model.tags().get("xqbzvddntwnd"));
        Assertions.assertEquals("odxobnbdxkqpxok", model.sku().name());
        Assertions.assertEquals("ionpimexg", model.sku().tier());
        Assertions.assertEquals("c", model.managedBy());
        Assertions.assertEquals("gddtocj", model.managedByExtended().get(0));
        Assertions.assertEquals("gcpo", model.availabilityZones().get(0));
        Assertions.assertEquals("aajrm", model.disks().get(0).id());
        Assertions.assertEquals("bkbfkgukdkex", model.subnetId());
        Assertions.assertEquals("ofmx", model.additionalCapabilities().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DiskPoolCreate model =
            new DiskPoolCreate()
                .withLocation("xhvpmoue")
                .withTags(
                    mapOf(
                        "xqbzvddntwnd", "zxibqeoj", "vuhrhcffcyddgl", "icbtwnpzao", "xmqci", "jthjqkwpyei", "hkh", "q"))
                .withSku(new Sku().withName("odxobnbdxkqpxok").withTier("ionpimexg"))
                .withManagedBy("c")
                .withManagedByExtended(Arrays.asList("gddtocj"))
                .withAvailabilityZones(Arrays.asList("gcpo"))
                .withDisks(
                    Arrays
                        .asList(
                            new Disk().withId("aajrm"),
                            new Disk().withId("djwzrlov"),
                            new Disk().withId("clwhijcoejctbz"),
                            new Disk().withId("qsqsy")))
                .withSubnetId("bkbfkgukdkex")
                .withAdditionalCapabilities(Arrays.asList("ofmx"));
        model = BinaryData.fromObject(model).toObject(DiskPoolCreate.class);
        Assertions.assertEquals("xhvpmoue", model.location());
        Assertions.assertEquals("zxibqeoj", model.tags().get("xqbzvddntwnd"));
        Assertions.assertEquals("odxobnbdxkqpxok", model.sku().name());
        Assertions.assertEquals("ionpimexg", model.sku().tier());
        Assertions.assertEquals("c", model.managedBy());
        Assertions.assertEquals("gddtocj", model.managedByExtended().get(0));
        Assertions.assertEquals("gcpo", model.availabilityZones().get(0));
        Assertions.assertEquals("aajrm", model.disks().get(0).id());
        Assertions.assertEquals("bkbfkgukdkex", model.subnetId());
        Assertions.assertEquals("ofmx", model.additionalCapabilities().get(0));
    }

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