// 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.DedicatedCloudNodeListResponse;
import com.azure.resourcemanager.vmwarecloudsimple.models.Sku;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Assertions;

public final class DedicatedCloudNodeListResponseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DedicatedCloudNodeListResponse model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"jhulsuuvmkjo\",\"value\":[{\"properties\":{\"availabilityZoneId\":\"f\",\"availabilityZoneName\":\"iodjp\",\"cloudRackName\":\"w\",\"created\":\"2021-12-10T02:07:51Z\",\"nodesCount\":1273374631,\"placementGroupId\":\"vwryoqpso\",\"placementGroupName\":\"ctazakljlahbcryf\",\"privateCloudId\":\"fdosyg\",\"privateCloudName\":\"paojakhmsbzjh\",\"provisioningState\":\"zevdphlx\",\"purchaseId\":\"b24ff01c-f46a-4d62-a77c-475cec3a672a\",\"status\":\"unused\",\"vmwareClusterName\":\"qtrgqjbpfzfsinzg\"},\"sku\":{\"capacity\":\"jrwzox\",\"description\":\"tfell\",\"family\":\"fziton\",\"name\":\"eqfpj\",\"tier\":\"lxofpdvhpfxxypin\"},\"location\":\"nmayhuybb\",\"tags\":{\"nuvamiheogna\":\"depoog\",\"usivye\":\"xzxtheo\",\"nfygxgispemvtz\":\"cciqihnhungbwjz\"},\"id\":\"kufubljo\",\"name\":\"xqeofjaeqjhqjba\",\"type\":\"v\"},{\"properties\":{\"availabilityZoneId\":\"mjqulngsn\",\"availabilityZoneName\":\"bybkzgcwrwclxx\",\"cloudRackName\":\"ljdousk\",\"created\":\"2021-02-01T10:32:52Z\",\"nodesCount\":1132832602,\"placementGroupId\":\"ocrcjdk\",\"placementGroupName\":\"nh\",\"privateCloudId\":\"njbiksqrglssain\",\"privateCloudName\":\"jwnzlljfmp\",\"provisioningState\":\"ebvmgxsabkyqd\",\"purchaseId\":\"7c211873-1855-4f4d-b3cf-402898522665\",\"status\":\"unused\",\"vmwareClusterName\":\"c\"},\"sku\":{\"capacity\":\"dzevndhkrw\",\"description\":\"appd\",\"family\":\"dkvwrwjfe\",\"name\":\"snhu\",\"tier\":\"eltmrldhugjzzdat\"},\"location\":\"xhocdgeablgphuti\",\"tags\":{\"k\":\"vkaozwyiftyhxhur\",\"kjfkg\":\"tyxolniwpwc\"},\"id\":\"awxklr\",\"name\":\"plwckbas\",\"type\":\"ypnddhsgcb\"}]}")
                .toObject(DedicatedCloudNodeListResponse.class);
        Assertions.assertEquals("jhulsuuvmkjo", model.nextLink());
        Assertions.assertEquals("nmayhuybb", model.value().get(0).location());
        Assertions.assertEquals("depoog", model.value().get(0).tags().get("nuvamiheogna"));
        Assertions.assertEquals("jrwzox", model.value().get(0).sku().capacity());
        Assertions.assertEquals("tfell", model.value().get(0).sku().description());
        Assertions.assertEquals("fziton", model.value().get(0).sku().family());
        Assertions.assertEquals("eqfpj", model.value().get(0).sku().name());
        Assertions.assertEquals("lxofpdvhpfxxypin", model.value().get(0).sku().tier());
        Assertions.assertEquals("f", model.value().get(0).availabilityZoneId());
        Assertions.assertEquals(1273374631, model.value().get(0).nodesCount());
        Assertions.assertEquals("vwryoqpso", model.value().get(0).placementGroupId());
        Assertions
            .assertEquals(UUID.fromString("b24ff01c-f46a-4d62-a77c-475cec3a672a"), model.value().get(0).purchaseId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DedicatedCloudNodeListResponse model =
            new DedicatedCloudNodeListResponse()
                .withNextLink("jhulsuuvmkjo")
                .withValue(
                    Arrays
                        .asList(
                            new DedicatedCloudNodeInner()
                                .withLocation("nmayhuybb")
                                .withTags(
                                    mapOf(
                                        "nuvamiheogna",
                                        "depoog",
                                        "usivye",
                                        "xzxtheo",
                                        "nfygxgispemvtz",
                                        "cciqihnhungbwjz"))
                                .withSku(
                                    new Sku()
                                        .withCapacity("jrwzox")
                                        .withDescription("tfell")
                                        .withFamily("fziton")
                                        .withName("eqfpj")
                                        .withTier("lxofpdvhpfxxypin"))
                                .withAvailabilityZoneId("f")
                                .withNodesCount(1273374631)
                                .withPlacementGroupId("vwryoqpso")
                                .withPurchaseId(UUID.fromString("b24ff01c-f46a-4d62-a77c-475cec3a672a")),
                            new DedicatedCloudNodeInner()
                                .withLocation("xhocdgeablgphuti")
                                .withTags(mapOf("k", "vkaozwyiftyhxhur", "kjfkg", "tyxolniwpwc"))
                                .withSku(
                                    new Sku()
                                        .withCapacity("dzevndhkrw")
                                        .withDescription("appd")
                                        .withFamily("dkvwrwjfe")
                                        .withName("snhu")
                                        .withTier("eltmrldhugjzzdat"))
                                .withAvailabilityZoneId("mjqulngsn")
                                .withNodesCount(1132832602)
                                .withPlacementGroupId("ocrcjdk")
                                .withPurchaseId(UUID.fromString("7c211873-1855-4f4d-b3cf-402898522665"))));
        model = BinaryData.fromObject(model).toObject(DedicatedCloudNodeListResponse.class);
        Assertions.assertEquals("jhulsuuvmkjo", model.nextLink());
        Assertions.assertEquals("nmayhuybb", model.value().get(0).location());
        Assertions.assertEquals("depoog", model.value().get(0).tags().get("nuvamiheogna"));
        Assertions.assertEquals("jrwzox", model.value().get(0).sku().capacity());
        Assertions.assertEquals("tfell", model.value().get(0).sku().description());
        Assertions.assertEquals("fziton", model.value().get(0).sku().family());
        Assertions.assertEquals("eqfpj", model.value().get(0).sku().name());
        Assertions.assertEquals("lxofpdvhpfxxypin", model.value().get(0).sku().tier());
        Assertions.assertEquals("f", model.value().get(0).availabilityZoneId());
        Assertions.assertEquals(1273374631, model.value().get(0).nodesCount());
        Assertions.assertEquals("vwryoqpso", model.value().get(0).placementGroupId());
        Assertions
            .assertEquals(UUID.fromString("b24ff01c-f46a-4d62-a77c-475cec3a672a"), model.value().get(0).purchaseId());
    }

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