// 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.AzureVMAppContainerProtectionContainer;
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 AzureVMAppContainerProtectionContainerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureVMAppContainerProtectionContainer model =
            BinaryData
                .fromString(
                    "{\"containerType\":\"VMAppContainer\",\"sourceResourceId\":\"cjc\",\"lastUpdatedTime\":\"2021-04-22T19:07:29Z\",\"extendedInfo\":{\"hostServerName\":\"snsqowxwcoml\",\"inquiryInfo\":{\"status\":\"twvc\",\"inquiryDetails\":[]},\"nodesList\":[{\"nodeName\":\"ve\",\"status\":\"fdv\"}]},\"workloadType\":\"Invalid\",\"operationType\":\"Register\",\"friendlyName\":\"f\",\"backupManagementType\":\"AzureSql\",\"registrationStatus\":\"dpqthehn\",\"healthStatus\":\"aoyankcoeqswa\",\"protectableObjectType\":\"ltytmhdr\"}")
                .toObject(AzureVMAppContainerProtectionContainer.class);
        Assertions.assertEquals("f", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_SQL, model.backupManagementType());
        Assertions.assertEquals("dpqthehn", model.registrationStatus());
        Assertions.assertEquals("aoyankcoeqswa", model.healthStatus());
        Assertions.assertEquals("ltytmhdr", model.protectableObjectType());
        Assertions.assertEquals("cjc", model.sourceResourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-22T19:07:29Z"), model.lastUpdatedTime());
        Assertions.assertEquals("snsqowxwcoml", model.extendedInfo().hostServerName());
        Assertions.assertEquals("twvc", model.extendedInfo().inquiryInfo().status());
        Assertions.assertEquals("ve", model.extendedInfo().nodesList().get(0).nodeName());
        Assertions.assertEquals("fdv", model.extendedInfo().nodesList().get(0).status());
        Assertions.assertEquals(WorkloadType.INVALID, model.workloadType());
        Assertions.assertEquals(OperationType.REGISTER, model.operationType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureVMAppContainerProtectionContainer model =
            new AzureVMAppContainerProtectionContainer()
                .withFriendlyName("f")
                .withBackupManagementType(BackupManagementType.AZURE_SQL)
                .withRegistrationStatus("dpqthehn")
                .withHealthStatus("aoyankcoeqswa")
                .withProtectableObjectType("ltytmhdr")
                .withSourceResourceId("cjc")
                .withLastUpdatedTime(OffsetDateTime.parse("2021-04-22T19:07:29Z"))
                .withExtendedInfo(
                    new AzureWorkloadContainerExtendedInfo()
                        .withHostServerName("snsqowxwcoml")
                        .withInquiryInfo(new InquiryInfo().withStatus("twvc").withInquiryDetails(Arrays.asList()))
                        .withNodesList(Arrays.asList(new DistributedNodesInfo().withNodeName("ve").withStatus("fdv"))))
                .withWorkloadType(WorkloadType.INVALID)
                .withOperationType(OperationType.REGISTER);
        model = BinaryData.fromObject(model).toObject(AzureVMAppContainerProtectionContainer.class);
        Assertions.assertEquals("f", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.AZURE_SQL, model.backupManagementType());
        Assertions.assertEquals("dpqthehn", model.registrationStatus());
        Assertions.assertEquals("aoyankcoeqswa", model.healthStatus());
        Assertions.assertEquals("ltytmhdr", model.protectableObjectType());
        Assertions.assertEquals("cjc", model.sourceResourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-22T19:07:29Z"), model.lastUpdatedTime());
        Assertions.assertEquals("snsqowxwcoml", model.extendedInfo().hostServerName());
        Assertions.assertEquals("twvc", model.extendedInfo().inquiryInfo().status());
        Assertions.assertEquals("ve", model.extendedInfo().nodesList().get(0).nodeName());
        Assertions.assertEquals("fdv", model.extendedInfo().nodesList().get(0).status());
        Assertions.assertEquals(WorkloadType.INVALID, model.workloadType());
        Assertions.assertEquals(OperationType.REGISTER, model.operationType());
    }
}
