// 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.AzureWorkloadContainer;
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureWorkloadContainerExtendedInfo;
import com.azure.resourcemanager.recoveryservicesbackup.models.BackupManagementType;
import com.azure.resourcemanager.recoveryservicesbackup.models.DistributedNodesInfo;
import com.azure.resourcemanager.recoveryservicesbackup.models.InquiryInfo;
import com.azure.resourcemanager.recoveryservicesbackup.models.OperationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.WorkloadType;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AzureWorkloadContainerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureWorkloadContainer model =
            BinaryData
                .fromString(
                    "{\"containerType\":\"AzureWorkloadContainer\",\"sourceResourceId\":\"htgv\",\"lastUpdatedTime\":\"2021-10-27T20:22:13Z\",\"extendedInfo\":{\"hostServerName\":\"rkolawjm\",\"inquiryInfo\":{\"status\":\"wro\",\"inquiryDetails\":[]},\"nodesList\":[{\"nodeName\":\"zwyjafitlhgu\",\"status\":\"uchlgmltx\"},{\"nodeName\":\"mozusgzvlnsnnjz\",\"status\":\"afolpymwamxqzrag\"}]},\"workloadType\":\"Exchange\",\"operationType\":\"Register\",\"friendlyName\":\"dulajvlejchcs\",\"backupManagementType\":\"MAB\",\"registrationStatus\":\"nmzlanru\",\"healthStatus\":\"wvnph\",\"protectableObjectType\":\"zqtpjhmq\"}")
                .toObject(AzureWorkloadContainer.class);
        Assertions.assertEquals("dulajvlejchcs", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.MAB, model.backupManagementType());
        Assertions.assertEquals("nmzlanru", model.registrationStatus());
        Assertions.assertEquals("wvnph", model.healthStatus());
        Assertions.assertEquals("zqtpjhmq", model.protectableObjectType());
        Assertions.assertEquals("htgv", model.sourceResourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-27T20:22:13Z"), model.lastUpdatedTime());
        Assertions.assertEquals("rkolawjm", model.extendedInfo().hostServerName());
        Assertions.assertEquals("wro", model.extendedInfo().inquiryInfo().status());
        Assertions.assertEquals("zwyjafitlhgu", model.extendedInfo().nodesList().get(0).nodeName());
        Assertions.assertEquals("uchlgmltx", model.extendedInfo().nodesList().get(0).status());
        Assertions.assertEquals(WorkloadType.EXCHANGE, model.workloadType());
        Assertions.assertEquals(OperationType.REGISTER, model.operationType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureWorkloadContainer model =
            new AzureWorkloadContainer()
                .withFriendlyName("dulajvlejchcs")
                .withBackupManagementType(BackupManagementType.MAB)
                .withRegistrationStatus("nmzlanru")
                .withHealthStatus("wvnph")
                .withProtectableObjectType("zqtpjhmq")
                .withSourceResourceId("htgv")
                .withLastUpdatedTime(OffsetDateTime.parse("2021-10-27T20:22:13Z"))
                .withExtendedInfo(
                    new AzureWorkloadContainerExtendedInfo()
                        .withHostServerName("rkolawjm")
                        .withInquiryInfo(new InquiryInfo().withStatus("wro").withInquiryDetails(Arrays.asList()))
                        .withNodesList(
                            Arrays
                                .asList(
                                    new DistributedNodesInfo().withNodeName("zwyjafitlhgu").withStatus("uchlgmltx"),
                                    new DistributedNodesInfo()
                                        .withNodeName("mozusgzvlnsnnjz")
                                        .withStatus("afolpymwamxqzrag"))))
                .withWorkloadType(WorkloadType.EXCHANGE)
                .withOperationType(OperationType.REGISTER);
        model = BinaryData.fromObject(model).toObject(AzureWorkloadContainer.class);
        Assertions.assertEquals("dulajvlejchcs", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.MAB, model.backupManagementType());
        Assertions.assertEquals("nmzlanru", model.registrationStatus());
        Assertions.assertEquals("wvnph", model.healthStatus());
        Assertions.assertEquals("zqtpjhmq", model.protectableObjectType());
        Assertions.assertEquals("htgv", model.sourceResourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-27T20:22:13Z"), model.lastUpdatedTime());
        Assertions.assertEquals("rkolawjm", model.extendedInfo().hostServerName());
        Assertions.assertEquals("wro", model.extendedInfo().inquiryInfo().status());
        Assertions.assertEquals("zwyjafitlhgu", model.extendedInfo().nodesList().get(0).nodeName());
        Assertions.assertEquals("uchlgmltx", model.extendedInfo().nodesList().get(0).status());
        Assertions.assertEquals(WorkloadType.EXCHANGE, model.workloadType());
        Assertions.assertEquals(OperationType.REGISTER, model.operationType());
    }
}
