// 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.BatchReleaseCriteria;
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.WorkflowTriggerRecurrence;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class BatchReleaseCriteriaTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BatchReleaseCriteria model =
            BinaryData
                .fromString(
                    "{\"messageCount\":2091031438,\"batchSize\":1107083346,\"recurrence\":{\"frequency\":\"Year\",\"interval\":895181053,\"startTime\":\"dkcrodt\",\"endTime\":\"nfwjlfltkacjvefk\",\"timeZone\":\"foakgg\",\"schedule\":{\"minutes\":[2109908244,488745932,1709159088,577549105],\"hours\":[597345805,1784212142,593695187,1177485669],\"weekDays\":[\"Sunday\",\"Wednesday\",\"Friday\"],\"monthDays\":[592325028],\"monthlyOccurrences\":[]}}}")
                .toObject(BatchReleaseCriteria.class);
        Assertions.assertEquals(2091031438, model.messageCount());
        Assertions.assertEquals(1107083346, model.batchSize());
        Assertions.assertEquals(RecurrenceFrequency.YEAR, model.recurrence().frequency());
        Assertions.assertEquals(895181053, model.recurrence().interval());
        Assertions.assertEquals("dkcrodt", model.recurrence().startTime());
        Assertions.assertEquals("nfwjlfltkacjvefk", model.recurrence().endTime());
        Assertions.assertEquals("foakgg", model.recurrence().timeZone());
        Assertions.assertEquals(2109908244, model.recurrence().schedule().minutes().get(0));
        Assertions.assertEquals(597345805, model.recurrence().schedule().hours().get(0));
        Assertions.assertEquals(DaysOfWeek.SUNDAY, model.recurrence().schedule().weekDays().get(0));
        Assertions.assertEquals(592325028, model.recurrence().schedule().monthDays().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BatchReleaseCriteria model =
            new BatchReleaseCriteria()
                .withMessageCount(2091031438)
                .withBatchSize(1107083346)
                .withRecurrence(
                    new WorkflowTriggerRecurrence()
                        .withFrequency(RecurrenceFrequency.YEAR)
                        .withInterval(895181053)
                        .withStartTime("dkcrodt")
                        .withEndTime("nfwjlfltkacjvefk")
                        .withTimeZone("foakgg")
                        .withSchedule(
                            new RecurrenceSchedule()
                                .withMinutes(Arrays.asList(2109908244, 488745932, 1709159088, 577549105))
                                .withHours(Arrays.asList(597345805, 1784212142, 593695187, 1177485669))
                                .withWeekDays(Arrays.asList(DaysOfWeek.SUNDAY, DaysOfWeek.WEDNESDAY, DaysOfWeek.FRIDAY))
                                .withMonthDays(Arrays.asList(592325028))
                                .withMonthlyOccurrences(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(BatchReleaseCriteria.class);
        Assertions.assertEquals(2091031438, model.messageCount());
        Assertions.assertEquals(1107083346, model.batchSize());
        Assertions.assertEquals(RecurrenceFrequency.YEAR, model.recurrence().frequency());
        Assertions.assertEquals(895181053, model.recurrence().interval());
        Assertions.assertEquals("dkcrodt", model.recurrence().startTime());
        Assertions.assertEquals("nfwjlfltkacjvefk", model.recurrence().endTime());
        Assertions.assertEquals("foakgg", model.recurrence().timeZone());
        Assertions.assertEquals(2109908244, model.recurrence().schedule().minutes().get(0));
        Assertions.assertEquals(597345805, model.recurrence().schedule().hours().get(0));
        Assertions.assertEquals(DaysOfWeek.SUNDAY, model.recurrence().schedule().weekDays().get(0));
        Assertions.assertEquals(592325028, model.recurrence().schedule().monthDays().get(0));
    }
}
