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

public final class ProtectionContainerResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ProtectionContainerResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"containerType\":\"ProtectionContainer\",\"friendlyName\":\"qal\",\"backupManagementType\":\"MAB\",\"registrationStatus\":\"jijpxac\",\"healthStatus\":\"udfnbyxba\",\"protectableObjectType\":\"bjyvay\"},\"eTag\":\"imrzrtuzqog\",\"location\":\"exn\",\"tags\":{\"wmewzsyy\":\"dnw\"},\"id\":\"euzsoi\",\"name\":\"judpfrxt\",\"type\":\"thzvaytdwkqbrqu\"}")
                .toObject(ProtectionContainerResourceInner.class);
        Assertions.assertEquals("exn", model.location());
        Assertions.assertEquals("dnw", model.tags().get("wmewzsyy"));
        Assertions.assertEquals("qal", model.properties().friendlyName());
        Assertions.assertEquals(BackupManagementType.MAB, model.properties().backupManagementType());
        Assertions.assertEquals("jijpxac", model.properties().registrationStatus());
        Assertions.assertEquals("udfnbyxba", model.properties().healthStatus());
        Assertions.assertEquals("bjyvay", model.properties().protectableObjectType());
        Assertions.assertEquals("imrzrtuzqog", model.etag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ProtectionContainerResourceInner model =
            new ProtectionContainerResourceInner()
                .withLocation("exn")
                .withTags(mapOf("wmewzsyy", "dnw"))
                .withProperties(
                    new ProtectionContainer()
                        .withFriendlyName("qal")
                        .withBackupManagementType(BackupManagementType.MAB)
                        .withRegistrationStatus("jijpxac")
                        .withHealthStatus("udfnbyxba")
                        .withProtectableObjectType("bjyvay"))
                .withEtag("imrzrtuzqog");
        model = BinaryData.fromObject(model).toObject(ProtectionContainerResourceInner.class);
        Assertions.assertEquals("exn", model.location());
        Assertions.assertEquals("dnw", model.tags().get("wmewzsyy"));
        Assertions.assertEquals("qal", model.properties().friendlyName());
        Assertions.assertEquals(BackupManagementType.MAB, model.properties().backupManagementType());
        Assertions.assertEquals("jijpxac", model.properties().registrationStatus());
        Assertions.assertEquals("udfnbyxba", model.properties().healthStatus());
        Assertions.assertEquals("bjyvay", model.properties().protectableObjectType());
        Assertions.assertEquals("imrzrtuzqog", 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;
    }
}
