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

public final class UriFileDataVersionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UriFileDataVersion model =
            BinaryData
                .fromString(
                    "{\"dataType\":\"uri_file\",\"dataUri\":\"zbtz\",\"isAnonymous\":true,\"isArchived\":true,\"description\":\"pfs\",\"properties\":{\"ezacfpztga\":\"pfnocm\",\"ctgkppgkqzkcyzmf\":\"wyqejgaao\"},\"tags\":{\"hlcqvhoe\":\"dyfcix\",\"mkahpqha\":\"goiutgw\",\"mip\":\"yntacihnco\",\"i\":\"mliqmvlb\"}}")
                .toObject(UriFileDataVersion.class);
        Assertions.assertEquals("pfs", model.description());
        Assertions.assertEquals("pfnocm", model.properties().get("ezacfpztga"));
        Assertions.assertEquals("dyfcix", model.tags().get("hlcqvhoe"));
        Assertions.assertEquals(true, model.isAnonymous());
        Assertions.assertEquals(true, model.isArchived());
        Assertions.assertEquals("zbtz", model.dataUri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UriFileDataVersion model =
            new UriFileDataVersion()
                .withDescription("pfs")
                .withProperties(mapOf("ezacfpztga", "pfnocm", "ctgkppgkqzkcyzmf", "wyqejgaao"))
                .withTags(mapOf("hlcqvhoe", "dyfcix", "mkahpqha", "goiutgw", "mip", "yntacihnco", "i", "mliqmvlb"))
                .withIsAnonymous(true)
                .withIsArchived(true)
                .withDataUri("zbtz");
        model = BinaryData.fromObject(model).toObject(UriFileDataVersion.class);
        Assertions.assertEquals("pfs", model.description());
        Assertions.assertEquals("pfnocm", model.properties().get("ezacfpztga"));
        Assertions.assertEquals("dyfcix", model.tags().get("hlcqvhoe"));
        Assertions.assertEquals(true, model.isAnonymous());
        Assertions.assertEquals(true, model.isArchived());
        Assertions.assertEquals("zbtz", 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;
    }
}
