// 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.models.OrchestratorIdentity;
import com.azure.resourcemanager.delegatednetwork.models.OrchestratorKind;
import com.azure.resourcemanager.delegatednetwork.models.OrchestratorResource;
import com.azure.resourcemanager.delegatednetwork.models.ResourceIdentityType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class OrchestratorResourceTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        OrchestratorResource model =
            BinaryData
                .fromString(
                    "{\"kind\":\"Kubernetes\",\"identity\":{\"principalId\":\"epoo\",\"tenantId\":\"nuvamiheogna\",\"type\":\"None\"},\"location\":\"xth\",\"tags\":{\"cciqihnhungbwjz\":\"usivye\",\"kufubljo\":\"nfygxgispemvtz\",\"v\":\"xqeofjaeqjhqjba\",\"zgcwrw\":\"smjqulngsntnbyb\"},\"id\":\"lxxwrljdouskc\",\"name\":\"vkocrcjdkwtn\",\"type\":\"xbnjbiksq\"}")
                .toObject(OrchestratorResource.class);
        Assertions.assertEquals("xth", model.location());
        Assertions.assertEquals("usivye", model.tags().get("cciqihnhungbwjz"));
        Assertions.assertEquals(OrchestratorKind.KUBERNETES, model.kind());
        Assertions.assertEquals(ResourceIdentityType.NONE, model.identity().type());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        OrchestratorResource model =
            new OrchestratorResource()
                .withLocation("xth")
                .withTags(
                    mapOf(
                        "cciqihnhungbwjz",
                        "usivye",
                        "kufubljo",
                        "nfygxgispemvtz",
                        "v",
                        "xqeofjaeqjhqjba",
                        "zgcwrw",
                        "smjqulngsntnbyb"))
                .withKind(OrchestratorKind.KUBERNETES)
                .withIdentity(new OrchestratorIdentity().withType(ResourceIdentityType.NONE));
        model = BinaryData.fromObject(model).toObject(OrchestratorResource.class);
        Assertions.assertEquals("xth", model.location());
        Assertions.assertEquals("usivye", model.tags().get("cciqihnhungbwjz"));
        Assertions.assertEquals(OrchestratorKind.KUBERNETES, model.kind());
        Assertions.assertEquals(ResourceIdentityType.NONE, model.identity().type());
    }

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