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

package com.azure.resourcemanager.mediaservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mediaservices.models.LiveEventIngestInterruption;
import com.azure.resourcemanager.mediaservices.models.LiveEventIngestion;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class LiveEventIngestionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LiveEventIngestion model =
            BinaryData
                .fromString(
                    "{\"streamName\":\"ivpdtiir\",\"begin\":\"2021-10-30T18:40:51Z\",\"end\":\"2021-05-16T22:52:08Z\",\"endReason\":\"xoruzfgsquyfxrx\",\"ingestInterruptions\":[{\"begin\":\"2021-03-08T21:24:21Z\",\"end\":\"2021-02-07T09:18:25Z\",\"duration\":\"PT185H23M6S\",\"reason\":\"ezw\"},{\"begin\":\"2020-12-20T08:57:46Z\",\"end\":\"2021-07-30T12:05:38Z\",\"duration\":\"PT194H47M22S\",\"reason\":\"cvydypatdoo\"}]}")
                .toObject(LiveEventIngestion.class);
        Assertions.assertEquals("ivpdtiir", model.streamName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-30T18:40:51Z"), model.begin());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-16T22:52:08Z"), model.end());
        Assertions.assertEquals("xoruzfgsquyfxrx", model.endReason());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-03-08T21:24:21Z"), model.ingestInterruptions().get(0).begin());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-07T09:18:25Z"), model.ingestInterruptions().get(0).end());
        Assertions.assertEquals(Duration.parse("PT185H23M6S"), model.ingestInterruptions().get(0).duration());
        Assertions.assertEquals("ezw", model.ingestInterruptions().get(0).reason());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LiveEventIngestion model =
            new LiveEventIngestion()
                .withStreamName("ivpdtiir")
                .withBegin(OffsetDateTime.parse("2021-10-30T18:40:51Z"))
                .withEnd(OffsetDateTime.parse("2021-05-16T22:52:08Z"))
                .withEndReason("xoruzfgsquyfxrx")
                .withIngestInterruptions(
                    Arrays
                        .asList(
                            new LiveEventIngestInterruption()
                                .withBegin(OffsetDateTime.parse("2021-03-08T21:24:21Z"))
                                .withEnd(OffsetDateTime.parse("2021-02-07T09:18:25Z"))
                                .withDuration(Duration.parse("PT185H23M6S"))
                                .withReason("ezw"),
                            new LiveEventIngestInterruption()
                                .withBegin(OffsetDateTime.parse("2020-12-20T08:57:46Z"))
                                .withEnd(OffsetDateTime.parse("2021-07-30T12:05:38Z"))
                                .withDuration(Duration.parse("PT194H47M22S"))
                                .withReason("cvydypatdoo")));
        model = BinaryData.fromObject(model).toObject(LiveEventIngestion.class);
        Assertions.assertEquals("ivpdtiir", model.streamName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-30T18:40:51Z"), model.begin());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-16T22:52:08Z"), model.end());
        Assertions.assertEquals("xoruzfgsquyfxrx", model.endReason());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-03-08T21:24:21Z"), model.ingestInterruptions().get(0).begin());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-07T09:18:25Z"), model.ingestInterruptions().get(0).end());
        Assertions.assertEquals(Duration.parse("PT185H23M6S"), model.ingestInterruptions().get(0).duration());
        Assertions.assertEquals("ezw", model.ingestInterruptions().get(0).reason());
    }
}
