// 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.DefenderForServersAwsOffering;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingArcAutoProvisioning;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingDefenderForServers;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingMdeAutoProvisioning;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingSubPlan;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingVaAutoProvisioning;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingVmScanners;
import com.azure.resourcemanager.security.models.DefenderForServersAwsOfferingVmScannersConfiguration;
import com.azure.resourcemanager.security.models.ScanningMode;
import com.azure.resourcemanager.security.models.SubPlan;
import com.azure.resourcemanager.security.models.Type;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DefenderForServersAwsOfferingTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DefenderForServersAwsOffering model =
            BinaryData
                .fromString(
                    "{\"offeringType\":\"DefenderForServersAws\",\"defenderForServers\":{\"cloudRoleArn\":\"egqphrgfnzhctm\"},\"arcAutoProvisioning\":{\"enabled\":true,\"cloudRoleArn\":\"pbcbcpzar\",\"configuration\":{\"proxy\":\"qacdldtzm\",\"privateLinkScope\":\"pefcpcz\"}},\"vaAutoProvisioning\":{\"enabled\":true,\"configuration\":{\"type\":\"Qualys\"}},\"mdeAutoProvisioning\":{\"enabled\":true,\"configuration\":\"datapfkhuytuszxhmt\"},\"subPlan\":{\"type\":\"P1\"},\"vmScanners\":{\"enabled\":true,\"configuration\":{\"cloudRoleArn\":\"kvzwydw\",\"scanningMode\":\"Default\",\"exclusionTags\":{\"fukpeexpgeu\":\"kgkskjivbsshaj\",\"hwu\":\"i\",\"dbzsx\":\"trdexyionofnin\"}}},\"description\":\"qqrsmpcbbprtugav\"}")
                .toObject(DefenderForServersAwsOffering.class);
        Assertions.assertEquals("egqphrgfnzhctm", model.defenderForServers().cloudRoleArn());
        Assertions.assertEquals(true, model.arcAutoProvisioning().enabled());
        Assertions.assertEquals("pbcbcpzar", model.arcAutoProvisioning().cloudRoleArn());
        Assertions.assertEquals("qacdldtzm", model.arcAutoProvisioning().configuration().proxy());
        Assertions.assertEquals("pefcpcz", model.arcAutoProvisioning().configuration().privateLinkScope());
        Assertions.assertEquals(true, model.vaAutoProvisioning().enabled());
        Assertions.assertEquals(Type.QUALYS, model.vaAutoProvisioning().configuration().type());
        Assertions.assertEquals(true, model.mdeAutoProvisioning().enabled());
        Assertions.assertEquals(SubPlan.P1, model.subPlan().type());
        Assertions.assertEquals(true, model.vmScanners().enabled());
        Assertions.assertEquals("kvzwydw", model.vmScanners().configuration().cloudRoleArn());
        Assertions.assertEquals(ScanningMode.DEFAULT, model.vmScanners().configuration().scanningMode());
        Assertions
            .assertEquals("kgkskjivbsshaj", model.vmScanners().configuration().exclusionTags().get("fukpeexpgeu"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DefenderForServersAwsOffering model =
            new DefenderForServersAwsOffering()
                .withDefenderForServers(
                    new DefenderForServersAwsOfferingDefenderForServers().withCloudRoleArn("egqphrgfnzhctm"))
                .withArcAutoProvisioning(
                    new DefenderForServersAwsOfferingArcAutoProvisioning()
                        .withEnabled(true)
                        .withCloudRoleArn("pbcbcpzar")
                        .withConfiguration(
                            new DefenderForServersAwsOfferingArcAutoProvisioningConfiguration()
                                .withProxy("qacdldtzm")
                                .withPrivateLinkScope("pefcpcz")))
                .withVaAutoProvisioning(
                    new DefenderForServersAwsOfferingVaAutoProvisioning()
                        .withEnabled(true)
                        .withConfiguration(
                            new DefenderForServersAwsOfferingVaAutoProvisioningConfiguration().withType(Type.QUALYS)))
                .withMdeAutoProvisioning(
                    new DefenderForServersAwsOfferingMdeAutoProvisioning()
                        .withEnabled(true)
                        .withConfiguration("datapfkhuytuszxhmt"))
                .withSubPlan(new DefenderForServersAwsOfferingSubPlan().withType(SubPlan.P1))
                .withVmScanners(
                    new DefenderForServersAwsOfferingVmScanners()
                        .withEnabled(true)
                        .withConfiguration(
                            new DefenderForServersAwsOfferingVmScannersConfiguration()
                                .withCloudRoleArn("kvzwydw")
                                .withScanningMode(ScanningMode.DEFAULT)
                                .withExclusionTags(
                                    mapOf("fukpeexpgeu", "kgkskjivbsshaj", "hwu", "i", "dbzsx", "trdexyionofnin"))));
        model = BinaryData.fromObject(model).toObject(DefenderForServersAwsOffering.class);
        Assertions.assertEquals("egqphrgfnzhctm", model.defenderForServers().cloudRoleArn());
        Assertions.assertEquals(true, model.arcAutoProvisioning().enabled());
        Assertions.assertEquals("pbcbcpzar", model.arcAutoProvisioning().cloudRoleArn());
        Assertions.assertEquals("qacdldtzm", model.arcAutoProvisioning().configuration().proxy());
        Assertions.assertEquals("pefcpcz", model.arcAutoProvisioning().configuration().privateLinkScope());
        Assertions.assertEquals(true, model.vaAutoProvisioning().enabled());
        Assertions.assertEquals(Type.QUALYS, model.vaAutoProvisioning().configuration().type());
        Assertions.assertEquals(true, model.mdeAutoProvisioning().enabled());
        Assertions.assertEquals(SubPlan.P1, model.subPlan().type());
        Assertions.assertEquals(true, model.vmScanners().enabled());
        Assertions.assertEquals("kvzwydw", model.vmScanners().configuration().cloudRoleArn());
        Assertions.assertEquals(ScanningMode.DEFAULT, model.vmScanners().configuration().scanningMode());
        Assertions
            .assertEquals("kgkskjivbsshaj", model.vmScanners().configuration().exclusionTags().get("fukpeexpgeu"));
    }

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