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

package com.azure.resourcemanager.recoveryservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservices.fluent.models.VaultInner;
import com.azure.resourcemanager.recoveryservices.models.IdentityData;
import com.azure.resourcemanager.recoveryservices.models.PublicNetworkAccess;
import com.azure.resourcemanager.recoveryservices.models.ResourceIdentityType;
import com.azure.resourcemanager.recoveryservices.models.Sku;
import com.azure.resourcemanager.recoveryservices.models.SkuName;
import com.azure.resourcemanager.recoveryservices.models.VaultList;
import com.azure.resourcemanager.recoveryservices.models.VaultProperties;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class VaultListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VaultList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"identity\":{\"principalId\":\"fygxgispemvtzfk\",\"tenantId\":\"ubljofxqe\",\"type\":\"None\",\"userAssignedIdentities\":{}},\"properties\":{\"provisioningState\":\"qjhqjbas\",\"privateEndpointConnections\":[],\"privateEndpointStateForBackup\":\"None\",\"privateEndpointStateForSiteRecovery\":\"None\",\"moveState\":\"PrepareTimedout\",\"backupStorageVersion\":\"Unassigned\",\"publicNetworkAccess\":\"Disabled\"},\"sku\":{\"name\":\"RS0\",\"tier\":\"rwclxxwrljdo\",\"family\":\"kcqvkocrc\",\"size\":\"kwt\",\"capacity\":\"xbnjbiksq\"},\"etag\":\"ssainqpjwnzll\",\"location\":\"fmppe\",\"tags\":{\"yqduujit\":\"mgxsab\",\"rwpdappdsbdkvwrw\":\"jczdzevndh\"},\"id\":\"feusnhut\",\"name\":\"eltmrldhugjzzdat\",\"type\":\"xhocdgeablgphuti\"}],\"nextLink\":\"dvkaozw\"}")
                .toObject(VaultList.class);
        Assertions.assertEquals("fmppe", model.value().get(0).location());
        Assertions.assertEquals("mgxsab", model.value().get(0).tags().get("yqduujit"));
        Assertions.assertEquals(ResourceIdentityType.NONE, model.value().get(0).identity().type());
        Assertions.assertEquals(PublicNetworkAccess.DISABLED, model.value().get(0).properties().publicNetworkAccess());
        Assertions.assertEquals(SkuName.RS0, model.value().get(0).sku().name());
        Assertions.assertEquals("rwclxxwrljdo", model.value().get(0).sku().tier());
        Assertions.assertEquals("kcqvkocrc", model.value().get(0).sku().family());
        Assertions.assertEquals("kwt", model.value().get(0).sku().size());
        Assertions.assertEquals("xbnjbiksq", model.value().get(0).sku().capacity());
        Assertions.assertEquals("ssainqpjwnzll", model.value().get(0).etag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VaultList model =
            new VaultList()
                .withValue(
                    Arrays
                        .asList(
                            new VaultInner()
                                .withLocation("fmppe")
                                .withTags(mapOf("yqduujit", "mgxsab", "rwpdappdsbdkvwrw", "jczdzevndh"))
                                .withIdentity(
                                    new IdentityData()
                                        .withType(ResourceIdentityType.NONE)
                                        .withUserAssignedIdentities(mapOf()))
                                .withProperties(
                                    new VaultProperties().withPublicNetworkAccess(PublicNetworkAccess.DISABLED))
                                .withSku(
                                    new Sku()
                                        .withName(SkuName.RS0)
                                        .withTier("rwclxxwrljdo")
                                        .withFamily("kcqvkocrc")
                                        .withSize("kwt")
                                        .withCapacity("xbnjbiksq"))
                                .withEtag("ssainqpjwnzll")));
        model = BinaryData.fromObject(model).toObject(VaultList.class);
        Assertions.assertEquals("fmppe", model.value().get(0).location());
        Assertions.assertEquals("mgxsab", model.value().get(0).tags().get("yqduujit"));
        Assertions.assertEquals(ResourceIdentityType.NONE, model.value().get(0).identity().type());
        Assertions.assertEquals(PublicNetworkAccess.DISABLED, model.value().get(0).properties().publicNetworkAccess());
        Assertions.assertEquals(SkuName.RS0, model.value().get(0).sku().name());
        Assertions.assertEquals("rwclxxwrljdo", model.value().get(0).sku().tier());
        Assertions.assertEquals("kcqvkocrc", model.value().get(0).sku().family());
        Assertions.assertEquals("kwt", model.value().get(0).sku().size());
        Assertions.assertEquals("xbnjbiksq", model.value().get(0).sku().capacity());
        Assertions.assertEquals("ssainqpjwnzll", model.value().get(0).etag());
    }

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