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

package com.azure.resourcemanager.managednetworkfabric.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managednetworkfabric.fluent.models.NetworkFabricInner;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkFabricsListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class NetworkFabricsListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkFabricsListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"networkFabricSku\":\"iv\",\"rackCount\":178963664,\"serverCountPerRack\":412719759,\"ipv4Prefix\":\"zunbixx\",\"ipv6Prefix\":\"ikvcpwp\",\"routerId\":\"lrcivtsoxfrke\",\"fabricASN\":1452448195,\"networkFabricControllerId\":\"pmyyefrpmpdnqq\",\"operationalState\":\"Provisioned\",\"provisioningState\":\"Canceled\",\"racks\":[],\"l2IsolationDomains\":[],\"l3IsolationDomains\":[],\"annotation\":\"mbnpqf\"},\"location\":\"qlkzme\",\"tags\":{\"fegcea\":\"tgvkxlzyqd\",\"gdivbkbxg\":\"zxwhcansymoyqhlw\"},\"id\":\"mf\",\"name\":\"juwasqvdaeyyguxa\",\"type\":\"jsqzhzbezk\"},{\"properties\":{\"networkFabricSku\":\"msidxasicddyvv\",\"rackCount\":1032831795,\"serverCountPerRack\":537435769,\"ipv4Prefix\":\"fmocwahpq\",\"ipv6Prefix\":\"tjeaahhvjhh\",\"routerId\":\"kzyb\",\"fabricASN\":1424152759,\"networkFabricControllerId\":\"jid\",\"operationalState\":\"ErrorDeprovisioning\",\"provisioningState\":\"Updating\",\"racks\":[],\"l2IsolationDomains\":[],\"l3IsolationDomains\":[],\"annotation\":\"xevbl\"},\"location\":\"ednljl\",\"tags\":{\"bn\":\"uaulxunsm\",\"xeizzg\":\"ppxynenls\"},\"id\":\"klnsrmffey\",\"name\":\"xcktpiymerteeamm\",\"type\":\"qiekkkzddrt\"}],\"nextLink\":\"doj\"}")
                .toObject(NetworkFabricsListResult.class);
        Assertions.assertEquals("qlkzme", model.value().get(0).location());
        Assertions.assertEquals("tgvkxlzyqd", model.value().get(0).tags().get("fegcea"));
        Assertions.assertEquals("iv", model.value().get(0).networkFabricSku());
        Assertions.assertEquals(178963664, model.value().get(0).rackCount());
        Assertions.assertEquals(412719759, model.value().get(0).serverCountPerRack());
        Assertions.assertEquals("zunbixx", model.value().get(0).ipv4Prefix());
        Assertions.assertEquals("ikvcpwp", model.value().get(0).ipv6Prefix());
        Assertions.assertEquals(1452448195, model.value().get(0).fabricAsn());
        Assertions.assertEquals("pmyyefrpmpdnqq", model.value().get(0).networkFabricControllerId());
        Assertions.assertEquals("mbnpqf", model.value().get(0).annotation());
        Assertions.assertEquals("doj", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkFabricsListResult model =
            new NetworkFabricsListResult()
                .withValue(
                    Arrays
                        .asList(
                            new NetworkFabricInner()
                                .withLocation("qlkzme")
                                .withTags(mapOf("fegcea", "tgvkxlzyqd", "gdivbkbxg", "zxwhcansymoyqhlw"))
                                .withNetworkFabricSku("iv")
                                .withRackCount(178963664)
                                .withServerCountPerRack(412719759)
                                .withIpv4Prefix("zunbixx")
                                .withIpv6Prefix("ikvcpwp")
                                .withFabricAsn(1452448195)
                                .withNetworkFabricControllerId("pmyyefrpmpdnqq")
                                .withAnnotation("mbnpqf"),
                            new NetworkFabricInner()
                                .withLocation("ednljl")
                                .withTags(mapOf("bn", "uaulxunsm", "xeizzg", "ppxynenls"))
                                .withNetworkFabricSku("msidxasicddyvv")
                                .withRackCount(1032831795)
                                .withServerCountPerRack(537435769)
                                .withIpv4Prefix("fmocwahpq")
                                .withIpv6Prefix("tjeaahhvjhh")
                                .withFabricAsn(1424152759)
                                .withNetworkFabricControllerId("jid")
                                .withAnnotation("xevbl")))
                .withNextLink("doj");
        model = BinaryData.fromObject(model).toObject(NetworkFabricsListResult.class);
        Assertions.assertEquals("qlkzme", model.value().get(0).location());
        Assertions.assertEquals("tgvkxlzyqd", model.value().get(0).tags().get("fegcea"));
        Assertions.assertEquals("iv", model.value().get(0).networkFabricSku());
        Assertions.assertEquals(178963664, model.value().get(0).rackCount());
        Assertions.assertEquals(412719759, model.value().get(0).serverCountPerRack());
        Assertions.assertEquals("zunbixx", model.value().get(0).ipv4Prefix());
        Assertions.assertEquals("ikvcpwp", model.value().get(0).ipv6Prefix());
        Assertions.assertEquals(1452448195, model.value().get(0).fabricAsn());
        Assertions.assertEquals("pmyyefrpmpdnqq", model.value().get(0).networkFabricControllerId());
        Assertions.assertEquals("mbnpqf", model.value().get(0).annotation());
        Assertions.assertEquals("doj", model.nextLink());
    }

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