// 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.models.SwaggerCustomDynamicTreeCommand;
import com.azure.resourcemanager.logic.models.SwaggerCustomDynamicTreeParameter;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SwaggerCustomDynamicTreeCommandTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SwaggerCustomDynamicTreeCommand model =
            BinaryData
                .fromString(
                    "{\"operationId\":\"xlzgsjgkzzl\",\"itemsPath\":\"fhbzffovwmbjlzq\",\"itemValuePath\":\"zpgvdwnapfd\",\"itemTitlePath\":\"owftptnuwjtks\",\"itemFullTitlePath\":\"gcgqyhleseyqrhvy\",\"itemIsParent\":\"dotjvdk\",\"selectableFilter\":\"swskuk\",\"parameters\":{\"aqkue\":{\"selectedItemValuePath\":\"bvwispkx\",\"value\":\"datatxfkndlqvt\",\"parameterReference\":\"nvgmmbugtywa\",\"required\":false},\"vjmvqmtdwckygr\":{\"selectedItemValuePath\":\"groeshoyg\",\"value\":\"databyfqxkfaoy\",\"parameterReference\":\"h\",\"required\":false}}}")
                .toObject(SwaggerCustomDynamicTreeCommand.class);
        Assertions.assertEquals("xlzgsjgkzzl", model.operationId());
        Assertions.assertEquals("fhbzffovwmbjlzq", model.itemsPath());
        Assertions.assertEquals("zpgvdwnapfd", model.itemValuePath());
        Assertions.assertEquals("owftptnuwjtks", model.itemTitlePath());
        Assertions.assertEquals("gcgqyhleseyqrhvy", model.itemFullTitlePath());
        Assertions.assertEquals("dotjvdk", model.itemIsParent());
        Assertions.assertEquals("swskuk", model.selectableFilter());
        Assertions.assertEquals("bvwispkx", model.parameters().get("aqkue").selectedItemValuePath());
        Assertions.assertEquals("nvgmmbugtywa", model.parameters().get("aqkue").parameterReference());
        Assertions.assertEquals(false, model.parameters().get("aqkue").required());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SwaggerCustomDynamicTreeCommand model =
            new SwaggerCustomDynamicTreeCommand()
                .withOperationId("xlzgsjgkzzl")
                .withItemsPath("fhbzffovwmbjlzq")
                .withItemValuePath("zpgvdwnapfd")
                .withItemTitlePath("owftptnuwjtks")
                .withItemFullTitlePath("gcgqyhleseyqrhvy")
                .withItemIsParent("dotjvdk")
                .withSelectableFilter("swskuk")
                .withParameters(
                    mapOf(
                        "aqkue",
                        new SwaggerCustomDynamicTreeParameter()
                            .withSelectedItemValuePath("bvwispkx")
                            .withValue("datatxfkndlqvt")
                            .withParameterReference("nvgmmbugtywa")
                            .withRequired(false),
                        "vjmvqmtdwckygr",
                        new SwaggerCustomDynamicTreeParameter()
                            .withSelectedItemValuePath("groeshoyg")
                            .withValue("databyfqxkfaoy")
                            .withParameterReference("h")
                            .withRequired(false)));
        model = BinaryData.fromObject(model).toObject(SwaggerCustomDynamicTreeCommand.class);
        Assertions.assertEquals("xlzgsjgkzzl", model.operationId());
        Assertions.assertEquals("fhbzffovwmbjlzq", model.itemsPath());
        Assertions.assertEquals("zpgvdwnapfd", model.itemValuePath());
        Assertions.assertEquals("owftptnuwjtks", model.itemTitlePath());
        Assertions.assertEquals("gcgqyhleseyqrhvy", model.itemFullTitlePath());
        Assertions.assertEquals("dotjvdk", model.itemIsParent());
        Assertions.assertEquals("swskuk", model.selectableFilter());
        Assertions.assertEquals("bvwispkx", model.parameters().get("aqkue").selectedItemValuePath());
        Assertions.assertEquals("nvgmmbugtywa", model.parameters().get("aqkue").parameterReference());
        Assertions.assertEquals(false, model.parameters().get("aqkue").required());
    }

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