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

package com.azure.resourcemanager.frontdoor.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.frontdoor.fluent.models.PreconfiguredEndpointInner;
import com.azure.resourcemanager.frontdoor.models.EndpointType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class PreconfiguredEndpointInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PreconfiguredEndpointInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"description\":\"iuiefozbhdmsm\",\"endpoint\":\"zqhof\",\"endpointType\":\"ATM\",\"backend\":\"equi\"},\"location\":\"hxicslfaoqz\",\"tags\":{\"ph\":\"ylhalnswhcc\",\"gwol\":\"aivwitqscywu\",\"zbwemh\":\"h\",\"sbrgz\":\"i\"},\"id\":\"wmsweypqwd\",\"name\":\"ggicccnxqhue\",\"type\":\"mkttlstvlzywem\"}")
                .toObject(PreconfiguredEndpointInner.class);
        Assertions.assertEquals("hxicslfaoqz", model.location());
        Assertions.assertEquals("ylhalnswhcc", model.tags().get("ph"));
        Assertions.assertEquals("iuiefozbhdmsm", model.description());
        Assertions.assertEquals("zqhof", model.endpoint());
        Assertions.assertEquals(EndpointType.ATM, model.endpointType());
        Assertions.assertEquals("equi", model.backend());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PreconfiguredEndpointInner model =
            new PreconfiguredEndpointInner()
                .withLocation("hxicslfaoqz")
                .withTags(mapOf("ph", "ylhalnswhcc", "gwol", "aivwitqscywu", "zbwemh", "h", "sbrgz", "i"))
                .withDescription("iuiefozbhdmsm")
                .withEndpoint("zqhof")
                .withEndpointType(EndpointType.ATM)
                .withBackend("equi");
        model = BinaryData.fromObject(model).toObject(PreconfiguredEndpointInner.class);
        Assertions.assertEquals("hxicslfaoqz", model.location());
        Assertions.assertEquals("ylhalnswhcc", model.tags().get("ph"));
        Assertions.assertEquals("iuiefozbhdmsm", model.description());
        Assertions.assertEquals("zqhof", model.endpoint());
        Assertions.assertEquals(EndpointType.ATM, model.endpointType());
        Assertions.assertEquals("equi", model.backend());
    }

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