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

public final class MLTableDataTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MLTableData model =
            BinaryData
                .fromString(
                    "{\"dataType\":\"mltable\",\"referencedUris\":[\"uavt\",\"tbkewkqynspg\"],\"dataUri\":\"voffbkkwvdxae\",\"isAnonymous\":false,\"isArchived\":false,\"description\":\"rlj\",\"properties\":{\"lpbcjtrpz\":\"zbnobr\",\"qelwgdhuruzytza\":\"yudivbxnhsqeaeo\",\"mpinmzvfkneerzzt\":\"ogatmoljiy\",\"bnhrxlelfjhkeiz\":\"knsjulugd\"},\"tags\":{\"wjekptycaydbj\":\"htdm\"}}")
                .toObject(MLTableData.class);
        Assertions.assertEquals("rlj", model.description());
        Assertions.assertEquals("zbnobr", model.properties().get("lpbcjtrpz"));
        Assertions.assertEquals("htdm", model.tags().get("wjekptycaydbj"));
        Assertions.assertEquals(false, model.isAnonymous());
        Assertions.assertEquals(false, model.isArchived());
        Assertions.assertEquals("voffbkkwvdxae", model.dataUri());
        Assertions.assertEquals("uavt", model.referencedUris().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MLTableData model =
            new MLTableData()
                .withDescription("rlj")
                .withProperties(
                    mapOf(
                        "lpbcjtrpz",
                        "zbnobr",
                        "qelwgdhuruzytza",
                        "yudivbxnhsqeaeo",
                        "mpinmzvfkneerzzt",
                        "ogatmoljiy",
                        "bnhrxlelfjhkeiz",
                        "knsjulugd"))
                .withTags(mapOf("wjekptycaydbj", "htdm"))
                .withIsAnonymous(false)
                .withIsArchived(false)
                .withDataUri("voffbkkwvdxae")
                .withReferencedUris(Arrays.asList("uavt", "tbkewkqynspg"));
        model = BinaryData.fromObject(model).toObject(MLTableData.class);
        Assertions.assertEquals("rlj", model.description());
        Assertions.assertEquals("zbnobr", model.properties().get("lpbcjtrpz"));
        Assertions.assertEquals("htdm", model.tags().get("wjekptycaydbj"));
        Assertions.assertEquals(false, model.isAnonymous());
        Assertions.assertEquals(false, model.isArchived());
        Assertions.assertEquals("voffbkkwvdxae", model.dataUri());
        Assertions.assertEquals("uavt", model.referencedUris().get(0));
    }

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