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

package com.azure.resourcemanager.dnsresolver.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.dnsresolver.fluent.models.InboundEndpointInner;
import com.azure.resourcemanager.dnsresolver.models.InboundEndpointListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class InboundEndpointListResultTests {
    @Test
    public void testDeserialize() {
        InboundEndpointListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"u\",\"properties\":{\"ipConfigurations\":[],\"provisioningState\":\"Deleting\",\"resourceGuid\":\"vmkjozkrwfndiodj\"},\"location\":\"lwejdpv\",\"tags\":{\"ctazakljlahbcryf\":\"oqpsoa\",\"ojakhmsbzjhcrze\":\"dfdosygexp\",\"qtrgqjbpfzfsinzg\":\"dphlxaolt\"},\"id\":\"f\",\"name\":\"jrwzox\",\"type\":\"j\"},{\"etag\":\"elluwfziton\",\"properties\":{\"ipConfigurations\":[],\"provisioningState\":\"Creating\",\"resourceGuid\":\"pjkjlxofpdv\"},\"location\":\"fxxypininmayhuy\",\"tags\":{\"inuvamiheogn\":\"podepoo\",\"usivye\":\"rxzxtheo\"},\"id\":\"cciqihnhungbwjz\",\"name\":\"nfygxgispemvtz\",\"type\":\"kufubljo\"},{\"etag\":\"qeof\",\"properties\":{\"ipConfigurations\":[],\"provisioningState\":\"Failed\",\"resourceGuid\":\"jhqjbasvmsmjqul\"},\"location\":\"sntnbybkzgcw\",\"tags\":{\"vkocrcjdkwtn\":\"lxxwrljdouskc\",\"gls\":\"xbnjbiksq\",\"pee\":\"ainqpjwnzlljfm\"},\"id\":\"vmgxsab\",\"name\":\"yqduujit\",\"type\":\"jczdzevndh\"}],\"nextLink\":\"wpdappdsbdkv\"}")
                .toObject(InboundEndpointListResult.class);
        Assertions.assertEquals("lwejdpv", model.value().get(0).location());
        Assertions.assertEquals("oqpsoa", model.value().get(0).tags().get("ctazakljlahbcryf"));
    }

    @Test
    public void testSerialize() {
        InboundEndpointListResult model =
            new InboundEndpointListResult()
                .withValue(
                    Arrays
                        .asList(
                            new InboundEndpointInner()
                                .withLocation("lwejdpv")
                                .withTags(
                                    mapOf(
                                        "ctazakljlahbcryf",
                                        "oqpsoa",
                                        "ojakhmsbzjhcrze",
                                        "dfdosygexp",
                                        "qtrgqjbpfzfsinzg",
                                        "dphlxaolt"))
                                .withIpConfigurations(Arrays.asList()),
                            new InboundEndpointInner()
                                .withLocation("fxxypininmayhuy")
                                .withTags(mapOf("inuvamiheogn", "podepoo", "usivye", "rxzxtheo"))
                                .withIpConfigurations(Arrays.asList()),
                            new InboundEndpointInner()
                                .withLocation("sntnbybkzgcw")
                                .withTags(
                                    mapOf("vkocrcjdkwtn", "lxxwrljdouskc", "gls", "xbnjbiksq", "pee", "ainqpjwnzlljfm"))
                                .withIpConfigurations(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(InboundEndpointListResult.class);
        Assertions.assertEquals("lwejdpv", model.value().get(0).location());
        Assertions.assertEquals("oqpsoa", model.value().get(0).tags().get("ctazakljlahbcryf"));
    }

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