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

package com.azure.resourcemanager.delegatednetwork.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.delegatednetwork.fluent.models.OrchestratorInner;
import com.azure.resourcemanager.delegatednetwork.models.ControllerDetails;
import com.azure.resourcemanager.delegatednetwork.models.OrchestratorIdentity;
import com.azure.resourcemanager.delegatednetwork.models.OrchestratorKind;
import com.azure.resourcemanager.delegatednetwork.models.OrchestratorResourceProperties;
import com.azure.resourcemanager.delegatednetwork.models.ResourceIdentityType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class OrchestratorInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        OrchestratorInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"resourceGuid\":\"ybrk\",\"provisioningState\":\"Failed\",\"orchestratorAppId\":\"mjgr\",\"orchestratorTenantId\":\"wvukx\",\"clusterRootCA\":\"udccsnhsjc\",\"apiServerEndpoint\":\"ejhkry\",\"privateLinkResourceId\":\"napczwlokjy\",\"controllerDetails\":{\"id\":\"kkvnipjox\"}},\"kind\":\"Kubernetes\",\"identity\":{\"principalId\":\"hgejspodma\",\"tenantId\":\"zyde\",\"type\":\"None\"},\"location\":\"wyahuxinpmqnja\",\"tags\":{\"prozvcputegjvwmf\":\"xj\",\"pjhulsuuvmkj\":\"atscmd\",\"iodjp\":\"zkrwfn\",\"ryo\":\"lwejdpv\"},\"id\":\"psoacctazakljl\",\"name\":\"hbcryffdfdosyge\",\"type\":\"paojakhmsbzjh\"}")
                .toObject(OrchestratorInner.class);
        Assertions.assertEquals("wyahuxinpmqnja", model.location());
        Assertions.assertEquals("xj", model.tags().get("prozvcputegjvwmf"));
        Assertions.assertEquals(OrchestratorKind.KUBERNETES, model.kind());
        Assertions.assertEquals(ResourceIdentityType.NONE, model.identity().type());
        Assertions.assertEquals("mjgr", model.properties().orchestratorAppId());
        Assertions.assertEquals("wvukx", model.properties().orchestratorTenantId());
        Assertions.assertEquals("udccsnhsjc", model.properties().clusterRootCA());
        Assertions.assertEquals("ejhkry", model.properties().apiServerEndpoint());
        Assertions.assertEquals("napczwlokjy", model.properties().privateLinkResourceId());
        Assertions.assertEquals("kkvnipjox", model.properties().controllerDetails().id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        OrchestratorInner model =
            new OrchestratorInner()
                .withLocation("wyahuxinpmqnja")
                .withTags(
                    mapOf("prozvcputegjvwmf", "xj", "pjhulsuuvmkj", "atscmd", "iodjp", "zkrwfn", "ryo", "lwejdpv"))
                .withKind(OrchestratorKind.KUBERNETES)
                .withIdentity(new OrchestratorIdentity().withType(ResourceIdentityType.NONE))
                .withProperties(
                    new OrchestratorResourceProperties()
                        .withOrchestratorAppId("mjgr")
                        .withOrchestratorTenantId("wvukx")
                        .withClusterRootCA("udccsnhsjc")
                        .withApiServerEndpoint("ejhkry")
                        .withPrivateLinkResourceId("napczwlokjy")
                        .withControllerDetails(new ControllerDetails().withId("kkvnipjox")));
        model = BinaryData.fromObject(model).toObject(OrchestratorInner.class);
        Assertions.assertEquals("wyahuxinpmqnja", model.location());
        Assertions.assertEquals("xj", model.tags().get("prozvcputegjvwmf"));
        Assertions.assertEquals(OrchestratorKind.KUBERNETES, model.kind());
        Assertions.assertEquals(ResourceIdentityType.NONE, model.identity().type());
        Assertions.assertEquals("mjgr", model.properties().orchestratorAppId());
        Assertions.assertEquals("wvukx", model.properties().orchestratorTenantId());
        Assertions.assertEquals("udccsnhsjc", model.properties().clusterRootCA());
        Assertions.assertEquals("ejhkry", model.properties().apiServerEndpoint());
        Assertions.assertEquals("napczwlokjy", model.properties().privateLinkResourceId());
        Assertions.assertEquals("kkvnipjox", model.properties().controllerDetails().id());
    }

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