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

package com.azure.resourcemanager.vmwarecloudsimple.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.vmwarecloudsimple.fluent.models.DedicatedCloudNodeInner;
import com.azure.resourcemanager.vmwarecloudsimple.models.Sku;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Assertions;

public final class DedicatedCloudNodeInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DedicatedCloudNodeInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"availabilityZoneId\":\"phejkotynqgoulz\",\"availabilityZoneName\":\"likwyqkgfgib\",\"cloudRackName\":\"dgak\",\"created\":\"2021-01-01T02:28:26Z\",\"nodesCount\":1093417192,\"placementGroupId\":\"xybz\",\"placementGroupName\":\"e\",\"privateCloudId\":\"ytb\",\"privateCloudName\":\"qfou\",\"provisioningState\":\"mmnkzsmodmgl\",\"purchaseId\":\"9afbe44a-a7ff-42b8-89fe-6616f981760e\",\"skuDescription\":{\"id\":\"gpbkwtmut\",\"name\":\"uqktap\"},\"status\":\"unused\",\"vmwareClusterName\":\"cuertu\"},\"sku\":{\"capacity\":\"o\",\"description\":\"qw\",\"family\":\"mdgbbjfdd\",\"name\":\"mbmbexppbh\",\"tier\":\"qrolfpf\"},\"location\":\"s\",\"tags\":{\"gzjaoyfhrtxilne\":\"bquxigjy\",\"wrlyxwjkcprb\":\"kujysvlejuvfq\"},\"id\":\"wbxgjvt\",\"name\":\"vpys\",\"type\":\"zdn\"}")
                .toObject(DedicatedCloudNodeInner.class);
        Assertions.assertEquals("s", model.location());
        Assertions.assertEquals("bquxigjy", model.tags().get("gzjaoyfhrtxilne"));
        Assertions.assertEquals("o", model.sku().capacity());
        Assertions.assertEquals("qw", model.sku().description());
        Assertions.assertEquals("mdgbbjfdd", model.sku().family());
        Assertions.assertEquals("mbmbexppbh", model.sku().name());
        Assertions.assertEquals("qrolfpf", model.sku().tier());
        Assertions.assertEquals("phejkotynqgoulz", model.availabilityZoneId());
        Assertions.assertEquals(1093417192, model.nodesCount());
        Assertions.assertEquals("xybz", model.placementGroupId());
        Assertions.assertEquals(UUID.fromString("9afbe44a-a7ff-42b8-89fe-6616f981760e"), model.purchaseId());
        Assertions.assertEquals("gpbkwtmut", model.idPropertiesId());
        Assertions.assertEquals("uqktap", model.namePropertiesName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DedicatedCloudNodeInner model =
            new DedicatedCloudNodeInner()
                .withLocation("s")
                .withTags(mapOf("gzjaoyfhrtxilne", "bquxigjy", "wrlyxwjkcprb", "kujysvlejuvfq"))
                .withSku(
                    new Sku()
                        .withCapacity("o")
                        .withDescription("qw")
                        .withFamily("mdgbbjfdd")
                        .withName("mbmbexppbh")
                        .withTier("qrolfpf"))
                .withAvailabilityZoneId("phejkotynqgoulz")
                .withNodesCount(1093417192)
                .withPlacementGroupId("xybz")
                .withPurchaseId(UUID.fromString("9afbe44a-a7ff-42b8-89fe-6616f981760e"))
                .withIdPropertiesId("gpbkwtmut")
                .withNamePropertiesName("uqktap");
        model = BinaryData.fromObject(model).toObject(DedicatedCloudNodeInner.class);
        Assertions.assertEquals("s", model.location());
        Assertions.assertEquals("bquxigjy", model.tags().get("gzjaoyfhrtxilne"));
        Assertions.assertEquals("o", model.sku().capacity());
        Assertions.assertEquals("qw", model.sku().description());
        Assertions.assertEquals("mdgbbjfdd", model.sku().family());
        Assertions.assertEquals("mbmbexppbh", model.sku().name());
        Assertions.assertEquals("qrolfpf", model.sku().tier());
        Assertions.assertEquals("phejkotynqgoulz", model.availabilityZoneId());
        Assertions.assertEquals(1093417192, model.nodesCount());
        Assertions.assertEquals("xybz", model.placementGroupId());
        Assertions.assertEquals(UUID.fromString("9afbe44a-a7ff-42b8-89fe-6616f981760e"), model.purchaseId());
        Assertions.assertEquals("gpbkwtmut", model.idPropertiesId());
        Assertions.assertEquals("uqktap", model.namePropertiesName());
    }

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