// 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.ScanResultInner;
import com.azure.resourcemanager.security.models.BaselineAdjustedResult;
import com.azure.resourcemanager.security.models.Remediation;
import com.azure.resourcemanager.security.models.RuleSeverity;
import com.azure.resourcemanager.security.models.RuleStatus;
import com.azure.resourcemanager.security.models.RuleType;
import com.azure.resourcemanager.security.models.ScanResultProperties;
import com.azure.resourcemanager.security.models.VaRule;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ScanResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScanResultInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"ruleId\":\"drrslblxydk\",\"status\":\"InternalError\",\"isTrimmed\":true,\"queryResults\":[[\"wkgfbqljnqkh\",\"chocokulehur\",\"lrqff\"],[\"eyu\",\"kphyjdxrav\",\"uqd\"],[\"xmrgchbapxkiy\",\"jjk\",\"ajb\"]],\"remediation\":{\"description\":\"gd\",\"scripts\":[\"ioycbl\",\"vpmclujyxkyxlz\",\"sjgkzzltafh\",\"zffovwmbjl\"],\"automated\":true,\"portalLink\":\"zpgvdwnapfd\"},\"baselineAdjustedResult\":{\"status\":\"Finding\",\"resultsNotInBaseline\":[[],[],[],[]],\"resultsOnlyInBaseline\":[[]]},\"ruleMetadata\":{\"ruleId\":\"jtks\",\"severity\":\"Medium\",\"category\":\"gqy\",\"ruleType\":\"BaselineExpected\",\"title\":\"eyqrhv\",\"description\":\"ldotjvdkwisws\",\"rationale\":\"kjtasb\",\"benchmarkReferences\":[]}},\"id\":\"pkxkdtxfk\",\"name\":\"dlqvtwknvg\",\"type\":\"mb\"}")
                .toObject(ScanResultInner.class);
        Assertions.assertEquals("drrslblxydk", model.properties().ruleId());
        Assertions.assertEquals(RuleStatus.INTERNAL_ERROR, model.properties().status());
        Assertions.assertEquals(true, model.properties().isTrimmed());
        Assertions.assertEquals("wkgfbqljnqkh", model.properties().queryResults().get(0).get(0));
        Assertions.assertEquals("gd", model.properties().remediation().description());
        Assertions.assertEquals("ioycbl", model.properties().remediation().scripts().get(0));
        Assertions.assertEquals(true, model.properties().remediation().automated());
        Assertions.assertEquals("zpgvdwnapfd", model.properties().remediation().portalLink());
        Assertions.assertEquals(RuleStatus.FINDING, model.properties().baselineAdjustedResult().status());
        Assertions.assertEquals("jtks", model.properties().ruleMetadata().ruleId());
        Assertions.assertEquals(RuleSeverity.MEDIUM, model.properties().ruleMetadata().severity());
        Assertions.assertEquals("gqy", model.properties().ruleMetadata().category());
        Assertions.assertEquals(RuleType.BASELINE_EXPECTED, model.properties().ruleMetadata().ruleType());
        Assertions.assertEquals("eyqrhv", model.properties().ruleMetadata().title());
        Assertions.assertEquals("ldotjvdkwisws", model.properties().ruleMetadata().description());
        Assertions.assertEquals("kjtasb", model.properties().ruleMetadata().rationale());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScanResultInner model =
            new ScanResultInner()
                .withProperties(
                    new ScanResultProperties()
                        .withRuleId("drrslblxydk")
                        .withStatus(RuleStatus.INTERNAL_ERROR)
                        .withIsTrimmed(true)
                        .withQueryResults(
                            Arrays
                                .asList(
                                    Arrays.asList("wkgfbqljnqkh", "chocokulehur", "lrqff"),
                                    Arrays.asList("eyu", "kphyjdxrav", "uqd"),
                                    Arrays.asList("xmrgchbapxkiy", "jjk", "ajb")))
                        .withRemediation(
                            new Remediation()
                                .withDescription("gd")
                                .withScripts(Arrays.asList("ioycbl", "vpmclujyxkyxlz", "sjgkzzltafh", "zffovwmbjl"))
                                .withAutomated(true)
                                .withPortalLink("zpgvdwnapfd"))
                        .withBaselineAdjustedResult(
                            new BaselineAdjustedResult()
                                .withStatus(RuleStatus.FINDING)
                                .withResultsNotInBaseline(
                                    Arrays.asList(Arrays.asList(), Arrays.asList(), Arrays.asList(), Arrays.asList()))
                                .withResultsOnlyInBaseline(Arrays.asList(Arrays.asList())))
                        .withRuleMetadata(
                            new VaRule()
                                .withRuleId("jtks")
                                .withSeverity(RuleSeverity.MEDIUM)
                                .withCategory("gqy")
                                .withRuleType(RuleType.BASELINE_EXPECTED)
                                .withTitle("eyqrhv")
                                .withDescription("ldotjvdkwisws")
                                .withRationale("kjtasb")
                                .withBenchmarkReferences(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(ScanResultInner.class);
        Assertions.assertEquals("drrslblxydk", model.properties().ruleId());
        Assertions.assertEquals(RuleStatus.INTERNAL_ERROR, model.properties().status());
        Assertions.assertEquals(true, model.properties().isTrimmed());
        Assertions.assertEquals("wkgfbqljnqkh", model.properties().queryResults().get(0).get(0));
        Assertions.assertEquals("gd", model.properties().remediation().description());
        Assertions.assertEquals("ioycbl", model.properties().remediation().scripts().get(0));
        Assertions.assertEquals(true, model.properties().remediation().automated());
        Assertions.assertEquals("zpgvdwnapfd", model.properties().remediation().portalLink());
        Assertions.assertEquals(RuleStatus.FINDING, model.properties().baselineAdjustedResult().status());
        Assertions.assertEquals("jtks", model.properties().ruleMetadata().ruleId());
        Assertions.assertEquals(RuleSeverity.MEDIUM, model.properties().ruleMetadata().severity());
        Assertions.assertEquals("gqy", model.properties().ruleMetadata().category());
        Assertions.assertEquals(RuleType.BASELINE_EXPECTED, model.properties().ruleMetadata().ruleType());
        Assertions.assertEquals("eyqrhv", model.properties().ruleMetadata().title());
        Assertions.assertEquals("ldotjvdkwisws", model.properties().ruleMetadata().description());
        Assertions.assertEquals("kjtasb", model.properties().ruleMetadata().rationale());
    }
}
