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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.fluent.models.DiskInner;
import com.azure.resourcemanager.devtestlabs.models.StorageType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DiskInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DiskInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"diskType\":\"Standard\",\"diskSizeGiB\":1543388563,\"leasedByLabVmId\":\"h\",\"diskBlobName\":\"komtkubotppn\",\"diskUri\":\"xz\",\"storageAccountId\":\"ihfrbbcevqa\",\"createdDate\":\"2021-01-25T14:16:29Z\",\"hostCaching\":\"dhlfkqojpykvgt\",\"managedDiskId\":\"cnifm\",\"provisioningState\":\"sdymbrn\",\"uniqueIdentifier\":\"u\"},\"location\":\"m\",\"tags\":{\"fqroudas\":\"fwgckhocxvdfffw\"},\"id\":\"avehhrvkbunzo\",\"name\":\"ud\",\"type\":\"cxgkmoyxcdyui\"}")
                .toObject(DiskInner.class);
        Assertions.assertEquals("m", model.location());
        Assertions.assertEquals("fwgckhocxvdfffw", model.tags().get("fqroudas"));
        Assertions.assertEquals(StorageType.STANDARD, model.diskType());
        Assertions.assertEquals(1543388563, model.diskSizeGiB());
        Assertions.assertEquals("h", model.leasedByLabVmId());
        Assertions.assertEquals("komtkubotppn", model.diskBlobName());
        Assertions.assertEquals("xz", model.diskUri());
        Assertions.assertEquals("ihfrbbcevqa", model.storageAccountId());
        Assertions.assertEquals("dhlfkqojpykvgt", model.hostCaching());
        Assertions.assertEquals("cnifm", model.managedDiskId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DiskInner model =
            new DiskInner()
                .withLocation("m")
                .withTags(mapOf("fqroudas", "fwgckhocxvdfffw"))
                .withDiskType(StorageType.STANDARD)
                .withDiskSizeGiB(1543388563)
                .withLeasedByLabVmId("h")
                .withDiskBlobName("komtkubotppn")
                .withDiskUri("xz")
                .withStorageAccountId("ihfrbbcevqa")
                .withHostCaching("dhlfkqojpykvgt")
                .withManagedDiskId("cnifm");
        model = BinaryData.fromObject(model).toObject(DiskInner.class);
        Assertions.assertEquals("m", model.location());
        Assertions.assertEquals("fwgckhocxvdfffw", model.tags().get("fqroudas"));
        Assertions.assertEquals(StorageType.STANDARD, model.diskType());
        Assertions.assertEquals(1543388563, model.diskSizeGiB());
        Assertions.assertEquals("h", model.leasedByLabVmId());
        Assertions.assertEquals("komtkubotppn", model.diskBlobName());
        Assertions.assertEquals("xz", model.diskUri());
        Assertions.assertEquals("ihfrbbcevqa", model.storageAccountId());
        Assertions.assertEquals("dhlfkqojpykvgt", model.hostCaching());
        Assertions.assertEquals("cnifm", model.managedDiskId());
    }

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