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

package com.azure.resourcemanager.hybridcontainerservice.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hybridcontainerservice.fluent.models.ProvisionedClustersResponseInner;
import com.azure.resourcemanager.hybridcontainerservice.models.ProvisionedClusterIdentity;
import com.azure.resourcemanager.hybridcontainerservice.models.ProvisionedClustersResponseExtendedLocation;
import com.azure.resourcemanager.hybridcontainerservice.models.ProvisionedClustersResponseListResult;
import com.azure.resourcemanager.hybridcontainerservice.models.ProvisionedClustersResponseProperties;
import com.azure.resourcemanager.hybridcontainerservice.models.ResourceIdentityType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ProvisionedClustersResponseListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ProvisionedClustersResponseListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"identity\":{\"principalId\":\"rp\",\"tenantId\":\"epcyvahfnlj\",\"type\":\"None\"},\"properties\":{\"enableRbac\":false,\"addonProfiles\":{},\"kubernetesVersion\":\"gidokgjljyoxgvcl\",\"nodeResourceGroup\":\"sncghkjeszz\",\"agentPoolProfiles\":[],\"provisioningState\":\"Created\"},\"extendedLocation\":{\"type\":\"fsm\",\"name\":\"eh\"},\"location\":\"pvecxgodeb\",\"tags\":{\"ukgri\":\"krbm\"},\"id\":\"flz\",\"name\":\"fbxzpuzycisp\",\"type\":\"qzahmgkbrp\"},{\"identity\":{\"principalId\":\"hibnuqqkpika\",\"tenantId\":\"gvtqagnbuynh\",\"type\":\"SystemAssigned\"},\"properties\":{\"enableRbac\":false,\"addonProfiles\":{},\"kubernetesVersion\":\"arbu\",\"nodeResourceGroup\":\"vpnazzm\",\"agentPoolProfiles\":[],\"provisioningState\":\"InProgress\"},\"extendedLocation\":{\"type\":\"hrbnlankxmyskpbh\",\"name\":\"btkcxywnytnrsyn\"},\"location\":\"qidybyx\",\"tags\":{\"xdbabphlwr\":\"clha\",\"cocmnyyaztt\":\"lfktsths\",\"edckzywbiexzfey\":\"twwrqp\",\"ujwb\":\"eaxib\"},\"id\":\"qwalmuzyoxaepd\",\"name\":\"zjancuxr\",\"type\":\"d\"}],\"nextLink\":\"avxbniwdjswztsdb\"}")
                .toObject(ProvisionedClustersResponseListResult.class);
        Assertions.assertEquals("pvecxgodeb", model.value().get(0).location());
        Assertions.assertEquals("krbm", model.value().get(0).tags().get("ukgri"));
        Assertions.assertEquals(ResourceIdentityType.NONE, model.value().get(0).identity().type());
        Assertions.assertEquals(false, model.value().get(0).properties().enableRbac());
        Assertions.assertEquals("gidokgjljyoxgvcl", model.value().get(0).properties().kubernetesVersion());
        Assertions.assertEquals("sncghkjeszz", model.value().get(0).properties().nodeResourceGroup());
        Assertions.assertEquals("fsm", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("eh", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("avxbniwdjswztsdb", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ProvisionedClustersResponseListResult model =
            new ProvisionedClustersResponseListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ProvisionedClustersResponseInner()
                                .withLocation("pvecxgodeb")
                                .withTags(mapOf("ukgri", "krbm"))
                                .withIdentity(new ProvisionedClusterIdentity().withType(ResourceIdentityType.NONE))
                                .withProperties(
                                    new ProvisionedClustersResponseProperties()
                                        .withEnableRbac(false)
                                        .withAddonProfiles(mapOf())
                                        .withKubernetesVersion("gidokgjljyoxgvcl")
                                        .withNodeResourceGroup("sncghkjeszz")
                                        .withAgentPoolProfiles(Arrays.asList()))
                                .withExtendedLocation(
                                    new ProvisionedClustersResponseExtendedLocation().withType("fsm").withName("eh")),
                            new ProvisionedClustersResponseInner()
                                .withLocation("qidybyx")
                                .withTags(
                                    mapOf(
                                        "xdbabphlwr",
                                        "clha",
                                        "cocmnyyaztt",
                                        "lfktsths",
                                        "edckzywbiexzfey",
                                        "twwrqp",
                                        "ujwb",
                                        "eaxib"))
                                .withIdentity(
                                    new ProvisionedClusterIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                                .withProperties(
                                    new ProvisionedClustersResponseProperties()
                                        .withEnableRbac(false)
                                        .withAddonProfiles(mapOf())
                                        .withKubernetesVersion("arbu")
                                        .withNodeResourceGroup("vpnazzm")
                                        .withAgentPoolProfiles(Arrays.asList()))
                                .withExtendedLocation(
                                    new ProvisionedClustersResponseExtendedLocation()
                                        .withType("hrbnlankxmyskpbh")
                                        .withName("btkcxywnytnrsyn"))))
                .withNextLink("avxbniwdjswztsdb");
        model = BinaryData.fromObject(model).toObject(ProvisionedClustersResponseListResult.class);
        Assertions.assertEquals("pvecxgodeb", model.value().get(0).location());
        Assertions.assertEquals("krbm", model.value().get(0).tags().get("ukgri"));
        Assertions.assertEquals(ResourceIdentityType.NONE, model.value().get(0).identity().type());
        Assertions.assertEquals(false, model.value().get(0).properties().enableRbac());
        Assertions.assertEquals("gidokgjljyoxgvcl", model.value().get(0).properties().kubernetesVersion());
        Assertions.assertEquals("sncghkjeszz", model.value().get(0).properties().nodeResourceGroup());
        Assertions.assertEquals("fsm", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals("eh", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("avxbniwdjswztsdb", 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;
    }
}
