// 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.DnsResolverInner;
import com.azure.resourcemanager.dnsresolver.models.DnsResolverListResult;
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 DnsResolverListResultTests {
    @Test
    public void testDeserialize() {
        DnsResolverListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"lhjxr\",\"properties\":{\"dnsResolverState\":\"Connected\",\"provisioningState\":\"Creating\",\"resourceGuid\":\"vktsizntocipao\"},\"location\":\"jpsq\",\"tags\":{\"gjofjd\":\"poyfdkfogkn\",\"zyf\":\"eqsrdeupewnwreit\"},\"id\":\"usarhmofc\",\"name\":\"hs\",\"type\":\"yurkdtmlxhekuksj\"}],\"nextLink\":\"ukcdmparcryuanzw\"}")
                .toObject(DnsResolverListResult.class);
        Assertions.assertEquals("jpsq", model.value().get(0).location());
        Assertions.assertEquals("poyfdkfogkn", model.value().get(0).tags().get("gjofjd"));
    }

    @Test
    public void testSerialize() {
        DnsResolverListResult model =
            new DnsResolverListResult()
                .withValue(
                    Arrays
                        .asList(
                            new DnsResolverInner()
                                .withLocation("jpsq")
                                .withTags(mapOf("gjofjd", "poyfdkfogkn", "zyf", "eqsrdeupewnwreit"))));
        model = BinaryData.fromObject(model).toObject(DnsResolverListResult.class);
        Assertions.assertEquals("jpsq", model.value().get(0).location());
        Assertions.assertEquals("poyfdkfogkn", model.value().get(0).tags().get("gjofjd"));
    }

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