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

package com.azure.resourcemanager.appcontainers.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.appcontainers.fluent.models.ContainerAppJobExecutionsInner;
import com.azure.resourcemanager.appcontainers.fluent.models.JobExecutionInner;
import com.azure.resourcemanager.appcontainers.models.JobExecutionTemplate;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ContainerAppJobExecutionsInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ContainerAppJobExecutionsInner model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"name\":\"uo\",\"id\":\"inyflnorwmduvwp\",\"type\":\"vxwmygd\",\"status\":\"Failed\",\"startTime\":\"2021-01-04T00:18:57Z\",\"endTime\":\"2021-06-03T06:53:08Z\",\"template\":{\"containers\":[],\"initContainers\":[]}},{\"name\":\"pnnbjc\",\"id\":\"gibbdaxc\",\"type\":\"fozauorsuk\",\"status\":\"Failed\",\"startTime\":\"2021-09-20T10:27:45Z\",\"endTime\":\"2021-03-26T17:33:57Z\",\"template\":{\"containers\":[],\"initContainers\":[]}},{\"name\":\"uuepzlrphwzsoldw\",\"id\":\"uqdunvmnnrwrbi\",\"type\":\"ktalywjhhgdnhxms\",\"status\":\"Succeeded\",\"startTime\":\"2021-07-20T04:17:10Z\",\"endTime\":\"2021-04-28T21:19:50Z\",\"template\":{\"containers\":[],\"initContainers\":[]}}],\"nextLink\":\"dufiq\"}")
                .toObject(ContainerAppJobExecutionsInner.class);
        Assertions.assertEquals("uo", model.value().get(0).name());
        Assertions.assertEquals("inyflnorwmduvwp", model.value().get(0).id());
        Assertions.assertEquals("vxwmygd", model.value().get(0).type());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-04T00:18:57Z"), model.value().get(0).startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-03T06:53:08Z"), model.value().get(0).endTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ContainerAppJobExecutionsInner model =
            new ContainerAppJobExecutionsInner()
                .withValue(
                    Arrays
                        .asList(
                            new JobExecutionInner()
                                .withName("uo")
                                .withId("inyflnorwmduvwp")
                                .withType("vxwmygd")
                                .withStartTime(OffsetDateTime.parse("2021-01-04T00:18:57Z"))
                                .withEndTime(OffsetDateTime.parse("2021-06-03T06:53:08Z"))
                                .withTemplate(
                                    new JobExecutionTemplate()
                                        .withContainers(Arrays.asList())
                                        .withInitContainers(Arrays.asList())),
                            new JobExecutionInner()
                                .withName("pnnbjc")
                                .withId("gibbdaxc")
                                .withType("fozauorsuk")
                                .withStartTime(OffsetDateTime.parse("2021-09-20T10:27:45Z"))
                                .withEndTime(OffsetDateTime.parse("2021-03-26T17:33:57Z"))
                                .withTemplate(
                                    new JobExecutionTemplate()
                                        .withContainers(Arrays.asList())
                                        .withInitContainers(Arrays.asList())),
                            new JobExecutionInner()
                                .withName("uuepzlrphwzsoldw")
                                .withId("uqdunvmnnrwrbi")
                                .withType("ktalywjhhgdnhxms")
                                .withStartTime(OffsetDateTime.parse("2021-07-20T04:17:10Z"))
                                .withEndTime(OffsetDateTime.parse("2021-04-28T21:19:50Z"))
                                .withTemplate(
                                    new JobExecutionTemplate()
                                        .withContainers(Arrays.asList())
                                        .withInitContainers(Arrays.asList()))));
        model = BinaryData.fromObject(model).toObject(ContainerAppJobExecutionsInner.class);
        Assertions.assertEquals("uo", model.value().get(0).name());
        Assertions.assertEquals("inyflnorwmduvwp", model.value().get(0).id());
        Assertions.assertEquals("vxwmygd", model.value().get(0).type());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-04T00:18:57Z"), model.value().get(0).startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-03T06:53:08Z"), model.value().get(0).endTime());
    }
}
