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

package com.azure.resourcemanager.devhub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devhub.fluent.models.WorkflowInner;
import com.azure.resourcemanager.devhub.models.WorkflowListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class WorkflowListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        WorkflowListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{},\"location\":\"rwfndiod\",\"tags\":{\"ryo\":\"lwejdpv\",\"hbcryffdfdosyge\":\"psoacctazakljl\",\"rzevdphlxaol\":\"paojakhmsbzjh\"},\"id\":\"hqtrgqjbpf\",\"name\":\"fsinzgvfcjrwzoxx\",\"type\":\"tfell\"},{\"properties\":{},\"location\":\"tonpe\",\"tags\":{\"ypininm\":\"jkjlxofpdvhpfx\",\"po\":\"yhuybbkpod\",\"ognarxzxtheotus\":\"ginuvamih\"},\"id\":\"vyevcciqi\",\"name\":\"nhungbw\",\"type\":\"zrnf\"},{\"properties\":{},\"location\":\"spemvtzfk\",\"tags\":{\"aeqjhqjbasvms\":\"bljofxqeof\",\"gsntnbybkzgcwr\":\"jqul\",\"skcqvkocrcjd\":\"clxxwrljdo\"},\"id\":\"wtnhxbnjbiksqr\",\"name\":\"lssai\",\"type\":\"qpjwnzlljfm\"}],\"nextLink\":\"eebvmgxsab\"}")
                .toObject(WorkflowListResult.class);
        Assertions.assertEquals("rwfndiod", model.value().get(0).location());
        Assertions.assertEquals("lwejdpv", model.value().get(0).tags().get("ryo"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        WorkflowListResult model =
            new WorkflowListResult()
                .withValue(
                    Arrays
                        .asList(
                            new WorkflowInner()
                                .withLocation("rwfndiod")
                                .withTags(
                                    mapOf(
                                        "ryo",
                                        "lwejdpv",
                                        "hbcryffdfdosyge",
                                        "psoacctazakljl",
                                        "rzevdphlxaol",
                                        "paojakhmsbzjh")),
                            new WorkflowInner()
                                .withLocation("tonpe")
                                .withTags(
                                    mapOf(
                                        "ypininm",
                                        "jkjlxofpdvhpfx",
                                        "po",
                                        "yhuybbkpod",
                                        "ognarxzxtheotus",
                                        "ginuvamih")),
                            new WorkflowInner()
                                .withLocation("spemvtzfk")
                                .withTags(
                                    mapOf(
                                        "aeqjhqjbasvms",
                                        "bljofxqeof",
                                        "gsntnbybkzgcwr",
                                        "jqul",
                                        "skcqvkocrcjd",
                                        "clxxwrljdo"))));
        model = BinaryData.fromObject(model).toObject(WorkflowListResult.class);
        Assertions.assertEquals("rwfndiod", model.value().get(0).location());
        Assertions.assertEquals("lwejdpv", model.value().get(0).tags().get("ryo"));
    }

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