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

package com.azure.resourcemanager.hdinsight.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hdinsight.fluent.models.ClusterInner;
import com.azure.resourcemanager.hdinsight.models.ClusterGetProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterIdentity;
import com.azure.resourcemanager.hdinsight.models.ClusterListResult;
import com.azure.resourcemanager.hdinsight.models.HDInsightClusterProvisioningState;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.ResourceIdentityType;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class ClusterListResultTests {
    @Test
    public void testDeserialize() {
        ClusterListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"etag\":\"buxwgip\",\"zones\":[\"nowkgshw\",\"nkixzbinj\"],\"properties\":{\"clusterVersion\":\"ttmrywnuzoqf\",\"clusterHdpVersion\":\"yqzrnkcqvyxlw\",\"osType\":\"Linux\",\"tier\":\"Premium\",\"clusterId\":\"ohoqqnwvlryav\",\"provisioningState\":\"Failed\",\"createdDate\":\"mqhgyxzkonocuk\",\"clusterState\":\"lyaxuc\",\"errors\":[],\"connectivityEndpoints\":[],\"minSupportedTlsVersion\":\"beypewrmjmw\",\"privateLinkConfigurations\":[],\"privateEndpointConnections\":[]},\"identity\":{\"principalId\":\"senhwlrs\",\"tenantId\":\"rzpwvlqdqgbiq\",\"type\":\"SystemAssigned,"
                        + " UserAssigned\",\"userAssignedIdentities\":{}},\"location\":\"aetcktvfcivfs\",\"tags\":{\"ctq\":\"m\",\"ebrjcxe\":\"jf\",\"jrbirphxepcyv\":\"fuwutttxf\",\"j\":\"hfnljkyq\"},\"id\":\"uujqgidokgjljyo\",\"name\":\"gvcl\",\"type\":\"bgsncghkjeszzhb\"},{\"etag\":\"htxfvgxbfsmxnehm\",\"zones\":[\"cxgod\"],\"properties\":{\"clusterVersion\":\"qkkrb\",\"clusterHdpVersion\":\"ukgri\",\"osType\":\"Linux\",\"tier\":\"Premium\",\"clusterId\":\"bxzpuzycisp\",\"provisioningState\":\"Deleting\",\"createdDate\":\"kbrpyydhibnuq\",\"clusterState\":\"pikad\",\"errors\":[],\"connectivityEndpoints\":[],\"minSupportedTlsVersion\":\"buynhijggm\",\"privateLinkConfigurations\":[],\"privateEndpointConnections\":[]},\"identity\":{\"principalId\":\"utrc\",\"tenantId\":\"na\",\"type\":\"None\",\"userAssignedIdentities\":{}},\"location\":\"runmp\",\"tags\":{\"skpbhenbtkcxywn\":\"dbhrbnlankxm\",\"qidybyx\":\"tnrsyn\",\"aaxdbabphlwrq\":\"zfcl\"},\"id\":\"fkts\",\"name\":\"hsucoc\",\"type\":\"nyyazttbtwwrqpue\"},{\"etag\":\"kzywbiex\",\"zones\":[\"yueaxibxujwb\",\"qwalmuzyoxaepd\",\"zjancuxr\",\"d\"],\"properties\":{\"clusterVersion\":\"v\",\"clusterHdpVersion\":\"niwdjsw\",\"osType\":\"Windows\",\"tier\":\"Standard\",\"clusterId\":\"gnxytxhpzxbz\",\"provisioningState\":\"Succeeded\",\"createdDate\":\"cuh\",\"clusterState\":\"tcty\",\"errors\":[],\"connectivityEndpoints\":[],\"minSupportedTlsVersion\":\"plwzbhvgyugu\",\"privateLinkConfigurations\":[],\"privateEndpointConnections\":[]},\"identity\":{\"principalId\":\"xquk\",\"tenantId\":\"plgmgsxnk\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"slpvlop\",\"tags\":{\"wzbaiue\":\"ighxpk\",\"a\":\"baumnyqupedeoj\"},\"id\":\"ckhsmtxpsieb\",\"name\":\"fhvpesaps\",\"type\":\"rdqmhjjdhtldwkyz\"},{\"etag\":\"utknc\",\"zones\":[\"wsvlxotogtwrupqs\",\"vnm\",\"cykvceo\"],\"properties\":{\"clusterVersion\":\"lo\",\"clusterHdpVersion\":\"oty\",\"osType\":\"Windows\",\"tier\":\"Premium\",\"clusterId\":\"bkc\",\"provisioningState\":\"InProgress\",\"createdDate\":\"kphywpnvjto\",\"clusterState\":\"ermclfplphoxuscr\",\"errors\":[],\"connectivityEndpoints\":[],\"minSupportedTlsVersion\":\"bjtazqugxywpmu\",\"privateLinkConfigurations\":[],\"privateEndpointConnections\":[]},\"identity\":{\"principalId\":\"kqujidsuyono\",\"tenantId\":\"laocqxtccmg\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"tlmoyrx\",\"tags\":{\"wpzntxhdzh\":\"u\",\"rxsbkyvp\":\"rqjbhckfrl\"},\"id\":\"ca\",\"name\":\"uzbpzkafku\",\"type\":\"b\"}],\"nextLink\":\"nwbmeh\"}")
                .toObject(ClusterListResult.class);
        Assertions.assertEquals("aetcktvfcivfs", model.value().get(0).location());
        Assertions.assertEquals("m", model.value().get(0).tags().get("ctq"));
        Assertions.assertEquals("buxwgip", model.value().get(0).etag());
        Assertions.assertEquals("nowkgshw", model.value().get(0).zones().get(0));
        Assertions.assertEquals("ttmrywnuzoqf", model.value().get(0).properties().clusterVersion());
        Assertions.assertEquals("yqzrnkcqvyxlw", model.value().get(0).properties().clusterHdpVersion());
        Assertions.assertEquals(OSType.LINUX, model.value().get(0).properties().osType());
        Assertions.assertEquals(Tier.PREMIUM, model.value().get(0).properties().tier());
        Assertions.assertEquals("ohoqqnwvlryav", model.value().get(0).properties().clusterId());
        Assertions
            .assertEquals(
                HDInsightClusterProvisioningState.FAILED, model.value().get(0).properties().provisioningState());
        Assertions.assertEquals("mqhgyxzkonocuk", model.value().get(0).properties().createdDate());
        Assertions.assertEquals("lyaxuc", model.value().get(0).properties().clusterState());
        Assertions.assertEquals("beypewrmjmw", model.value().get(0).properties().minSupportedTlsVersion());
        Assertions
            .assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.value().get(0).identity().type());
    }

    @Test
    public void testSerialize() {
        ClusterListResult model =
            new ClusterListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ClusterInner()
                                .withLocation("aetcktvfcivfs")
                                .withTags(
                                    mapOf("ctq", "m", "ebrjcxe", "jf", "jrbirphxepcyv", "fuwutttxf", "j", "hfnljkyq"))
                                .withEtag("buxwgip")
                                .withZones(Arrays.asList("nowkgshw", "nkixzbinj"))
                                .withProperties(
                                    new ClusterGetProperties()
                                        .withClusterVersion("ttmrywnuzoqf")
                                        .withClusterHdpVersion("yqzrnkcqvyxlw")
                                        .withOsType(OSType.LINUX)
                                        .withTier(Tier.PREMIUM)
                                        .withClusterId("ohoqqnwvlryav")
                                        .withProvisioningState(HDInsightClusterProvisioningState.FAILED)
                                        .withCreatedDate("mqhgyxzkonocuk")
                                        .withClusterState("lyaxuc")
                                        .withErrors(Arrays.asList())
                                        .withConnectivityEndpoints(Arrays.asList())
                                        .withMinSupportedTlsVersion("beypewrmjmw")
                                        .withPrivateLinkConfigurations(Arrays.asList()))
                                .withIdentity(
                                    new ClusterIdentity()
                                        .withType(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf())),
                            new ClusterInner()
                                .withLocation("runmp")
                                .withTags(
                                    mapOf(
                                        "skpbhenbtkcxywn",
                                        "dbhrbnlankxm",
                                        "qidybyx",
                                        "tnrsyn",
                                        "aaxdbabphlwrq",
                                        "zfcl"))
                                .withEtag("htxfvgxbfsmxnehm")
                                .withZones(Arrays.asList("cxgod"))
                                .withProperties(
                                    new ClusterGetProperties()
                                        .withClusterVersion("qkkrb")
                                        .withClusterHdpVersion("ukgri")
                                        .withOsType(OSType.LINUX)
                                        .withTier(Tier.PREMIUM)
                                        .withClusterId("bxzpuzycisp")
                                        .withProvisioningState(HDInsightClusterProvisioningState.DELETING)
                                        .withCreatedDate("kbrpyydhibnuq")
                                        .withClusterState("pikad")
                                        .withErrors(Arrays.asList())
                                        .withConnectivityEndpoints(Arrays.asList())
                                        .withMinSupportedTlsVersion("buynhijggm")
                                        .withPrivateLinkConfigurations(Arrays.asList()))
                                .withIdentity(
                                    new ClusterIdentity()
                                        .withType(ResourceIdentityType.NONE)
                                        .withUserAssignedIdentities(mapOf())),
                            new ClusterInner()
                                .withLocation("slpvlop")
                                .withTags(mapOf("wzbaiue", "ighxpk", "a", "baumnyqupedeoj"))
                                .withEtag("kzywbiex")
                                .withZones(Arrays.asList("yueaxibxujwb", "qwalmuzyoxaepd", "zjancuxr", "d"))
                                .withProperties(
                                    new ClusterGetProperties()
                                        .withClusterVersion("v")
                                        .withClusterHdpVersion("niwdjsw")
                                        .withOsType(OSType.WINDOWS)
                                        .withTier(Tier.STANDARD)
                                        .withClusterId("gnxytxhpzxbz")
                                        .withProvisioningState(HDInsightClusterProvisioningState.SUCCEEDED)
                                        .withCreatedDate("cuh")
                                        .withClusterState("tcty")
                                        .withErrors(Arrays.asList())
                                        .withConnectivityEndpoints(Arrays.asList())
                                        .withMinSupportedTlsVersion("plwzbhvgyugu")
                                        .withPrivateLinkConfigurations(Arrays.asList()))
                                .withIdentity(
                                    new ClusterIdentity()
                                        .withType(ResourceIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf())),
                            new ClusterInner()
                                .withLocation("tlmoyrx")
                                .withTags(mapOf("wpzntxhdzh", "u", "rxsbkyvp", "rqjbhckfrl"))
                                .withEtag("utknc")
                                .withZones(Arrays.asList("wsvlxotogtwrupqs", "vnm", "cykvceo"))
                                .withProperties(
                                    new ClusterGetProperties()
                                        .withClusterVersion("lo")
                                        .withClusterHdpVersion("oty")
                                        .withOsType(OSType.WINDOWS)
                                        .withTier(Tier.PREMIUM)
                                        .withClusterId("bkc")
                                        .withProvisioningState(HDInsightClusterProvisioningState.IN_PROGRESS)
                                        .withCreatedDate("kphywpnvjto")
                                        .withClusterState("ermclfplphoxuscr")
                                        .withErrors(Arrays.asList())
                                        .withConnectivityEndpoints(Arrays.asList())
                                        .withMinSupportedTlsVersion("bjtazqugxywpmu")
                                        .withPrivateLinkConfigurations(Arrays.asList()))
                                .withIdentity(
                                    new ClusterIdentity()
                                        .withType(ResourceIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))));
        model = BinaryData.fromObject(model).toObject(ClusterListResult.class);
        Assertions.assertEquals("aetcktvfcivfs", model.value().get(0).location());
        Assertions.assertEquals("m", model.value().get(0).tags().get("ctq"));
        Assertions.assertEquals("buxwgip", model.value().get(0).etag());
        Assertions.assertEquals("nowkgshw", model.value().get(0).zones().get(0));
        Assertions.assertEquals("ttmrywnuzoqf", model.value().get(0).properties().clusterVersion());
        Assertions.assertEquals("yqzrnkcqvyxlw", model.value().get(0).properties().clusterHdpVersion());
        Assertions.assertEquals(OSType.LINUX, model.value().get(0).properties().osType());
        Assertions.assertEquals(Tier.PREMIUM, model.value().get(0).properties().tier());
        Assertions.assertEquals("ohoqqnwvlryav", model.value().get(0).properties().clusterId());
        Assertions
            .assertEquals(
                HDInsightClusterProvisioningState.FAILED, model.value().get(0).properties().provisioningState());
        Assertions.assertEquals("mqhgyxzkonocuk", model.value().get(0).properties().createdDate());
        Assertions.assertEquals("lyaxuc", model.value().get(0).properties().clusterState());
        Assertions.assertEquals("beypewrmjmw", model.value().get(0).properties().minSupportedTlsVersion());
        Assertions
            .assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.value().get(0).identity().type());
    }

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