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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.AgentPoolInner;
import com.azure.resourcemanager.networkcloud.models.AgentPoolList;
import com.azure.resourcemanager.networkcloud.models.AgentPoolMode;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AgentPoolListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AgentPoolList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"bkgozxwopdbydpi\",\"value\":[{\"extendedLocation\":{\"name\":\"lnapxbiygn\",\"type\":\"gjkn\"},\"properties\":{\"availabilityZones\":[],\"count\":8486285334605495834,\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"uyilflqoiquvrehm\",\"kubernetesVersion\":\"jhvsujztczyt\",\"labels\":[],\"mode\":\"User\",\"provisioningState\":\"Accepted\",\"taints\":[],\"vmSkuName\":\"unfprnjletlxs\"},\"location\":\"pddouifamowaziyn\",\"tags\":{\"zdtmaajquhuxylrj\":\"qwzdvpiwhxq\",\"ygjbmzyospspsh\":\"m\",\"sp\":\"kfkyjp\",\"ujtv\":\"pssdfppyogtie\"},\"id\":\"zkc\",\"name\":\"yxrxmunj\",\"type\":\"xvglnkvxlxp\"},{\"extendedLocation\":{\"name\":\"lqivbgkcv\",\"type\":\"hpzvuqdflvoniyp\"},\"properties\":{\"availabilityZones\":[],\"count\":1373508345652934978,\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"tivhjknidibgqjx\",\"kubernetesVersion\":\"n\",\"labels\":[],\"mode\":\"User\",\"provisioningState\":\"InProgress\",\"taints\":[],\"vmSkuName\":\"pikqmh\"},\"location\":\"owjrmzvuporqz\",\"tags\":{\"xcnqmxqpswokmvkh\":\"ydzvkf\",\"wtglxx\":\"ggdhbemzqkzszuw\"},\"id\":\"ljfp\",\"name\":\"picrmnzhrgmqgjsx\",\"type\":\"pqcbfrmbodthsq\"},{\"extendedLocation\":{\"name\":\"vriibakclacjfr\",\"type\":\"xousxauzl\"},\"properties\":{\"availabilityZones\":[],\"count\":2109671896042755396,\"detailedStatus\":\"Provisioning\",\"detailedStatusMessage\":\"zizvuxmmk\",\"kubernetesVersion\":\"vthn\",\"labels\":[],\"mode\":\"NotApplicable\",\"provisioningState\":\"Canceled\",\"taints\":[],\"vmSkuName\":\"vmribiat\"},\"location\":\"plucfotangcfhnyk\",\"tags\":{\"tx\":\"gswvxwlmzqwm\",\"cvclxynpdk\":\"jmxmcuqud\"},\"id\":\"gfabuiyjibuzphdu\",\"name\":\"neiknpg\",\"type\":\"xgjiuqh\"},{\"extendedLocation\":{\"name\":\"tozipqwj\",\"type\":\"d\"},\"properties\":{\"availabilityZones\":[],\"count\":994426263609562850,\"detailedStatus\":\"Available\",\"detailedStatusMessage\":\"ktvqylkmqpzoy\",\"kubernetesVersion\":\"fbcgwgcloxoebqin\",\"labels\":[],\"mode\":\"User\",\"provisioningState\":\"Deleting\",\"taints\":[],\"vmSkuName\":\"ujqlafcbahh\"},\"location\":\"pofoi\",\"tags\":{\"ilkmk\":\"p\"},\"id\":\"holvdn\",\"name\":\"viauogphua\",\"type\":\"tvt\"}]}")
                .toObject(AgentPoolList.class);
        Assertions.assertEquals("bkgozxwopdbydpi", model.nextLink());
        Assertions.assertEquals("pddouifamowaziyn", model.value().get(0).location());
        Assertions.assertEquals("qwzdvpiwhxq", model.value().get(0).tags().get("zdtmaajquhuxylrj"));
        Assertions.assertEquals("lnapxbiygn", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("gjkn", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(8486285334605495834L, model.value().get(0).count());
        Assertions.assertEquals(AgentPoolMode.USER, model.value().get(0).mode());
        Assertions.assertEquals("unfprnjletlxs", model.value().get(0).vmSkuName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AgentPoolList model =
            new AgentPoolList()
                .withNextLink("bkgozxwopdbydpi")
                .withValue(
                    Arrays
                        .asList(
                            new AgentPoolInner()
                                .withLocation("pddouifamowaziyn")
                                .withTags(
                                    mapOf(
                                        "zdtmaajquhuxylrj",
                                        "qwzdvpiwhxq",
                                        "ygjbmzyospspsh",
                                        "m",
                                        "sp",
                                        "kfkyjp",
                                        "ujtv",
                                        "pssdfppyogtie"))
                                .withExtendedLocation(new ExtendedLocation().withName("lnapxbiygn").withType("gjkn"))
                                .withAvailabilityZones(Arrays.asList())
                                .withCount(8486285334605495834L)
                                .withLabels(Arrays.asList())
                                .withMode(AgentPoolMode.USER)
                                .withTaints(Arrays.asList())
                                .withVmSkuName("unfprnjletlxs"),
                            new AgentPoolInner()
                                .withLocation("owjrmzvuporqz")
                                .withTags(mapOf("xcnqmxqpswokmvkh", "ydzvkf", "wtglxx", "ggdhbemzqkzszuw"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("lqivbgkcv").withType("hpzvuqdflvoniyp"))
                                .withAvailabilityZones(Arrays.asList())
                                .withCount(1373508345652934978L)
                                .withLabels(Arrays.asList())
                                .withMode(AgentPoolMode.USER)
                                .withTaints(Arrays.asList())
                                .withVmSkuName("pikqmh"),
                            new AgentPoolInner()
                                .withLocation("plucfotangcfhnyk")
                                .withTags(mapOf("tx", "gswvxwlmzqwm", "cvclxynpdk", "jmxmcuqud"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("vriibakclacjfr").withType("xousxauzl"))
                                .withAvailabilityZones(Arrays.asList())
                                .withCount(2109671896042755396L)
                                .withLabels(Arrays.asList())
                                .withMode(AgentPoolMode.NOT_APPLICABLE)
                                .withTaints(Arrays.asList())
                                .withVmSkuName("vmribiat"),
                            new AgentPoolInner()
                                .withLocation("pofoi")
                                .withTags(mapOf("ilkmk", "p"))
                                .withExtendedLocation(new ExtendedLocation().withName("tozipqwj").withType("d"))
                                .withAvailabilityZones(Arrays.asList())
                                .withCount(994426263609562850L)
                                .withLabels(Arrays.asList())
                                .withMode(AgentPoolMode.USER)
                                .withTaints(Arrays.asList())
                                .withVmSkuName("ujqlafcbahh")));
        model = BinaryData.fromObject(model).toObject(AgentPoolList.class);
        Assertions.assertEquals("bkgozxwopdbydpi", model.nextLink());
        Assertions.assertEquals("pddouifamowaziyn", model.value().get(0).location());
        Assertions.assertEquals("qwzdvpiwhxq", model.value().get(0).tags().get("zdtmaajquhuxylrj"));
        Assertions.assertEquals("lnapxbiygn", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("gjkn", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(8486285334605495834L, model.value().get(0).count());
        Assertions.assertEquals(AgentPoolMode.USER, model.value().get(0).mode());
        Assertions.assertEquals("unfprnjletlxs", model.value().get(0).vmSkuName());
    }

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