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

package com.azure.resourcemanager.networkcloud.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkcloud.fluent.models.ClusterMetricsConfigurationInner;
import com.azure.resourcemanager.networkcloud.models.ClusterMetricsConfigurationList;
import com.azure.resourcemanager.networkcloud.models.ExtendedLocation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ClusterMetricsConfigurationListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ClusterMetricsConfigurationList model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"bkiw\",\"value\":[{\"extendedLocation\":{\"name\":\"n\",\"type\":\"ophzfylsgcrp\"},\"properties\":{\"collectionInterval\":2804347969541145358,\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"zzcezelfwyfwlw\",\"disabledMetrics\":[],\"enabledMetrics\":[],\"provisioningState\":\"Failed\"},\"location\":\"psihcla\",\"tags\":{\"rsqqwztcm\":\"aylp\"},\"id\":\"qkc\",\"name\":\"cxwaxfewz\",\"type\":\"kjexfdeqvhp\"},{\"extendedLocation\":{\"name\":\"ylkkshkbffmbm\",\"type\":\"zjrgyww\"},\"properties\":{\"collectionInterval\":646490035612760857,\"detailedStatus\":\"Applied\",\"detailedStatusMessage\":\"ptfujgicgaaoept\",\"disabledMetrics\":[],\"enabledMetrics\":[],\"provisioningState\":\"Succeeded\"},\"location\":\"ewemxs\",\"tags\":{\"zjgehkfkim\":\"uun\",\"ffqyinlj\":\"tixo\",\"ixmonstshiyxg\":\"epqw\"},\"id\":\"elfclducc\",\"name\":\"irdsvuwcob\",\"type\":\"egstmninwjizci\"},{\"extendedLocation\":{\"name\":\"nghgshej\",\"type\":\"tbxqmuluxlxq\"},\"properties\":{\"collectionInterval\":4603582249541593699,\"detailedStatus\":\"Processing\",\"detailedStatusMessage\":\"bycucrwnamikz\",\"disabledMetrics\":[],\"enabledMetrics\":[],\"provisioningState\":\"Failed\"},\"location\":\"mswziq\",\"tags\":{\"vhczznvfby\":\"hokzrusw\"},\"id\":\"jsxjwwix\",\"name\":\"vumwmxqh\",\"type\":\"dvnoamldsehaohdj\"}]}")
                .toObject(ClusterMetricsConfigurationList.class);
        Assertions.assertEquals("bkiw", model.nextLink());
        Assertions.assertEquals("psihcla", model.value().get(0).location());
        Assertions.assertEquals("aylp", model.value().get(0).tags().get("rsqqwztcm"));
        Assertions.assertEquals("n", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("ophzfylsgcrp", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(2804347969541145358L, model.value().get(0).collectionInterval());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ClusterMetricsConfigurationList model =
            new ClusterMetricsConfigurationList()
                .withNextLink("bkiw")
                .withValue(
                    Arrays
                        .asList(
                            new ClusterMetricsConfigurationInner()
                                .withLocation("psihcla")
                                .withTags(mapOf("rsqqwztcm", "aylp"))
                                .withExtendedLocation(new ExtendedLocation().withName("n").withType("ophzfylsgcrp"))
                                .withCollectionInterval(2804347969541145358L)
                                .withEnabledMetrics(Arrays.asList()),
                            new ClusterMetricsConfigurationInner()
                                .withLocation("ewemxs")
                                .withTags(mapOf("zjgehkfkim", "uun", "ffqyinlj", "tixo", "ixmonstshiyxg", "epqw"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("ylkkshkbffmbm").withType("zjrgyww"))
                                .withCollectionInterval(646490035612760857L)
                                .withEnabledMetrics(Arrays.asList()),
                            new ClusterMetricsConfigurationInner()
                                .withLocation("mswziq")
                                .withTags(mapOf("vhczznvfby", "hokzrusw"))
                                .withExtendedLocation(
                                    new ExtendedLocation().withName("nghgshej").withType("tbxqmuluxlxq"))
                                .withCollectionInterval(4603582249541593699L)
                                .withEnabledMetrics(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(ClusterMetricsConfigurationList.class);
        Assertions.assertEquals("bkiw", model.nextLink());
        Assertions.assertEquals("psihcla", model.value().get(0).location());
        Assertions.assertEquals("aylp", model.value().get(0).tags().get("rsqqwztcm"));
        Assertions.assertEquals("n", model.value().get(0).extendedLocation().name());
        Assertions.assertEquals("ophzfylsgcrp", model.value().get(0).extendedLocation().type());
        Assertions.assertEquals(2804347969541145358L, model.value().get(0).collectionInterval());
    }

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