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

public final class DpmContainerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DpmContainer model =
            BinaryData
                .fromString(
                    "{\"containerType\":\"DPMContainer\",\"canReRegister\":false,\"containerId\":\"jxhpdulontacn\",\"protectedItemCount\":877103691312415497,\"dpmAgentVersion\":\"htuevrhrljy\",\"dpmServers\":[\"wxhn\",\"duugwbsre\",\"rfqkfuar\",\"nlvhhtklnvnafvv\"],\"upgradeAvailable\":false,\"protectionStatus\":\"devjb\",\"extendedInfo\":{\"lastRefreshedAt\":\"2021-06-07T05:21:39Z\"},\"friendlyName\":\"xypokkhmi\",\"backupManagementType\":\"AzureWorkload\",\"registrationStatus\":\"mczngn\",\"healthStatus\":\"xxewu\",\"protectableObjectType\":\"nvudbchaqdtvqecr\"}")
                .toObject(DpmContainer.class);
        Assertions.assertEquals("xypokkhmi", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_WORKLOAD, model.backupManagementType());
        Assertions.assertEquals("mczngn", model.registrationStatus());
        Assertions.assertEquals("xxewu", model.healthStatus());
        Assertions.assertEquals("nvudbchaqdtvqecr", model.protectableObjectType());
        Assertions.assertEquals(false, model.canReRegister());
        Assertions.assertEquals("jxhpdulontacn", model.containerId());
        Assertions.assertEquals(877103691312415497L, model.protectedItemCount());
        Assertions.assertEquals("htuevrhrljy", model.dpmAgentVersion());
        Assertions.assertEquals("wxhn", model.dpmServers().get(0));
        Assertions.assertEquals(false, model.upgradeAvailable());
        Assertions.assertEquals("devjb", model.protectionStatus());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-07T05:21:39Z"), model.extendedInfo().lastRefreshedAt());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DpmContainer model =
            new DpmContainer()
                .withFriendlyName("xypokkhmi")
                .withBackupManagementType(BackupManagementType.AZURE_WORKLOAD)
                .withRegistrationStatus("mczngn")
                .withHealthStatus("xxewu")
                .withProtectableObjectType("nvudbchaqdtvqecr")
                .withCanReRegister(false)
                .withContainerId("jxhpdulontacn")
                .withProtectedItemCount(877103691312415497L)
                .withDpmAgentVersion("htuevrhrljy")
                .withDpmServers(Arrays.asList("wxhn", "duugwbsre", "rfqkfuar", "nlvhhtklnvnafvv"))
                .withUpgradeAvailable(false)
                .withProtectionStatus("devjb")
                .withExtendedInfo(
                    new DpmContainerExtendedInfo().withLastRefreshedAt(OffsetDateTime.parse("2021-06-07T05:21:39Z")));
        model = BinaryData.fromObject(model).toObject(DpmContainer.class);
        Assertions.assertEquals("xypokkhmi", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_WORKLOAD, model.backupManagementType());
        Assertions.assertEquals("mczngn", model.registrationStatus());
        Assertions.assertEquals("xxewu", model.healthStatus());
        Assertions.assertEquals("nvudbchaqdtvqecr", model.protectableObjectType());
        Assertions.assertEquals(false, model.canReRegister());
        Assertions.assertEquals("jxhpdulontacn", model.containerId());
        Assertions.assertEquals(877103691312415497L, model.protectedItemCount());
        Assertions.assertEquals("htuevrhrljy", model.dpmAgentVersion());
        Assertions.assertEquals("wxhn", model.dpmServers().get(0));
        Assertions.assertEquals(false, model.upgradeAvailable());
        Assertions.assertEquals("devjb", model.protectionStatus());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-07T05:21:39Z"), model.extendedInfo().lastRefreshedAt());
    }
}
