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

package com.azure.resourcemanager.postgresqlflexibleserver.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.postgresqlflexibleserver.fluent.models.ServerBackupProperties;
import com.azure.resourcemanager.postgresqlflexibleserver.models.Origin;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ServerBackupPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServerBackupProperties model =
            BinaryData
                .fromString("{\"backupType\":\"Full\",\"completedTime\":\"2021-02-24T15:23:22Z\",\"source\":\"cs\"}")
                .toObject(ServerBackupProperties.class);
        Assertions.assertEquals(Origin.FULL, model.backupType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-24T15:23:22Z"), model.completedTime());
        Assertions.assertEquals("cs", model.source());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServerBackupProperties model =
            new ServerBackupProperties()
                .withBackupType(Origin.FULL)
                .withCompletedTime(OffsetDateTime.parse("2021-02-24T15:23:22Z"))
                .withSource("cs");
        model = BinaryData.fromObject(model).toObject(ServerBackupProperties.class);
        Assertions.assertEquals(Origin.FULL, model.backupType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-24T15:23:22Z"), model.completedTime());
        Assertions.assertEquals("cs", model.source());
    }
}
