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

public final class BackupEngineBaseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackupEngineBase model =
            BinaryData
                .fromString(
                    "{\"backupEngineType\":\"BackupEngineBase\",\"friendlyName\":\"oenwashr\",\"backupManagementType\":\"Invalid\",\"registrationStatus\":\"cnqxwbpokulpi\",\"backupEngineState\":\"waasip\",\"healthStatus\":\"iobyu\",\"canReRegister\":false,\"backupEngineId\":\"qlpqwcciuq\",\"dpmVersion\":\"dbutauvfbtkuwhh\",\"azureBackupAgentVersion\":\"ykojoxafnndlpic\",\"isAzureBackupAgentUpgradeAvailable\":false,\"isDpmUpgradeAvailable\":true,\"extendedInfo\":{\"databaseName\":\"dyh\",\"protectedItemsCount\":1262943142,\"protectedServersCount\":823230249,\"diskCount\":426200809,\"usedDiskSpace\":65.57203087294614,\"availableDiskSpace\":82.71397462119481,\"refreshedAt\":\"2021-02-14T23:28:55Z\",\"azureProtectedInstances\":188406178}}")
                .toObject(BackupEngineBase.class);
        Assertions.assertEquals("oenwashr", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.INVALID, model.backupManagementType());
        Assertions.assertEquals("cnqxwbpokulpi", model.registrationStatus());
        Assertions.assertEquals("waasip", model.backupEngineState());
        Assertions.assertEquals("iobyu", model.healthStatus());
        Assertions.assertEquals(false, model.canReRegister());
        Assertions.assertEquals("qlpqwcciuq", model.backupEngineId());
        Assertions.assertEquals("dbutauvfbtkuwhh", model.dpmVersion());
        Assertions.assertEquals("ykojoxafnndlpic", model.azureBackupAgentVersion());
        Assertions.assertEquals(false, model.isAzureBackupAgentUpgradeAvailable());
        Assertions.assertEquals(true, model.isDpmUpgradeAvailable());
        Assertions.assertEquals("dyh", model.extendedInfo().databaseName());
        Assertions.assertEquals(1262943142, model.extendedInfo().protectedItemsCount());
        Assertions.assertEquals(823230249, model.extendedInfo().protectedServersCount());
        Assertions.assertEquals(426200809, model.extendedInfo().diskCount());
        Assertions.assertEquals(65.57203087294614D, model.extendedInfo().usedDiskSpace());
        Assertions.assertEquals(82.71397462119481D, model.extendedInfo().availableDiskSpace());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-14T23:28:55Z"), model.extendedInfo().refreshedAt());
        Assertions.assertEquals(188406178, model.extendedInfo().azureProtectedInstances());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackupEngineBase model =
            new BackupEngineBase()
                .withFriendlyName("oenwashr")
                .withBackupManagementType(BackupManagementType.INVALID)
                .withRegistrationStatus("cnqxwbpokulpi")
                .withBackupEngineState("waasip")
                .withHealthStatus("iobyu")
                .withCanReRegister(false)
                .withBackupEngineId("qlpqwcciuq")
                .withDpmVersion("dbutauvfbtkuwhh")
                .withAzureBackupAgentVersion("ykojoxafnndlpic")
                .withIsAzureBackupAgentUpgradeAvailable(false)
                .withIsDpmUpgradeAvailable(true)
                .withExtendedInfo(
                    new BackupEngineExtendedInfo()
                        .withDatabaseName("dyh")
                        .withProtectedItemsCount(1262943142)
                        .withProtectedServersCount(823230249)
                        .withDiskCount(426200809)
                        .withUsedDiskSpace(65.57203087294614D)
                        .withAvailableDiskSpace(82.71397462119481D)
                        .withRefreshedAt(OffsetDateTime.parse("2021-02-14T23:28:55Z"))
                        .withAzureProtectedInstances(188406178));
        model = BinaryData.fromObject(model).toObject(BackupEngineBase.class);
        Assertions.assertEquals("oenwashr", model.friendlyName());
        Assertions.assertEquals(BackupManagementType.INVALID, model.backupManagementType());
        Assertions.assertEquals("cnqxwbpokulpi", model.registrationStatus());
        Assertions.assertEquals("waasip", model.backupEngineState());
        Assertions.assertEquals("iobyu", model.healthStatus());
        Assertions.assertEquals(false, model.canReRegister());
        Assertions.assertEquals("qlpqwcciuq", model.backupEngineId());
        Assertions.assertEquals("dbutauvfbtkuwhh", model.dpmVersion());
        Assertions.assertEquals("ykojoxafnndlpic", model.azureBackupAgentVersion());
        Assertions.assertEquals(false, model.isAzureBackupAgentUpgradeAvailable());
        Assertions.assertEquals(true, model.isDpmUpgradeAvailable());
        Assertions.assertEquals("dyh", model.extendedInfo().databaseName());
        Assertions.assertEquals(1262943142, model.extendedInfo().protectedItemsCount());
        Assertions.assertEquals(823230249, model.extendedInfo().protectedServersCount());
        Assertions.assertEquals(426200809, model.extendedInfo().diskCount());
        Assertions.assertEquals(65.57203087294614D, model.extendedInfo().usedDiskSpace());
        Assertions.assertEquals(82.71397462119481D, model.extendedInfo().availableDiskSpace());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-14T23:28:55Z"), model.extendedInfo().refreshedAt());
        Assertions.assertEquals(188406178, model.extendedInfo().azureProtectedInstances());
    }
}
