// 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.AzureWorkloadSqlRecoveryPointExtendedInfo;
import com.azure.resourcemanager.recoveryservicesbackup.models.SqlDataDirectory;
import com.azure.resourcemanager.recoveryservicesbackup.models.SqlDataDirectoryType;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AzureWorkloadSqlRecoveryPointExtendedInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureWorkloadSqlRecoveryPointExtendedInfo model =
            BinaryData
                .fromString(
                    "{\"dataDirectoryTimeInUTC\":\"2021-11-04T18:23Z\",\"dataDirectoryPaths\":[{\"type\":\"Data\",\"path\":\"kyuizabsnmfpp\",\"logicalName\":\"jee\"}]}")
                .toObject(AzureWorkloadSqlRecoveryPointExtendedInfo.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-04T18:23Z"), model.dataDirectoryTimeInUtc());
        Assertions.assertEquals(SqlDataDirectoryType.DATA, model.dataDirectoryPaths().get(0).type());
        Assertions.assertEquals("kyuizabsnmfpp", model.dataDirectoryPaths().get(0).path());
        Assertions.assertEquals("jee", model.dataDirectoryPaths().get(0).logicalName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureWorkloadSqlRecoveryPointExtendedInfo model =
            new AzureWorkloadSqlRecoveryPointExtendedInfo()
                .withDataDirectoryTimeInUtc(OffsetDateTime.parse("2021-11-04T18:23Z"))
                .withDataDirectoryPaths(
                    Arrays
                        .asList(
                            new SqlDataDirectory()
                                .withType(SqlDataDirectoryType.DATA)
                                .withPath("kyuizabsnmfpp")
                                .withLogicalName("jee")));
        model = BinaryData.fromObject(model).toObject(AzureWorkloadSqlRecoveryPointExtendedInfo.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-04T18:23Z"), model.dataDirectoryTimeInUtc());
        Assertions.assertEquals(SqlDataDirectoryType.DATA, model.dataDirectoryPaths().get(0).type());
        Assertions.assertEquals("kyuizabsnmfpp", model.dataDirectoryPaths().get(0).path());
        Assertions.assertEquals("jee", model.dataDirectoryPaths().get(0).logicalName());
    }
}
