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

package com.azure.resourcemanager.logic.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.logic.fluent.models.IntegrationAccountMapInner;
import com.azure.resourcemanager.logic.models.IntegrationAccountMapListResult;
import com.azure.resourcemanager.logic.models.MapType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationAccountMapListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountMapListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"mapType\":\"Xslt\",\"createdTime\":\"2021-09-27T04:00:59Z\",\"changedTime\":\"2021-06-03T19:27:08Z\",\"content\":\"jguufzdm\",\"contentType\":\"qtfihwhbotzinga\",\"metadata\":\"dataphoszqz\"},\"location\":\"dphqamv\",\"tags\":{\"nvyq\":\"wynwcvtbvkayhm\",\"cjaesgvvs\":\"atkzwpcnpw\",\"wygzlvdnkfxusem\":\"cyajguqf\",\"pfcqdp\":\"wzrmuh\"},\"id\":\"qxqvpsvuoymgc\",\"name\":\"elvezrypq\",\"type\":\"mfe\"},{\"properties\":{\"mapType\":\"Liquid\",\"createdTime\":\"2021-10-17T10:06:59Z\",\"changedTime\":\"2021-02-20T05:54:30Z\",\"content\":\"hkobopgxedk\",\"contentType\":\"epbqpcrfkbw\",\"metadata\":\"datanjv\"},\"location\":\"dw\",\"tags\":{\"tn\":\"qek\"},\"id\":\"htjsying\",\"name\":\"fq\",\"type\":\"tmtdhtmdvypgik\"},{\"properties\":{\"mapType\":\"Liquid\",\"createdTime\":\"2021-07-11T10:33:14Z\",\"changedTime\":\"2021-03-02T21:03:10Z\",\"content\":\"rryuzhlhkjo\",\"contentType\":\"vqqaatjinrvgo\",\"metadata\":\"datafiibfggjioolvr\"},\"location\":\"x\",\"tags\":{\"wjygvjayvblmhvk\":\"kkgll\",\"gsopbyrqufegxu\":\"uhbxvvy\",\"bnhlmc\":\"wz\"},\"id\":\"l\",\"name\":\"dn\",\"type\":\"itvgbmhrixkwm\"}],\"nextLink\":\"jejveg\"}")
                .toObject(IntegrationAccountMapListResult.class);
        Assertions.assertEquals("dphqamv", model.value().get(0).location());
        Assertions.assertEquals("wynwcvtbvkayhm", model.value().get(0).tags().get("nvyq"));
        Assertions.assertEquals(MapType.XSLT, model.value().get(0).mapType());
        Assertions.assertEquals("jguufzdm", model.value().get(0).content());
        Assertions.assertEquals("qtfihwhbotzinga", model.value().get(0).contentType());
        Assertions.assertEquals("jejveg", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountMapListResult model =
            new IntegrationAccountMapListResult()
                .withValue(
                    Arrays
                        .asList(
                            new IntegrationAccountMapInner()
                                .withLocation("dphqamv")
                                .withTags(
                                    mapOf(
                                        "nvyq",
                                        "wynwcvtbvkayhm",
                                        "cjaesgvvs",
                                        "atkzwpcnpw",
                                        "wygzlvdnkfxusem",
                                        "cyajguqf",
                                        "pfcqdp",
                                        "wzrmuh"))
                                .withMapType(MapType.XSLT)
                                .withContent("jguufzdm")
                                .withContentType("qtfihwhbotzinga")
                                .withMetadata("dataphoszqz"),
                            new IntegrationAccountMapInner()
                                .withLocation("dw")
                                .withTags(mapOf("tn", "qek"))
                                .withMapType(MapType.LIQUID)
                                .withContent("hkobopgxedk")
                                .withContentType("epbqpcrfkbw")
                                .withMetadata("datanjv"),
                            new IntegrationAccountMapInner()
                                .withLocation("x")
                                .withTags(
                                    mapOf("wjygvjayvblmhvk", "kkgll", "gsopbyrqufegxu", "uhbxvvy", "bnhlmc", "wz"))
                                .withMapType(MapType.LIQUID)
                                .withContent("rryuzhlhkjo")
                                .withContentType("vqqaatjinrvgo")
                                .withMetadata("datafiibfggjioolvr")))
                .withNextLink("jejveg");
        model = BinaryData.fromObject(model).toObject(IntegrationAccountMapListResult.class);
        Assertions.assertEquals("dphqamv", model.value().get(0).location());
        Assertions.assertEquals("wynwcvtbvkayhm", model.value().get(0).tags().get("nvyq"));
        Assertions.assertEquals(MapType.XSLT, model.value().get(0).mapType());
        Assertions.assertEquals("jguufzdm", model.value().get(0).content());
        Assertions.assertEquals("qtfihwhbotzinga", model.value().get(0).contentType());
        Assertions.assertEquals("jejveg", 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;
    }
}
