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

public final class IntegrationAccountSessionListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationAccountSessionListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"createdTime\":\"2021-04-28T18:21:43Z\",\"changedTime\":\"2021-09-17T03:05:08Z\",\"content\":\"datac\"},\"location\":\"kvyklxubyjaffmm\",\"tags\":{\"ubgq\":\"cqc\",\"metttwgd\":\"brta\",\"seypxiutcxapz\":\"lqxihhrmooiz\",\"petogebjox\":\"y\"},\"id\":\"lhvnhlab\",\"name\":\"q\",\"type\":\"kkzjcjbtrga\"},{\"properties\":{\"createdTime\":\"2021-11-06T16:53:49Z\",\"changedTime\":\"2021-05-17T21:24:33Z\",\"content\":\"datarxjjstoqbeitpk\"},\"location\":\"ztmoobklftidg\",\"tags\":{\"yhohujswtwkozzwc\":\"qmpimaqxzhem\",\"wpfaj\":\"lkb\",\"talhsnvkcdmxzr\":\"jwltlwtjjgu\",\"aaomylweazu\":\"oaimlnw\"},\"id\":\"cse\",\"name\":\"hwwn\",\"type\":\"jhlfzswpchwahf\"},{\"properties\":{\"createdTime\":\"2021-07-25T08:18:30Z\",\"changedTime\":\"2021-04-23T04:46:24Z\",\"content\":\"dataepgfew\"},\"location\":\"twly\",\"tags\":{\"xhdjhl\":\"cxy\",\"rxvxcjzh\":\"mmbcxfhbcp\",\"qscjavftjuh\":\"izxfpxt\",\"mtggu\":\"qaz\"},\"id\":\"pijrajcivmmghf\",\"name\":\"fiwrxgkn\",\"type\":\"uvyinzqodfvpgs\"}],\"nextLink\":\"xgsg\"}")
                .toObject(IntegrationAccountSessionListResult.class);
        Assertions.assertEquals("kvyklxubyjaffmm", model.value().get(0).location());
        Assertions.assertEquals("cqc", model.value().get(0).tags().get("ubgq"));
        Assertions.assertEquals("xgsg", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationAccountSessionListResult model =
            new IntegrationAccountSessionListResult()
                .withValue(
                    Arrays
                        .asList(
                            new IntegrationAccountSessionInner()
                                .withLocation("kvyklxubyjaffmm")
                                .withTags(
                                    mapOf(
                                        "ubgq",
                                        "cqc",
                                        "metttwgd",
                                        "brta",
                                        "seypxiutcxapz",
                                        "lqxihhrmooiz",
                                        "petogebjox",
                                        "y"))
                                .withContent("datac"),
                            new IntegrationAccountSessionInner()
                                .withLocation("ztmoobklftidg")
                                .withTags(
                                    mapOf(
                                        "yhohujswtwkozzwc",
                                        "qmpimaqxzhem",
                                        "wpfaj",
                                        "lkb",
                                        "talhsnvkcdmxzr",
                                        "jwltlwtjjgu",
                                        "aaomylweazu",
                                        "oaimlnw"))
                                .withContent("datarxjjstoqbeitpk"),
                            new IntegrationAccountSessionInner()
                                .withLocation("twly")
                                .withTags(
                                    mapOf(
                                        "xhdjhl",
                                        "cxy",
                                        "rxvxcjzh",
                                        "mmbcxfhbcp",
                                        "qscjavftjuh",
                                        "izxfpxt",
                                        "mtggu",
                                        "qaz"))
                                .withContent("dataepgfew")))
                .withNextLink("xgsg");
        model = BinaryData.fromObject(model).toObject(IntegrationAccountSessionListResult.class);
        Assertions.assertEquals("kvyklxubyjaffmm", model.value().get(0).location());
        Assertions.assertEquals("cqc", model.value().get(0).tags().get("ubgq"));
        Assertions.assertEquals("xgsg", 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;
    }
}
