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

package com.azure.resourcemanager.elasticsan.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.elasticsan.models.ElasticSanUpdate;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class ElasticSanUpdateTests {
    @Test
    public void testDeserialize() {
        ElasticSanUpdate model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"baseSizeTiB\":1046762399333359388,\"extendedCapacitySizeTiB\":6432231641159211987},\"tags\":{\"bexppb\":\"ddgmb\"}}")
                .toObject(ElasticSanUpdate.class);
        Assertions.assertEquals("ddgmb", model.tags().get("bexppb"));
        Assertions.assertEquals(1046762399333359388L, model.baseSizeTiB());
        Assertions.assertEquals(6432231641159211987L, model.extendedCapacitySizeTiB());
    }

    @Test
    public void testSerialize() {
        ElasticSanUpdate model =
            new ElasticSanUpdate()
                .withTags(mapOf("bexppb", "ddgmb"))
                .withBaseSizeTiB(1046762399333359388L)
                .withExtendedCapacitySizeTiB(6432231641159211987L);
        model = BinaryData.fromObject(model).toObject(ElasticSanUpdate.class);
        Assertions.assertEquals("ddgmb", model.tags().get("bexppb"));
        Assertions.assertEquals(1046762399333359388L, model.baseSizeTiB());
        Assertions.assertEquals(6432231641159211987L, model.extendedCapacitySizeTiB());
    }

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