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

package com.azure.resourcemanager.devcenter.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devcenter.models.LicenseType;
import com.azure.resourcemanager.devcenter.models.LocalAdminStatus;
import com.azure.resourcemanager.devcenter.models.PoolUpdate;
import com.azure.resourcemanager.devcenter.models.StopOnDisconnectConfiguration;
import com.azure.resourcemanager.devcenter.models.StopOnDisconnectEnableStatus;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class PoolUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PoolUpdate model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"devBoxDefinitionName\":\"eqidbqfatpx\",\"networkConnectionName\":\"rxcyjmoad\",\"licenseType\":\"Windows_Client\",\"localAdministrator\":\"Disabled\",\"stopOnDisconnect\":{\"status\":\"Disabled\",\"gracePeriodMinutes\":1450729079}},\"tags\":{\"xrwlyc\":\"jqbjhhy\",\"kgymareqnajxqug\":\"duhpk\",\"ubeddg\":\"hky\"},\"location\":\"ofwq\"}")
                .toObject(PoolUpdate.class);
        Assertions.assertEquals("jqbjhhy", model.tags().get("xrwlyc"));
        Assertions.assertEquals("ofwq", model.location());
        Assertions.assertEquals("eqidbqfatpx", model.devBoxDefinitionName());
        Assertions.assertEquals("rxcyjmoad", model.networkConnectionName());
        Assertions.assertEquals(LicenseType.WINDOWS_CLIENT, model.licenseType());
        Assertions.assertEquals(LocalAdminStatus.DISABLED, model.localAdministrator());
        Assertions.assertEquals(StopOnDisconnectEnableStatus.DISABLED, model.stopOnDisconnect().status());
        Assertions.assertEquals(1450729079, model.stopOnDisconnect().gracePeriodMinutes());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PoolUpdate model =
            new PoolUpdate()
                .withTags(mapOf("xrwlyc", "jqbjhhy", "kgymareqnajxqug", "duhpk", "ubeddg", "hky"))
                .withLocation("ofwq")
                .withDevBoxDefinitionName("eqidbqfatpx")
                .withNetworkConnectionName("rxcyjmoad")
                .withLicenseType(LicenseType.WINDOWS_CLIENT)
                .withLocalAdministrator(LocalAdminStatus.DISABLED)
                .withStopOnDisconnect(
                    new StopOnDisconnectConfiguration()
                        .withStatus(StopOnDisconnectEnableStatus.DISABLED)
                        .withGracePeriodMinutes(1450729079));
        model = BinaryData.fromObject(model).toObject(PoolUpdate.class);
        Assertions.assertEquals("jqbjhhy", model.tags().get("xrwlyc"));
        Assertions.assertEquals("ofwq", model.location());
        Assertions.assertEquals("eqidbqfatpx", model.devBoxDefinitionName());
        Assertions.assertEquals("rxcyjmoad", model.networkConnectionName());
        Assertions.assertEquals(LicenseType.WINDOWS_CLIENT, model.licenseType());
        Assertions.assertEquals(LocalAdminStatus.DISABLED, model.localAdministrator());
        Assertions.assertEquals(StopOnDisconnectEnableStatus.DISABLED, model.stopOnDisconnect().status());
        Assertions.assertEquals(1450729079, model.stopOnDisconnect().gracePeriodMinutes());
    }

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