// 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.Type;
import com.azure.resourcemanager.netapp.models.VolumeQuotaRulePatch;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class VolumeQuotaRulePatchTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VolumeQuotaRulePatch model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"ph\":\"ylhalnswhcc\",\"gwol\":\"aivwitqscywu\",\"zbwemh\":\"h\",\"sbrgz\":\"i\"},\"properties\":{\"provisioningState\":\"Succeeded\",\"quotaSizeInKiBs\":6841623833142002976,\"quotaType\":\"IndividualUserQuota\",\"quotaTarget\":\"dxggicccnxqhuexm\"}}")
                .toObject(VolumeQuotaRulePatch.class);
        Assertions.assertEquals("ylhalnswhcc", model.tags().get("ph"));
        Assertions.assertEquals(6841623833142002976L, model.quotaSizeInKiBs());
        Assertions.assertEquals(Type.INDIVIDUAL_USER_QUOTA, model.quotaType());
        Assertions.assertEquals("dxggicccnxqhuexm", model.quotaTarget());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VolumeQuotaRulePatch model =
            new VolumeQuotaRulePatch()
                .withTags(mapOf("ph", "ylhalnswhcc", "gwol", "aivwitqscywu", "zbwemh", "h", "sbrgz", "i"))
                .withQuotaSizeInKiBs(6841623833142002976L)
                .withQuotaType(Type.INDIVIDUAL_USER_QUOTA)
                .withQuotaTarget("dxggicccnxqhuexm");
        model = BinaryData.fromObject(model).toObject(VolumeQuotaRulePatch.class);
        Assertions.assertEquals("ylhalnswhcc", model.tags().get("ph"));
        Assertions.assertEquals(6841623833142002976L, model.quotaSizeInKiBs());
        Assertions.assertEquals(Type.INDIVIDUAL_USER_QUOTA, model.quotaType());
        Assertions.assertEquals("dxggicccnxqhuexm", model.quotaTarget());
    }

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