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

public final class DailyRetentionScheduleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DailyRetentionSchedule model =
            BinaryData
                .fromString(
                    "{\"retentionTimes\":[\"2021-11-10T08:55:59Z\",\"2021-07-20T07:23:19Z\"],\"retentionDuration\":{\"count\":2025422564,\"durationType\":\"Months\"}}")
                .toObject(DailyRetentionSchedule.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-10T08:55:59Z"), model.retentionTimes().get(0));
        Assertions.assertEquals(2025422564, model.retentionDuration().count());
        Assertions.assertEquals(RetentionDurationType.MONTHS, model.retentionDuration().durationType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DailyRetentionSchedule model =
            new DailyRetentionSchedule()
                .withRetentionTimes(
                    Arrays
                        .asList(
                            OffsetDateTime.parse("2021-11-10T08:55:59Z"), OffsetDateTime.parse("2021-07-20T07:23:19Z")))
                .withRetentionDuration(
                    new RetentionDuration().withCount(2025422564).withDurationType(RetentionDurationType.MONTHS));
        model = BinaryData.fromObject(model).toObject(DailyRetentionSchedule.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-10T08:55:59Z"), model.retentionTimes().get(0));
        Assertions.assertEquals(2025422564, model.retentionDuration().count());
        Assertions.assertEquals(RetentionDurationType.MONTHS, model.retentionDuration().durationType());
    }
}
