// 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.OutboundEndpointInner;
import com.azure.resourcemanager.dnsresolver.models.OutboundEndpointListResult;
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 OutboundEndpointListResultTests {
    @Test
    public void testDeserialize() {
        OutboundEndpointListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"dgak\",\"properties\":{\"provisioningState\":\"Deleting\",\"resourceGuid\":\"xybz\"},\"location\":\"e\",\"tags\":{\"kzsmodm\":\"tbciqfouflmm\"},\"id\":\"lougpbkw\",\"name\":\"mutduqktaps\",\"type\":\"wgcu\"},{\"etag\":\"tumkdosvqwhbm\",\"properties\":{\"provisioningState\":\"Creating\",\"resourceGuid\":\"jfddgmbmbe\"},\"location\":\"pbhtqqrolfpfpsa\",\"tags\":{\"gjyjgzjaoyfhrtxi\":\"qux\",\"rkujy\":\"n\"},\"id\":\"vlejuvfqa\",\"name\":\"rlyxwjkcprbnw\",\"type\":\"xgjvtbv\"},{\"etag\":\"sszdnru\",\"properties\":{\"provisioningState\":\"Failed\",\"resourceGuid\":\"hmuouqfprwzwbn\"},\"location\":\"itnwuizgazxufi\",\"tags\":{\"rfidfvzwdz\":\"kyfi\",\"sdkf\":\"htymw\"},\"id\":\"hwxmnteiwa\",\"name\":\"pvkmijcmmxdcuf\",\"type\":\"fsrpymzidnse\"},{\"etag\":\"xtbzsgfyccsne\",\"properties\":{\"provisioningState\":\"Failed\",\"resourceGuid\":\"z\"},\"location\":\"iachbo\",\"tags\":{\"eeh\":\"lnrosfqp\",\"swjdkirso\":\"zvypyqrimzinp\",\"soifiyipjxsqw\":\"dqxhcrmnohjtckwh\",\"bznorcjxvsnby\":\"gr\"},\"id\":\"qabnmoc\",\"name\":\"cyshurzafbljjgp\",\"type\":\"toqcjmklja\"}],\"nextLink\":\"qidtqajzyu\"}")
                .toObject(OutboundEndpointListResult.class);
        Assertions.assertEquals("e", model.value().get(0).location());
        Assertions.assertEquals("tbciqfouflmm", model.value().get(0).tags().get("kzsmodm"));
    }

    @Test
    public void testSerialize() {
        OutboundEndpointListResult model =
            new OutboundEndpointListResult()
                .withValue(
                    Arrays
                        .asList(
                            new OutboundEndpointInner().withLocation("e").withTags(mapOf("kzsmodm", "tbciqfouflmm")),
                            new OutboundEndpointInner()
                                .withLocation("pbhtqqrolfpfpsa")
                                .withTags(mapOf("gjyjgzjaoyfhrtxi", "qux", "rkujy", "n")),
                            new OutboundEndpointInner()
                                .withLocation("itnwuizgazxufi")
                                .withTags(mapOf("rfidfvzwdz", "kyfi", "sdkf", "htymw")),
                            new OutboundEndpointInner()
                                .withLocation("iachbo")
                                .withTags(
                                    mapOf(
                                        "eeh",
                                        "lnrosfqp",
                                        "swjdkirso",
                                        "zvypyqrimzinp",
                                        "soifiyipjxsqw",
                                        "dqxhcrmnohjtckwh",
                                        "bznorcjxvsnby",
                                        "gr"))));
        model = BinaryData.fromObject(model).toObject(OutboundEndpointListResult.class);
        Assertions.assertEquals("e", model.value().get(0).location());
        Assertions.assertEquals("tbciqfouflmm", model.value().get(0).tags().get("kzsmodm"));
    }

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