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

package com.azure.resourcemanager.purview.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.purview.fluent.models.AccountInner;
import com.azure.resourcemanager.purview.models.AccountList;
import com.azure.resourcemanager.purview.models.Identity;
import com.azure.resourcemanager.purview.models.PublicNetworkAccess;
import com.azure.resourcemanager.purview.models.Type;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AccountListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AccountList model =
            BinaryData
                .fromString(
                    "{\"count\":1151238805444659333,\"nextLink\":\"uv\",\"value\":[{\"properties\":{\"createdAt\":\"2021-08-02T07:01:22Z\",\"createdBy\":\"zm\",\"createdByObjectId\":\"mtz\",\"friendlyName\":\"sphrupidgs\",\"managedResourceGroupName\":\"bejhphoycmsxa\",\"privateEndpointConnections\":[],\"provisioningState\":\"Deleting\",\"publicNetworkAccess\":\"NotSpecified\"},\"sku\":{\"capacity\":589802492,\"name\":\"Standard\"},\"identity\":{\"principalId\":\"ehtbm\",\"tenantId\":\"p\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"zhwlrxy\",\"tags\":{\"obcu\":\"oqijgkdmbpaz\",\"qgn\":\"pdznrbtcqqjnqgl\"},\"id\":\"foooj\",\"name\":\"wifsq\",\"type\":\"saagdf\"},{\"properties\":{\"createdAt\":\"2021-05-15T08:16:53Z\",\"createdBy\":\"j\",\"createdByObjectId\":\"ifkwmrvktsizntoc\",\"friendlyName\":\"ouajpsqucmpoyf\",\"managedResourceGroupName\":\"fogknygjofjdde\",\"privateEndpointConnections\":[],\"provisioningState\":\"Failed\",\"publicNetworkAccess\":\"Enabled\"},\"sku\":{\"capacity\":727938504,\"name\":\"Standard\"},\"identity\":{\"principalId\":\"tjzyflus\",\"tenantId\":\"hmofc\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"urkdtmlx\",\"tags\":{\"rcryuanzwuxzdxta\":\"uksjtxukcdmp\",\"hfpmrqobmtukknr\":\"rlhm\",\"gnwzsymglzufc\":\"rtihfxtijbpz\"},\"id\":\"zk\",\"name\":\"hdbihan\",\"type\":\"fhfcb\"},{\"properties\":{\"createdAt\":\"2021-04-18T20:42:54Z\",\"createdBy\":\"th\",\"createdByObjectId\":\"hab\",\"friendlyName\":\"ikxwc\",\"managedResourceGroupName\":\"yscnpqxu\",\"privateEndpointConnections\":[],\"provisioningState\":\"SoftDeleting\",\"publicNetworkAccess\":\"Disabled\"},\"sku\":{\"capacity\":992034682,\"name\":\"Standard\"},\"identity\":{\"principalId\":\"vd\",\"tenantId\":\"jgrtfwvukxga\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"location\":\"nhsjcnyej\",\"tags\":{\"kkvnipjox\":\"yhtnapczwlokjye\",\"podmailzydehojwy\":\"jnchgej\",\"qwixjspro\":\"huxinpmqnj\",\"wmfdatscmdvpjhul\":\"vcputegj\"},\"id\":\"uuvmkjozkrwfnd\",\"name\":\"odjpslwejd\",\"type\":\"vwryoqpso\"}]}")
                .toObject(AccountList.class);
        Assertions.assertEquals(1151238805444659333L, model.count());
        Assertions.assertEquals("uv", model.nextLink());
        Assertions.assertEquals("zhwlrxy", model.value().get(0).location());
        Assertions.assertEquals("oqijgkdmbpaz", model.value().get(0).tags().get("obcu"));
        Assertions.assertEquals(Type.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("bejhphoycmsxa", model.value().get(0).managedResourceGroupName());
        Assertions.assertEquals(PublicNetworkAccess.NOT_SPECIFIED, model.value().get(0).publicNetworkAccess());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AccountList model =
            new AccountList()
                .withCount(1151238805444659333L)
                .withNextLink("uv")
                .withValue(
                    Arrays
                        .asList(
                            new AccountInner()
                                .withLocation("zhwlrxy")
                                .withTags(mapOf("obcu", "oqijgkdmbpaz", "qgn", "pdznrbtcqqjnqgl"))
                                .withIdentity(
                                    new Identity().withType(Type.SYSTEM_ASSIGNED).withUserAssignedIdentities(mapOf()))
                                .withManagedResourceGroupName("bejhphoycmsxa")
                                .withPublicNetworkAccess(PublicNetworkAccess.NOT_SPECIFIED),
                            new AccountInner()
                                .withLocation("urkdtmlx")
                                .withTags(
                                    mapOf(
                                        "rcryuanzwuxzdxta",
                                        "uksjtxukcdmp",
                                        "hfpmrqobmtukknr",
                                        "rlhm",
                                        "gnwzsymglzufc",
                                        "rtihfxtijbpz"))
                                .withIdentity(
                                    new Identity().withType(Type.SYSTEM_ASSIGNED).withUserAssignedIdentities(mapOf()))
                                .withManagedResourceGroupName("fogknygjofjdde")
                                .withPublicNetworkAccess(PublicNetworkAccess.ENABLED),
                            new AccountInner()
                                .withLocation("nhsjcnyej")
                                .withTags(
                                    mapOf(
                                        "kkvnipjox",
                                        "yhtnapczwlokjye",
                                        "podmailzydehojwy",
                                        "jnchgej",
                                        "qwixjspro",
                                        "huxinpmqnj",
                                        "wmfdatscmdvpjhul",
                                        "vcputegj"))
                                .withIdentity(
                                    new Identity().withType(Type.SYSTEM_ASSIGNED).withUserAssignedIdentities(mapOf()))
                                .withManagedResourceGroupName("yscnpqxu")
                                .withPublicNetworkAccess(PublicNetworkAccess.DISABLED)));
        model = BinaryData.fromObject(model).toObject(AccountList.class);
        Assertions.assertEquals(1151238805444659333L, model.count());
        Assertions.assertEquals("uv", model.nextLink());
        Assertions.assertEquals("zhwlrxy", model.value().get(0).location());
        Assertions.assertEquals("oqijgkdmbpaz", model.value().get(0).tags().get("obcu"));
        Assertions.assertEquals(Type.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("bejhphoycmsxa", model.value().get(0).managedResourceGroupName());
        Assertions.assertEquals(PublicNetworkAccess.NOT_SPECIFIED, model.value().get(0).publicNetworkAccess());
    }

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