// 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.models.AzureBackupServerContainer;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupManagementType;
import com.azure.resourcemanager.recoveryservicesbackup.models.DpmContainerExtendedInfo;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AzureBackupServerContainerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureBackupServerContainer model =
            BinaryData
                .fromString(
                    "{\"containerType\":\"AzureBackupServerContainer\",\"canReRegister\":true,\"containerId\":\"gqfu\",\"protectedItemCount\":3753149715330381909,\"dpmAgentVersion\":\"mkwkl\",\"dpmServers\":[\"xaxmq\",\"qalhhjnh\"],\"upgradeAvailable\":true,\"protectionStatus\":\"yynfsvkhgbv\",\"extendedInfo\":{\"lastRefreshedAt\":\"2021-09-07T09:46:08Z\"},\"friendlyName\":\"rfdl\",\"backupManagementType\":\"AzureWorkload\",\"registrationStatus\":\"py\",\"healthStatus\":\"eizjcpeogkhnmg\",\"protectableObjectType\":\"ouxddbhfhpfpazj\"}")
                .toObject(AzureBackupServerContainer.class);
        Assertions.assertEquals("rfdl", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_WORKLOAD, model.backupManagementType());
        Assertions.assertEquals("py", model.registrationStatus());
        Assertions.assertEquals("eizjcpeogkhnmg", model.healthStatus());
        Assertions.assertEquals("ouxddbhfhpfpazj", model.protectableObjectType());
        Assertions.assertEquals(true, model.canReRegister());
        Assertions.assertEquals("gqfu", model.containerId());
        Assertions.assertEquals(3753149715330381909L, model.protectedItemCount());
        Assertions.assertEquals("mkwkl", model.dpmAgentVersion());
        Assertions.assertEquals("xaxmq", model.dpmServers().get(0));
        Assertions.assertEquals(true, model.upgradeAvailable());
        Assertions.assertEquals("yynfsvkhgbv", model.protectionStatus());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-07T09:46:08Z"), model.extendedInfo().lastRefreshedAt());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureBackupServerContainer model =
            new AzureBackupServerContainer()
                .withFriendlyName("rfdl")
                .withBackupManagementType(BackupManagementType.AZURE_WORKLOAD)
                .withRegistrationStatus("py")
                .withHealthStatus("eizjcpeogkhnmg")
                .withProtectableObjectType("ouxddbhfhpfpazj")
                .withCanReRegister(true)
                .withContainerId("gqfu")
                .withProtectedItemCount(3753149715330381909L)
                .withDpmAgentVersion("mkwkl")
                .withDpmServers(Arrays.asList("xaxmq", "qalhhjnh"))
                .withUpgradeAvailable(true)
                .withProtectionStatus("yynfsvkhgbv")
                .withExtendedInfo(
                    new DpmContainerExtendedInfo().withLastRefreshedAt(OffsetDateTime.parse("2021-09-07T09:46:08Z")));
        model = BinaryData.fromObject(model).toObject(AzureBackupServerContainer.class);
        Assertions.assertEquals("rfdl", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_WORKLOAD, model.backupManagementType());
        Assertions.assertEquals("py", model.registrationStatus());
        Assertions.assertEquals("eizjcpeogkhnmg", model.healthStatus());
        Assertions.assertEquals("ouxddbhfhpfpazj", model.protectableObjectType());
        Assertions.assertEquals(true, model.canReRegister());
        Assertions.assertEquals("gqfu", model.containerId());
        Assertions.assertEquals(3753149715330381909L, model.protectedItemCount());
        Assertions.assertEquals("mkwkl", model.dpmAgentVersion());
        Assertions.assertEquals("xaxmq", model.dpmServers().get(0));
        Assertions.assertEquals(true, model.upgradeAvailable());
        Assertions.assertEquals("yynfsvkhgbv", model.protectionStatus());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-07T09:46:08Z"), model.extendedInfo().lastRefreshedAt());
    }
}
