// 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.ModelVersionInner;
import com.azure.resourcemanager.machinelearning.models.FlavorData;
import com.azure.resourcemanager.machinelearning.models.ModelVersionProperties;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ModelVersionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ModelVersionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"flavors\":{\"ckknhxkizvy\":{\"data\":{}},\"rzvul\":{\"data\":{}},\"aaeranokqgukk\":{\"data\":{}},\"nvbroylaxx\":{\"data\":{}}},\"jobName\":\"cdisd\",\"modelType\":\"fj\",\"modelUri\":\"svgjrwhryvy\",\"isAnonymous\":false,\"isArchived\":false,\"description\":\"xgccknfnw\",\"properties\":{\"dxihc\":\"mvpdvjdhttzaef\",\"bg\":\"rphkmcrjdqnsdfz\",\"euutlwxezwzh\":\"gkylkdghr\"},\"tags\":{\"ehgpp\":\"bwnhhtql\",\"csheafidltugsr\":\"pifhpfeoajvgcxtx\"}},\"id\":\"mks\",\"name\":\"jhoiftxfkfweg\",\"type\":\"rhptilluc\"}")
                .toObject(ModelVersionInner.class);
        Assertions.assertEquals("xgccknfnw", model.properties().description());
        Assertions.assertEquals("mvpdvjdhttzaef", model.properties().properties().get("dxihc"));
        Assertions.assertEquals("bwnhhtql", model.properties().tags().get("ehgpp"));
        Assertions.assertEquals(false, model.properties().isAnonymous());
        Assertions.assertEquals(false, model.properties().isArchived());
        Assertions.assertEquals("cdisd", model.properties().jobName());
        Assertions.assertEquals("fj", model.properties().modelType());
        Assertions.assertEquals("svgjrwhryvy", model.properties().modelUri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ModelVersionInner model =
            new ModelVersionInner()
                .withProperties(
                    new ModelVersionProperties()
                        .withDescription("xgccknfnw")
                        .withProperties(
                            mapOf("dxihc", "mvpdvjdhttzaef", "bg", "rphkmcrjdqnsdfz", "euutlwxezwzh", "gkylkdghr"))
                        .withTags(mapOf("ehgpp", "bwnhhtql", "csheafidltugsr", "pifhpfeoajvgcxtx"))
                        .withIsAnonymous(false)
                        .withIsArchived(false)
                        .withFlavors(
                            mapOf(
                                "ckknhxkizvy",
                                new FlavorData().withData(mapOf()),
                                "rzvul",
                                new FlavorData().withData(mapOf()),
                                "aaeranokqgukk",
                                new FlavorData().withData(mapOf()),
                                "nvbroylaxx",
                                new FlavorData().withData(mapOf())))
                        .withJobName("cdisd")
                        .withModelType("fj")
                        .withModelUri("svgjrwhryvy"));
        model = BinaryData.fromObject(model).toObject(ModelVersionInner.class);
        Assertions.assertEquals("xgccknfnw", model.properties().description());
        Assertions.assertEquals("mvpdvjdhttzaef", model.properties().properties().get("dxihc"));
        Assertions.assertEquals("bwnhhtql", model.properties().tags().get("ehgpp"));
        Assertions.assertEquals(false, model.properties().isAnonymous());
        Assertions.assertEquals(false, model.properties().isArchived());
        Assertions.assertEquals("cdisd", model.properties().jobName());
        Assertions.assertEquals("fj", model.properties().modelType());
        Assertions.assertEquals("svgjrwhryvy", model.properties().modelUri());
    }

    @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;
    }
}
