// 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.BatchConfigurationProperties;
import com.azure.resourcemanager.logic.models.BatchReleaseCriteria;
import com.azure.resourcemanager.logic.models.RecurrenceFrequency;
import com.azure.resourcemanager.logic.models.WorkflowTriggerRecurrence;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class BatchConfigurationPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BatchConfigurationProperties model =
            BinaryData
                .fromString(
                    "{\"batchGroupName\":\"q\",\"releaseCriteria\":{\"messageCount\":586646303,\"batchSize\":887642500,\"recurrence\":{\"frequency\":\"NotSpecified\",\"interval\":849949401,\"startTime\":\"gsquyfxrxxlept\",\"endTime\":\"mxjezwlw\",\"timeZone\":\"xuqlcvydypat\"}},\"createdTime\":\"2021-10-15T00:40:10Z\",\"changedTime\":\"2021-10-30T20:25:20Z\",\"metadata\":\"dataniodkooeb\"}")
                .toObject(BatchConfigurationProperties.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-15T00:40:10Z"), model.createdTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-30T20:25:20Z"), model.changedTime());
        Assertions.assertEquals("q", model.batchGroupName());
        Assertions.assertEquals(586646303, model.releaseCriteria().messageCount());
        Assertions.assertEquals(887642500, model.releaseCriteria().batchSize());
        Assertions.assertEquals(RecurrenceFrequency.NOT_SPECIFIED, model.releaseCriteria().recurrence().frequency());
        Assertions.assertEquals(849949401, model.releaseCriteria().recurrence().interval());
        Assertions.assertEquals("gsquyfxrxxlept", model.releaseCriteria().recurrence().startTime());
        Assertions.assertEquals("mxjezwlw", model.releaseCriteria().recurrence().endTime());
        Assertions.assertEquals("xuqlcvydypat", model.releaseCriteria().recurrence().timeZone());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BatchConfigurationProperties model =
            new BatchConfigurationProperties()
                .withCreatedTime(OffsetDateTime.parse("2021-10-15T00:40:10Z"))
                .withChangedTime(OffsetDateTime.parse("2021-10-30T20:25:20Z"))
                .withMetadata("dataniodkooeb")
                .withBatchGroupName("q")
                .withReleaseCriteria(
                    new BatchReleaseCriteria()
                        .withMessageCount(586646303)
                        .withBatchSize(887642500)
                        .withRecurrence(
                            new WorkflowTriggerRecurrence()
                                .withFrequency(RecurrenceFrequency.NOT_SPECIFIED)
                                .withInterval(849949401)
                                .withStartTime("gsquyfxrxxlept")
                                .withEndTime("mxjezwlw")
                                .withTimeZone("xuqlcvydypat")));
        model = BinaryData.fromObject(model).toObject(BatchConfigurationProperties.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-15T00:40:10Z"), model.createdTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-30T20:25:20Z"), model.changedTime());
        Assertions.assertEquals("q", model.batchGroupName());
        Assertions.assertEquals(586646303, model.releaseCriteria().messageCount());
        Assertions.assertEquals(887642500, model.releaseCriteria().batchSize());
        Assertions.assertEquals(RecurrenceFrequency.NOT_SPECIFIED, model.releaseCriteria().recurrence().frequency());
        Assertions.assertEquals(849949401, model.releaseCriteria().recurrence().interval());
        Assertions.assertEquals("gsquyfxrxxlept", model.releaseCriteria().recurrence().startTime());
        Assertions.assertEquals("mxjezwlw", model.releaseCriteria().recurrence().endTime());
        Assertions.assertEquals("xuqlcvydypat", model.releaseCriteria().recurrence().timeZone());
    }
}
