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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.JobService;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class JobServiceTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JobService model =
            BinaryData
                .fromString(
                    "{\"endpoint\":\"oaimlnw\",\"errorMessage\":\"aomylwea\",\"jobServiceType\":\"lcsethwwnpj\",\"port\":307378678,\"properties\":{\"ousnfepgfewe\":\"wpchwahf\",\"hdjhlimmbcx\":\"wlyxgncxyk\",\"cporxvxcjz\":\"h\",\"juhdqazkmtgguwpi\":\"qizxfpxtgqscjavf\"},\"status\":\"ajc\"}")
                .toObject(JobService.class);
        Assertions.assertEquals("oaimlnw", model.endpoint());
        Assertions.assertEquals("lcsethwwnpj", model.jobServiceType());
        Assertions.assertEquals(307378678, model.port());
        Assertions.assertEquals("wpchwahf", model.properties().get("ousnfepgfewe"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JobService model =
            new JobService()
                .withEndpoint("oaimlnw")
                .withJobServiceType("lcsethwwnpj")
                .withPort(307378678)
                .withProperties(
                    mapOf(
                        "ousnfepgfewe",
                        "wpchwahf",
                        "hdjhlimmbcx",
                        "wlyxgncxyk",
                        "cporxvxcjz",
                        "h",
                        "juhdqazkmtgguwpi",
                        "qizxfpxtgqscjavf"));
        model = BinaryData.fromObject(model).toObject(JobService.class);
        Assertions.assertEquals("oaimlnw", model.endpoint());
        Assertions.assertEquals("lcsethwwnpj", model.jobServiceType());
        Assertions.assertEquals(307378678, model.port());
        Assertions.assertEquals("wpchwahf", model.properties().get("ousnfepgfewe"));
    }

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