// 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.ExtendedLocation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ClusterMetricsConfigurationInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ClusterMetricsConfigurationInner model =
            BinaryData
                .fromString(
                    "{\"extendedLocation\":{\"name\":\"hflzokxco\",\"type\":\"pelnjetag\"},\"properties\":{\"collectionInterval\":2159915633768308562,\"detailedStatus\":\"Error\",\"detailedStatusMessage\":\"tft\",\"disabledMetrics\":[\"npbs\",\"vefloccsrmozihmi\",\"g\",\"wtxxpkyjcx\"],\"enabledMetrics\":[\"grytfmpcyci\",\"rmcaykgg\"],\"provisioningState\":\"Canceled\"},\"location\":\"ztrksxwpndf\",\"tags\":{\"jaosrxuzv\":\"nznthjtw\",\"xqdlyrtltlapr\":\"amktcqiosmgbzah\"},\"id\":\"tz\",\"name\":\"atbhjmznn\",\"type\":\"s\"}")
                .toObject(ClusterMetricsConfigurationInner.class);
        Assertions.assertEquals("ztrksxwpndf", model.location());
        Assertions.assertEquals("nznthjtw", model.tags().get("jaosrxuzv"));
        Assertions.assertEquals("hflzokxco", model.extendedLocation().name());
        Assertions.assertEquals("pelnjetag", model.extendedLocation().type());
        Assertions.assertEquals(2159915633768308562L, model.collectionInterval());
        Assertions.assertEquals("grytfmpcyci", model.enabledMetrics().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ClusterMetricsConfigurationInner model =
            new ClusterMetricsConfigurationInner()
                .withLocation("ztrksxwpndf")
                .withTags(mapOf("jaosrxuzv", "nznthjtw", "xqdlyrtltlapr", "amktcqiosmgbzah"))
                .withExtendedLocation(new ExtendedLocation().withName("hflzokxco").withType("pelnjetag"))
                .withCollectionInterval(2159915633768308562L)
                .withEnabledMetrics(Arrays.asList("grytfmpcyci", "rmcaykgg"));
        model = BinaryData.fromObject(model).toObject(ClusterMetricsConfigurationInner.class);
        Assertions.assertEquals("ztrksxwpndf", model.location());
        Assertions.assertEquals("nznthjtw", model.tags().get("jaosrxuzv"));
        Assertions.assertEquals("hflzokxco", model.extendedLocation().name());
        Assertions.assertEquals("pelnjetag", model.extendedLocation().type());
        Assertions.assertEquals(2159915633768308562L, model.collectionInterval());
        Assertions.assertEquals("grytfmpcyci", model.enabledMetrics().get(0));
    }

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