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

package com.azure.resourcemanager.datadog.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.datadog.fluent.models.DatadogMonitorResourceInner;
import com.azure.resourcemanager.datadog.models.DatadogMonitorResourceListResponse;
import com.azure.resourcemanager.datadog.models.IdentityProperties;
import com.azure.resourcemanager.datadog.models.ManagedIdentityTypes;
import com.azure.resourcemanager.datadog.models.MonitorProperties;
import com.azure.resourcemanager.datadog.models.MonitoringStatus;
import com.azure.resourcemanager.datadog.models.ResourceSku;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DatadogMonitorResourceListResponseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DatadogMonitorResourceListResponse model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"sku\":{\"name\":\"rhhbcs\"},\"properties\":{\"provisioningState\":\"Deleting\",\"monitoringStatus\":\"Enabled\",\"marketplaceSubscriptionStatus\":\"Suspended\",\"liftrResourceCategory\":\"Unknown\",\"liftrResourcePreference\":1555681942},\"identity\":{\"principalId\":\"bdxkqpxokaj\",\"tenantId\":\"npime\",\"type\":\"SystemAssigned\"},\"location\":\"xgcp\",\"tags\":{\"mcl\":\"maajrmvdjwzrlo\",\"jctbza\":\"hijco\"},\"id\":\"s\",\"name\":\"sycbkbfk\",\"type\":\"ukdkexxppofmxa\"},{\"sku\":{\"name\":\"fjpgddtocjjxhvp\"},\"properties\":{\"provisioningState\":\"NotSpecified\",\"monitoringStatus\":\"Enabled\",\"marketplaceSubscriptionStatus\":\"Active\",\"liftrResourceCategory\":\"MonitorLogs\",\"liftrResourcePreference\":427127517},\"identity\":{\"principalId\":\"xqbzvddntwnd\",\"tenantId\":\"cbtwnpzaoqvuh\",\"type\":\"UserAssigned\"},\"location\":\"fcyddg\",\"tags\":{\"jqkwpyeicx\":\"t\",\"pbobjo\":\"qciwqvhkhixuigdt\",\"w\":\"hm\"},\"id\":\"a\",\"name\":\"a\",\"type\":\"hrzayvvtpgvdf\"},{\"sku\":{\"name\":\"otkftutqxlngx\"},\"properties\":{\"provisioningState\":\"Failed\",\"monitoringStatus\":\"Disabled\",\"marketplaceSubscriptionStatus\":\"Active\",\"liftrResourceCategory\":\"Unknown\",\"liftrResourcePreference\":435751453},\"identity\":{\"principalId\":\"tthzrvqd\",\"tenantId\":\"bhj\",\"type\":\"SystemAssigned\"},\"location\":\"ehoqfbowskan\",\"tags\":{\"nhzgpphrcgyn\":\"zlcuiywgqywgndrv\",\"fsxlzevgbmqjqa\":\"ocpecfvmmco\",\"pmivkwlzu\":\"c\",\"ebxetqgtzxdp\":\"ccfwnfnbacfion\"},\"id\":\"qbqqwxr\",\"name\":\"feallnwsu\",\"type\":\"isnjampmngnz\"},{\"sku\":{\"name\":\"xaqwoochcbonqv\"},\"properties\":{\"provisioningState\":\"Accepted\",\"monitoringStatus\":\"Enabled\",\"marketplaceSubscriptionStatus\":\"Active\",\"liftrResourceCategory\":\"MonitorLogs\",\"liftrResourcePreference\":625674029},\"identity\":{\"principalId\":\"oflokey\",\"tenantId\":\"enjbdlwtgrhp\",\"type\":\"SystemAssigned\"},\"location\":\"umasxazjpq\",\"tags\":{\"zvdudgwdslfhotwm\":\"ualhbxxhejj\"},\"id\":\"ynpwlbj\",\"name\":\"pgacftadehxnlty\",\"type\":\"sop\"}],\"nextLink\":\"suesnzw\"}")
                .toObject(DatadogMonitorResourceListResponse.class);
        Assertions.assertEquals("xgcp", model.value().get(0).location());
        Assertions.assertEquals("maajrmvdjwzrlo", model.value().get(0).tags().get("mcl"));
        Assertions.assertEquals("rhhbcs", model.value().get(0).sku().name());
        Assertions.assertEquals(MonitoringStatus.ENABLED, model.value().get(0).properties().monitoringStatus());
        Assertions.assertEquals(ManagedIdentityTypes.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("suesnzw", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DatadogMonitorResourceListResponse model =
            new DatadogMonitorResourceListResponse()
                .withValue(
                    Arrays
                        .asList(
                            new DatadogMonitorResourceInner()
                                .withLocation("xgcp")
                                .withTags(mapOf("mcl", "maajrmvdjwzrlo", "jctbza", "hijco"))
                                .withSku(new ResourceSku().withName("rhhbcs"))
                                .withProperties(new MonitorProperties().withMonitoringStatus(MonitoringStatus.ENABLED))
                                .withIdentity(new IdentityProperties().withType(ManagedIdentityTypes.SYSTEM_ASSIGNED)),
                            new DatadogMonitorResourceInner()
                                .withLocation("fcyddg")
                                .withTags(mapOf("jqkwpyeicx", "t", "pbobjo", "qciwqvhkhixuigdt", "w", "hm"))
                                .withSku(new ResourceSku().withName("fjpgddtocjjxhvp"))
                                .withProperties(new MonitorProperties().withMonitoringStatus(MonitoringStatus.ENABLED))
                                .withIdentity(new IdentityProperties().withType(ManagedIdentityTypes.USER_ASSIGNED)),
                            new DatadogMonitorResourceInner()
                                .withLocation("ehoqfbowskan")
                                .withTags(
                                    mapOf(
                                        "nhzgpphrcgyn",
                                        "zlcuiywgqywgndrv",
                                        "fsxlzevgbmqjqa",
                                        "ocpecfvmmco",
                                        "pmivkwlzu",
                                        "c",
                                        "ebxetqgtzxdp",
                                        "ccfwnfnbacfion"))
                                .withSku(new ResourceSku().withName("otkftutqxlngx"))
                                .withProperties(new MonitorProperties().withMonitoringStatus(MonitoringStatus.DISABLED))
                                .withIdentity(new IdentityProperties().withType(ManagedIdentityTypes.SYSTEM_ASSIGNED)),
                            new DatadogMonitorResourceInner()
                                .withLocation("umasxazjpq")
                                .withTags(mapOf("zvdudgwdslfhotwm", "ualhbxxhejj"))
                                .withSku(new ResourceSku().withName("xaqwoochcbonqv"))
                                .withProperties(new MonitorProperties().withMonitoringStatus(MonitoringStatus.ENABLED))
                                .withIdentity(new IdentityProperties().withType(ManagedIdentityTypes.SYSTEM_ASSIGNED))))
                .withNextLink("suesnzw");
        model = BinaryData.fromObject(model).toObject(DatadogMonitorResourceListResponse.class);
        Assertions.assertEquals("xgcp", model.value().get(0).location());
        Assertions.assertEquals("maajrmvdjwzrlo", model.value().get(0).tags().get("mcl"));
        Assertions.assertEquals("rhhbcs", model.value().get(0).sku().name());
        Assertions.assertEquals(MonitoringStatus.ENABLED, model.value().get(0).properties().monitoringStatus());
        Assertions.assertEquals(ManagedIdentityTypes.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("suesnzw", model.nextLink());
    }

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