// 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.ScheduledActionInner;
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.ScheduledActionKind;
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 ScheduledActionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduledActionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"displayName\":\"yajguqfhwygzlv\",\"fileDestination\":{\"fileFormats\":[\"Csv\",\"Csv\",\"Csv\"]},\"notification\":{\"to\":[\"mdwzrmuhapfcqdps\",\"xqv\",\"svuo\",\"mgccelvezrypq\"],\"language\":\"feo\",\"message\":\"rqwky\",\"regionalFormat\":\"ob\",\"subject\":\"pg\"},\"notificationEmail\":\"dkow\",\"schedule\":{\"frequency\":\"Weekly\",\"hourOfDay\":1181532095,\"daysOfWeek\":[\"Wednesday\"],\"weeksOfMonth\":[\"Third\",\"Third\"],\"dayOfMonth\":2104767633,\"startDate\":\"2021-10-14T17:11:50Z\",\"endDate\":\"2021-02-04T16:35:40Z\"},\"scope\":\"vcdwxlpqekftn\",\"status\":\"Enabled\",\"viewId\":\"tjsyin\"},\"eTag\":\"fq\",\"kind\":\"Email\",\"id\":\"dhtmdvypgikd\",\"name\":\"szywkbirryu\",\"type\":\"hlhkjoqrvqqaatj\"}")
                .toObject(ScheduledActionInner.class);
        Assertions.assertEquals(ScheduledActionKind.EMAIL, model.kind());
        Assertions.assertEquals("yajguqfhwygzlv", model.displayName());
        Assertions.assertEquals(FileFormat.CSV, model.fileDestination().fileFormats().get(0));
        Assertions.assertEquals("mdwzrmuhapfcqdps", model.notification().to().get(0));
        Assertions.assertEquals("feo", model.notification().language());
        Assertions.assertEquals("rqwky", model.notification().message());
        Assertions.assertEquals("ob", model.notification().regionalFormat());
        Assertions.assertEquals("pg", model.notification().subject());
        Assertions.assertEquals("dkow", model.notificationEmail());
        Assertions.assertEquals(ScheduleFrequency.WEEKLY, model.schedule().frequency());
        Assertions.assertEquals(1181532095, model.schedule().hourOfDay());
        Assertions.assertEquals(DaysOfWeek.WEDNESDAY, model.schedule().daysOfWeek().get(0));
        Assertions.assertEquals(WeeksOfMonth.THIRD, model.schedule().weeksOfMonth().get(0));
        Assertions.assertEquals(2104767633, model.schedule().dayOfMonth());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-14T17:11:50Z"), model.schedule().startDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-04T16:35:40Z"), model.schedule().endDate());
        Assertions.assertEquals("vcdwxlpqekftn", model.scope());
        Assertions.assertEquals(ScheduledActionStatus.ENABLED, model.status());
        Assertions.assertEquals("tjsyin", model.viewId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduledActionInner model =
            new ScheduledActionInner()
                .withKind(ScheduledActionKind.EMAIL)
                .withDisplayName("yajguqfhwygzlv")
                .withFileDestination(
                    new FileDestination()
                        .withFileFormats(Arrays.asList(FileFormat.CSV, FileFormat.CSV, FileFormat.CSV)))
                .withNotification(
                    new NotificationProperties()
                        .withTo(Arrays.asList("mdwzrmuhapfcqdps", "xqv", "svuo", "mgccelvezrypq"))
                        .withLanguage("feo")
                        .withMessage("rqwky")
                        .withRegionalFormat("ob")
                        .withSubject("pg"))
                .withNotificationEmail("dkow")
                .withSchedule(
                    new ScheduleProperties()
                        .withFrequency(ScheduleFrequency.WEEKLY)
                        .withHourOfDay(1181532095)
                        .withDaysOfWeek(Arrays.asList(DaysOfWeek.WEDNESDAY))
                        .withWeeksOfMonth(Arrays.asList(WeeksOfMonth.THIRD, WeeksOfMonth.THIRD))
                        .withDayOfMonth(2104767633)
                        .withStartDate(OffsetDateTime.parse("2021-10-14T17:11:50Z"))
                        .withEndDate(OffsetDateTime.parse("2021-02-04T16:35:40Z")))
                .withScope("vcdwxlpqekftn")
                .withStatus(ScheduledActionStatus.ENABLED)
                .withViewId("tjsyin");
        model = BinaryData.fromObject(model).toObject(ScheduledActionInner.class);
        Assertions.assertEquals(ScheduledActionKind.EMAIL, model.kind());
        Assertions.assertEquals("yajguqfhwygzlv", model.displayName());
        Assertions.assertEquals(FileFormat.CSV, model.fileDestination().fileFormats().get(0));
        Assertions.assertEquals("mdwzrmuhapfcqdps", model.notification().to().get(0));
        Assertions.assertEquals("feo", model.notification().language());
        Assertions.assertEquals("rqwky", model.notification().message());
        Assertions.assertEquals("ob", model.notification().regionalFormat());
        Assertions.assertEquals("pg", model.notification().subject());
        Assertions.assertEquals("dkow", model.notificationEmail());
        Assertions.assertEquals(ScheduleFrequency.WEEKLY, model.schedule().frequency());
        Assertions.assertEquals(1181532095, model.schedule().hourOfDay());
        Assertions.assertEquals(DaysOfWeek.WEDNESDAY, model.schedule().daysOfWeek().get(0));
        Assertions.assertEquals(WeeksOfMonth.THIRD, model.schedule().weeksOfMonth().get(0));
        Assertions.assertEquals(2104767633, model.schedule().dayOfMonth());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-14T17:11:50Z"), model.schedule().startDate());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-04T16:35:40Z"), model.schedule().endDate());
        Assertions.assertEquals("vcdwxlpqekftn", model.scope());
        Assertions.assertEquals(ScheduledActionStatus.ENABLED, model.status());
        Assertions.assertEquals("tjsyin", model.viewId());
    }
}
