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

package com.azure.resourcemanager.mysqlflexibleserver.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mysqlflexibleserver.fluent.models.BackupAndExportResponseInner;
import com.azure.resourcemanager.mysqlflexibleserver.models.OperationStatus;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class BackupAndExportResponseInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackupAndExportResponseInner model =
            BinaryData
                .fromString(
                    "{\"status\":\"CancelInProgress\",\"startTime\":\"2021-01-15T00:39:28Z\",\"endTime\":\"2021-04-04T07:45:50Z\",\"percentComplete\":13.198921536177277,\"properties\":{\"datasourceSizeInBytes\":8699509419424523906,\"dataTransferredInBytes\":7670793912698215607,\"backupMetadata\":\"jdpvwryo\"},\"id\":\"soacctazakl\",\"name\":\"lahbcryff\",\"type\":\"fdosyg\"}")
                .toObject(BackupAndExportResponseInner.class);
        Assertions.assertEquals(OperationStatus.CANCEL_IN_PROGRESS, model.status());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-15T00:39:28Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-04T07:45:50Z"), model.endTime());
        Assertions.assertEquals(13.198921536177277D, model.percentComplete());
        Assertions.assertEquals(8699509419424523906L, model.datasourceSizeInBytes());
        Assertions.assertEquals(7670793912698215607L, model.dataTransferredInBytes());
        Assertions.assertEquals("jdpvwryo", model.backupMetadata());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackupAndExportResponseInner model =
            new BackupAndExportResponseInner()
                .withStatus(OperationStatus.CANCEL_IN_PROGRESS)
                .withStartTime(OffsetDateTime.parse("2021-01-15T00:39:28Z"))
                .withEndTime(OffsetDateTime.parse("2021-04-04T07:45:50Z"))
                .withPercentComplete(13.198921536177277D)
                .withDatasourceSizeInBytes(8699509419424523906L)
                .withDataTransferredInBytes(7670793912698215607L)
                .withBackupMetadata("jdpvwryo");
        model = BinaryData.fromObject(model).toObject(BackupAndExportResponseInner.class);
        Assertions.assertEquals(OperationStatus.CANCEL_IN_PROGRESS, model.status());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-15T00:39:28Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-04T07:45:50Z"), model.endTime());
        Assertions.assertEquals(13.198921536177277D, model.percentComplete());
        Assertions.assertEquals(8699509419424523906L, model.datasourceSizeInBytes());
        Assertions.assertEquals(7670793912698215607L, model.dataTransferredInBytes());
        Assertions.assertEquals("jdpvwryo", model.backupMetadata());
    }
}
