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

package com.azure.resourcemanager.dataprotection.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.dataprotection.models.DppWorkerRequest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DppWorkerRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DppWorkerRequest model =
            BinaryData
                .fromString(
                    "{\"subscriptionId\":\"etaebu\",\"uri\":\"vdmovsmzlxwabm\",\"headers\":{\"btndo\":[\"kif\",\"vtpuqujmqlgk\"],\"ed\":[\"n\",\"bjcntujitc\"]},\"supportedGroupVersions\":[\"waezkojvd\"],\"cultureInfo\":\"zfoqouicybxar\",\"parameters\":{\"x\":\"zuf\",\"khazxkhnzbonlwn\":\"iqopidoamciod\",\"szzcmrvexztv\":\"oegokdwbwh\",\"gsfraoyzkoow\":\"t\"},\"httpMethod\":\"mnguxawqaldsyu\"}")
                .toObject(DppWorkerRequest.class);
        Assertions.assertEquals("etaebu", model.subscriptionId());
        Assertions.assertEquals("vdmovsmzlxwabm", model.uri());
        Assertions.assertEquals("kif", model.headers().get("btndo").get(0));
        Assertions.assertEquals("waezkojvd", model.supportedGroupVersions().get(0));
        Assertions.assertEquals("zfoqouicybxar", model.cultureInfo());
        Assertions.assertEquals("zuf", model.parameters().get("x"));
        Assertions.assertEquals("mnguxawqaldsyu", model.httpMethod());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DppWorkerRequest model =
            new DppWorkerRequest()
                .withSubscriptionId("etaebu")
                .withUri("vdmovsmzlxwabm")
                .withHeaders(
                    mapOf("btndo", Arrays.asList("kif", "vtpuqujmqlgk"), "ed", Arrays.asList("n", "bjcntujitc")))
                .withSupportedGroupVersions(Arrays.asList("waezkojvd"))
                .withCultureInfo("zfoqouicybxar")
                .withParameters(
                    mapOf(
                        "x",
                        "zuf",
                        "khazxkhnzbonlwn",
                        "iqopidoamciod",
                        "szzcmrvexztv",
                        "oegokdwbwh",
                        "gsfraoyzkoow",
                        "t"))
                .withHttpMethod("mnguxawqaldsyu");
        model = BinaryData.fromObject(model).toObject(DppWorkerRequest.class);
        Assertions.assertEquals("etaebu", model.subscriptionId());
        Assertions.assertEquals("vdmovsmzlxwabm", model.uri());
        Assertions.assertEquals("kif", model.headers().get("btndo").get(0));
        Assertions.assertEquals("waezkojvd", model.supportedGroupVersions().get(0));
        Assertions.assertEquals("zfoqouicybxar", model.cultureInfo());
        Assertions.assertEquals("zuf", model.parameters().get("x"));
        Assertions.assertEquals("mnguxawqaldsyu", model.httpMethod());
    }

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