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

package com.azure.resourcemanager.costmanagement.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.costmanagement.fluent.models.ForecastResultInner;
import com.azure.resourcemanager.costmanagement.models.ForecastColumn;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ForecastResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ForecastResultInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"nextLink\":\"awgqwgxhni\",\"columns\":[{\"name\":\"bkpyc\",\"type\":\"lwn\"}],\"rows\":[[\"datadauwhvylwzbtd\",\"dataxujznbmpowu\"],[\"datarzqlveu\",\"datalupj\"],[\"datahfxobbcswsrtj\",\"dataiplrbpbewtghfgb\",\"datac\",\"datawxzvlvqhjkb\"]]},\"sku\":\"ibtnmxiebwwaloay\",\"eTag\":\"gwrtzju\",\"location\":\"gwyzm\",\"tags\":{\"jcbpwxqpsrknft\":\"ongmtsa\",\"yvxqtayriwwroy\":\"uvriuhprwm\",\"bycnojvkn\":\"bexrmcq\",\"qsgzvahapj\":\"e\"},\"id\":\"zhpvgqzcjrvxd\",\"name\":\"zlmwlxkvugfhz\",\"type\":\"vawjvzunlu\"}")
                .toObject(ForecastResultInner.class);
        Assertions.assertEquals("gwyzm", model.location());
        Assertions.assertEquals("ongmtsa", model.tags().get("jcbpwxqpsrknft"));
        Assertions.assertEquals("awgqwgxhni", model.nextLink());
        Assertions.assertEquals("bkpyc", model.columns().get(0).name());
        Assertions.assertEquals("lwn", model.columns().get(0).type());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ForecastResultInner model =
            new ForecastResultInner()
                .withLocation("gwyzm")
                .withTags(
                    mapOf(
                        "jcbpwxqpsrknft",
                        "ongmtsa",
                        "yvxqtayriwwroy",
                        "uvriuhprwm",
                        "bycnojvkn",
                        "bexrmcq",
                        "qsgzvahapj",
                        "e"))
                .withNextLink("awgqwgxhni")
                .withColumns(Arrays.asList(new ForecastColumn().withName("bkpyc").withType("lwn")))
                .withRows(
                    Arrays
                        .asList(
                            Arrays.asList("datadauwhvylwzbtd", "dataxujznbmpowu"),
                            Arrays.asList("datarzqlveu", "datalupj"),
                            Arrays.asList("datahfxobbcswsrtj", "dataiplrbpbewtghfgb", "datac", "datawxzvlvqhjkb")));
        model = BinaryData.fromObject(model).toObject(ForecastResultInner.class);
        Assertions.assertEquals("gwyzm", model.location());
        Assertions.assertEquals("ongmtsa", model.tags().get("jcbpwxqpsrknft"));
        Assertions.assertEquals("awgqwgxhni", model.nextLink());
        Assertions.assertEquals("bkpyc", model.columns().get(0).name());
        Assertions.assertEquals("lwn", model.columns().get(0).type());
    }

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