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

package com.azure.resourcemanager.synapse.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeComputeProperties;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeEdition;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeLicenseType;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeSsisProperties;
import com.azure.resourcemanager.synapse.models.ManagedIntegrationRuntime;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ManagedIntegrationRuntimeTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ManagedIntegrationRuntime model =
            BinaryData
                .fromString(
                    "{\"type\":\"Managed\",\"state\":\"Limited\",\"typeProperties\":{\"computeProperties\":{\"location\":\"lkhhu\",\"nodeSize\":\"cpoq\",\"numberOfNodes\":2065973208,\"maxParallelExecutionsPerNode\":1853837051,\"\":{\"nlejjjkxybwf\":\"datao\"}},\"ssisProperties\":{\"licenseType\":\"LicenseIncluded\",\"edition\":\"Standard\",\"expressCustomSetupProperties\":[],\"\":{\"tjknsxfwushcdp\":\"datayk\",\"kuwxeoiojfizfavk\":\"dataupnqrmgjfb\",\"fwxrzxmdew\":\"datazwfbcyaykmmfzs\"}}},\"managedVirtualNetwork\":{\"referenceName\":\"xkrplbjaz\",\"type\":\"wwviyo\",\"id\":\"suhbrnn\"},\"description\":\"xs\",\"\":{\"wetp\":\"datahqkb\",\"se\":\"datazycyqiqyhg\",\"sfledyn\":\"datazlex\",\"fbzkk\":\"datajpziu\"}}")
                .toObject(ManagedIntegrationRuntime.class);
        Assertions.assertEquals("xs", model.description());
        Assertions.assertEquals("lkhhu", model.computeProperties().location());
        Assertions.assertEquals("cpoq", model.computeProperties().nodeSize());
        Assertions.assertEquals(2065973208, model.computeProperties().numberOfNodes());
        Assertions.assertEquals(1853837051, model.computeProperties().maxParallelExecutionsPerNode());
        Assertions.assertEquals(IntegrationRuntimeLicenseType.LICENSE_INCLUDED, model.ssisProperties().licenseType());
        Assertions.assertEquals(IntegrationRuntimeEdition.STANDARD, model.ssisProperties().edition());
        Assertions.assertEquals("xkrplbjaz", model.referenceName());
        Assertions.assertEquals("wwviyo", model.typeManagedVirtualNetworkType());
        Assertions.assertEquals("suhbrnn", model.id());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ManagedIntegrationRuntime model =
            new ManagedIntegrationRuntime()
                .withDescription("xs")
                .withComputeProperties(
                    new IntegrationRuntimeComputeProperties()
                        .withLocation("lkhhu")
                        .withNodeSize("cpoq")
                        .withNumberOfNodes(2065973208)
                        .withMaxParallelExecutionsPerNode(1853837051)
                        .withAdditionalProperties(mapOf()))
                .withSsisProperties(
                    new IntegrationRuntimeSsisProperties()
                        .withLicenseType(IntegrationRuntimeLicenseType.LICENSE_INCLUDED)
                        .withEdition(IntegrationRuntimeEdition.STANDARD)
                        .withExpressCustomSetupProperties(Arrays.asList())
                        .withAdditionalProperties(mapOf()))
                .withReferenceName("xkrplbjaz")
                .withTypeManagedVirtualNetworkType("wwviyo")
                .withId("suhbrnn");
        model = BinaryData.fromObject(model).toObject(ManagedIntegrationRuntime.class);
        Assertions.assertEquals("xs", model.description());
        Assertions.assertEquals("lkhhu", model.computeProperties().location());
        Assertions.assertEquals("cpoq", model.computeProperties().nodeSize());
        Assertions.assertEquals(2065973208, model.computeProperties().numberOfNodes());
        Assertions.assertEquals(1853837051, model.computeProperties().maxParallelExecutionsPerNode());
        Assertions.assertEquals(IntegrationRuntimeLicenseType.LICENSE_INCLUDED, model.ssisProperties().licenseType());
        Assertions.assertEquals(IntegrationRuntimeEdition.STANDARD, model.ssisProperties().edition());
        Assertions.assertEquals("xkrplbjaz", model.referenceName());
        Assertions.assertEquals("wwviyo", model.typeManagedVirtualNetworkType());
        Assertions.assertEquals("suhbrnn", model.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;
    }
}
