// 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.JobExecutionInner;
import com.azure.resourcemanager.appcontainers.models.JobExecutionContainer;
import com.azure.resourcemanager.appcontainers.models.JobExecutionTemplate;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class JobExecutionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JobExecutionInner model =
            BinaryData
                .fromString(
                    "{\"name\":\"ieuzaofjchvcyyy\",\"id\":\"gdotcubiipuipwo\",\"type\":\"nmacj\",\"status\":\"Failed\",\"startTime\":\"2021-11-17T10:08:40Z\",\"endTime\":\"2021-10-27T20:39:18Z\",\"template\":{\"containers\":[{\"image\":\"m\",\"name\":\"vfgmblrrilby\",\"command\":[],\"args\":[],\"env\":[]},{\"image\":\"ccwr\",\"name\":\"scjfnyns\",\"command\":[],\"args\":[],\"env\":[]}],\"initContainers\":[{\"image\":\"oqytibyowbblgy\",\"name\":\"utp\",\"command\":[],\"args\":[],\"env\":[]},{\"image\":\"ismsksbpimlqolj\",\"name\":\"cgxxlxs\",\"command\":[],\"args\":[],\"env\":[]}]}}")
                .toObject(JobExecutionInner.class);
        Assertions.assertEquals("ieuzaofjchvcyyy", model.name());
        Assertions.assertEquals("gdotcubiipuipwo", model.id());
        Assertions.assertEquals("nmacj", model.type());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-17T10:08:40Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-27T20:39:18Z"), model.endTime());
        Assertions.assertEquals("m", model.template().containers().get(0).image());
        Assertions.assertEquals("vfgmblrrilby", model.template().containers().get(0).name());
        Assertions.assertEquals("oqytibyowbblgy", model.template().initContainers().get(0).image());
        Assertions.assertEquals("utp", model.template().initContainers().get(0).name());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JobExecutionInner model =
            new JobExecutionInner()
                .withName("ieuzaofjchvcyyy")
                .withId("gdotcubiipuipwo")
                .withType("nmacj")
                .withStartTime(OffsetDateTime.parse("2021-11-17T10:08:40Z"))
                .withEndTime(OffsetDateTime.parse("2021-10-27T20:39:18Z"))
                .withTemplate(
                    new JobExecutionTemplate()
                        .withContainers(
                            Arrays
                                .asList(
                                    new JobExecutionContainer()
                                        .withImage("m")
                                        .withName("vfgmblrrilby")
                                        .withCommand(Arrays.asList())
                                        .withArgs(Arrays.asList())
                                        .withEnv(Arrays.asList()),
                                    new JobExecutionContainer()
                                        .withImage("ccwr")
                                        .withName("scjfnyns")
                                        .withCommand(Arrays.asList())
                                        .withArgs(Arrays.asList())
                                        .withEnv(Arrays.asList())))
                        .withInitContainers(
                            Arrays
                                .asList(
                                    new JobExecutionContainer()
                                        .withImage("oqytibyowbblgy")
                                        .withName("utp")
                                        .withCommand(Arrays.asList())
                                        .withArgs(Arrays.asList())
                                        .withEnv(Arrays.asList()),
                                    new JobExecutionContainer()
                                        .withImage("ismsksbpimlqolj")
                                        .withName("cgxxlxs")
                                        .withCommand(Arrays.asList())
                                        .withArgs(Arrays.asList())
                                        .withEnv(Arrays.asList()))));
        model = BinaryData.fromObject(model).toObject(JobExecutionInner.class);
        Assertions.assertEquals("ieuzaofjchvcyyy", model.name());
        Assertions.assertEquals("gdotcubiipuipwo", model.id());
        Assertions.assertEquals("nmacj", model.type());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-17T10:08:40Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-27T20:39:18Z"), model.endTime());
        Assertions.assertEquals("m", model.template().containers().get(0).image());
        Assertions.assertEquals("vfgmblrrilby", model.template().containers().get(0).name());
        Assertions.assertEquals("oqytibyowbblgy", model.template().initContainers().get(0).image());
        Assertions.assertEquals("utp", model.template().initContainers().get(0).name());
    }
}
