// 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.AdaptiveApplicationControlGroupInner;
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.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 AdaptiveApplicationControlGroupInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AdaptiveApplicationControlGroupInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"enforcementMode\":\"Enforce\",\"protectionMode\":{\"exe\":\"Audit\",\"msi\":\"Enforce\",\"script\":\"None\",\"executable\":\"Audit\"},\"configurationStatus\":\"Configured\",\"recommendationStatus\":\"NoStatus\",\"issues\":[{\"issue\":\"ExecutableViolationsAudited\",\"numberOfVms\":81.69838},{\"issue\":\"ExecutableViolationsAudited\",\"numberOfVms\":25.884687},{\"issue\":\"ViolationsBlocked\",\"numberOfVms\":0.6237805}],\"sourceSystem\":\"None\",\"vmRecommendations\":[{\"configurationStatus\":\"Failed\",\"recommendationAction\":\"Remove\",\"resourceId\":\"hlabrq\",\"enforcementSupport\":\"Unknown\"},{\"configurationStatus\":\"NoStatus\",\"recommendationAction\":\"Recommended\",\"resourceId\":\"trgaehvv\",\"enforcementSupport\":\"NotSupported\"},{\"configurationStatus\":\"NoStatus\",\"recommendationAction\":\"Remove\",\"resourceId\":\"oqbeitpkxzt\",\"enforcementSupport\":\"Supported\"},{\"configurationStatus\":\"InProgress\",\"recommendationAction\":\"Remove\",\"resourceId\":\"idgfc\",\"enforcementSupport\":\"NotSupported\"}],\"pathRecommendations\":[{\"path\":\"aqxzhemjyho\",\"action\":\"Remove\",\"type\":\"IoT_EdgeLoggingOptions\",\"common\":true,\"userSids\":[],\"usernames\":[],\"fileType\":\"Script\",\"configurationStatus\":\"Configured\"}]},\"location\":\"kb\",\"id\":\"wpfaj\",\"name\":\"jwltlwtjjgu\",\"type\":\"talhsnvkcdmxzr\"}")
                .toObject(AdaptiveApplicationControlGroupInner.class);
        Assertions.assertEquals(EnforcementMode.ENFORCE, model.enforcementMode());
        Assertions.assertEquals(EnforcementMode.AUDIT, model.protectionMode().exe());
        Assertions.assertEquals(EnforcementMode.ENFORCE, model.protectionMode().msi());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().script());
        Assertions.assertEquals(EnforcementMode.AUDIT, model.protectionMode().executable());
        Assertions.assertEquals(ConfigurationStatus.FAILED, model.vmRecommendations().get(0).configurationStatus());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.vmRecommendations().get(0).recommendationAction());
        Assertions.assertEquals("hlabrq", model.vmRecommendations().get(0).resourceId());
        Assertions.assertEquals(EnforcementSupport.UNKNOWN, model.vmRecommendations().get(0).enforcementSupport());
        Assertions.assertEquals("aqxzhemjyho", model.pathRecommendations().get(0).path());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.pathRecommendations().get(0).action());
        Assertions
            .assertEquals(RecommendationType.IO_T_EDGE_LOGGING_OPTIONS, model.pathRecommendations().get(0).type());
        Assertions.assertEquals(true, model.pathRecommendations().get(0).common());
        Assertions.assertEquals(FileType.SCRIPT, model.pathRecommendations().get(0).fileType());
        Assertions
            .assertEquals(ConfigurationStatus.CONFIGURED, model.pathRecommendations().get(0).configurationStatus());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AdaptiveApplicationControlGroupInner model =
            new AdaptiveApplicationControlGroupInner()
                .withEnforcementMode(EnforcementMode.ENFORCE)
                .withProtectionMode(
                    new ProtectionMode()
                        .withExe(EnforcementMode.AUDIT)
                        .withMsi(EnforcementMode.ENFORCE)
                        .withScript(EnforcementMode.NONE)
                        .withExecutable(EnforcementMode.AUDIT))
                .withVmRecommendations(
                    Arrays
                        .asList(
                            new VmRecommendation()
                                .withConfigurationStatus(ConfigurationStatus.FAILED)
                                .withRecommendationAction(RecommendationAction.REMOVE)
                                .withResourceId("hlabrq")
                                .withEnforcementSupport(EnforcementSupport.UNKNOWN),
                            new VmRecommendation()
                                .withConfigurationStatus(ConfigurationStatus.NO_STATUS)
                                .withRecommendationAction(RecommendationAction.RECOMMENDED)
                                .withResourceId("trgaehvv")
                                .withEnforcementSupport(EnforcementSupport.NOT_SUPPORTED),
                            new VmRecommendation()
                                .withConfigurationStatus(ConfigurationStatus.NO_STATUS)
                                .withRecommendationAction(RecommendationAction.REMOVE)
                                .withResourceId("oqbeitpkxzt")
                                .withEnforcementSupport(EnforcementSupport.SUPPORTED),
                            new VmRecommendation()
                                .withConfigurationStatus(ConfigurationStatus.IN_PROGRESS)
                                .withRecommendationAction(RecommendationAction.REMOVE)
                                .withResourceId("idgfc")
                                .withEnforcementSupport(EnforcementSupport.NOT_SUPPORTED)))
                .withPathRecommendations(
                    Arrays
                        .asList(
                            new PathRecommendation()
                                .withPath("aqxzhemjyho")
                                .withAction(RecommendationAction.REMOVE)
                                .withType(RecommendationType.IO_T_EDGE_LOGGING_OPTIONS)
                                .withCommon(true)
                                .withUserSids(Arrays.asList())
                                .withUsernames(Arrays.asList())
                                .withFileType(FileType.SCRIPT)
                                .withConfigurationStatus(ConfigurationStatus.CONFIGURED)));
        model = BinaryData.fromObject(model).toObject(AdaptiveApplicationControlGroupInner.class);
        Assertions.assertEquals(EnforcementMode.ENFORCE, model.enforcementMode());
        Assertions.assertEquals(EnforcementMode.AUDIT, model.protectionMode().exe());
        Assertions.assertEquals(EnforcementMode.ENFORCE, model.protectionMode().msi());
        Assertions.assertEquals(EnforcementMode.NONE, model.protectionMode().script());
        Assertions.assertEquals(EnforcementMode.AUDIT, model.protectionMode().executable());
        Assertions.assertEquals(ConfigurationStatus.FAILED, model.vmRecommendations().get(0).configurationStatus());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.vmRecommendations().get(0).recommendationAction());
        Assertions.assertEquals("hlabrq", model.vmRecommendations().get(0).resourceId());
        Assertions.assertEquals(EnforcementSupport.UNKNOWN, model.vmRecommendations().get(0).enforcementSupport());
        Assertions.assertEquals("aqxzhemjyho", model.pathRecommendations().get(0).path());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.pathRecommendations().get(0).action());
        Assertions
            .assertEquals(RecommendationType.IO_T_EDGE_LOGGING_OPTIONS, model.pathRecommendations().get(0).type());
        Assertions.assertEquals(true, model.pathRecommendations().get(0).common());
        Assertions.assertEquals(FileType.SCRIPT, model.pathRecommendations().get(0).fileType());
        Assertions
            .assertEquals(ConfigurationStatus.CONFIGURED, model.pathRecommendations().get(0).configurationStatus());
    }
}
