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

package com.azure.resourcemanager.netapp.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.netapp.models.ServiceLevel;
import com.azure.resourcemanager.netapp.models.VolumePatch;
import com.azure.resourcemanager.netapp.models.VolumePatchPropertiesDataProtection;
import com.azure.resourcemanager.netapp.models.VolumePatchPropertiesExportPolicy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class VolumePatchTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VolumePatch model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"serviceLevel\":\"Premium\",\"usageThreshold\":798754251901632491,\"exportPolicy\":{\"rules\":[]},\"throughputMibps\":49.891884,\"dataProtection\":{},\"isDefaultQuotaEnabled\":false,\"defaultUserQuotaInKiBs\":8279092425079677109,\"defaultGroupQuotaInKiBs\":8739681618516710945,\"unixPermissions\":\"nyyazttbtwwrqpue\",\"coolAccess\":false,\"coolnessPeriod\":1525019471},\"location\":\"wbiexzfey\",\"tags\":{\"zyoxaepdkzjan\":\"xibxujwbhqwalm\",\"hdwbavxbniwdjs\":\"ux\"},\"id\":\"zt\",\"name\":\"dbpgnxytxhp\",\"type\":\"xbzpfzab\"}")
                .toObject(VolumePatch.class);
        Assertions.assertEquals("wbiexzfey", model.location());
        Assertions.assertEquals("xibxujwbhqwalm", model.tags().get("zyoxaepdkzjan"));
        Assertions.assertEquals(ServiceLevel.PREMIUM, model.serviceLevel());
        Assertions.assertEquals(798754251901632491L, model.usageThreshold());
        Assertions.assertEquals(49.891884F, model.throughputMibps());
        Assertions.assertEquals(false, model.isDefaultQuotaEnabled());
        Assertions.assertEquals(8279092425079677109L, model.defaultUserQuotaInKiBs());
        Assertions.assertEquals(8739681618516710945L, model.defaultGroupQuotaInKiBs());
        Assertions.assertEquals("nyyazttbtwwrqpue", model.unixPermissions());
        Assertions.assertEquals(false, model.coolAccess());
        Assertions.assertEquals(1525019471, model.coolnessPeriod());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VolumePatch model =
            new VolumePatch()
                .withLocation("wbiexzfey")
                .withTags(mapOf("zyoxaepdkzjan", "xibxujwbhqwalm", "hdwbavxbniwdjs", "ux"))
                .withServiceLevel(ServiceLevel.PREMIUM)
                .withUsageThreshold(798754251901632491L)
                .withExportPolicy(new VolumePatchPropertiesExportPolicy().withRules(Arrays.asList()))
                .withThroughputMibps(49.891884F)
                .withDataProtection(new VolumePatchPropertiesDataProtection())
                .withIsDefaultQuotaEnabled(false)
                .withDefaultUserQuotaInKiBs(8279092425079677109L)
                .withDefaultGroupQuotaInKiBs(8739681618516710945L)
                .withUnixPermissions("nyyazttbtwwrqpue")
                .withCoolAccess(false)
                .withCoolnessPeriod(1525019471);
        model = BinaryData.fromObject(model).toObject(VolumePatch.class);
        Assertions.assertEquals("wbiexzfey", model.location());
        Assertions.assertEquals("xibxujwbhqwalm", model.tags().get("zyoxaepdkzjan"));
        Assertions.assertEquals(ServiceLevel.PREMIUM, model.serviceLevel());
        Assertions.assertEquals(798754251901632491L, model.usageThreshold());
        Assertions.assertEquals(49.891884F, model.throughputMibps());
        Assertions.assertEquals(false, model.isDefaultQuotaEnabled());
        Assertions.assertEquals(8279092425079677109L, model.defaultUserQuotaInKiBs());
        Assertions.assertEquals(8739681618516710945L, model.defaultGroupQuotaInKiBs());
        Assertions.assertEquals("nyyazttbtwwrqpue", model.unixPermissions());
        Assertions.assertEquals(false, model.coolAccess());
        Assertions.assertEquals(1525019471, model.coolnessPeriod());
    }

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