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

public final class FormulaListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        FormulaList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"description\":\"cqqudf\",\"author\":\"yxbaaabjyvayf\",\"osType\":\"m\",\"creationDate\":\"2021-07-11T14:35:31Z\",\"provisioningState\":\"qogsexnevfd\",\"uniqueIdentifier\":\"nw\"},\"location\":\"ewzsyyceuzsoib\",\"tags\":{\"dwkqbrq\":\"pfrxtrthzvay\",\"irqtdqoa\":\"bpaxhexiilivpdt\",\"eptra\":\"oruzfgsquyfxrxx\",\"wlwnwxuqlcv\":\"xje\"},\"id\":\"dy\",\"name\":\"atdooaojkniod\",\"type\":\"oo\"},{\"properties\":{\"description\":\"wnujhemmsbvdk\",\"author\":\"odtji\",\"osType\":\"wj\",\"creationDate\":\"2021-06-03T21:25:15Z\",\"provisioningState\":\"cjvefkdlfo\",\"uniqueIdentifier\":\"ggkfpagaowpul\"},\"location\":\"qblylsyxkqj\",\"tags\":{\"sz\":\"ervtiagxs\",\"psbzkfzbeyvpn\":\"e\"},\"id\":\"icvi\",\"name\":\"v\",\"type\":\"jjxd\"},{\"properties\":{\"description\":\"buukzclewyhml\",\"author\":\"aztz\",\"osType\":\"fn\",\"creationDate\":\"2021-07-07T15:20:18Z\",\"provisioningState\":\"qwhxxbuyqaxzfeqz\",\"uniqueIdentifier\":\"priolx\"},\"location\":\"rjaltolmncw\",\"tags\":{\"dpfuvg\":\"qwcsdbnwdcfhuc\",\"nvxbvt\":\"sbjjc\",\"mr\":\"udutnco\"},\"id\":\"xqtvcofu\",\"name\":\"f\",\"type\":\"vkg\"}],\"nextLink\":\"bgdknnqv\"}")
                .toObject(FormulaList.class);
        Assertions.assertEquals("ewzsyyceuzsoib", model.value().get(0).location());
        Assertions.assertEquals("pfrxtrthzvay", model.value().get(0).tags().get("dwkqbrq"));
        Assertions.assertEquals("cqqudf", model.value().get(0).description());
        Assertions.assertEquals("m", model.value().get(0).osType());
        Assertions.assertEquals("bgdknnqv", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        FormulaList model =
            new FormulaList()
                .withValue(
                    Arrays
                        .asList(
                            new FormulaInner()
                                .withLocation("ewzsyyceuzsoib")
                                .withTags(
                                    mapOf(
                                        "dwkqbrq",
                                        "pfrxtrthzvay",
                                        "irqtdqoa",
                                        "bpaxhexiilivpdt",
                                        "eptra",
                                        "oruzfgsquyfxrxx",
                                        "wlwnwxuqlcv",
                                        "xje"))
                                .withDescription("cqqudf")
                                .withOsType("m"),
                            new FormulaInner()
                                .withLocation("qblylsyxkqj")
                                .withTags(mapOf("sz", "ervtiagxs", "psbzkfzbeyvpn", "e"))
                                .withDescription("wnujhemmsbvdk")
                                .withOsType("wj"),
                            new FormulaInner()
                                .withLocation("rjaltolmncw")
                                .withTags(mapOf("dpfuvg", "qwcsdbnwdcfhuc", "nvxbvt", "sbjjc", "mr", "udutnco"))
                                .withDescription("buukzclewyhml")
                                .withOsType("fn")))
                .withNextLink("bgdknnqv");
        model = BinaryData.fromObject(model).toObject(FormulaList.class);
        Assertions.assertEquals("ewzsyyceuzsoib", model.value().get(0).location());
        Assertions.assertEquals("pfrxtrthzvay", model.value().get(0).tags().get("dwkqbrq"));
        Assertions.assertEquals("cqqudf", model.value().get(0).description());
        Assertions.assertEquals("m", model.value().get(0).osType());
        Assertions.assertEquals("bgdknnqv", 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;
    }
}
