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

package com.azure.resourcemanager.logic.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.logic.fluent.models.IntegrationServiceEnvironmentManagedApiInner;
import com.azure.resourcemanager.logic.models.IntegrationServiceEnvironmentManagedApiListResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationServiceEnvironmentManagedApiListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationServiceEnvironmentManagedApiListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"name\":\"dk\",\"connectionParameters\":{},\"runtimeUrls\":[],\"capabilities\":[],\"apiDefinitionUrl\":\"sdbccxjmonfdgnwn\",\"provisioningState\":\"Canceled\",\"category\":\"NotSpecified\"},\"location\":\"ltv\",\"tags\":{\"svflyhbxcudch\":\"ctzenkeifzzhmkd\",\"lvizb\":\"gsrboldforobw\",\"dxe\":\"hfovvacqpbtu\"},\"id\":\"zab\",\"name\":\"elawumu\",\"type\":\"slzkwrrwoycqu\"},{\"properties\":{\"name\":\"ahnomdrkywu\",\"connectionParameters\":{},\"runtimeUrls\":[],\"capabilities\":[],\"apiDefinitionUrl\":\"tlwexxwlalniexz\",\"provisioningState\":\"Moving\",\"category\":\"Enterprise\"},\"location\":\"q\",\"tags\":{\"lixqnrkcxkjibn\":\"bwwpgdakchzy\"},\"id\":\"mysu\",\"name\":\"swqrntvlwijp\",\"type\":\"ttexoqqpwcyyufmh\"},{\"properties\":{\"name\":\"uwm\",\"connectionParameters\":{},\"runtimeUrls\":[],\"capabilities\":[],\"apiDefinitionUrl\":\"lctddunqndyfpch\",\"provisioningState\":\"Moving\",\"category\":\"Premium\"},\"location\":\"cgegydcwbo\",\"tags\":{\"raiouaubrjtl\":\"mvqqolih\"},\"id\":\"qxfuojrngif\",\"name\":\"rzpasccbiuimzdly\",\"type\":\"dfqwmkyoq\"},{\"properties\":{\"name\":\"ruzslzoj\",\"connectionParameters\":{},\"runtimeUrls\":[],\"capabilities\":[],\"apiDefinitionUrl\":\"otngfdgu\",\"provisioningState\":\"Accepted\",\"category\":\"Premium\"},\"location\":\"rkyui\",\"tags\":{\"yhsgz\":\"snmfpphojeevy\",\"qgleohibetnluank\":\"czbgomfgbeg\"},\"id\":\"rfxeeebtij\",\"name\":\"acvbmqz\",\"type\":\"qqxlajr\"}],\"nextLink\":\"xaceve\"}")
                .toObject(IntegrationServiceEnvironmentManagedApiListResult.class);
        Assertions.assertEquals("ltv", model.value().get(0).location());
        Assertions.assertEquals("ctzenkeifzzhmkd", model.value().get(0).tags().get("svflyhbxcudch"));
        Assertions.assertEquals("xaceve", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationServiceEnvironmentManagedApiListResult model =
            new IntegrationServiceEnvironmentManagedApiListResult()
                .withValue(
                    Arrays
                        .asList(
                            new IntegrationServiceEnvironmentManagedApiInner()
                                .withLocation("ltv")
                                .withTags(
                                    mapOf(
                                        "svflyhbxcudch",
                                        "ctzenkeifzzhmkd",
                                        "lvizb",
                                        "gsrboldforobw",
                                        "dxe",
                                        "hfovvacqpbtu")),
                            new IntegrationServiceEnvironmentManagedApiInner()
                                .withLocation("q")
                                .withTags(mapOf("lixqnrkcxkjibn", "bwwpgdakchzy")),
                            new IntegrationServiceEnvironmentManagedApiInner()
                                .withLocation("cgegydcwbo")
                                .withTags(mapOf("raiouaubrjtl", "mvqqolih")),
                            new IntegrationServiceEnvironmentManagedApiInner()
                                .withLocation("rkyui")
                                .withTags(mapOf("yhsgz", "snmfpphojeevy", "qgleohibetnluank", "czbgomfgbeg"))))
                .withNextLink("xaceve");
        model = BinaryData.fromObject(model).toObject(IntegrationServiceEnvironmentManagedApiListResult.class);
        Assertions.assertEquals("ltv", model.value().get(0).location());
        Assertions.assertEquals("ctzenkeifzzhmkd", model.value().get(0).tags().get("svflyhbxcudch"));
        Assertions.assertEquals("xaceve", 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;
    }
}
