// 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.models.DefenderCspmAwsOffering;
import com.azure.resourcemanager.security.models.DefenderCspmAwsOfferingDataSensitivityDiscovery;
import com.azure.resourcemanager.security.models.DefenderCspmAwsOfferingDatabasesDspm;
import com.azure.resourcemanager.security.models.DefenderCspmAwsOfferingVmScanners;
import com.azure.resourcemanager.security.models.DefenderCspmAwsOfferingVmScannersConfiguration;
import com.azure.resourcemanager.security.models.ScanningMode;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DefenderCspmAwsOfferingTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DefenderCspmAwsOffering model =
            BinaryData
                .fromString(
                    "{\"offeringType\":\"DefenderCspmAws\",\"vmScanners\":{\"enabled\":false,\"configuration\":{\"cloudRoleArn\":\"e\",\"scanningMode\":\"Default\",\"exclusionTags\":{\"ktjtgra\":\"llbvgwzsfftedous\",\"fkbebauzl\":\"aqo\"}}},\"dataSensitivityDiscovery\":{\"enabled\":false,\"cloudRoleArn\":\"wpfhnjzudrtpzkgm\"},\"databasesDspm\":{\"enabled\":false,\"cloudRoleArn\":\"hczzqrhm\"},\"description\":\"qbedygisrzwn\"}")
                .toObject(DefenderCspmAwsOffering.class);
        Assertions.assertEquals(false, model.vmScanners().enabled());
        Assertions.assertEquals("e", model.vmScanners().configuration().cloudRoleArn());
        Assertions.assertEquals(ScanningMode.DEFAULT, model.vmScanners().configuration().scanningMode());
        Assertions.assertEquals("llbvgwzsfftedous", model.vmScanners().configuration().exclusionTags().get("ktjtgra"));
        Assertions.assertEquals(false, model.dataSensitivityDiscovery().enabled());
        Assertions.assertEquals("wpfhnjzudrtpzkgm", model.dataSensitivityDiscovery().cloudRoleArn());
        Assertions.assertEquals(false, model.databasesDspm().enabled());
        Assertions.assertEquals("hczzqrhm", model.databasesDspm().cloudRoleArn());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DefenderCspmAwsOffering model =
            new DefenderCspmAwsOffering()
                .withVmScanners(
                    new DefenderCspmAwsOfferingVmScanners()
                        .withEnabled(false)
                        .withConfiguration(
                            new DefenderCspmAwsOfferingVmScannersConfiguration()
                                .withCloudRoleArn("e")
                                .withScanningMode(ScanningMode.DEFAULT)
                                .withExclusionTags(mapOf("ktjtgra", "llbvgwzsfftedous", "fkbebauzl", "aqo"))))
                .withDataSensitivityDiscovery(
                    new DefenderCspmAwsOfferingDataSensitivityDiscovery()
                        .withEnabled(false)
                        .withCloudRoleArn("wpfhnjzudrtpzkgm"))
                .withDatabasesDspm(
                    new DefenderCspmAwsOfferingDatabasesDspm().withEnabled(false).withCloudRoleArn("hczzqrhm"));
        model = BinaryData.fromObject(model).toObject(DefenderCspmAwsOffering.class);
        Assertions.assertEquals(false, model.vmScanners().enabled());
        Assertions.assertEquals("e", model.vmScanners().configuration().cloudRoleArn());
        Assertions.assertEquals(ScanningMode.DEFAULT, model.vmScanners().configuration().scanningMode());
        Assertions.assertEquals("llbvgwzsfftedous", model.vmScanners().configuration().exclusionTags().get("ktjtgra"));
        Assertions.assertEquals(false, model.dataSensitivityDiscovery().enabled());
        Assertions.assertEquals("wpfhnjzudrtpzkgm", model.dataSensitivityDiscovery().cloudRoleArn());
        Assertions.assertEquals(false, model.databasesDspm().enabled());
        Assertions.assertEquals("hczzqrhm", model.databasesDspm().cloudRoleArn());
    }

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