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

package com.azure.resourcemanager.costmanagement.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.costmanagement.fluent.models.ScheduledActionProperties;
import com.azure.resourcemanager.costmanagement.models.DaysOfWeek;
import com.azure.resourcemanager.costmanagement.models.FileDestination;
import com.azure.resourcemanager.costmanagement.models.FileFormat;
import com.azure.resourcemanager.costmanagement.models.NotificationProperties;
import com.azure.resourcemanager.costmanagement.models.ScheduleFrequency;
import com.azure.resourcemanager.costmanagement.models.ScheduleProperties;
import com.azure.resourcemanager.costmanagement.models.ScheduledActionStatus;
import com.azure.resourcemanager.costmanagement.models.WeeksOfMonth;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ScheduledActionPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduledActionProperties model =
            BinaryData
                .fromString(
                    "{\"displayName\":\"nrvgoupmfiibfgg\",\"fileDestination\":{\"fileFormats\":[\"Csv\",\"Csv\"]},\"notification\":{\"to\":[\"wxkvtkkgll\",\"wjygvjayvblmhvk\",\"uhbxvvy\"],\"language\":\"s\",\"message\":\"byrqufeg\",\"regionalFormat\":\"vwz\",\"subject\":\"bnhlmc\"},\"notificationEmail\":\"p\",\"schedule\":{\"frequency\":\"Daily\",\"hourOfDay\":1262930280,\"daysOfWeek\":[\"Thursday\",\"Wednesday\"],\"weeksOfMonth\":[\"Fourth\",\"First\"],\"dayOfMonth\":283160638,\"startDate\":\"2021-08-25T00:52:30Z\",\"endDate\":\"2021-02-16T12:45:58Z\"},\"scope\":\"ijejvegrhbpn\",\"status\":\"Enabled\",\"viewId\":\"xexccbdreaxhcexd\"}")
                .toObject(ScheduledActionProperties.class);
        Assertions.assertEquals("nrvgoupmfiibfgg", model.displayName());
        Assertions.assertEquals(FileFormat.CSV, model.fileDestination().fileFormats().get(0));
        Assertions.assertEquals("wxkvtkkgll", model.notification().to().get(0));
        Assertions.assertEquals("s", model.notification().language());
        Assertions.assertEquals("byrqufeg", model.notification().message());
        Assertions.assertEquals("vwz", model.notification().regionalFormat());
        Assertions.assertEquals("bnhlmc", model.notification().subject());
        Assertions.assertEquals("p", model.notificationEmail());
        Assertions.assertEquals(ScheduleFrequency.DAILY, model.schedule().frequency());
        Assertions.assertEquals(1262930280, model.schedule().hourOfDay());
        Assertions.assertEquals(DaysOfWeek.THURSDAY, model.schedule().daysOfWeek().get(0));
        Assertions.assertEquals(WeeksOfMonth.FOURTH, model.schedule().weeksOfMonth().get(0));
        Assertions.assertEquals(283160638, model.schedule().dayOfMonth());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-25T00:52:30Z"), model.schedule().startDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-16T12:45:58Z"), model.schedule().endDate());
        Assertions.assertEquals("ijejvegrhbpn", model.scope());
        Assertions.assertEquals(ScheduledActionStatus.ENABLED, model.status());
        Assertions.assertEquals("xexccbdreaxhcexd", model.viewId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduledActionProperties model =
            new ScheduledActionProperties()
                .withDisplayName("nrvgoupmfiibfgg")
                .withFileDestination(
                    new FileDestination().withFileFormats(Arrays.asList(FileFormat.CSV, FileFormat.CSV)))
                .withNotification(
                    new NotificationProperties()
                        .withTo(Arrays.asList("wxkvtkkgll", "wjygvjayvblmhvk", "uhbxvvy"))
                        .withLanguage("s")
                        .withMessage("byrqufeg")
                        .withRegionalFormat("vwz")
                        .withSubject("bnhlmc"))
                .withNotificationEmail("p")
                .withSchedule(
                    new ScheduleProperties()
                        .withFrequency(ScheduleFrequency.DAILY)
                        .withHourOfDay(1262930280)
                        .withDaysOfWeek(Arrays.asList(DaysOfWeek.THURSDAY, DaysOfWeek.WEDNESDAY))
                        .withWeeksOfMonth(Arrays.asList(WeeksOfMonth.FOURTH, WeeksOfMonth.FIRST))
                        .withDayOfMonth(283160638)
                        .withStartDate(OffsetDateTime.parse("2021-08-25T00:52:30Z"))
                        .withEndDate(OffsetDateTime.parse("2021-02-16T12:45:58Z")))
                .withScope("ijejvegrhbpn")
                .withStatus(ScheduledActionStatus.ENABLED)
                .withViewId("xexccbdreaxhcexd");
        model = BinaryData.fromObject(model).toObject(ScheduledActionProperties.class);
        Assertions.assertEquals("nrvgoupmfiibfgg", model.displayName());
        Assertions.assertEquals(FileFormat.CSV, model.fileDestination().fileFormats().get(0));
        Assertions.assertEquals("wxkvtkkgll", model.notification().to().get(0));
        Assertions.assertEquals("s", model.notification().language());
        Assertions.assertEquals("byrqufeg", model.notification().message());
        Assertions.assertEquals("vwz", model.notification().regionalFormat());
        Assertions.assertEquals("bnhlmc", model.notification().subject());
        Assertions.assertEquals("p", model.notificationEmail());
        Assertions.assertEquals(ScheduleFrequency.DAILY, model.schedule().frequency());
        Assertions.assertEquals(1262930280, model.schedule().hourOfDay());
        Assertions.assertEquals(DaysOfWeek.THURSDAY, model.schedule().daysOfWeek().get(0));
        Assertions.assertEquals(WeeksOfMonth.FOURTH, model.schedule().weeksOfMonth().get(0));
        Assertions.assertEquals(283160638, model.schedule().dayOfMonth());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-25T00:52:30Z"), model.schedule().startDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-16T12:45:58Z"), model.schedule().endDate());
        Assertions.assertEquals("ijejvegrhbpn", model.scope());
        Assertions.assertEquals(ScheduledActionStatus.ENABLED, model.status());
        Assertions.assertEquals("xexccbdreaxhcexd", model.viewId());
    }
}
