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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.fluent.models.SecretInner;
import com.azure.resourcemanager.devtestlabs.models.SecretList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SecretListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SecretList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"value\":\"idxas\",\"provisioningState\":\"ddyvvjskgfmo\",\"uniqueIdentifier\":\"ah\"},\"location\":\"qgatjeaahhvjhhn\",\"tags\":{\"yxvxevblbjed\":\"ybbjjidjksyx\",\"smjbnkppxyn\":\"ljlageuaulxu\"},\"id\":\"nlsvxeiz\",\"name\":\"gwklnsr\",\"type\":\"ffeycx\"},{\"properties\":{\"value\":\"tpiymerteea\",\"provisioningState\":\"xqiekkkzddrtk\",\"uniqueIdentifier\":\"ojbmxv\"},\"location\":\"vrefdeesv\",\"tags\":{\"uwprtujwsawd\":\"ijpxtx\"},\"id\":\"jibabxvititvtze\",\"name\":\"xavo\",\"type\":\"tfgle\"},{\"properties\":{\"value\":\"m\",\"provisioningState\":\"bwpypqtgsfjacb\",\"uniqueIdentifier\":\"hhxud\"},\"location\":\"xvodhtnsir\",\"tags\":{\"mes\":\"z\",\"zrcxfailcfxwmdbo\":\"kdlpa\"},\"id\":\"dfgsftufqobrj\",\"name\":\"nac\",\"type\":\"cc\"},{\"properties\":{\"value\":\"nhxk\",\"provisioningState\":\"v\",\"uniqueIdentifier\":\"nrzvuljraaer\"},\"location\":\"nok\",\"tags\":{\"cdisd\":\"kkjqnvbroylaxxu\",\"rwhryvycytd\":\"sfjbjsvg\",\"pdvjdhttzaefedx\":\"lxgccknfnwmbtm\",\"dfzpbgtgkylkdg\":\"hchrphkmcrjdqn\"},\"id\":\"rjeuut\",\"name\":\"wxezwzhok\",\"type\":\"bwnhhtql\"}],\"nextLink\":\"hgppipifhpfeoa\"}")
                .toObject(SecretList.class);
        Assertions.assertEquals("qgatjeaahhvjhhn", model.value().get(0).location());
        Assertions.assertEquals("ybbjjidjksyx", model.value().get(0).tags().get("yxvxevblbjed"));
        Assertions.assertEquals("idxas", model.value().get(0).value());
        Assertions.assertEquals("hgppipifhpfeoa", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SecretList model =
            new SecretList()
                .withValue(
                    Arrays
                        .asList(
                            new SecretInner()
                                .withLocation("qgatjeaahhvjhhn")
                                .withTags(mapOf("yxvxevblbjed", "ybbjjidjksyx", "smjbnkppxyn", "ljlageuaulxu"))
                                .withValue("idxas"),
                            new SecretInner()
                                .withLocation("vrefdeesv")
                                .withTags(mapOf("uwprtujwsawd", "ijpxtx"))
                                .withValue("tpiymerteea"),
                            new SecretInner()
                                .withLocation("xvodhtnsir")
                                .withTags(mapOf("mes", "z", "zrcxfailcfxwmdbo", "kdlpa"))
                                .withValue("m"),
                            new SecretInner()
                                .withLocation("nok")
                                .withTags(
                                    mapOf(
                                        "cdisd",
                                        "kkjqnvbroylaxxu",
                                        "rwhryvycytd",
                                        "sfjbjsvg",
                                        "pdvjdhttzaefedx",
                                        "lxgccknfnwmbtm",
                                        "dfzpbgtgkylkdg",
                                        "hchrphkmcrjdqn"))
                                .withValue("nhxk")))
                .withNextLink("hgppipifhpfeoa");
        model = BinaryData.fromObject(model).toObject(SecretList.class);
        Assertions.assertEquals("qgatjeaahhvjhhn", model.value().get(0).location());
        Assertions.assertEquals("ybbjjidjksyx", model.value().get(0).tags().get("yxvxevblbjed"));
        Assertions.assertEquals("idxas", model.value().get(0).value());
        Assertions.assertEquals("hgppipifhpfeoa", 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;
    }
}
