// 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.IntegrationAccountSchemaInner;
import com.azure.resourcemanager.logic.models.IntegrationAccountSchemaListResult;
import com.azure.resourcemanager.logic.models.SchemaType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationAccountSchemaListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountSchemaListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"schemaType\":\"NotSpecified\",\"targetNamespace\":\"ujmqlgkfbtndoa\",\"documentName\":\"gbjcntujitcjed\",\"fileName\":\"wwa\",\"createdTime\":\"2020-12-30T10:34:47Z\",\"changedTime\":\"2021-01-12T06:35:18Z\",\"metadata\":\"datadcpzfoqo\",\"content\":\"cybxa\",\"contentType\":\"gszufoxciqopid\"},\"location\":\"mciodhkhazxkhn\",\"tags\":{\"okdwb\":\"nlwntoe\",\"cmrvexzt\":\"hksz\",\"gsfraoyzkoow\":\"bt\"},\"id\":\"lmnguxaw\",\"name\":\"aldsy\",\"type\":\"uximerqfobw\"},{\"properties\":{\"schemaType\":\"Xml\",\"targetNamespace\":\"kby\",\"documentName\":\"t\",\"fileName\":\"fhpagmhrskdsnf\",\"createdTime\":\"2021-10-10T07:52:18Z\",\"changedTime\":\"2020-12-22T21:30:22Z\",\"metadata\":\"datagtdlmk\",\"content\":\"evdlh\",\"contentType\":\"pusdstt\"},\"location\":\"ogvbbejdcngq\",\"tags\":{\"wr\":\"akufgmjz\",\"u\":\"grtwae\"},\"id\":\"zkopb\",\"name\":\"inrfdwoyu\",\"type\":\"hziuiefozbhdms\"},{\"properties\":{\"schemaType\":\"NotSpecified\",\"targetNamespace\":\"zqhof\",\"documentName\":\"maequiahxicslfa\",\"fileName\":\"z\",\"createdTime\":\"2021-10-29T12:24:36Z\",\"changedTime\":\"2021-07-09T22:00:16Z\",\"metadata\":\"dataalnswhccsphk\",\"content\":\"vwitqscyw\",\"contentType\":\"gwol\"},\"location\":\"czbwemhairsbr\",\"tags\":{\"ggicccnxqhue\":\"wmsweypqwd\",\"zrncsdt\":\"mkttlstvlzywem\",\"bsfgytguslfea\":\"lusiy\"},\"id\":\"cy\",\"name\":\"qukyhejhzi\",\"type\":\"xgfpelolppv\"},{\"properties\":{\"schemaType\":\"NotSpecified\",\"targetNamespace\":\"pqvujzraehtwdwrf\",\"documentName\":\"wib\",\"fileName\":\"cdl\",\"createdTime\":\"2021-11-13T01:36:21Z\",\"changedTime\":\"2021-05-15T13:33:35Z\",\"metadata\":\"datap\",\"content\":\"cstwity\",\"contentType\":\"evxccedcp\"},\"location\":\"dyodnwzxltj\",\"tags\":{\"ugcxnavvwxq\":\"hlt\",\"wlmdjrkv\":\"byqunyow\",\"vfvpdbodaciz\":\"g\"},\"id\":\"j\",\"name\":\"lhkrribdeibqipqk\",\"type\":\"hvxndzwmkrefajpj\"}],\"nextLink\":\"wkqnyhg\"}")
                .toObject(IntegrationAccountSchemaListResult.class);
        Assertions.assertEquals("mciodhkhazxkhn", model.value().get(0).location());
        Assertions.assertEquals("nlwntoe", model.value().get(0).tags().get("okdwb"));
        Assertions.assertEquals(SchemaType.NOT_SPECIFIED, model.value().get(0).schemaType());
        Assertions.assertEquals("ujmqlgkfbtndoa", model.value().get(0).targetNamespace());
        Assertions.assertEquals("gbjcntujitcjed", model.value().get(0).documentName());
        Assertions.assertEquals("wwa", model.value().get(0).fileName());
        Assertions.assertEquals("cybxa", model.value().get(0).content());
        Assertions.assertEquals("gszufoxciqopid", model.value().get(0).contentType());
        Assertions.assertEquals("wkqnyhg", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountSchemaListResult model =
            new IntegrationAccountSchemaListResult()
                .withValue(
                    Arrays
                        .asList(
                            new IntegrationAccountSchemaInner()
                                .withLocation("mciodhkhazxkhn")
                                .withTags(mapOf("okdwb", "nlwntoe", "cmrvexzt", "hksz", "gsfraoyzkoow", "bt"))
                                .withSchemaType(SchemaType.NOT_SPECIFIED)
                                .withTargetNamespace("ujmqlgkfbtndoa")
                                .withDocumentName("gbjcntujitcjed")
                                .withFileName("wwa")
                                .withMetadata("datadcpzfoqo")
                                .withContent("cybxa")
                                .withContentType("gszufoxciqopid"),
                            new IntegrationAccountSchemaInner()
                                .withLocation("ogvbbejdcngq")
                                .withTags(mapOf("wr", "akufgmjz", "u", "grtwae"))
                                .withSchemaType(SchemaType.XML)
                                .withTargetNamespace("kby")
                                .withDocumentName("t")
                                .withFileName("fhpagmhrskdsnf")
                                .withMetadata("datagtdlmk")
                                .withContent("evdlh")
                                .withContentType("pusdstt"),
                            new IntegrationAccountSchemaInner()
                                .withLocation("czbwemhairsbr")
                                .withTags(
                                    mapOf(
                                        "ggicccnxqhue",
                                        "wmsweypqwd",
                                        "zrncsdt",
                                        "mkttlstvlzywem",
                                        "bsfgytguslfea",
                                        "lusiy"))
                                .withSchemaType(SchemaType.NOT_SPECIFIED)
                                .withTargetNamespace("zqhof")
                                .withDocumentName("maequiahxicslfa")
                                .withFileName("z")
                                .withMetadata("dataalnswhccsphk")
                                .withContent("vwitqscyw")
                                .withContentType("gwol"),
                            new IntegrationAccountSchemaInner()
                                .withLocation("dyodnwzxltj")
                                .withTags(mapOf("ugcxnavvwxq", "hlt", "wlmdjrkv", "byqunyow", "vfvpdbodaciz", "g"))
                                .withSchemaType(SchemaType.NOT_SPECIFIED)
                                .withTargetNamespace("pqvujzraehtwdwrf")
                                .withDocumentName("wib")
                                .withFileName("cdl")
                                .withMetadata("datap")
                                .withContent("cstwity")
                                .withContentType("evxccedcp")))
                .withNextLink("wkqnyhg");
        model = BinaryData.fromObject(model).toObject(IntegrationAccountSchemaListResult.class);
        Assertions.assertEquals("mciodhkhazxkhn", model.value().get(0).location());
        Assertions.assertEquals("nlwntoe", model.value().get(0).tags().get("okdwb"));
        Assertions.assertEquals(SchemaType.NOT_SPECIFIED, model.value().get(0).schemaType());
        Assertions.assertEquals("ujmqlgkfbtndoa", model.value().get(0).targetNamespace());
        Assertions.assertEquals("gbjcntujitcjed", model.value().get(0).documentName());
        Assertions.assertEquals("wwa", model.value().get(0).fileName());
        Assertions.assertEquals("cybxa", model.value().get(0).content());
        Assertions.assertEquals("gszufoxciqopid", model.value().get(0).contentType());
        Assertions.assertEquals("wkqnyhg", 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;
    }
}
