// 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.SecurityConnectorInner;
import com.azure.resourcemanager.security.models.CloudName;
import com.azure.resourcemanager.security.models.SecurityConnectorsList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SecurityConnectorsListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SecurityConnectorsList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"hierarchyIdentifier\":\"ifrkgwltxeqipx\",\"hierarchyIdentifierTrialEndDate\":\"2021-05-11T17:28:43Z\",\"environmentName\":\"GCP\",\"offerings\":[]},\"location\":\"fayorpravkjoges\",\"tags\":{\"kvwjtqpkevmy\":\"nsmjkwynqxaekqs\",\"gxannnoytzposewx\":\"tjcrspxklurccl\",\"dfaifyzyzeyuube\":\"gpxvkqmaupxvpi\",\"l\":\"ds\"},\"id\":\"ytoithgygvfl\",\"name\":\"gvdihoynkrxwetwk\",\"type\":\"rcyrucpcunnu\"},{\"properties\":{\"hierarchyIdentifier\":\"moenodnaien\",\"hierarchyIdentifierTrialEndDate\":\"2021-09-25T15:40:50Z\",\"environmentName\":\"GCP\",\"offerings\":[]},\"location\":\"nelqkaadl\",\"tags\":{\"vcnrly\":\"foanniyopetx\"},\"id\":\"nucaephblkwqpat\",\"name\":\"bqsdtcjbctvi\",\"type\":\"uzqymtuowog\"}],\"nextLink\":\"it\"}")
                .toObject(SecurityConnectorsList.class);
        Assertions.assertEquals("fayorpravkjoges", model.value().get(0).location());
        Assertions.assertEquals("nsmjkwynqxaekqs", model.value().get(0).tags().get("kvwjtqpkevmy"));
        Assertions.assertEquals("ifrkgwltxeqipx", model.value().get(0).hierarchyIdentifier());
        Assertions.assertEquals(CloudName.GCP, model.value().get(0).environmentName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SecurityConnectorsList model =
            new SecurityConnectorsList()
                .withValue(
                    Arrays
                        .asList(
                            new SecurityConnectorInner()
                                .withLocation("fayorpravkjoges")
                                .withTags(
                                    mapOf(
                                        "kvwjtqpkevmy",
                                        "nsmjkwynqxaekqs",
                                        "gxannnoytzposewx",
                                        "tjcrspxklurccl",
                                        "dfaifyzyzeyuube",
                                        "gpxvkqmaupxvpi",
                                        "l",
                                        "ds"))
                                .withHierarchyIdentifier("ifrkgwltxeqipx")
                                .withEnvironmentName(CloudName.GCP)
                                .withOfferings(Arrays.asList()),
                            new SecurityConnectorInner()
                                .withLocation("nelqkaadl")
                                .withTags(mapOf("vcnrly", "foanniyopetx"))
                                .withHierarchyIdentifier("moenodnaien")
                                .withEnvironmentName(CloudName.GCP)
                                .withOfferings(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(SecurityConnectorsList.class);
        Assertions.assertEquals("fayorpravkjoges", model.value().get(0).location());
        Assertions.assertEquals("nsmjkwynqxaekqs", model.value().get(0).tags().get("kvwjtqpkevmy"));
        Assertions.assertEquals("ifrkgwltxeqipx", model.value().get(0).hierarchyIdentifier());
        Assertions.assertEquals(CloudName.GCP, model.value().get(0).environmentName());
    }

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