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

package com.azure.resourcemanager.recoveryservicesbackup.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservicesbackup.fluent.models.BackupResourceVaultConfigResourceInner;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupResourceVaultConfig;
import com.azure.resourcemanager.recoveryservicesbackup.models.EnhancedSecurityState;
import com.azure.resourcemanager.recoveryservicesbackup.models.SoftDeleteFeatureState;
import com.azure.resourcemanager.recoveryservicesbackup.models.StorageType;
import com.azure.resourcemanager.recoveryservicesbackup.models.StorageTypeState;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class BackupResourceVaultConfigResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackupResourceVaultConfigResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"storageModelType\":\"LocallyRedundant\",\"storageType\":\"ZoneRedundant\",\"storageTypeState\":\"Locked\",\"enhancedSecurityState\":\"Invalid\",\"softDeleteFeatureState\":\"Enabled\",\"resourceGuardOperationRequests\":[\"csglum\",\"a\",\"tjaodxobnb\"],\"isSoftDeleteFeatureStateEditable\":false},\"eTag\":\"pxokajionp\",\"location\":\"mexgstxgcp\",\"tags\":{\"mcl\":\"maajrmvdjwzrlo\",\"jctbza\":\"hijco\"},\"id\":\"s\",\"name\":\"sycbkbfk\",\"type\":\"ukdkexxppofmxa\"}")
                .toObject(BackupResourceVaultConfigResourceInner.class);
        Assertions.assertEquals("mexgstxgcp", model.location());
        Assertions.assertEquals("maajrmvdjwzrlo", model.tags().get("mcl"));
        Assertions.assertEquals(StorageType.LOCALLY_REDUNDANT, model.properties().storageModelType());
        Assertions.assertEquals(StorageType.ZONE_REDUNDANT, model.properties().storageType());
        Assertions.assertEquals(StorageTypeState.LOCKED, model.properties().storageTypeState());
        Assertions.assertEquals(EnhancedSecurityState.INVALID, model.properties().enhancedSecurityState());
        Assertions.assertEquals(SoftDeleteFeatureState.ENABLED, model.properties().softDeleteFeatureState());
        Assertions.assertEquals("csglum", model.properties().resourceGuardOperationRequests().get(0));
        Assertions.assertEquals(false, model.properties().isSoftDeleteFeatureStateEditable());
        Assertions.assertEquals("pxokajionp", model.etag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackupResourceVaultConfigResourceInner model =
            new BackupResourceVaultConfigResourceInner()
                .withLocation("mexgstxgcp")
                .withTags(mapOf("mcl", "maajrmvdjwzrlo", "jctbza", "hijco"))
                .withProperties(
                    new BackupResourceVaultConfig()
                        .withStorageModelType(StorageType.LOCALLY_REDUNDANT)
                        .withStorageType(StorageType.ZONE_REDUNDANT)
                        .withStorageTypeState(StorageTypeState.LOCKED)
                        .withEnhancedSecurityState(EnhancedSecurityState.INVALID)
                        .withSoftDeleteFeatureState(SoftDeleteFeatureState.ENABLED)
                        .withResourceGuardOperationRequests(Arrays.asList("csglum", "a", "tjaodxobnb"))
                        .withIsSoftDeleteFeatureStateEditable(false))
                .withEtag("pxokajionp");
        model = BinaryData.fromObject(model).toObject(BackupResourceVaultConfigResourceInner.class);
        Assertions.assertEquals("mexgstxgcp", model.location());
        Assertions.assertEquals("maajrmvdjwzrlo", model.tags().get("mcl"));
        Assertions.assertEquals(StorageType.LOCALLY_REDUNDANT, model.properties().storageModelType());
        Assertions.assertEquals(StorageType.ZONE_REDUNDANT, model.properties().storageType());
        Assertions.assertEquals(StorageTypeState.LOCKED, model.properties().storageTypeState());
        Assertions.assertEquals(EnhancedSecurityState.INVALID, model.properties().enhancedSecurityState());
        Assertions.assertEquals(SoftDeleteFeatureState.ENABLED, model.properties().softDeleteFeatureState());
        Assertions.assertEquals("csglum", model.properties().resourceGuardOperationRequests().get(0));
        Assertions.assertEquals(false, model.properties().isSoftDeleteFeatureStateEditable());
        Assertions.assertEquals("pxokajionp", model.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;
    }
}
