// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.datamigration.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.datamigration.models.BackupFileInfo;
import com.azure.resourcemanager.datamigration.models.BackupFileStatus;
import com.azure.resourcemanager.datamigration.models.BackupSetInfo;
import com.azure.resourcemanager.datamigration.models.BackupType;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class BackupSetInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackupSetInfo model =
            BinaryData
                .fromString(
                    "{\"backupSetId\":\"nrs\",\"firstLsn\":\"lqidyby\",\"lastLsn\":\"zfcl\",\"lastModifiedTime\":\"2021-01-18T05:48:26Z\",\"backupType\":\"File\",\"listOfBackupFiles\":[{\"fileLocation\":\"p\",\"familySequenceNumber\":1346758763,\"status\":\"Queued\"},{\"fileLocation\":\"fkts\",\"familySequenceNumber\":1927626418,\"status\":\"Cancelled\"}],\"databaseName\":\"cmnyyazttb\",\"backupStartDate\":\"2021-08-28T10:19:16Z\",\"backupFinishedDate\":\"2021-09-21T11:54:29Z\",\"isBackupRestored\":false}")
                .toObject(BackupSetInfo.class);
        Assertions.assertEquals("nrs", model.backupSetId());
        Assertions.assertEquals("lqidyby", model.firstLsn());
        Assertions.assertEquals("zfcl", model.lastLsn());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-18T05:48:26Z"), model.lastModifiedTime());
        Assertions.assertEquals(BackupType.FILE, model.backupType());
        Assertions.assertEquals("p", model.listOfBackupFiles().get(0).fileLocation());
        Assertions.assertEquals(1346758763, model.listOfBackupFiles().get(0).familySequenceNumber());
        Assertions.assertEquals(BackupFileStatus.QUEUED, model.listOfBackupFiles().get(0).status());
        Assertions.assertEquals("cmnyyazttb", model.databaseName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-28T10:19:16Z"), model.backupStartDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-21T11:54:29Z"), model.backupFinishedDate());
        Assertions.assertEquals(false, model.isBackupRestored());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackupSetInfo model =
            new BackupSetInfo()
                .withBackupSetId("nrs")
                .withFirstLsn("lqidyby")
                .withLastLsn("zfcl")
                .withLastModifiedTime(OffsetDateTime.parse("2021-01-18T05:48:26Z"))
                .withBackupType(BackupType.FILE)
                .withListOfBackupFiles(
                    Arrays
                        .asList(
                            new BackupFileInfo()
                                .withFileLocation("p")
                                .withFamilySequenceNumber(1346758763)
                                .withStatus(BackupFileStatus.QUEUED),
                            new BackupFileInfo()
                                .withFileLocation("fkts")
                                .withFamilySequenceNumber(1927626418)
                                .withStatus(BackupFileStatus.CANCELLED)))
                .withDatabaseName("cmnyyazttb")
                .withBackupStartDate(OffsetDateTime.parse("2021-08-28T10:19:16Z"))
                .withBackupFinishedDate(OffsetDateTime.parse("2021-09-21T11:54:29Z"))
                .withIsBackupRestored(false);
        model = BinaryData.fromObject(model).toObject(BackupSetInfo.class);
        Assertions.assertEquals("nrs", model.backupSetId());
        Assertions.assertEquals("lqidyby", model.firstLsn());
        Assertions.assertEquals("zfcl", model.lastLsn());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-18T05:48:26Z"), model.lastModifiedTime());
        Assertions.assertEquals(BackupType.FILE, model.backupType());
        Assertions.assertEquals("p", model.listOfBackupFiles().get(0).fileLocation());
        Assertions.assertEquals(1346758763, model.listOfBackupFiles().get(0).familySequenceNumber());
        Assertions.assertEquals(BackupFileStatus.QUEUED, model.listOfBackupFiles().get(0).status());
        Assertions.assertEquals("cmnyyazttb", model.databaseName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-28T10:19:16Z"), model.backupStartDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-21T11:54:29Z"), model.backupFinishedDate());
        Assertions.assertEquals(false, model.isBackupRestored());
    }
}
