// 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.DnsForwardingRulesetInner;
import com.azure.resourcemanager.dnsresolver.models.DnsForwardingRulesetListResult;
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 DnsForwardingRulesetListResultTests {
    @Test
    public void testDeserialize() {
        DnsForwardingRulesetListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"xmqci\",\"properties\":{\"dnsResolverOutboundEndpoints\":[],\"provisioningState\":\"Failed\",\"resourceGuid\":\"khixuigdtopbo\"},\"location\":\"og\",\"tags\":{\"a\":\"w\"},\"id\":\"a\",\"name\":\"hrzayvvtpgvdf\",\"type\":\"iotkftutqxl\"}],\"nextLink\":\"xlefgugnxkrx\"}")
                .toObject(DnsForwardingRulesetListResult.class);
        Assertions.assertEquals("og", model.value().get(0).location());
        Assertions.assertEquals("w", model.value().get(0).tags().get("a"));
    }

    @Test
    public void testSerialize() {
        DnsForwardingRulesetListResult model =
            new DnsForwardingRulesetListResult()
                .withValue(
                    Arrays
                        .asList(
                            new DnsForwardingRulesetInner()
                                .withLocation("og")
                                .withTags(mapOf("a", "w"))
                                .withDnsResolverOutboundEndpoints(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(DnsForwardingRulesetListResult.class);
        Assertions.assertEquals("og", model.value().get(0).location());
        Assertions.assertEquals("w", model.value().get(0).tags().get("a"));
    }

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