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

public final class NeighborGroupsListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NeighborGroupsListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"networkTapIds\":[\"oksz\",\"nm\",\"wgpterdiuw\",\"i\"],\"networkTapRuleIds\":[\"kwztsdetj\"],\"provisioningState\":\"Failed\",\"destination\":{\"ipv4Addresses\":[\"cq\",\"olzkgys\"],\"ipv6Addresses\":[\"yybzoxlvoc\",\"tvdxxhe\"]},\"annotation\":\"mlil\"},\"location\":\"ghjhjvmabzzbwa\",\"tags\":{\"apr\":\"mdafbgymqt\",\"neychbjizq\":\"ojxrjnbsconxavi\",\"rfbo\":\"sgnwdxzedpq\",\"mlnfyz\":\"xi\"},\"id\":\"vfrbypic\",\"name\":\"bkpdjtaqhsmq\",\"type\":\"zpdgonjhxshthmgp\"}],\"nextLink\":\"qulpt\"}")
                .toObject(NeighborGroupsListResult.class);
        Assertions.assertEquals("ghjhjvmabzzbwa", model.value().get(0).location());
        Assertions.assertEquals("mdafbgymqt", model.value().get(0).tags().get("apr"));
        Assertions.assertEquals("cq", model.value().get(0).destination().ipv4Addresses().get(0));
        Assertions.assertEquals("yybzoxlvoc", model.value().get(0).destination().ipv6Addresses().get(0));
        Assertions.assertEquals("mlil", model.value().get(0).annotation());
        Assertions.assertEquals("qulpt", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NeighborGroupsListResult model =
            new NeighborGroupsListResult()
                .withValue(
                    Arrays
                        .asList(
                            new NeighborGroupInner()
                                .withLocation("ghjhjvmabzzbwa")
                                .withTags(
                                    mapOf(
                                        "apr",
                                        "mdafbgymqt",
                                        "neychbjizq",
                                        "ojxrjnbsconxavi",
                                        "rfbo",
                                        "sgnwdxzedpq",
                                        "mlnfyz",
                                        "xi"))
                                .withDestination(
                                    new NeighborGroupDestination()
                                        .withIpv4Addresses(Arrays.asList("cq", "olzkgys"))
                                        .withIpv6Addresses(Arrays.asList("yybzoxlvoc", "tvdxxhe")))
                                .withAnnotation("mlil")))
                .withNextLink("qulpt");
        model = BinaryData.fromObject(model).toObject(NeighborGroupsListResult.class);
        Assertions.assertEquals("ghjhjvmabzzbwa", model.value().get(0).location());
        Assertions.assertEquals("mdafbgymqt", model.value().get(0).tags().get("apr"));
        Assertions.assertEquals("cq", model.value().get(0).destination().ipv4Addresses().get(0));
        Assertions.assertEquals("yybzoxlvoc", model.value().get(0).destination().ipv6Addresses().get(0));
        Assertions.assertEquals("mlil", model.value().get(0).annotation());
        Assertions.assertEquals("qulpt", 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;
    }
}
