// 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.ExperimentInner;
import com.azure.resourcemanager.frontdoor.models.Endpoint;
import com.azure.resourcemanager.frontdoor.models.State;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ExperimentInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ExperimentInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"description\":\"y\",\"endpointA\":{\"name\":\"wlmdjrkv\",\"endpoint\":\"bvfvpdbod\"},\"endpointB\":{\"name\":\"zsjqlh\",\"endpoint\":\"r\"},\"enabledState\":\"Enabled\",\"resourceState\":\"Enabled\",\"status\":\"qipqkghvxndz\",\"scriptFileUri\":\"krefajpjo\"},\"location\":\"wkqnyhg\",\"tags\":{\"ystawfsdjpvkvp\":\"tjivfxzsjabib\"},\"id\":\"jxbkzbzkdvn\",\"name\":\"jabudurgkakmo\",\"type\":\"zhjjklffhmouwq\"}")
                .toObject(ExperimentInner.class);
        Assertions.assertEquals("wkqnyhg", model.location());
        Assertions.assertEquals("tjivfxzsjabib", model.tags().get("ystawfsdjpvkvp"));
        Assertions.assertEquals("y", model.description());
        Assertions.assertEquals("wlmdjrkv", model.endpointA().name());
        Assertions.assertEquals("bvfvpdbod", model.endpointA().endpoint());
        Assertions.assertEquals("zsjqlh", model.endpointB().name());
        Assertions.assertEquals("r", model.endpointB().endpoint());
        Assertions.assertEquals(State.ENABLED, model.enabledState());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ExperimentInner model =
            new ExperimentInner()
                .withLocation("wkqnyhg")
                .withTags(mapOf("ystawfsdjpvkvp", "tjivfxzsjabib"))
                .withDescription("y")
                .withEndpointA(new Endpoint().withName("wlmdjrkv").withEndpoint("bvfvpdbod"))
                .withEndpointB(new Endpoint().withName("zsjqlh").withEndpoint("r"))
                .withEnabledState(State.ENABLED);
        model = BinaryData.fromObject(model).toObject(ExperimentInner.class);
        Assertions.assertEquals("wkqnyhg", model.location());
        Assertions.assertEquals("tjivfxzsjabib", model.tags().get("ystawfsdjpvkvp"));
        Assertions.assertEquals("y", model.description());
        Assertions.assertEquals("wlmdjrkv", model.endpointA().name());
        Assertions.assertEquals("bvfvpdbod", model.endpointA().endpoint());
        Assertions.assertEquals("zsjqlh", model.endpointB().name());
        Assertions.assertEquals("r", model.endpointB().endpoint());
        Assertions.assertEquals(State.ENABLED, model.enabledState());
    }

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