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

public final class InvoiceSectionsOnExpandTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        InvoiceSectionsOnExpand model =
            BinaryData
                .fromString(
                    "{\"hasMoreResults\":false,\"value\":[{\"properties\":{\"displayName\":\"ozwyiftyhxhuro\",\"labels\":{},\"state\":\"Active\",\"systemId\":\"olniwpwcukjf\",\"tags\":{},\"targetCloud\":\"USNat\"},\"id\":\"w\",\"name\":\"klryplwck\",\"type\":\"asy\"},{\"properties\":{\"displayName\":\"ddhsgcbacphe\",\"labels\":{},\"state\":\"Active\",\"systemId\":\"nqgoulzndli\",\"tags\":{},\"targetCloud\":\"USSec\"},\"id\":\"kgfg\",\"name\":\"bmadgak\",\"type\":\"qsrxybzqqed\"},{\"properties\":{\"displayName\":\"bciqfouflm\",\"labels\":{},\"state\":\"Active\",\"systemId\":\"modmglougpb\",\"tags\":{},\"targetCloud\":\"USNat\"},\"id\":\"utduqktapspwgcu\",\"name\":\"rtumkdosvq\",\"type\":\"hbmdgbbjfdd\"},{\"properties\":{\"displayName\":\"mbe\",\"labels\":{},\"state\":\"Restricted\",\"systemId\":\"tq\",\"tags\":{},\"targetCloud\":\"USGov\"},\"id\":\"fpfpsalgbquxigj\",\"name\":\"jgzjaoyfhrtx\",\"type\":\"lnerkujysvleju\"}]}")
                .toObject(InvoiceSectionsOnExpand.class);
        Assertions.assertEquals("ozwyiftyhxhuro", model.value().get(0).displayName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        InvoiceSectionsOnExpand model =
            new InvoiceSectionsOnExpand()
                .withValue(
                    Arrays
                        .asList(
                            new InvoiceSectionInner()
                                .withDisplayName("ozwyiftyhxhuro")
                                .withLabels(mapOf())
                                .withTags(mapOf()),
                            new InvoiceSectionInner()
                                .withDisplayName("ddhsgcbacphe")
                                .withLabels(mapOf())
                                .withTags(mapOf()),
                            new InvoiceSectionInner()
                                .withDisplayName("bciqfouflm")
                                .withLabels(mapOf())
                                .withTags(mapOf()),
                            new InvoiceSectionInner().withDisplayName("mbe").withLabels(mapOf()).withTags(mapOf())));
        model = BinaryData.fromObject(model).toObject(InvoiceSectionsOnExpand.class);
        Assertions.assertEquals("ozwyiftyhxhuro", model.value().get(0).displayName());
    }

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