// 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.AgentPoolInner;
import com.azure.resourcemanager.hybridcontainerservice.models.AgentPoolExtendedLocation;
import com.azure.resourcemanager.hybridcontainerservice.models.AgentPoolProvisioningStatusStatus;
import com.azure.resourcemanager.hybridcontainerservice.models.CloudProviderProfile;
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 AgentPoolInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AgentPoolInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"Failed\",\"status\":{\"errorMessage\":\"juahaquhcdhmdual\",\"readyReplicas\":552039222,\"replicas\":1809510954},\"count\":792525510,\"availabilityZones\":[\"ws\",\"crgvxpvgom\",\"lf\",\"isgwbnbbeldawkz\"],\"maxCount\":70118233,\"maxPods\":113893877,\"minCount\":12612409,\"mode\":\"LB\",\"nodeLabels\":{\"sowzxcugi\":\"auhashsfwx\",\"ucww\":\"jooxdjebw\",\"bvmeuecivy\":\"vo\"},\"nodeTaints\":[\"euojgjrwju\"],\"osType\":\"Linux\",\"nodeImageVersion\":\"wmcdytdxwi\",\"vmSize\":\"nrjawgqwg\",\"cloudProviderProfile\":{}},\"extendedLocation\":{\"type\":\"fbkp\",\"name\":\"gklwn\"},\"location\":\"nhjdauw\",\"tags\":{\"zbtd\":\"l\"},\"id\":\"xujznbmpowu\",\"name\":\"przqlveu\",\"type\":\"lupj\"}")
                .toObject(AgentPoolInner.class);
        Assertions.assertEquals("nhjdauw", model.location());
        Assertions.assertEquals("l", model.tags().get("zbtd"));
        Assertions.assertEquals("fbkp", model.extendedLocation().type());
        Assertions.assertEquals("gklwn", model.extendedLocation().name());
        Assertions.assertEquals("juahaquhcdhmdual", model.status().errorMessage());
        Assertions.assertEquals(552039222, model.status().readyReplicas());
        Assertions.assertEquals(1809510954, model.status().replicas());
        Assertions.assertEquals(792525510, model.count());
        Assertions.assertEquals("ws", model.availabilityZones().get(0));
        Assertions.assertEquals(70118233, model.maxCount());
        Assertions.assertEquals(113893877, model.maxPods());
        Assertions.assertEquals(12612409, model.minCount());
        Assertions.assertEquals(Mode.LB, model.mode());
        Assertions.assertEquals("auhashsfwx", model.nodeLabels().get("sowzxcugi"));
        Assertions.assertEquals("euojgjrwju", model.nodeTaints().get(0));
        Assertions.assertEquals(OsType.LINUX, model.osType());
        Assertions.assertEquals("wmcdytdxwi", model.nodeImageVersion());
        Assertions.assertEquals("nrjawgqwg", model.vmSize());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AgentPoolInner model =
            new AgentPoolInner()
                .withLocation("nhjdauw")
                .withTags(mapOf("zbtd", "l"))
                .withExtendedLocation(new AgentPoolExtendedLocation().withType("fbkp").withName("gklwn"))
                .withStatus(
                    new AgentPoolProvisioningStatusStatus()
                        .withErrorMessage("juahaquhcdhmdual")
                        .withReadyReplicas(552039222)
                        .withReplicas(1809510954))
                .withCount(792525510)
                .withAvailabilityZones(Arrays.asList("ws", "crgvxpvgom", "lf", "isgwbnbbeldawkz"))
                .withMaxCount(70118233)
                .withMaxPods(113893877)
                .withMinCount(12612409)
                .withMode(Mode.LB)
                .withNodeLabels(mapOf("sowzxcugi", "auhashsfwx", "ucww", "jooxdjebw", "bvmeuecivy", "vo"))
                .withNodeTaints(Arrays.asList("euojgjrwju"))
                .withOsType(OsType.LINUX)
                .withNodeImageVersion("wmcdytdxwi")
                .withVmSize("nrjawgqwg")
                .withCloudProviderProfile(new CloudProviderProfile());
        model = BinaryData.fromObject(model).toObject(AgentPoolInner.class);
        Assertions.assertEquals("nhjdauw", model.location());
        Assertions.assertEquals("l", model.tags().get("zbtd"));
        Assertions.assertEquals("fbkp", model.extendedLocation().type());
        Assertions.assertEquals("gklwn", model.extendedLocation().name());
        Assertions.assertEquals("juahaquhcdhmdual", model.status().errorMessage());
        Assertions.assertEquals(552039222, model.status().readyReplicas());
        Assertions.assertEquals(1809510954, model.status().replicas());
        Assertions.assertEquals(792525510, model.count());
        Assertions.assertEquals("ws", model.availabilityZones().get(0));
        Assertions.assertEquals(70118233, model.maxCount());
        Assertions.assertEquals(113893877, model.maxPods());
        Assertions.assertEquals(12612409, model.minCount());
        Assertions.assertEquals(Mode.LB, model.mode());
        Assertions.assertEquals("auhashsfwx", model.nodeLabels().get("sowzxcugi"));
        Assertions.assertEquals("euojgjrwju", model.nodeTaints().get(0));
        Assertions.assertEquals(OsType.LINUX, model.osType());
        Assertions.assertEquals("wmcdytdxwi", model.nodeImageVersion());
        Assertions.assertEquals("nrjawgqwg", model.vmSize());
    }

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