// 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.AzureSqlagWorkloadContainerProtectionContainer;
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 AzureSqlagWorkloadContainerProtectionContainerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureSqlagWorkloadContainerProtectionContainer model =
            BinaryData
                .fromString(
                    "{\"containerType\":\"SQLAGWorkLoadContainer\",\"sourceResourceId\":\"pubntnbatz\",\"lastUpdatedTime\":\"2021-05-08T04:44:08Z\",\"extendedInfo\":{\"hostServerName\":\"wsaae\",\"inquiryInfo\":{\"status\":\"ttcjuhplrvkmjc\",\"inquiryDetails\":[]},\"nodesList\":[{\"nodeName\":\"ggcvk\",\"status\":\"lizrzbjpsfxsfuz\"},{\"nodeName\":\"tmvag\",\"status\":\"idqlvhu\"},{\"nodeName\":\"eofiz\",\"status\":\"jfnmjmvlwyz\"},{\"nodeName\":\"lkujrllfojui\",\"status\":\"puuyjucejik\"}]},\"workloadType\":\"AzureFileShare\",\"operationType\":\"Register\",\"friendlyName\":\"zejet\",\"backupManagementType\":\"DPM\",\"registrationStatus\":\"tikyj\",\"healthStatus\":\"k\",\"protectableObjectType\":\"qzolxrzvhqjw\"}")
                .toObject(AzureSqlagWorkloadContainerProtectionContainer.class);
        Assertions.assertEquals("zejet", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.DPM, model.backupManagementType());
        Assertions.assertEquals("tikyj", model.registrationStatus());
        Assertions.assertEquals("k", model.healthStatus());
        Assertions.assertEquals("qzolxrzvhqjw", model.protectableObjectType());
        Assertions.assertEquals("pubntnbatz", model.sourceResourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-08T04:44:08Z"), model.lastUpdatedTime());
        Assertions.assertEquals("wsaae", model.extendedInfo().hostServerName());
        Assertions.assertEquals("ttcjuhplrvkmjc", model.extendedInfo().inquiryInfo().status());
        Assertions.assertEquals("ggcvk", model.extendedInfo().nodesList().get(0).nodeName());
        Assertions.assertEquals("lizrzbjpsfxsfuz", model.extendedInfo().nodesList().get(0).status());
        Assertions.assertEquals(WorkloadType.AZURE_FILE_SHARE, model.workloadType());
        Assertions.assertEquals(OperationType.REGISTER, model.operationType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureSqlagWorkloadContainerProtectionContainer model =
            new AzureSqlagWorkloadContainerProtectionContainer()
                .withFriendlyName("zejet")
                .withBackupManagementType(BackupManagementType.DPM)
                .withRegistrationStatus("tikyj")
                .withHealthStatus("k")
                .withProtectableObjectType("qzolxrzvhqjw")
                .withSourceResourceId("pubntnbatz")
                .withLastUpdatedTime(OffsetDateTime.parse("2021-05-08T04:44:08Z"))
                .withExtendedInfo(
                    new AzureWorkloadContainerExtendedInfo()
                        .withHostServerName("wsaae")
                        .withInquiryInfo(
                            new InquiryInfo().withStatus("ttcjuhplrvkmjc").withInquiryDetails(Arrays.asList()))
                        .withNodesList(
                            Arrays
                                .asList(
                                    new DistributedNodesInfo().withNodeName("ggcvk").withStatus("lizrzbjpsfxsfuz"),
                                    new DistributedNodesInfo().withNodeName("tmvag").withStatus("idqlvhu"),
                                    new DistributedNodesInfo().withNodeName("eofiz").withStatus("jfnmjmvlwyz"),
                                    new DistributedNodesInfo().withNodeName("lkujrllfojui").withStatus("puuyjucejik"))))
                .withWorkloadType(WorkloadType.AZURE_FILE_SHARE)
                .withOperationType(OperationType.REGISTER);
        model = BinaryData.fromObject(model).toObject(AzureSqlagWorkloadContainerProtectionContainer.class);
        Assertions.assertEquals("zejet", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.DPM, model.backupManagementType());
        Assertions.assertEquals("tikyj", model.registrationStatus());
        Assertions.assertEquals("k", model.healthStatus());
        Assertions.assertEquals("qzolxrzvhqjw", model.protectableObjectType());
        Assertions.assertEquals("pubntnbatz", model.sourceResourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-08T04:44:08Z"), model.lastUpdatedTime());
        Assertions.assertEquals("wsaae", model.extendedInfo().hostServerName());
        Assertions.assertEquals("ttcjuhplrvkmjc", model.extendedInfo().inquiryInfo().status());
        Assertions.assertEquals("ggcvk", model.extendedInfo().nodesList().get(0).nodeName());
        Assertions.assertEquals("lizrzbjpsfxsfuz", model.extendedInfo().nodesList().get(0).status());
        Assertions.assertEquals(WorkloadType.AZURE_FILE_SHARE, model.workloadType());
        Assertions.assertEquals(OperationType.REGISTER, model.operationType());
    }
}
