// 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.TrunkedNetworkInner;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import com.azure.resourcemanager.networkcloud.models.HybridAksPluginType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class TrunkedNetworkInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TrunkedNetworkInner model =
            BinaryData
                .fromString(
                    "{\"extendedLocation\":{\"name\":\"juisavokqdzf\",\"type\":\"azivjlfrqttbajl\"},\"properties\":{\"associatedResourceIds\":[\"nwxyiop\",\"dkqqfkuvscxkd\"],\"clusterId\":\"igovi\",\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"pmloazuruoc\",\"hybridAksClustersAssociatedIds\":[\"orbteoy\"],\"hybridAksPluginType\":\"DPDK\",\"interfaceName\":\"xakvvjgslor\",\"isolationDomainIds\":[\"lmywwtkgkxnyed\"],\"provisioningState\":\"Accepted\",\"virtualMachinesAssociatedIds\":[\"udtjuewbc\",\"hxuuwhcjyxccybvp\",\"yakk\",\"dzpxgwjpl\"],\"vlans\":[717820134294381361]},\"location\":\"cyohpfkyrkdbd\",\"tags\":{\"mnwqj\":\"gsj\",\"n\":\"obaiyhddviaceg\",\"dwvvba\":\"ntfpmvmemfnc\"},\"id\":\"xlllchp\",\"name\":\"db\",\"type\":\"evwrdnhfuk\"}")
                .toObject(TrunkedNetworkInner.class);
        Assertions.assertEquals("cyohpfkyrkdbd", model.location());
        Assertions.assertEquals("gsj", model.tags().get("mnwqj"));
        Assertions.assertEquals("juisavokqdzf", model.extendedLocation().name());
        Assertions.assertEquals("azivjlfrqttbajl", model.extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.DPDK, model.hybridAksPluginType());
        Assertions.assertEquals("xakvvjgslor", model.interfaceName());
        Assertions.assertEquals("lmywwtkgkxnyed", model.isolationDomainIds().get(0));
        Assertions.assertEquals(717820134294381361L, model.vlans().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TrunkedNetworkInner model =
            new TrunkedNetworkInner()
                .withLocation("cyohpfkyrkdbd")
                .withTags(mapOf("mnwqj", "gsj", "n", "obaiyhddviaceg", "dwvvba", "ntfpmvmemfnc"))
                .withExtendedLocation(new ExtendedLocation().withName("juisavokqdzf").withType("azivjlfrqttbajl"))
                .withHybridAksPluginType(HybridAksPluginType.DPDK)
                .withInterfaceName("xakvvjgslor")
                .withIsolationDomainIds(Arrays.asList("lmywwtkgkxnyed"))
                .withVlans(Arrays.asList(717820134294381361L));
        model = BinaryData.fromObject(model).toObject(TrunkedNetworkInner.class);
        Assertions.assertEquals("cyohpfkyrkdbd", model.location());
        Assertions.assertEquals("gsj", model.tags().get("mnwqj"));
        Assertions.assertEquals("juisavokqdzf", model.extendedLocation().name());
        Assertions.assertEquals("azivjlfrqttbajl", model.extendedLocation().type());
        Assertions.assertEquals(HybridAksPluginType.DPDK, model.hybridAksPluginType());
        Assertions.assertEquals("xakvvjgslor", model.interfaceName());
        Assertions.assertEquals("lmywwtkgkxnyed", model.isolationDomainIds().get(0));
        Assertions.assertEquals(717820134294381361L, model.vlans().get(0));
    }

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