// 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.AdaptiveApplicationControlGroupData;
import com.azure.resourcemanager.security.models.ConfigurationStatus;
import com.azure.resourcemanager.security.models.EnforcementMode;
import com.azure.resourcemanager.security.models.EnforcementSupport;
import com.azure.resourcemanager.security.models.FileType;
import com.azure.resourcemanager.security.models.PathRecommendation;
import com.azure.resourcemanager.security.models.ProtectionMode;
import com.azure.resourcemanager.security.models.PublisherInfo;
import com.azure.resourcemanager.security.models.RecommendationAction;
import com.azure.resourcemanager.security.models.RecommendationType;
import com.azure.resourcemanager.security.models.VmRecommendation;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AdaptiveApplicationControlGroupDataTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AdaptiveApplicationControlGroupData model =
            BinaryData
                .fromString(
                    "{\"enforcementMode\":\"Audit\",\"protectionMode\":{\"exe\":\"None\",\"msi\":\"None\",\"script\":\"None\",\"executable\":\"Audit\"},\"configurationStatus\":\"InProgress\",\"recommendationStatus\":\"NotRecommended\",\"issues\":[{\"issue\":\"RulesViolatedManually\",\"numberOfVms\":15.610468}],\"sourceSystem\":\"Azure_AuditD\",\"vmRecommendations\":[{\"configurationStatus\":\"NoStatus\",\"recommendationAction\":\"Recommended\",\"resourceId\":\"hlf\",\"enforcementSupport\":\"Supported\"}],\"pathRecommendations\":[{\"path\":\"wahfbousnfepgfew\",\"action\":\"Add\",\"type\":\"IoT_SharedCredentials\",\"publisherInfo\":{\"publisherName\":\"ncxykxhdjhlimm\",\"productName\":\"x\",\"binaryName\":\"bcporxvxcjzhqizx\",\"version\":\"xtgqscjavftjuh\"},\"common\":true,\"userSids\":[\"mtggu\"],\"usernames\":[],\"fileType\":\"Script\",\"configurationStatus\":\"Failed\"}]}")
                .toObject(AdaptiveApplicationControlGroupData.class);
        Assertions.assertEquals(EnforcementMode.AUDIT, model.enforcementMode());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().exe());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().msi());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().script());
        Assertions.assertEquals(EnforcementMode.AUDIT, model.protectionMode().executable());
        Assertions.assertEquals(ConfigurationStatus.NO_STATUS, model.vmRecommendations().get(0).configurationStatus());
        Assertions
            .assertEquals(RecommendationAction.RECOMMENDED, model.vmRecommendations().get(0).recommendationAction());
        Assertions.assertEquals("hlf", model.vmRecommendations().get(0).resourceId());
        Assertions.assertEquals(EnforcementSupport.SUPPORTED, model.vmRecommendations().get(0).enforcementSupport());
        Assertions.assertEquals("wahfbousnfepgfew", model.pathRecommendations().get(0).path());
        Assertions.assertEquals(RecommendationAction.ADD, model.pathRecommendations().get(0).action());
        Assertions.assertEquals(RecommendationType.IO_T_SHARED_CREDENTIALS, model.pathRecommendations().get(0).type());
        Assertions.assertEquals("ncxykxhdjhlimm", model.pathRecommendations().get(0).publisherInfo().publisherName());
        Assertions.assertEquals("x", model.pathRecommendations().get(0).publisherInfo().productName());
        Assertions.assertEquals("bcporxvxcjzhqizx", model.pathRecommendations().get(0).publisherInfo().binaryName());
        Assertions.assertEquals("xtgqscjavftjuh", model.pathRecommendations().get(0).publisherInfo().version());
        Assertions.assertEquals(true, model.pathRecommendations().get(0).common());
        Assertions.assertEquals("mtggu", model.pathRecommendations().get(0).userSids().get(0));
        Assertions.assertEquals(FileType.SCRIPT, model.pathRecommendations().get(0).fileType());
        Assertions.assertEquals(ConfigurationStatus.FAILED, model.pathRecommendations().get(0).configurationStatus());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AdaptiveApplicationControlGroupData model =
            new AdaptiveApplicationControlGroupData()
                .withEnforcementMode(EnforcementMode.AUDIT)
                .withProtectionMode(
                    new ProtectionMode()
                        .withExe(EnforcementMode.NONE)
                        .withMsi(EnforcementMode.NONE)
                        .withScript(EnforcementMode.NONE)
                        .withExecutable(EnforcementMode.AUDIT))
                .withVmRecommendations(
                    Arrays
                        .asList(
                            new VmRecommendation()
                                .withConfigurationStatus(ConfigurationStatus.NO_STATUS)
                                .withRecommendationAction(RecommendationAction.RECOMMENDED)
                                .withResourceId("hlf")
                                .withEnforcementSupport(EnforcementSupport.SUPPORTED)))
                .withPathRecommendations(
                    Arrays
                        .asList(
                            new PathRecommendation()
                                .withPath("wahfbousnfepgfew")
                                .withAction(RecommendationAction.ADD)
                                .withType(RecommendationType.IO_T_SHARED_CREDENTIALS)
                                .withPublisherInfo(
                                    new PublisherInfo()
                                        .withPublisherName("ncxykxhdjhlimm")
                                        .withProductName("x")
                                        .withBinaryName("bcporxvxcjzhqizx")
                                        .withVersion("xtgqscjavftjuh"))
                                .withCommon(true)
                                .withUserSids(Arrays.asList("mtggu"))
                                .withUsernames(Arrays.asList())
                                .withFileType(FileType.SCRIPT)
                                .withConfigurationStatus(ConfigurationStatus.FAILED)));
        model = BinaryData.fromObject(model).toObject(AdaptiveApplicationControlGroupData.class);
        Assertions.assertEquals(EnforcementMode.AUDIT, model.enforcementMode());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().exe());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().msi());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().script());
        Assertions.assertEquals(EnforcementMode.AUDIT, model.protectionMode().executable());
        Assertions.assertEquals(ConfigurationStatus.NO_STATUS, model.vmRecommendations().get(0).configurationStatus());
        Assertions
            .assertEquals(RecommendationAction.RECOMMENDED, model.vmRecommendations().get(0).recommendationAction());
        Assertions.assertEquals("hlf", model.vmRecommendations().get(0).resourceId());
        Assertions.assertEquals(EnforcementSupport.SUPPORTED, model.vmRecommendations().get(0).enforcementSupport());
        Assertions.assertEquals("wahfbousnfepgfew", model.pathRecommendations().get(0).path());
        Assertions.assertEquals(RecommendationAction.ADD, model.pathRecommendations().get(0).action());
        Assertions.assertEquals(RecommendationType.IO_T_SHARED_CREDENTIALS, model.pathRecommendations().get(0).type());
        Assertions.assertEquals("ncxykxhdjhlimm", model.pathRecommendations().get(0).publisherInfo().publisherName());
        Assertions.assertEquals("x", model.pathRecommendations().get(0).publisherInfo().productName());
        Assertions.assertEquals("bcporxvxcjzhqizx", model.pathRecommendations().get(0).publisherInfo().binaryName());
        Assertions.assertEquals("xtgqscjavftjuh", model.pathRecommendations().get(0).publisherInfo().version());
        Assertions.assertEquals(true, model.pathRecommendations().get(0).common());
        Assertions.assertEquals("mtggu", model.pathRecommendations().get(0).userSids().get(0));
        Assertions.assertEquals(FileType.SCRIPT, model.pathRecommendations().get(0).fileType());
        Assertions.assertEquals(ConfigurationStatus.FAILED, model.pathRecommendations().get(0).configurationStatus());
    }
}
