// 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.ProtectableContainerResourceInner;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupManagementType;
import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectableContainer;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ProtectableContainerResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ProtectableContainerResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"protectableContainerType\":\"ProtectableContainer\",\"friendlyName\":\"jos\",\"backupManagementType\":\"AzureWorkload\",\"healthStatus\":\"ulpjr\",\"containerId\":\"ag\"},\"eTag\":\"vimjwos\",\"location\":\"tx\",\"tags\":{\"tq\":\"skfc\",\"gqggebdunygae\":\"miekkezzikhlyfjh\",\"fatpxllrxcyjmoa\":\"idb\",\"arm\":\"su\"},\"id\":\"wdmjsjqbjhhyx\",\"name\":\"rw\",\"type\":\"yc\"}")
                .toObject(ProtectableContainerResourceInner.class);
        Assertions.assertEquals("tx", model.location());
        Assertions.assertEquals("skfc", model.tags().get("tq"));
        Assertions.assertEquals("jos", model.properties().friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_WORKLOAD, model.properties().backupManagementType());
        Assertions.assertEquals("ulpjr", model.properties().healthStatus());
        Assertions.assertEquals("ag", model.properties().containerId());
        Assertions.assertEquals("vimjwos", model.etag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ProtectableContainerResourceInner model =
            new ProtectableContainerResourceInner()
                .withLocation("tx")
                .withTags(
                    mapOf("tq", "skfc", "gqggebdunygae", "miekkezzikhlyfjh", "fatpxllrxcyjmoa", "idb", "arm", "su"))
                .withProperties(
                    new ProtectableContainer()
                        .withFriendlyName("jos")
                        .withBackupManagementType(BackupManagementType.AZURE_WORKLOAD)
                        .withHealthStatus("ulpjr")
                        .withContainerId("ag"))
                .withEtag("vimjwos");
        model = BinaryData.fromObject(model).toObject(ProtectableContainerResourceInner.class);
        Assertions.assertEquals("tx", model.location());
        Assertions.assertEquals("skfc", model.tags().get("tq"));
        Assertions.assertEquals("jos", model.properties().friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_WORKLOAD, model.properties().backupManagementType());
        Assertions.assertEquals("ulpjr", model.properties().healthStatus());
        Assertions.assertEquals("ag", model.properties().containerId());
        Assertions.assertEquals("vimjwos", 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;
    }
}
