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

public final class SecurityConnectorInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SecurityConnectorInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"hierarchyIdentifier\":\"vbrzcdb\",\"hierarchyIdentifierTrialEndDate\":\"2021-09-14T13:57:27Z\",\"environmentName\":\"Github\",\"offerings\":[{\"offeringType\":\"CloudOffering\",\"description\":\"xmxeatkdb\"},{\"offeringType\":\"CloudOffering\",\"description\":\"nrd\"}],\"environmentData\":{\"environmentType\":\"EnvironmentData\"}},\"location\":\"ibqbnaomhjrm\",\"tags\":{\"obcancdexxqcw\":\"maxljalfihcj\",\"fgvaknokzwj\":\"a\",\"tpq\":\"zrltixldzyyf\"},\"id\":\"ixymmpujivyql\",\"name\":\"juvsmbmslzoyovw\",\"type\":\"dbpqvybefgvm\"}")
                .toObject(SecurityConnectorInner.class);
        Assertions.assertEquals("ibqbnaomhjrm", model.location());
        Assertions.assertEquals("maxljalfihcj", model.tags().get("obcancdexxqcw"));
        Assertions.assertEquals("vbrzcdb", model.hierarchyIdentifier());
        Assertions.assertEquals(CloudName.GITHUB, model.environmentName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SecurityConnectorInner model =
            new SecurityConnectorInner()
                .withLocation("ibqbnaomhjrm")
                .withTags(mapOf("obcancdexxqcw", "maxljalfihcj", "fgvaknokzwj", "a", "tpq", "zrltixldzyyf"))
                .withHierarchyIdentifier("vbrzcdb")
                .withEnvironmentName(CloudName.GITHUB)
                .withOfferings(Arrays.asList(new CloudOffering(), new CloudOffering()))
                .withEnvironmentData(new EnvironmentData());
        model = BinaryData.fromObject(model).toObject(SecurityConnectorInner.class);
        Assertions.assertEquals("ibqbnaomhjrm", model.location());
        Assertions.assertEquals("maxljalfihcj", model.tags().get("obcancdexxqcw"));
        Assertions.assertEquals("vbrzcdb", model.hierarchyIdentifier());
        Assertions.assertEquals(CloudName.GITHUB, model.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;
    }
}
