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

public final class ModelVersionResourceArmPaginatedResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ModelVersionResourceArmPaginatedResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"xkyxvxevblbj\",\"value\":[{\"properties\":{\"flavors\":{},\"jobName\":\"lageuaulxun\",\"modelType\":\"jbnkpp\",\"modelUri\":\"nenlsvxeizzg\",\"isAnonymous\":false,\"isArchived\":true,\"description\":\"mffeycxcktpi\",\"properties\":{},\"tags\":{}},\"id\":\"teeammxqiekkkzd\",\"name\":\"rtkgdojbmxvavref\",\"type\":\"eesvecu\"},{\"properties\":{\"flavors\":{},\"jobName\":\"xtxsuwprtujw\",\"modelType\":\"wddji\",\"modelUri\":\"bxv\",\"isAnonymous\":true,\"isArchived\":false,\"description\":\"zeexavoxtfgle\",\"properties\":{},\"tags\":{}},\"id\":\"qbw\",\"name\":\"ypq\",\"type\":\"gsfjac\"},{\"properties\":{\"flavors\":{},\"jobName\":\"hhxud\",\"modelType\":\"vodhtn\",\"modelUri\":\"rudhzmmesckdl\",\"isAnonymous\":true,\"isArchived\":true,\"description\":\"x\",\"properties\":{},\"tags\":{}},\"id\":\"cfxwmdbox\",\"name\":\"fgsftufqob\",\"type\":\"jln\"}]}")
                .toObject(ModelVersionResourceArmPaginatedResult.class);
        Assertions.assertEquals("xkyxvxevblbj", model.nextLink());
        Assertions.assertEquals("mffeycxcktpi", model.value().get(0).properties().description());
        Assertions.assertEquals(false, model.value().get(0).properties().isAnonymous());
        Assertions.assertEquals(true, model.value().get(0).properties().isArchived());
        Assertions.assertEquals("lageuaulxun", model.value().get(0).properties().jobName());
        Assertions.assertEquals("jbnkpp", model.value().get(0).properties().modelType());
        Assertions.assertEquals("nenlsvxeizzg", model.value().get(0).properties().modelUri());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ModelVersionResourceArmPaginatedResult model =
            new ModelVersionResourceArmPaginatedResult()
                .withNextLink("xkyxvxevblbj")
                .withValue(
                    Arrays
                        .asList(
                            new ModelVersionInner()
                                .withProperties(
                                    new ModelVersionProperties()
                                        .withDescription("mffeycxcktpi")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withIsAnonymous(false)
                                        .withIsArchived(true)
                                        .withFlavors(mapOf())
                                        .withJobName("lageuaulxun")
                                        .withModelType("jbnkpp")
                                        .withModelUri("nenlsvxeizzg")),
                            new ModelVersionInner()
                                .withProperties(
                                    new ModelVersionProperties()
                                        .withDescription("zeexavoxtfgle")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withIsAnonymous(true)
                                        .withIsArchived(false)
                                        .withFlavors(mapOf())
                                        .withJobName("xtxsuwprtujw")
                                        .withModelType("wddji")
                                        .withModelUri("bxv")),
                            new ModelVersionInner()
                                .withProperties(
                                    new ModelVersionProperties()
                                        .withDescription("x")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withIsAnonymous(true)
                                        .withIsArchived(true)
                                        .withFlavors(mapOf())
                                        .withJobName("hhxud")
                                        .withModelType("vodhtn")
                                        .withModelUri("rudhzmmesckdl"))));
        model = BinaryData.fromObject(model).toObject(ModelVersionResourceArmPaginatedResult.class);
        Assertions.assertEquals("xkyxvxevblbj", model.nextLink());
        Assertions.assertEquals("mffeycxcktpi", model.value().get(0).properties().description());
        Assertions.assertEquals(false, model.value().get(0).properties().isAnonymous());
        Assertions.assertEquals(true, model.value().get(0).properties().isArchived());
        Assertions.assertEquals("lageuaulxun", model.value().get(0).properties().jobName());
        Assertions.assertEquals("jbnkpp", model.value().get(0).properties().modelType());
        Assertions.assertEquals("nenlsvxeizzg", model.value().get(0).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;
    }
}
