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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.RackInner;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import com.azure.resourcemanager.networkcloud.models.RackList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class RackListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RackList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"rddh\",\"value\":[{\"extendedLocation\":{\"name\":\"tizzronasxif\",\"type\":\"ozqyzh\"},\"properties\":{\"availabilityZone\":\"tw\",\"clusterId\":\"gogczhonnxkrlgny\",\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"sxkkg\",\"provisioningState\":\"Canceled\",\"rackLocation\":\"rghxjb\",\"rackSerialNumber\":\"hqxvcxgfrpdsofbs\",\"rackSkuId\":\"rnsvbuswd\"},\"location\":\"yybyc\",\"tags\":{\"rtkfawnopq\":\"vj\",\"x\":\"ikyzirtxdy\",\"sewgioilqukr\":\"ejnt\"},\"id\":\"dxtqmieoxo\",\"name\":\"ggufhyaomtb\",\"type\":\"hhavgrvkffovjz\"}]}")
                .toObject(RackList.class);
        Assertions.assertEquals("rddh", model.nextLink());
        Assertions.assertEquals("yybyc", model.value().get(0).location());
        Assertions.assertEquals("vj", model.value().get(0).tags().get("rtkfawnopq"));
        Assertions.assertEquals("tizzronasxif", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("ozqyzh", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("tw", model.value().get(0).availabilityZone());
        Assertions.assertEquals("rghxjb", model.value().get(0).rackLocation());
        Assertions.assertEquals("hqxvcxgfrpdsofbs", model.value().get(0).rackSerialNumber());
        Assertions.assertEquals("rnsvbuswd", model.value().get(0).rackSkuId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RackList model =
            new RackList()
                .withNextLink("rddh")
                .withValue(
                    Arrays
                        .asList(
                            new RackInner()
                                .withLocation("yybyc")
                                .withTags(mapOf("rtkfawnopq", "vj", "x", "ikyzirtxdy", "sewgioilqukr", "ejnt"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("tizzronasxif").withType("ozqyzh"))
                                .withAvailabilityZone("tw")
                                .withRackLocation("rghxjb")
                                .withRackSerialNumber("hqxvcxgfrpdsofbs")
                                .withRackSkuId("rnsvbuswd")));
        model = BinaryData.fromObject(model).toObject(RackList.class);
        Assertions.assertEquals("rddh", model.nextLink());
        Assertions.assertEquals("yybyc", model.value().get(0).location());
        Assertions.assertEquals("vj", model.value().get(0).tags().get("rtkfawnopq"));
        Assertions.assertEquals("tizzronasxif", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("ozqyzh", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("tw", model.value().get(0).availabilityZone());
        Assertions.assertEquals("rghxjb", model.value().get(0).rackLocation());
        Assertions.assertEquals("hqxvcxgfrpdsofbs", model.value().get(0).rackSerialNumber());
        Assertions.assertEquals("rnsvbuswd", model.value().get(0).rackSkuId());
    }

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