// 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.NetworkFabricControllerInner;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkFabricControllersListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class NetworkFabricControllersListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkFabricControllersListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"networkFabricIds\":[],\"workloadManagementNetwork\":true,\"ipv4AddressSpace\":\"wzqa\",\"ipv6AddressSpace\":\"lgzurig\",\"operationalState\":\"Configuring\",\"provisioningState\":\"Deleting\",\"infrastructureExpressRouteConnections\":[],\"workloadExpressRouteConnections\":[],\"annotation\":\"icokpv\"},\"location\":\"lqtmldgxob\",\"tags\":{\"yzriykhy\":\"clnpkci\",\"jlb\":\"wf\"},\"id\":\"xqvkjlmxhomdyn\",\"name\":\"dwdigumb\",\"type\":\"raauzzpt\"}],\"nextLink\":\"zysdzh\"}")
                .toObject(NetworkFabricControllersListResult.class);
        Assertions.assertEquals("lqtmldgxob", model.value().get(0).location());
        Assertions.assertEquals("clnpkci", model.value().get(0).tags().get("yzriykhy"));
        Assertions.assertEquals("wzqa", model.value().get(0).ipv4AddressSpace());
        Assertions.assertEquals("lgzurig", model.value().get(0).ipv6AddressSpace());
        Assertions.assertEquals("icokpv", model.value().get(0).annotation());
        Assertions.assertEquals("zysdzh", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkFabricControllersListResult model =
            new NetworkFabricControllersListResult()
                .withValue(
                    Arrays
                        .asList(
                            new NetworkFabricControllerInner()
                                .withLocation("lqtmldgxob")
                                .withTags(mapOf("yzriykhy", "clnpkci", "jlb", "wf"))
                                .withIpv4AddressSpace("wzqa")
                                .withIpv6AddressSpace("lgzurig")
                                .withInfrastructureExpressRouteConnections(Arrays.asList())
                                .withWorkloadExpressRouteConnections(Arrays.asList())
                                .withAnnotation("icokpv")))
                .withNextLink("zysdzh");
        model = BinaryData.fromObject(model).toObject(NetworkFabricControllersListResult.class);
        Assertions.assertEquals("lqtmldgxob", model.value().get(0).location());
        Assertions.assertEquals("clnpkci", model.value().get(0).tags().get("yzriykhy"));
        Assertions.assertEquals("wzqa", model.value().get(0).ipv4AddressSpace());
        Assertions.assertEquals("lgzurig", model.value().get(0).ipv6AddressSpace());
        Assertions.assertEquals("icokpv", model.value().get(0).annotation());
        Assertions.assertEquals("zysdzh", 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;
    }
}
