// 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.DiskPoolInner;
import com.azure.resourcemanager.storagepool.models.Disk;
import com.azure.resourcemanager.storagepool.models.OperationalStatus;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DiskPoolInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DiskPoolInner model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"name\":\"dosvqwhbmdgbbjf\",\"tier\":\"gmbmbexppbh\"},\"properties\":{\"provisioningState\":\"Invalid\",\"availabilityZones\":[\"rolfpfp\",\"algbquxigjyjg\"],\"status\":\"Updating\",\"disks\":[{\"id\":\"yfhrtxilnerkujy\"}],\"subnetId\":\"vlejuvfqa\",\"additionalCapabilities\":[\"yxwjkcp\",\"bnwbxgjvtbvpyssz\",\"nruj\",\"guhmuouqfpr\"]},\"managedBy\":\"wbnguitnwui\",\"managedByExtended\":[\"zxufiz\"],\"systemData\":{\"createdBy\":\"y\",\"createdByType\":\"User\",\"createdAt\":\"2021-11-08T13:56:21Z\",\"lastModifiedBy\":\"dfvzwdzuhty\",\"lastModifiedByType\":\"Key\",\"lastModifiedAt\":\"2021-04-25T02:46:04Z\"},\"location\":\"kfthwxmntei\",\"tags\":{\"fsrpymzidnse\":\"pvkmijcmmxdcuf\",\"yc\":\"cxtbzsg\",\"mdwzjeiachboo\":\"sne\"},\"id\":\"flnrosfqpteehzz\",\"name\":\"ypyqrimzinp\",\"type\":\"swjdkirso\"}")
                .toObject(DiskPoolInner.class);
        Assertions.assertEquals("kfthwxmntei", model.location());
        Assertions.assertEquals("pvkmijcmmxdcuf", model.tags().get("fsrpymzidnse"));
        Assertions.assertEquals("dosvqwhbmdgbbjf", model.nameSkuName());
        Assertions.assertEquals("gmbmbexppbh", model.tier());
        Assertions.assertEquals("rolfpfp", model.availabilityZones().get(0));
        Assertions.assertEquals(OperationalStatus.UPDATING, model.status());
        Assertions.assertEquals("yfhrtxilnerkujy", model.disks().get(0).id());
        Assertions.assertEquals("vlejuvfqa", model.subnetId());
        Assertions.assertEquals("yxwjkcp", model.additionalCapabilities().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DiskPoolInner model =
            new DiskPoolInner()
                .withLocation("kfthwxmntei")
                .withTags(mapOf("fsrpymzidnse", "pvkmijcmmxdcuf", "yc", "cxtbzsg", "mdwzjeiachboo", "sne"))
                .withNameSkuName("dosvqwhbmdgbbjf")
                .withTier("gmbmbexppbh")
                .withAvailabilityZones(Arrays.asList("rolfpfp", "algbquxigjyjg"))
                .withStatus(OperationalStatus.UPDATING)
                .withDisks(Arrays.asList(new Disk().withId("yfhrtxilnerkujy")))
                .withSubnetId("vlejuvfqa")
                .withAdditionalCapabilities(Arrays.asList("yxwjkcp", "bnwbxgjvtbvpyssz", "nruj", "guhmuouqfpr"));
        model = BinaryData.fromObject(model).toObject(DiskPoolInner.class);
        Assertions.assertEquals("kfthwxmntei", model.location());
        Assertions.assertEquals("pvkmijcmmxdcuf", model.tags().get("fsrpymzidnse"));
        Assertions.assertEquals("dosvqwhbmdgbbjf", model.nameSkuName());
        Assertions.assertEquals("gmbmbexppbh", model.tier());
        Assertions.assertEquals("rolfpfp", model.availabilityZones().get(0));
        Assertions.assertEquals(OperationalStatus.UPDATING, model.status());
        Assertions.assertEquals("yfhrtxilnerkujy", model.disks().get(0).id());
        Assertions.assertEquals("vlejuvfqa", model.subnetId());
        Assertions.assertEquals("yxwjkcp", 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;
    }
}
