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

package com.azure.resourcemanager.hybridcontainerservice.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hybridcontainerservice.fluent.models.AgentPoolProperties;
import com.azure.resourcemanager.hybridcontainerservice.models.AgentPoolProvisioningStatusStatus;
import com.azure.resourcemanager.hybridcontainerservice.models.AgentPoolProvisioningStatusStatusProvisioningStatus;
import com.azure.resourcemanager.hybridcontainerservice.models.CloudProviderProfile;
import com.azure.resourcemanager.hybridcontainerservice.models.CloudProviderProfileInfraNetworkProfile;
import com.azure.resourcemanager.hybridcontainerservice.models.CloudProviderProfileInfraStorageProfile;
import com.azure.resourcemanager.hybridcontainerservice.models.Mode;
import com.azure.resourcemanager.hybridcontainerservice.models.OsType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AgentPoolPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AgentPoolProperties model =
            BinaryData
                .fromString(
                    "{\"provisioningState\":\"InProgress\",\"status\":{\"errorMessage\":\"obbc\",\"provisioningStatus\":{\"operationId\":\"tjrip\",\"phase\":\"bpbewtghfgb\",\"status\":\"gw\"},\"readyReplicas\":748159283,\"replicas\":161265854},\"count\":1837116433,\"availabilityZones\":[\"begibtnmxiebwwa\",\"oayqc\"],\"maxCount\":1214313613,\"maxPods\":1999029226,\"minCount\":350152394,\"mode\":\"System\",\"nodeLabels\":{\"xongmtsavjcbpwxq\":\"zmh\"},\"nodeTaints\":[\"knftguvriuh\",\"rwmdyvxqtay\",\"iwwroyqbexrmc\",\"ibycno\"],\"osType\":\"Linux\",\"nodeImageVersion\":\"mefqsgzvahapjyzh\",\"vmSize\":\"gqzcjr\",\"cloudProviderProfile\":{\"infraNetworkProfile\":{\"vnetSubnetIds\":[\"lmwlxkvugfhzo\",\"awjvzunluthnnp\",\"nxipeil\",\"jzuaejxdultskzbb\"]},\"infraStorageProfile\":{\"storageSpaceIds\":[\"mv\",\"ekg\",\"wozuhkf\",\"bsjyofdx\"]}}}")
                .toObject(AgentPoolProperties.class);
        Assertions.assertEquals(1837116433, model.count());
        Assertions.assertEquals("begibtnmxiebwwa", model.availabilityZones().get(0));
        Assertions.assertEquals(1214313613, model.maxCount());
        Assertions.assertEquals(1999029226, model.maxPods());
        Assertions.assertEquals(350152394, model.minCount());
        Assertions.assertEquals(Mode.SYSTEM, model.mode());
        Assertions.assertEquals("zmh", model.nodeLabels().get("xongmtsavjcbpwxq"));
        Assertions.assertEquals("knftguvriuh", model.nodeTaints().get(0));
        Assertions.assertEquals(OsType.LINUX, model.osType());
        Assertions.assertEquals("mefqsgzvahapjyzh", model.nodeImageVersion());
        Assertions.assertEquals("gqzcjr", model.vmSize());
        Assertions
            .assertEquals("lmwlxkvugfhzo", model.cloudProviderProfile().infraNetworkProfile().vnetSubnetIds().get(0));
        Assertions.assertEquals("mv", model.cloudProviderProfile().infraStorageProfile().storageSpaceIds().get(0));
        Assertions.assertEquals("obbc", model.status().errorMessage());
        Assertions.assertEquals("tjrip", model.status().provisioningStatus().operationId());
        Assertions.assertEquals("bpbewtghfgb", model.status().provisioningStatus().phase());
        Assertions.assertEquals("gw", model.status().provisioningStatus().status());
        Assertions.assertEquals(748159283, model.status().readyReplicas());
        Assertions.assertEquals(161265854, model.status().replicas());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AgentPoolProperties model =
            new AgentPoolProperties()
                .withCount(1837116433)
                .withAvailabilityZones(Arrays.asList("begibtnmxiebwwa", "oayqc"))
                .withMaxCount(1214313613)
                .withMaxPods(1999029226)
                .withMinCount(350152394)
                .withMode(Mode.SYSTEM)
                .withNodeLabels(mapOf("xongmtsavjcbpwxq", "zmh"))
                .withNodeTaints(Arrays.asList("knftguvriuh", "rwmdyvxqtay", "iwwroyqbexrmc", "ibycno"))
                .withOsType(OsType.LINUX)
                .withNodeImageVersion("mefqsgzvahapjyzh")
                .withVmSize("gqzcjr")
                .withCloudProviderProfile(
                    new CloudProviderProfile()
                        .withInfraNetworkProfile(
                            new CloudProviderProfileInfraNetworkProfile()
                                .withVnetSubnetIds(
                                    Arrays.asList("lmwlxkvugfhzo", "awjvzunluthnnp", "nxipeil", "jzuaejxdultskzbb")))
                        .withInfraStorageProfile(
                            new CloudProviderProfileInfraStorageProfile()
                                .withStorageSpaceIds(Arrays.asList("mv", "ekg", "wozuhkf", "bsjyofdx"))))
                .withStatus(
                    new AgentPoolProvisioningStatusStatus()
                        .withErrorMessage("obbc")
                        .withProvisioningStatus(
                            new AgentPoolProvisioningStatusStatusProvisioningStatus()
                                .withOperationId("tjrip")
                                .withPhase("bpbewtghfgb")
                                .withStatus("gw"))
                        .withReadyReplicas(748159283)
                        .withReplicas(161265854));
        model = BinaryData.fromObject(model).toObject(AgentPoolProperties.class);
        Assertions.assertEquals(1837116433, model.count());
        Assertions.assertEquals("begibtnmxiebwwa", model.availabilityZones().get(0));
        Assertions.assertEquals(1214313613, model.maxCount());
        Assertions.assertEquals(1999029226, model.maxPods());
        Assertions.assertEquals(350152394, model.minCount());
        Assertions.assertEquals(Mode.SYSTEM, model.mode());
        Assertions.assertEquals("zmh", model.nodeLabels().get("xongmtsavjcbpwxq"));
        Assertions.assertEquals("knftguvriuh", model.nodeTaints().get(0));
        Assertions.assertEquals(OsType.LINUX, model.osType());
        Assertions.assertEquals("mefqsgzvahapjyzh", model.nodeImageVersion());
        Assertions.assertEquals("gqzcjr", model.vmSize());
        Assertions
            .assertEquals("lmwlxkvugfhzo", model.cloudProviderProfile().infraNetworkProfile().vnetSubnetIds().get(0));
        Assertions.assertEquals("mv", model.cloudProviderProfile().infraStorageProfile().storageSpaceIds().get(0));
        Assertions.assertEquals("obbc", model.status().errorMessage());
        Assertions.assertEquals("tjrip", model.status().provisioningStatus().operationId());
        Assertions.assertEquals("bpbewtghfgb", model.status().provisioningStatus().phase());
        Assertions.assertEquals("gw", model.status().provisioningStatus().status());
        Assertions.assertEquals(748159283, model.status().readyReplicas());
        Assertions.assertEquals(161265854, model.status().replicas());
    }

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