// 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.DataVersionBaseInner;
import com.azure.resourcemanager.machinelearning.models.DataVersionBaseProperties;
import com.azure.resourcemanager.machinelearning.models.DataVersionBaseResourceArmPaginatedResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DataVersionBaseResourceArmPaginatedResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DataVersionBaseResourceArmPaginatedResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"qntcypsxjvfoimwk\",\"value\":[{\"properties\":{\"dataType\":\"DataVersionBaseProperties\",\"dataUri\":\"rcizjxvyd\",\"isAnonymous\":false,\"isArchived\":false,\"description\":\"lhvygdyftu\",\"properties\":{},\"tags\":{}},\"id\":\"nawjslbiwkojgcy\",\"name\":\"tsf\",\"type\":\"z\"},{\"properties\":{\"dataType\":\"DataVersionBaseProperties\",\"dataUri\":\"baeqphc\",\"isAnonymous\":false,\"isArchived\":false,\"description\":\"pxehuwrykqga\",\"properties\":{},\"tags\":{}},\"id\":\"iklbydvkhb\",\"name\":\"jdz\",\"type\":\"xcv\"},{\"properties\":{\"dataType\":\"DataVersionBaseProperties\",\"dataUri\":\"srhnjivo\",\"isAnonymous\":true,\"isArchived\":false,\"description\":\"qfzgemjdftul\",\"properties\":{},\"tags\":{}},\"id\":\"ucea\",\"name\":\"tmczuomejwcwwqi\",\"type\":\"knssxmojm\"}]}")
                .toObject(DataVersionBaseResourceArmPaginatedResult.class);
        Assertions.assertEquals("qntcypsxjvfoimwk", model.nextLink());
        Assertions.assertEquals("lhvygdyftu", model.value().get(0).properties().description());
        Assertions.assertEquals(false, model.value().get(0).properties().isAnonymous());
        Assertions.assertEquals(false, model.value().get(0).properties().isArchived());
        Assertions.assertEquals("rcizjxvyd", model.value().get(0).properties().dataUri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DataVersionBaseResourceArmPaginatedResult model =
            new DataVersionBaseResourceArmPaginatedResult()
                .withNextLink("qntcypsxjvfoimwk")
                .withValue(
                    Arrays
                        .asList(
                            new DataVersionBaseInner()
                                .withProperties(
                                    new DataVersionBaseProperties()
                                        .withDescription("lhvygdyftu")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withIsAnonymous(false)
                                        .withIsArchived(false)
                                        .withDataUri("rcizjxvyd")),
                            new DataVersionBaseInner()
                                .withProperties(
                                    new DataVersionBaseProperties()
                                        .withDescription("pxehuwrykqga")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withIsAnonymous(false)
                                        .withIsArchived(false)
                                        .withDataUri("baeqphc")),
                            new DataVersionBaseInner()
                                .withProperties(
                                    new DataVersionBaseProperties()
                                        .withDescription("qfzgemjdftul")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withIsAnonymous(true)
                                        .withIsArchived(false)
                                        .withDataUri("srhnjivo"))));
        model = BinaryData.fromObject(model).toObject(DataVersionBaseResourceArmPaginatedResult.class);
        Assertions.assertEquals("qntcypsxjvfoimwk", model.nextLink());
        Assertions.assertEquals("lhvygdyftu", model.value().get(0).properties().description());
        Assertions.assertEquals(false, model.value().get(0).properties().isAnonymous());
        Assertions.assertEquals(false, model.value().get(0).properties().isArchived());
        Assertions.assertEquals("rcizjxvyd", model.value().get(0).properties().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;
    }
}
