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

public final class JobExecutionTemplateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JobExecutionTemplate model =
            BinaryData
                .fromString(
                    "{\"containers\":[{\"image\":\"auutpwoqhihe\",\"name\":\"g\",\"command\":[\"nfqn\",\"cypsxjv\",\"oimwkslirc\"],\"args\":[\"xvydfceacvlhvygd\"],\"env\":[],\"resources\":{\"cpu\":64.9648919138758,\"memory\":\"nawjslbiwkojgcy\",\"ephemeralStorage\":\"sfmznbaeqphc\"}},{\"image\":\"nrnrp\",\"name\":\"huwrykqgaifm\",\"command\":[\"lb\",\"dvk\"],\"args\":[\"jdz\"],\"env\":[],\"resources\":{\"cpu\":47.61854442423811,\"memory\":\"njivolvtnovq\",\"ephemeralStorage\":\"gemjdftuljltdu\"}}],\"initContainers\":[{\"image\":\"tmczuomejwcwwqi\",\"name\":\"nssxmojmsvpk\",\"command\":[\"vk\",\"cfzq\"],\"args\":[\"x\",\"tczheydbsdshmkx\"],\"env\":[],\"resources\":{\"cpu\":47.19244293398387,\"memory\":\"uripltfnhtba\",\"ephemeralStorage\":\"gx\"}},{\"image\":\"rc\",\"name\":\"yklyhpluodpvruud\",\"command\":[\"ibthostgktstvd\"],\"args\":[\"lzedqbcvhzlhplo\",\"qkdlw\",\"qfbumlkxtrqjf\"],\"env\":[],\"resources\":{\"cpu\":43.959664818997865,\"memory\":\"w\",\"ephemeralStorage\":\"wsrt\"}}]}")
                .toObject(JobExecutionTemplate.class);
        Assertions.assertEquals("auutpwoqhihe", model.containers().get(0).image());
        Assertions.assertEquals("g", model.containers().get(0).name());
        Assertions.assertEquals("nfqn", model.containers().get(0).command().get(0));
        Assertions.assertEquals("xvydfceacvlhvygd", model.containers().get(0).args().get(0));
        Assertions.assertEquals(64.9648919138758D, model.containers().get(0).resources().cpu());
        Assertions.assertEquals("nawjslbiwkojgcy", model.containers().get(0).resources().memory());
        Assertions.assertEquals("tmczuomejwcwwqi", model.initContainers().get(0).image());
        Assertions.assertEquals("nssxmojmsvpk", model.initContainers().get(0).name());
        Assertions.assertEquals("vk", model.initContainers().get(0).command().get(0));
        Assertions.assertEquals("x", model.initContainers().get(0).args().get(0));
        Assertions.assertEquals(47.19244293398387D, model.initContainers().get(0).resources().cpu());
        Assertions.assertEquals("uripltfnhtba", model.initContainers().get(0).resources().memory());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JobExecutionTemplate model =
            new JobExecutionTemplate()
                .withContainers(
                    Arrays
                        .asList(
                            new JobExecutionContainer()
                                .withImage("auutpwoqhihe")
                                .withName("g")
                                .withCommand(Arrays.asList("nfqn", "cypsxjv", "oimwkslirc"))
                                .withArgs(Arrays.asList("xvydfceacvlhvygd"))
                                .withEnv(Arrays.asList())
                                .withResources(
                                    new ContainerResources().withCpu(64.9648919138758D).withMemory("nawjslbiwkojgcy")),
                            new JobExecutionContainer()
                                .withImage("nrnrp")
                                .withName("huwrykqgaifm")
                                .withCommand(Arrays.asList("lb", "dvk"))
                                .withArgs(Arrays.asList("jdz"))
                                .withEnv(Arrays.asList())
                                .withResources(
                                    new ContainerResources().withCpu(47.61854442423811D).withMemory("njivolvtnovq"))))
                .withInitContainers(
                    Arrays
                        .asList(
                            new JobExecutionContainer()
                                .withImage("tmczuomejwcwwqi")
                                .withName("nssxmojmsvpk")
                                .withCommand(Arrays.asList("vk", "cfzq"))
                                .withArgs(Arrays.asList("x", "tczheydbsdshmkx"))
                                .withEnv(Arrays.asList())
                                .withResources(
                                    new ContainerResources().withCpu(47.19244293398387D).withMemory("uripltfnhtba")),
                            new JobExecutionContainer()
                                .withImage("rc")
                                .withName("yklyhpluodpvruud")
                                .withCommand(Arrays.asList("ibthostgktstvd"))
                                .withArgs(Arrays.asList("lzedqbcvhzlhplo", "qkdlw", "qfbumlkxtrqjf"))
                                .withEnv(Arrays.asList())
                                .withResources(new ContainerResources().withCpu(43.959664818997865D).withMemory("w"))));
        model = BinaryData.fromObject(model).toObject(JobExecutionTemplate.class);
        Assertions.assertEquals("auutpwoqhihe", model.containers().get(0).image());
        Assertions.assertEquals("g", model.containers().get(0).name());
        Assertions.assertEquals("nfqn", model.containers().get(0).command().get(0));
        Assertions.assertEquals("xvydfceacvlhvygd", model.containers().get(0).args().get(0));
        Assertions.assertEquals(64.9648919138758D, model.containers().get(0).resources().cpu());
        Assertions.assertEquals("nawjslbiwkojgcy", model.containers().get(0).resources().memory());
        Assertions.assertEquals("tmczuomejwcwwqi", model.initContainers().get(0).image());
        Assertions.assertEquals("nssxmojmsvpk", model.initContainers().get(0).name());
        Assertions.assertEquals("vk", model.initContainers().get(0).command().get(0));
        Assertions.assertEquals("x", model.initContainers().get(0).args().get(0));
        Assertions.assertEquals(47.19244293398387D, model.initContainers().get(0).resources().cpu());
        Assertions.assertEquals("uripltfnhtba", model.initContainers().get(0).resources().memory());
    }
}
