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

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.fluent.models.IoTSecurityAggregatedAlertInner;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class IoTSecurityAggregatedAlertInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IoTSecurityAggregatedAlertInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"alertType\":\"riplrbpbewtg\",\"alertDisplayName\":\"gblcgwxzvlvq\",\"vendorName\":\"begibtnmxiebwwa\",\"reportedSeverity\":\"Low\",\"remediationSteps\":\"qcgw\",\"description\":\"zjuzgwyz\",\"count\":4114340895697399622,\"effectedResourceType\":\"ngmtsavjcb\",\"systemSource\":\"xqpsrknftguv\",\"actionTaken\":\"uhprwmdyvxqt\",\"logAnalyticsQuery\":\"riwwroy\",\"topDevicesList\":[{\"deviceId\":\"rmcqiby\",\"alertsCount\":8763943848607308417,\"lastOccurrence\":\"knme\"},{\"deviceId\":\"sgzvahapjyzhpv\",\"alertsCount\":6872658649281325491,\"lastOccurrence\":\"rvxdjzlmw\"},{\"deviceId\":\"kvugfhzovawjvzun\",\"alertsCount\":6384208989627743230,\"lastOccurrence\":\"n\"},{\"deviceId\":\"nxipeil\",\"alertsCount\":7813618899616430195,\"lastOccurrence\":\"e\"}]},\"tags\":{\"mv\":\"ultskzbbtdz\",\"wozuhkf\":\"ekg\"},\"id\":\"bsjyofdx\",\"name\":\"uusdttouwa\",\"type\":\"oekqvk\"}")
                .toObject(IoTSecurityAggregatedAlertInner.class);
        Assertions.assertEquals("ultskzbbtdz", model.tags().get("mv"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IoTSecurityAggregatedAlertInner model =
            new IoTSecurityAggregatedAlertInner().withTags(mapOf("mv", "ultskzbbtdz", "wozuhkf", "ekg"));
        model = BinaryData.fromObject(model).toObject(IoTSecurityAggregatedAlertInner.class);
        Assertions.assertEquals("ultskzbbtdz", model.tags().get("mv"));
    }

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