// 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.models.UriFolderDataVersion;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class UriFolderDataVersionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UriFolderDataVersion model =
            BinaryData
                .fromString(
                    "{\"dataType\":\"uri_folder\",\"dataUri\":\"mpyzgleo\",\"isAnonymous\":true,\"isArchived\":false,\"description\":\"wwzvdaj\",\"properties\":{\"fmaciqgjjrlhiq\":\"n\",\"jtt\":\"wixvtbouguxtndop\",\"bkixvvlwyn\":\"asualapdlndbea\",\"qvzfj\":\"bb\"},\"tags\":{\"mphfkyezolgjzm\":\"ugzfeuzjl\"}}")
                .toObject(UriFolderDataVersion.class);
        Assertions.assertEquals("wwzvdaj", model.description());
        Assertions.assertEquals("n", model.properties().get("fmaciqgjjrlhiq"));
        Assertions.assertEquals("ugzfeuzjl", model.tags().get("mphfkyezolgjzm"));
        Assertions.assertEquals(true, model.isAnonymous());
        Assertions.assertEquals(false, model.isArchived());
        Assertions.assertEquals("mpyzgleo", model.dataUri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UriFolderDataVersion model =
            new UriFolderDataVersion()
                .withDescription("wwzvdaj")
                .withProperties(
                    mapOf(
                        "fmaciqgjjrlhiq",
                        "n",
                        "jtt",
                        "wixvtbouguxtndop",
                        "bkixvvlwyn",
                        "asualapdlndbea",
                        "qvzfj",
                        "bb"))
                .withTags(mapOf("mphfkyezolgjzm", "ugzfeuzjl"))
                .withIsAnonymous(true)
                .withIsArchived(false)
                .withDataUri("mpyzgleo");
        model = BinaryData.fromObject(model).toObject(UriFolderDataVersion.class);
        Assertions.assertEquals("wwzvdaj", model.description());
        Assertions.assertEquals("n", model.properties().get("fmaciqgjjrlhiq"));
        Assertions.assertEquals("ugzfeuzjl", model.tags().get("mphfkyezolgjzm"));
        Assertions.assertEquals(true, model.isAnonymous());
        Assertions.assertEquals(false, model.isArchived());
        Assertions.assertEquals("mpyzgleo", model.dataUri());
    }

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