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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.fluent.models.EnvironmentVersionInner;
import com.azure.resourcemanager.machinelearning.models.AutoRebuildSetting;
import com.azure.resourcemanager.machinelearning.models.BuildContext;
import com.azure.resourcemanager.machinelearning.models.EnvironmentVersionProperties;
import com.azure.resourcemanager.machinelearning.models.InferenceContainerProperties;
import com.azure.resourcemanager.machinelearning.models.OperatingSystemType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class EnvironmentVersionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EnvironmentVersionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"autoRebuild\":\"OnBaseImageUpdate\",\"build\":{\"contextUri\":\"vizqzdwl\",\"dockerfilePath\":\"lyoupfgfbkju\"},\"condaFile\":\"yhgk\",\"environmentType\":\"Curated\",\"image\":\"sgow\",\"inferenceConfig\":{},\"osType\":\"Linux\",\"isAnonymous\":false,\"isArchived\":true,\"description\":\"bqactxtgzukx\",\"properties\":{\"tg\":\"m\",\"isavok\":\"qqxhrnxrxcpj\",\"azivjlfrqttbajl\":\"dzf\"},\"tags\":{\"dkqqfkuvscxkd\":\"nwxyiop\",\"oaz\":\"ligovibrxkpm\"}},\"id\":\"u\",\"name\":\"cbgoor\",\"type\":\"te\"}")
                .toObject(EnvironmentVersionInner.class);
        Assertions.assertEquals("bqactxtgzukx", model.properties().description());
        Assertions.assertEquals("m", model.properties().properties().get("tg"));
        Assertions.assertEquals("nwxyiop", model.properties().tags().get("dkqqfkuvscxkd"));
        Assertions.assertEquals(false, model.properties().isAnonymous());
        Assertions.assertEquals(true, model.properties().isArchived());
        Assertions.assertEquals(AutoRebuildSetting.ON_BASE_IMAGE_UPDATE, model.properties().autoRebuild());
        Assertions.assertEquals("vizqzdwl", model.properties().build().contextUri());
        Assertions.assertEquals("lyoupfgfbkju", model.properties().build().dockerfilePath());
        Assertions.assertEquals("yhgk", model.properties().condaFile());
        Assertions.assertEquals("sgow", model.properties().image());
        Assertions.assertEquals(OperatingSystemType.LINUX, model.properties().osType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EnvironmentVersionInner model =
            new EnvironmentVersionInner()
                .withProperties(
                    new EnvironmentVersionProperties()
                        .withDescription("bqactxtgzukx")
                        .withProperties(mapOf("tg", "m", "isavok", "qqxhrnxrxcpj", "azivjlfrqttbajl", "dzf"))
                        .withTags(mapOf("dkqqfkuvscxkd", "nwxyiop", "oaz", "ligovibrxkpm"))
                        .withIsAnonymous(false)
                        .withIsArchived(true)
                        .withAutoRebuild(AutoRebuildSetting.ON_BASE_IMAGE_UPDATE)
                        .withBuild(new BuildContext().withContextUri("vizqzdwl").withDockerfilePath("lyoupfgfbkju"))
                        .withCondaFile("yhgk")
                        .withImage("sgow")
                        .withInferenceConfig(new InferenceContainerProperties())
                        .withOsType(OperatingSystemType.LINUX));
        model = BinaryData.fromObject(model).toObject(EnvironmentVersionInner.class);
        Assertions.assertEquals("bqactxtgzukx", model.properties().description());
        Assertions.assertEquals("m", model.properties().properties().get("tg"));
        Assertions.assertEquals("nwxyiop", model.properties().tags().get("dkqqfkuvscxkd"));
        Assertions.assertEquals(false, model.properties().isAnonymous());
        Assertions.assertEquals(true, model.properties().isArchived());
        Assertions.assertEquals(AutoRebuildSetting.ON_BASE_IMAGE_UPDATE, model.properties().autoRebuild());
        Assertions.assertEquals("vizqzdwl", model.properties().build().contextUri());
        Assertions.assertEquals("lyoupfgfbkju", model.properties().build().dockerfilePath());
        Assertions.assertEquals("yhgk", model.properties().condaFile());
        Assertions.assertEquals("sgow", model.properties().image());
        Assertions.assertEquals(OperatingSystemType.LINUX, model.properties().osType());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
