// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.synapse.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.synapse.fluent.models.IntegrationRuntimeResourceInner;
import com.azure.resourcemanager.synapse.models.IntegrationRuntime;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeListResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationRuntimeListResponseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationRuntimeListResponse model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"type\":\"IntegrationRuntime\",\"description\":\"zytqjtwhauunfpr\",\"\":{}},\"etag\":\"etlxsm\",\"id\":\"pddouifamowaziyn\",\"name\":\"nlqwzdvpiwhx\",\"type\":\"szdtmaajquh\"},{\"properties\":{\"type\":\"IntegrationRuntime\",\"description\":\"ylr\",\"\":{}},\"etag\":\"ty\",\"id\":\"jbmzyospspsh\",\"name\":\"kfkyjp\",\"type\":\"sp\"},{\"properties\":{\"type\":\"IntegrationRuntime\",\"description\":\"ssdfpp\",\"\":{}},\"etag\":\"tieyujtvczkcny\",\"id\":\"rxmunjdxvgln\",\"name\":\"vxlx\",\"type\":\"aglqivbgkcvkh\"}],\"nextLink\":\"vuqd\"}")
                .toObject(IntegrationRuntimeListResponse.class);
        Assertions.assertEquals("zytqjtwhauunfpr", model.value().get(0).properties().description());
        Assertions.assertEquals("vuqd", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationRuntimeListResponse model =
            new IntegrationRuntimeListResponse()
                .withValue(
                    Arrays
                        .asList(
                            new IntegrationRuntimeResourceInner()
                                .withProperties(
                                    new IntegrationRuntime()
                                        .withDescription("zytqjtwhauunfpr")
                                        .withAdditionalProperties(mapOf("type", "IntegrationRuntime"))),
                            new IntegrationRuntimeResourceInner()
                                .withProperties(
                                    new IntegrationRuntime()
                                        .withDescription("ylr")
                                        .withAdditionalProperties(mapOf("type", "IntegrationRuntime"))),
                            new IntegrationRuntimeResourceInner()
                                .withProperties(
                                    new IntegrationRuntime()
                                        .withDescription("ssdfpp")
                                        .withAdditionalProperties(mapOf("type", "IntegrationRuntime")))))
                .withNextLink("vuqd");
        model = BinaryData.fromObject(model).toObject(IntegrationRuntimeListResponse.class);
        Assertions.assertEquals("zytqjtwhauunfpr", model.value().get(0).properties().description());
        Assertions.assertEquals("vuqd", model.nextLink());
    }

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