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

package com.azure.resourcemanager.hdinsight.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hdinsight.models.ClientGroupInfo;
import com.azure.resourcemanager.hdinsight.models.KafkaRestProperties;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class KafkaRestPropertiesTests {
    @Test
    public void testDeserialize() {
        KafkaRestProperties model =
            BinaryData
                .fromString(
                    "{\"clientGroupInfo\":{\"groupName\":\"ahuxinpm\",\"groupId\":\"jaqwixjsp\"},\"configurationOverride\":{\"wmfdatscmdvpjhul\":\"vcputegj\",\"odjpslwejd\":\"uuvmkjozkrwfnd\",\"cctazakljlahbc\":\"vwryoqpso\",\"gexpaojakhmsbz\":\"yffdfdos\"}}")
                .toObject(KafkaRestProperties.class);
        Assertions.assertEquals("ahuxinpm", model.clientGroupInfo().groupName());
        Assertions.assertEquals("jaqwixjsp", model.clientGroupInfo().groupId());
        Assertions.assertEquals("vcputegj", model.configurationOverride().get("wmfdatscmdvpjhul"));
    }

    @Test
    public void testSerialize() {
        KafkaRestProperties model =
            new KafkaRestProperties()
                .withClientGroupInfo(new ClientGroupInfo().withGroupName("ahuxinpm").withGroupId("jaqwixjsp"))
                .withConfigurationOverride(
                    mapOf(
                        "wmfdatscmdvpjhul",
                        "vcputegj",
                        "odjpslwejd",
                        "uuvmkjozkrwfnd",
                        "cctazakljlahbc",
                        "vwryoqpso",
                        "gexpaojakhmsbz",
                        "yffdfdos"));
        model = BinaryData.fromObject(model).toObject(KafkaRestProperties.class);
        Assertions.assertEquals("ahuxinpm", model.clientGroupInfo().groupName());
        Assertions.assertEquals("jaqwixjsp", model.clientGroupInfo().groupId());
        Assertions.assertEquals("vcputegj", model.configurationOverride().get("wmfdatscmdvpjhul"));
    }

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