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

package com.azure.resourcemanager.logic.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.logic.models.DayOfWeek;
import com.azure.resourcemanager.logic.models.DaysOfWeek;
import com.azure.resourcemanager.logic.models.RecurrenceFrequency;
import com.azure.resourcemanager.logic.models.RecurrenceSchedule;
import com.azure.resourcemanager.logic.models.RecurrenceScheduleOccurrence;
import com.azure.resourcemanager.logic.models.WorkflowTriggerRecurrence;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class WorkflowTriggerRecurrenceTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        WorkflowTriggerRecurrence model =
            BinaryData
                .fromString(
                    "{\"frequency\":\"Minute\",\"interval\":1106278422,\"startTime\":\"zmhjrunmp\",\"endTime\":\"tdbhrbnla\",\"timeZone\":\"xmyskp\",\"schedule\":{\"minutes\":[1813898530,1326044907,2131694851,679470188],\"hours\":[83692384],\"weekDays\":[\"Sunday\"],\"monthDays\":[1863766018],\"monthlyOccurrences\":[{\"day\":\"Thursday\",\"occurrence\":1149857481},{\"day\":\"Monday\",\"occurrence\":1405653076},{\"day\":\"Monday\",\"occurrence\":858824887}]}}")
                .toObject(WorkflowTriggerRecurrence.class);
        Assertions.assertEquals(RecurrenceFrequency.MINUTE, model.frequency());
        Assertions.assertEquals(1106278422, model.interval());
        Assertions.assertEquals("zmhjrunmp", model.startTime());
        Assertions.assertEquals("tdbhrbnla", model.endTime());
        Assertions.assertEquals("xmyskp", model.timeZone());
        Assertions.assertEquals(1813898530, model.schedule().minutes().get(0));
        Assertions.assertEquals(83692384, model.schedule().hours().get(0));
        Assertions.assertEquals(DaysOfWeek.SUNDAY, model.schedule().weekDays().get(0));
        Assertions.assertEquals(1863766018, model.schedule().monthDays().get(0));
        Assertions.assertEquals(DayOfWeek.THURSDAY, model.schedule().monthlyOccurrences().get(0).day());
        Assertions.assertEquals(1149857481, model.schedule().monthlyOccurrences().get(0).occurrence());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        WorkflowTriggerRecurrence model =
            new WorkflowTriggerRecurrence()
                .withFrequency(RecurrenceFrequency.MINUTE)
                .withInterval(1106278422)
                .withStartTime("zmhjrunmp")
                .withEndTime("tdbhrbnla")
                .withTimeZone("xmyskp")
                .withSchedule(
                    new RecurrenceSchedule()
                        .withMinutes(Arrays.asList(1813898530, 1326044907, 2131694851, 679470188))
                        .withHours(Arrays.asList(83692384))
                        .withWeekDays(Arrays.asList(DaysOfWeek.SUNDAY))
                        .withMonthDays(Arrays.asList(1863766018))
                        .withMonthlyOccurrences(
                            Arrays
                                .asList(
                                    new RecurrenceScheduleOccurrence()
                                        .withDay(DayOfWeek.THURSDAY)
                                        .withOccurrence(1149857481),
                                    new RecurrenceScheduleOccurrence()
                                        .withDay(DayOfWeek.MONDAY)
                                        .withOccurrence(1405653076),
                                    new RecurrenceScheduleOccurrence()
                                        .withDay(DayOfWeek.MONDAY)
                                        .withOccurrence(858824887))));
        model = BinaryData.fromObject(model).toObject(WorkflowTriggerRecurrence.class);
        Assertions.assertEquals(RecurrenceFrequency.MINUTE, model.frequency());
        Assertions.assertEquals(1106278422, model.interval());
        Assertions.assertEquals("zmhjrunmp", model.startTime());
        Assertions.assertEquals("tdbhrbnla", model.endTime());
        Assertions.assertEquals("xmyskp", model.timeZone());
        Assertions.assertEquals(1813898530, model.schedule().minutes().get(0));
        Assertions.assertEquals(83692384, model.schedule().hours().get(0));
        Assertions.assertEquals(DaysOfWeek.SUNDAY, model.schedule().weekDays().get(0));
        Assertions.assertEquals(1863766018, model.schedule().monthDays().get(0));
        Assertions.assertEquals(DayOfWeek.THURSDAY, model.schedule().monthlyOccurrences().get(0).day());
        Assertions.assertEquals(1149857481, model.schedule().monthlyOccurrences().get(0).occurrence());
    }
}
