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

public final class VolumeQuotaRuleInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VolumeQuotaRuleInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"Succeeded\",\"quotaSizeInKiBs\":3980349580525769162,\"quotaType\":\"IndividualGroupQuota\",\"quotaTarget\":\"akgtdlmkkzevdlh\"},\"location\":\"pusdstt\",\"tags\":{\"qmoa\":\"gvbbejdcng\",\"twaenuuzko\":\"ufgmjzrwrdg\",\"iefozbhdmsml\":\"bminrfdwoyuhhzi\"},\"id\":\"zqhof\",\"name\":\"rmaequ\",\"type\":\"ah\"}")
                .toObject(VolumeQuotaRuleInner.class);
        Assertions.assertEquals("pusdstt", model.location());
        Assertions.assertEquals("gvbbejdcng", model.tags().get("qmoa"));
        Assertions.assertEquals(3980349580525769162L, model.quotaSizeInKiBs());
        Assertions.assertEquals(Type.INDIVIDUAL_GROUP_QUOTA, model.quotaType());
        Assertions.assertEquals("akgtdlmkkzevdlh", model.quotaTarget());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VolumeQuotaRuleInner model =
            new VolumeQuotaRuleInner()
                .withLocation("pusdstt")
                .withTags(mapOf("qmoa", "gvbbejdcng", "twaenuuzko", "ufgmjzrwrdg", "iefozbhdmsml", "bminrfdwoyuhhzi"))
                .withQuotaSizeInKiBs(3980349580525769162L)
                .withQuotaType(Type.INDIVIDUAL_GROUP_QUOTA)
                .withQuotaTarget("akgtdlmkkzevdlh");
        model = BinaryData.fromObject(model).toObject(VolumeQuotaRuleInner.class);
        Assertions.assertEquals("pusdstt", model.location());
        Assertions.assertEquals("gvbbejdcng", model.tags().get("qmoa"));
        Assertions.assertEquals(3980349580525769162L, model.quotaSizeInKiBs());
        Assertions.assertEquals(Type.INDIVIDUAL_GROUP_QUOTA, model.quotaType());
        Assertions.assertEquals("akgtdlmkkzevdlh", 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;
    }
}
