// 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.DataFlowComputeType;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeComputeProperties;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeDataFlowProperties;
import com.azure.resourcemanager.synapse.models.IntegrationRuntimeVNetProperties;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IntegrationRuntimeComputePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IntegrationRuntimeComputeProperties model =
            BinaryData
                .fromString(
                    "{\"location\":\"itpkpztrgdg\",\"nodeSize\":\"coqra\",\"numberOfNodes\":2040757308,\"maxParallelExecutionsPerNode\":601079141,\"dataFlowProperties\":{\"computeType\":\"General\",\"coreCount\":2036171481,\"timeToLive\":151899144,\"cleanup\":false,\"\":{\"yltcoqcuj\":\"datavskbuhzacaq\",\"ztjofqcvovjufyc\":\"datadsxzakuejkmvb\",\"gthortudaw\":\"datajmlbemyejiriux\",\"qerpptcbgqnzm\":\"datapjfe\"}},\"vNetProperties\":{\"vNetId\":\"ilialwcjgc\",\"subnet\":\"bcccgzpra\",\"publicIPs\":[\"yuffatsgf\",\"ipwcxbyu\"],\"subnetId\":\"iqdxyurnpnuh\",\"\":{\"yl\":\"dataccnuhiig\",\"vxva\":\"dataui\",\"lbnb\":\"datavcrk\"}},\"\":{\"syhzlwx\":\"datah\"}}")
                .toObject(IntegrationRuntimeComputeProperties.class);
        Assertions.assertEquals("itpkpztrgdg", model.location());
        Assertions.assertEquals("coqra", model.nodeSize());
        Assertions.assertEquals(2040757308, model.numberOfNodes());
        Assertions.assertEquals(601079141, model.maxParallelExecutionsPerNode());
        Assertions.assertEquals(DataFlowComputeType.GENERAL, model.dataFlowProperties().computeType());
        Assertions.assertEquals(2036171481, model.dataFlowProperties().coreCount());
        Assertions.assertEquals(151899144, model.dataFlowProperties().timeToLive());
        Assertions.assertEquals(false, model.dataFlowProperties().cleanup());
        Assertions.assertEquals("ilialwcjgc", model.vNetProperties().vNetId());
        Assertions.assertEquals("bcccgzpra", model.vNetProperties().subnet());
        Assertions.assertEquals("yuffatsgf", model.vNetProperties().publicIPs().get(0));
        Assertions.assertEquals("iqdxyurnpnuh", model.vNetProperties().subnetId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IntegrationRuntimeComputeProperties model =
            new IntegrationRuntimeComputeProperties()
                .withLocation("itpkpztrgdg")
                .withNodeSize("coqra")
                .withNumberOfNodes(2040757308)
                .withMaxParallelExecutionsPerNode(601079141)
                .withDataFlowProperties(
                    new IntegrationRuntimeDataFlowProperties()
                        .withComputeType(DataFlowComputeType.GENERAL)
                        .withCoreCount(2036171481)
                        .withTimeToLive(151899144)
                        .withCleanup(false)
                        .withAdditionalProperties(mapOf()))
                .withVNetProperties(
                    new IntegrationRuntimeVNetProperties()
                        .withVNetId("ilialwcjgc")
                        .withSubnet("bcccgzpra")
                        .withPublicIPs(Arrays.asList("yuffatsgf", "ipwcxbyu"))
                        .withSubnetId("iqdxyurnpnuh")
                        .withAdditionalProperties(mapOf()))
                .withAdditionalProperties(mapOf());
        model = BinaryData.fromObject(model).toObject(IntegrationRuntimeComputeProperties.class);
        Assertions.assertEquals("itpkpztrgdg", model.location());
        Assertions.assertEquals("coqra", model.nodeSize());
        Assertions.assertEquals(2040757308, model.numberOfNodes());
        Assertions.assertEquals(601079141, model.maxParallelExecutionsPerNode());
        Assertions.assertEquals(DataFlowComputeType.GENERAL, model.dataFlowProperties().computeType());
        Assertions.assertEquals(2036171481, model.dataFlowProperties().coreCount());
        Assertions.assertEquals(151899144, model.dataFlowProperties().timeToLive());
        Assertions.assertEquals(false, model.dataFlowProperties().cleanup());
        Assertions.assertEquals("ilialwcjgc", model.vNetProperties().vNetId());
        Assertions.assertEquals("bcccgzpra", model.vNetProperties().subnet());
        Assertions.assertEquals("yuffatsgf", model.vNetProperties().publicIPs().get(0));
        Assertions.assertEquals("iqdxyurnpnuh", model.vNetProperties().subnetId());
    }

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