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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.models.ControlPlaneNodePatchConfiguration;
import com.azure.resourcemanager.networkcloud.models.KubernetesClusterPatchParameters;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class KubernetesClusterPatchParametersTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        KubernetesClusterPatchParameters model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"controlPlaneNodeConfiguration\":{\"count\":2920344548186760497},\"kubernetesVersion\":\"gfgrwsdp\"},\"tags\":{\"vzbglbyvi\":\"t\"}}")
                .toObject(KubernetesClusterPatchParameters.class);
        Assertions.assertEquals("t", model.tags().get("vzbglbyvi"));
        Assertions.assertEquals(2920344548186760497L, model.controlPlaneNodeConfiguration().count());
        Assertions.assertEquals("gfgrwsdp", model.kubernetesVersion());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        KubernetesClusterPatchParameters model =
            new KubernetesClusterPatchParameters()
                .withTags(mapOf("vzbglbyvi", "t"))
                .withControlPlaneNodeConfiguration(
                    new ControlPlaneNodePatchConfiguration().withCount(2920344548186760497L))
                .withKubernetesVersion("gfgrwsdp");
        model = BinaryData.fromObject(model).toObject(KubernetesClusterPatchParameters.class);
        Assertions.assertEquals("t", model.tags().get("vzbglbyvi"));
        Assertions.assertEquals(2920344548186760497L, model.controlPlaneNodeConfiguration().count());
        Assertions.assertEquals("gfgrwsdp", model.kubernetesVersion());
    }

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