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

package com.azure.resourcemanager.signalr.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.signalr.fluent.models.SignalRResourceInner;
import com.azure.resourcemanager.signalr.models.ManagedIdentity;
import com.azure.resourcemanager.signalr.models.ManagedIdentityType;
import com.azure.resourcemanager.signalr.models.ResourceSku;
import com.azure.resourcemanager.signalr.models.ServiceKind;
import com.azure.resourcemanager.signalr.models.SignalRResourceList;
import com.azure.resourcemanager.signalr.models.SignalRSkuTier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SignalRResourceListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SignalRResourceList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"jaoyfhrtx\",\"tier\":\"Free\",\"size\":\"rkujy\",\"family\":\"l\",\"capacity\":867367638},\"properties\":{\"provisioningState\":\"Canceled\",\"externalIP\":\"wrlyxwjkcprb\",\"hostName\":\"b\",\"publicPort\":19976049,\"serverPort\":1017472579,\"version\":\"vpys\",\"privateEndpointConnections\":[],\"sharedPrivateLinkResources\":[],\"hostNamePrefix\":\"uj\",\"features\":[],\"publicNetworkAccess\":\"f\",\"disableLocalAuth\":true,\"disableAadAuth\":true},\"kind\":\"RawWebSockets\",\"identity\":{\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{},\"principalId\":\"wu\",\"tenantId\":\"gazxuf\"},\"location\":\"uckyf\",\"tags\":{\"zuhtymwisdkfthwx\":\"fidfvzw\",\"mijcmmxdcufufs\":\"nteiwaopv\",\"fycc\":\"pymzidnsezcxtbzs\"},\"id\":\"newmdwzjeiachbo\",\"name\":\"sflnrosfqp\",\"type\":\"eeh\"},{\"sku\":{\"name\":\"vypyqrimzinpv\",\"tier\":\"Standard\",\"size\":\"kirsoodqxhc\",\"family\":\"nohjt\",\"capacity\":683362936},\"properties\":{\"provisioningState\":\"Running\",\"externalIP\":\"ifiyipjxsqwpgrj\",\"hostName\":\"norcjxvsnbyxqab\",\"publicPort\":1299140464,\"serverPort\":1412724720,\"version\":\"ysh\",\"privateEndpointConnections\":[],\"sharedPrivateLinkResources\":[],\"hostNamePrefix\":\"bl\",\"features\":[],\"publicNetworkAccess\":\"jmkljavbqidtqajz\",\"disableLocalAuth\":false,\"disableAadAuth\":true},\"kind\":\"SignalR\",\"identity\":{\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{},\"principalId\":\"hbzhfepg\",\"tenantId\":\"qex\"},\"location\":\"ocxscpaierhhbcs\",\"tags\":{\"bnbdxkqpxokajion\":\"mmajtjaodx\",\"jrmvdjwzrlo\":\"imexgstxgcpodgma\",\"hijco\":\"mcl\"},\"id\":\"jctbza\",\"name\":\"s\",\"type\":\"sycbkbfk\"},{\"sku\":{\"name\":\"kdkexxp\",\"tier\":\"Free\",\"size\":\"xaxcfjpgddtocjjx\",\"family\":\"pmouexhdz\",\"capacity\":738311617},\"properties\":{\"provisioningState\":\"Creating\",\"externalIP\":\"nxqbzvddn\",\"hostName\":\"ndei\",\"publicPort\":1638817627,\"serverPort\":1604770276,\"version\":\"zao\",\"privateEndpointConnections\":[],\"sharedPrivateLinkResources\":[],\"hostNamePrefix\":\"hcffcyddglmjthjq\",\"features\":[],\"publicNetworkAccess\":\"qciwqvhkhixuigdt\",\"disableLocalAuth\":false,\"disableAadAuth\":true},\"kind\":\"SignalR\",\"identity\":{\"type\":\"UserAssigned\",\"userAssignedIdentities\":{},\"principalId\":\"u\",\"tenantId\":\"a\"},\"location\":\"rzayv\",\"tags\":{\"ln\":\"gvdfgiotkftutq\",\"qmi\":\"xlefgugnxkrx\"},\"id\":\"tthzrvqd\",\"name\":\"abhjybi\",\"type\":\"ehoqfbowskan\"},{\"sku\":{\"name\":\"tzlcuiywgqywgn\",\"tier\":\"Standard\",\"size\":\"nhzgpphrcgyn\",\"family\":\"cpecfvmmcoofs\",\"capacity\":1165207027},\"properties\":{\"provisioningState\":\"Moving\",\"externalIP\":\"m\",\"hostName\":\"qabcypm\",\"publicPort\":1275704162,\"serverPort\":699585009,\"version\":\"uvcc\",\"privateEndpointConnections\":[],\"sharedPrivateLinkResources\":[],\"hostNamePrefix\":\"bacfionlebxetq\",\"features\":[],\"publicNetworkAccess\":\"qqwx\",\"disableLocalAuth\":true,\"disableAadAuth\":false},\"kind\":\"RawWebSockets\",\"identity\":{\"type\":\"None\",\"userAssignedIdentities\":{},\"principalId\":\"isnjampmngnz\",\"tenantId\":\"xaqwoochcbonqv\"},\"location\":\"vlrxnjeaseiph\",\"tags\":{\"enjbdlwtgrhp\":\"lokeyy\"},\"id\":\"jp\",\"name\":\"umasxazjpq\",\"type\":\"e\"}],\"nextLink\":\"alhbx\"}")
                .toObject(SignalRResourceList.class);
        Assertions.assertEquals("uckyf", model.value().get(0).location());
        Assertions.assertEquals("fidfvzw", model.value().get(0).tags().get("zuhtymwisdkfthwx"));
        Assertions.assertEquals("jaoyfhrtx", model.value().get(0).sku().name());
        Assertions.assertEquals(SignalRSkuTier.FREE, model.value().get(0).sku().tier());
        Assertions.assertEquals(867367638, model.value().get(0).sku().capacity());
        Assertions.assertEquals(ServiceKind.RAW_WEB_SOCKETS, model.value().get(0).kind());
        Assertions.assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("f", model.value().get(0).publicNetworkAccess());
        Assertions.assertEquals(true, model.value().get(0).disableLocalAuth());
        Assertions.assertEquals(true, model.value().get(0).disableAadAuth());
        Assertions.assertEquals("alhbx", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SignalRResourceList model =
            new SignalRResourceList()
                .withValue(
                    Arrays
                        .asList(
                            new SignalRResourceInner()
                                .withLocation("uckyf")
                                .withTags(
                                    mapOf(
                                        "zuhtymwisdkfthwx",
                                        "fidfvzw",
                                        "mijcmmxdcufufs",
                                        "nteiwaopv",
                                        "fycc",
                                        "pymzidnsezcxtbzs"))
                                .withSku(
                                    new ResourceSku()
                                        .withName("jaoyfhrtx")
                                        .withTier(SignalRSkuTier.FREE)
                                        .withCapacity(867367638))
                                .withKind(ServiceKind.RAW_WEB_SOCKETS)
                                .withIdentity(
                                    new ManagedIdentity()
                                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withFeatures(Arrays.asList())
                                .withPublicNetworkAccess("f")
                                .withDisableLocalAuth(true)
                                .withDisableAadAuth(true),
                            new SignalRResourceInner()
                                .withLocation("ocxscpaierhhbcs")
                                .withTags(
                                    mapOf(
                                        "bnbdxkqpxokajion",
                                        "mmajtjaodx",
                                        "jrmvdjwzrlo",
                                        "imexgstxgcpodgma",
                                        "hijco",
                                        "mcl"))
                                .withSku(
                                    new ResourceSku()
                                        .withName("vypyqrimzinpv")
                                        .withTier(SignalRSkuTier.STANDARD)
                                        .withCapacity(683362936))
                                .withKind(ServiceKind.SIGNALR)
                                .withIdentity(
                                    new ManagedIdentity()
                                        .withType(ManagedIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withFeatures(Arrays.asList())
                                .withPublicNetworkAccess("jmkljavbqidtqajz")
                                .withDisableLocalAuth(false)
                                .withDisableAadAuth(true),
                            new SignalRResourceInner()
                                .withLocation("rzayv")
                                .withTags(mapOf("ln", "gvdfgiotkftutq", "qmi", "xlefgugnxkrx"))
                                .withSku(
                                    new ResourceSku()
                                        .withName("kdkexxp")
                                        .withTier(SignalRSkuTier.FREE)
                                        .withCapacity(738311617))
                                .withKind(ServiceKind.SIGNALR)
                                .withIdentity(
                                    new ManagedIdentity()
                                        .withType(ManagedIdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withFeatures(Arrays.asList())
                                .withPublicNetworkAccess("qciwqvhkhixuigdt")
                                .withDisableLocalAuth(false)
                                .withDisableAadAuth(true),
                            new SignalRResourceInner()
                                .withLocation("vlrxnjeaseiph")
                                .withTags(mapOf("enjbdlwtgrhp", "lokeyy"))
                                .withSku(
                                    new ResourceSku()
                                        .withName("tzlcuiywgqywgn")
                                        .withTier(SignalRSkuTier.STANDARD)
                                        .withCapacity(1165207027))
                                .withKind(ServiceKind.RAW_WEB_SOCKETS)
                                .withIdentity(
                                    new ManagedIdentity()
                                        .withType(ManagedIdentityType.NONE)
                                        .withUserAssignedIdentities(mapOf()))
                                .withFeatures(Arrays.asList())
                                .withPublicNetworkAccess("qqwx")
                                .withDisableLocalAuth(true)
                                .withDisableAadAuth(false)))
                .withNextLink("alhbx");
        model = BinaryData.fromObject(model).toObject(SignalRResourceList.class);
        Assertions.assertEquals("uckyf", model.value().get(0).location());
        Assertions.assertEquals("fidfvzw", model.value().get(0).tags().get("zuhtymwisdkfthwx"));
        Assertions.assertEquals("jaoyfhrtx", model.value().get(0).sku().name());
        Assertions.assertEquals(SignalRSkuTier.FREE, model.value().get(0).sku().tier());
        Assertions.assertEquals(867367638, model.value().get(0).sku().capacity());
        Assertions.assertEquals(ServiceKind.RAW_WEB_SOCKETS, model.value().get(0).kind());
        Assertions.assertEquals(ManagedIdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("f", model.value().get(0).publicNetworkAccess());
        Assertions.assertEquals(true, model.value().get(0).disableLocalAuth());
        Assertions.assertEquals(true, model.value().get(0).disableAadAuth());
        Assertions.assertEquals("alhbx", 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;
    }
}
