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

public final class L3IsolationDomainsListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L3IsolationDomainsListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"networkFabricId\":\"hl\",\"disabledOnResources\":[],\"administrativeState\":\"Enabled\",\"optionBDisabledOnResources\":[],\"provisioningState\":\"Updating\",\"redistributeConnectedSubnets\":\"True\",\"redistributeStaticRoutes\":\"True\",\"description\":\"sbkyvpycanuzbp\",\"annotation\":\"fkuwbcrnwbmehhse\"},\"location\":\"jusrtslhspk\",\"tags\":{\"melmqkrha\":\"maofmxagkv\",\"aquhcdhm\":\"vljua\",\"rcrgvx\":\"ualaexqpvfadmw\"},\"id\":\"vgomz\",\"name\":\"fmisg\",\"type\":\"bnbbeldawkz\"},{\"properties\":{\"networkFabricId\":\"liourqhak\",\"disabledOnResources\":[],\"administrativeState\":\"Disabled\",\"optionBDisabledOnResources\":[],\"provisioningState\":\"Canceled\",\"redistributeConnectedSubnets\":\"False\",\"redistributeStaticRoutes\":\"True\",\"description\":\"w\",\"annotation\":\"ugicjooxdjebw\"},\"location\":\"cwwfvovbvme\",\"tags\":{\"iotwmcdytdxwit\":\"ivyhzceuojgjrwju\",\"hniskxfbkpyc\":\"nrjawgqwg\",\"l\":\"klwndnhjdauwhv\"},\"id\":\"zbtd\",\"name\":\"xujznbmpowu\",\"type\":\"przqlveu\"}],\"nextLink\":\"upjm\"}")
                .toObject(L3IsolationDomainsListResult.class);
        Assertions.assertEquals("jusrtslhspk", model.value().get(0).location());
        Assertions.assertEquals("maofmxagkv", model.value().get(0).tags().get("melmqkrha"));
        Assertions.assertEquals("hl", model.value().get(0).networkFabricId());
        Assertions.assertEquals(RedistributeConnectedSubnets.TRUE, model.value().get(0).redistributeConnectedSubnets());
        Assertions.assertEquals(RedistributeStaticRoutes.TRUE, model.value().get(0).redistributeStaticRoutes());
        Assertions.assertEquals("sbkyvpycanuzbp", model.value().get(0).description());
        Assertions.assertEquals("fkuwbcrnwbmehhse", model.value().get(0).annotation());
        Assertions.assertEquals("upjm", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L3IsolationDomainsListResult model =
            new L3IsolationDomainsListResult()
                .withValue(
                    Arrays
                        .asList(
                            new L3IsolationDomainInner()
                                .withLocation("jusrtslhspk")
                                .withTags(
                                    mapOf("melmqkrha", "maofmxagkv", "aquhcdhm", "vljua", "rcrgvx", "ualaexqpvfadmw"))
                                .withNetworkFabricId("hl")
                                .withRedistributeConnectedSubnets(RedistributeConnectedSubnets.TRUE)
                                .withRedistributeStaticRoutes(RedistributeStaticRoutes.TRUE)
                                .withDescription("sbkyvpycanuzbp")
                                .withAnnotation("fkuwbcrnwbmehhse"),
                            new L3IsolationDomainInner()
                                .withLocation("cwwfvovbvme")
                                .withTags(
                                    mapOf(
                                        "iotwmcdytdxwit",
                                        "ivyhzceuojgjrwju",
                                        "hniskxfbkpyc",
                                        "nrjawgqwg",
                                        "l",
                                        "klwndnhjdauwhv"))
                                .withNetworkFabricId("liourqhak")
                                .withRedistributeConnectedSubnets(RedistributeConnectedSubnets.FALSE)
                                .withRedistributeStaticRoutes(RedistributeStaticRoutes.TRUE)
                                .withDescription("w")
                                .withAnnotation("ugicjooxdjebw")))
                .withNextLink("upjm");
        model = BinaryData.fromObject(model).toObject(L3IsolationDomainsListResult.class);
        Assertions.assertEquals("jusrtslhspk", model.value().get(0).location());
        Assertions.assertEquals("maofmxagkv", model.value().get(0).tags().get("melmqkrha"));
        Assertions.assertEquals("hl", model.value().get(0).networkFabricId());
        Assertions.assertEquals(RedistributeConnectedSubnets.TRUE, model.value().get(0).redistributeConnectedSubnets());
        Assertions.assertEquals(RedistributeStaticRoutes.TRUE, model.value().get(0).redistributeStaticRoutes());
        Assertions.assertEquals("sbkyvpycanuzbp", model.value().get(0).description());
        Assertions.assertEquals("fkuwbcrnwbmehhse", model.value().get(0).annotation());
        Assertions.assertEquals("upjm", 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;
    }
}
