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

package com.azure.resourcemanager.billing.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.billing.fluent.models.InvoiceSectionInner;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class InvoiceSectionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        InvoiceSectionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"displayName\":\"awrlyx\",\"labels\":{\"nwbxgjvtbvpyssz\":\"cpr\",\"guhmuouqfpr\":\"nruj\"},\"state\":\"Restricted\",\"systemId\":\"nguitnwuizgazxu\",\"tags\":{\"hr\":\"uckyf\",\"zwdzuh\":\"idf\"},\"targetCloud\":\"USGov\"},\"id\":\"wisdkft\",\"name\":\"wxmnteiwao\",\"type\":\"vkmijcmmxdcuf\"}")
                .toObject(InvoiceSectionInner.class);
        Assertions.assertEquals("awrlyx", model.displayName());
        Assertions.assertEquals("cpr", model.labels().get("nwbxgjvtbvpyssz"));
        Assertions.assertEquals("uckyf", model.tags().get("hr"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        InvoiceSectionInner model =
            new InvoiceSectionInner()
                .withDisplayName("awrlyx")
                .withLabels(mapOf("nwbxgjvtbvpyssz", "cpr", "guhmuouqfpr", "nruj"))
                .withTags(mapOf("hr", "uckyf", "zwdzuh", "idf"));
        model = BinaryData.fromObject(model).toObject(InvoiceSectionInner.class);
        Assertions.assertEquals("awrlyx", model.displayName());
        Assertions.assertEquals("cpr", model.labels().get("nwbxgjvtbvpyssz"));
        Assertions.assertEquals("uckyf", model.tags().get("hr"));
    }

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