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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.RecurrenceFrequency;
import com.azure.resourcemanager.machinelearning.models.RecurrenceSchedule;
import com.azure.resourcemanager.machinelearning.models.RecurrenceTrigger;
import com.azure.resourcemanager.machinelearning.models.WeekDay;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RecurrenceTriggerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RecurrenceTrigger model =
            BinaryData
                .fromString(
                    "{\"triggerType\":\"Recurrence\",\"frequency\":\"Hour\",\"interval\":712298972,\"schedule\":{\"hours\":[2143245313,620966114],\"minutes\":[41999694,2076319922],\"monthDays\":[2043297749,1561277343,1217879659,986610623],\"weekDays\":[\"Wednesday\",\"Monday\"]},\"endTime\":\"rlktgjcsggu\",\"startTime\":\"eml\",\"timeZone\":\"waeeczgfb\"}")
                .toObject(RecurrenceTrigger.class);
        Assertions.assertEquals("rlktgjcsggu", model.endTime());
        Assertions.assertEquals("eml", model.startTime());
        Assertions.assertEquals("waeeczgfb", model.timeZone());
        Assertions.assertEquals(RecurrenceFrequency.HOUR, model.frequency());
        Assertions.assertEquals(712298972, model.interval());
        Assertions.assertEquals(2143245313, model.schedule().hours().get(0));
        Assertions.assertEquals(41999694, model.schedule().minutes().get(0));
        Assertions.assertEquals(2043297749, model.schedule().monthDays().get(0));
        Assertions.assertEquals(WeekDay.WEDNESDAY, model.schedule().weekDays().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RecurrenceTrigger model =
            new RecurrenceTrigger()
                .withEndTime("rlktgjcsggu")
                .withStartTime("eml")
                .withTimeZone("waeeczgfb")
                .withFrequency(RecurrenceFrequency.HOUR)
                .withInterval(712298972)
                .withSchedule(
                    new RecurrenceSchedule()
                        .withHours(Arrays.asList(2143245313, 620966114))
                        .withMinutes(Arrays.asList(41999694, 2076319922))
                        .withMonthDays(Arrays.asList(2043297749, 1561277343, 1217879659, 986610623))
                        .withWeekDays(Arrays.asList(WeekDay.WEDNESDAY, WeekDay.MONDAY)));
        model = BinaryData.fromObject(model).toObject(RecurrenceTrigger.class);
        Assertions.assertEquals("rlktgjcsggu", model.endTime());
        Assertions.assertEquals("eml", model.startTime());
        Assertions.assertEquals("waeeczgfb", model.timeZone());
        Assertions.assertEquals(RecurrenceFrequency.HOUR, model.frequency());
        Assertions.assertEquals(712298972, model.interval());
        Assertions.assertEquals(2143245313, model.schedule().hours().get(0));
        Assertions.assertEquals(41999694, model.schedule().minutes().get(0));
        Assertions.assertEquals(2043297749, model.schedule().monthDays().get(0));
        Assertions.assertEquals(WeekDay.WEDNESDAY, model.schedule().weekDays().get(0));
    }
}
