// 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.Baseline;
import com.azure.resourcemanager.security.models.BaselineAdjustedResult;
import com.azure.resourcemanager.security.models.BenchmarkReference;
import com.azure.resourcemanager.security.models.QueryCheck;
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.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ScanResultPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScanResultProperties model =
            BinaryData
                .fromString(
                    "{\"ruleId\":\"tywatmqaq\",\"status\":\"InternalError\",\"isTrimmed\":false,\"queryResults\":[[\"eshoygzcb\",\"fqxkfaoyteh\",\"puvjmvqmtd\",\"ckygroejnndljdju\"],[\"br\"],[\"qyn\"]],\"remediation\":{\"description\":\"ysfaqegplwrysh\",\"scripts\":[\"kvb\"],\"automated\":true,\"portalLink\":\"usybwptdaca\"},\"baselineAdjustedResult\":{\"baseline\":{\"expectedResults\":[[]],\"updatedTime\":\"2021-11-02T10:29:39Z\"},\"status\":\"NonFinding\",\"resultsNotInBaseline\":[[\"iwenazero\",\"zrsq\",\"lsxkd\",\"wqapfgsdp\"]],\"resultsOnlyInBaseline\":[[\"smzhhkuuipldqqct\",\"kva\",\"blhtjq\"],[\"yvwehtaemxh\"],[\"ysev\",\"sxivzrrryvei\",\"ipsk\"]]},\"ruleMetadata\":{\"ruleId\":\"atvfuzkaftj\",\"severity\":\"High\",\"category\":\"xwigsye\",\"ruleType\":\"BaselineExpected\",\"title\":\"smjtgrqgdg\",\"description\":\"ileplk\",\"rationale\":\"mknhwtbbaedor\",\"queryCheck\":{\"query\":\"qfloygbdgwum\",\"expectedResult\":[[],[],[]],\"columnNames\":[\"hpabgdexjddvjs\"]},\"benchmarkReferences\":[{\"benchmark\":\"tm\",\"reference\":\"llcolsrsxapte\"},{\"benchmark\":\"excgjokjljnhvl\",\"reference\":\"bekpeeksnbksdqhj\"},{\"benchmark\":\"klxesl\",\"reference\":\"hustcpoqmavnwqjw\"},{\"benchmark\":\"knlejjjkxybwfd\",\"reference\":\"jbzten\"}]}}")
                .toObject(ScanResultProperties.class);
        Assertions.assertEquals("tywatmqaq", model.ruleId());
        Assertions.assertEquals(RuleStatus.INTERNAL_ERROR, model.status());
        Assertions.assertEquals(false, model.isTrimmed());
        Assertions.assertEquals("eshoygzcb", model.queryResults().get(0).get(0));
        Assertions.assertEquals("ysfaqegplwrysh", model.remediation().description());
        Assertions.assertEquals("kvb", model.remediation().scripts().get(0));
        Assertions.assertEquals(true, model.remediation().automated());
        Assertions.assertEquals("usybwptdaca", model.remediation().portalLink());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-02T10:29:39Z"), model.baselineAdjustedResult().baseline().updatedTime());
        Assertions.assertEquals(RuleStatus.NON_FINDING, model.baselineAdjustedResult().status());
        Assertions.assertEquals("iwenazero", model.baselineAdjustedResult().resultsNotInBaseline().get(0).get(0));
        Assertions
            .assertEquals("smzhhkuuipldqqct", model.baselineAdjustedResult().resultsOnlyInBaseline().get(0).get(0));
        Assertions.assertEquals("atvfuzkaftj", model.ruleMetadata().ruleId());
        Assertions.assertEquals(RuleSeverity.HIGH, model.ruleMetadata().severity());
        Assertions.assertEquals("xwigsye", model.ruleMetadata().category());
        Assertions.assertEquals(RuleType.BASELINE_EXPECTED, model.ruleMetadata().ruleType());
        Assertions.assertEquals("smjtgrqgdg", model.ruleMetadata().title());
        Assertions.assertEquals("ileplk", model.ruleMetadata().description());
        Assertions.assertEquals("mknhwtbbaedor", model.ruleMetadata().rationale());
        Assertions.assertEquals("qfloygbdgwum", model.ruleMetadata().queryCheck().query());
        Assertions.assertEquals("hpabgdexjddvjs", model.ruleMetadata().queryCheck().columnNames().get(0));
        Assertions.assertEquals("tm", model.ruleMetadata().benchmarkReferences().get(0).benchmark());
        Assertions.assertEquals("llcolsrsxapte", model.ruleMetadata().benchmarkReferences().get(0).reference());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScanResultProperties model =
            new ScanResultProperties()
                .withRuleId("tywatmqaq")
                .withStatus(RuleStatus.INTERNAL_ERROR)
                .withIsTrimmed(false)
                .withQueryResults(
                    Arrays
                        .asList(
                            Arrays.asList("eshoygzcb", "fqxkfaoyteh", "puvjmvqmtd", "ckygroejnndljdju"),
                            Arrays.asList("br"),
                            Arrays.asList("qyn")))
                .withRemediation(
                    new Remediation()
                        .withDescription("ysfaqegplwrysh")
                        .withScripts(Arrays.asList("kvb"))
                        .withAutomated(true)
                        .withPortalLink("usybwptdaca"))
                .withBaselineAdjustedResult(
                    new BaselineAdjustedResult()
                        .withBaseline(
                            new Baseline()
                                .withExpectedResults(Arrays.asList(Arrays.asList()))
                                .withUpdatedTime(OffsetDateTime.parse("2021-11-02T10:29:39Z")))
                        .withStatus(RuleStatus.NON_FINDING)
                        .withResultsNotInBaseline(
                            Arrays.asList(Arrays.asList("iwenazero", "zrsq", "lsxkd", "wqapfgsdp")))
                        .withResultsOnlyInBaseline(
                            Arrays
                                .asList(
                                    Arrays.asList("smzhhkuuipldqqct", "kva", "blhtjq"),
                                    Arrays.asList("yvwehtaemxh"),
                                    Arrays.asList("ysev", "sxivzrrryvei", "ipsk"))))
                .withRuleMetadata(
                    new VaRule()
                        .withRuleId("atvfuzkaftj")
                        .withSeverity(RuleSeverity.HIGH)
                        .withCategory("xwigsye")
                        .withRuleType(RuleType.BASELINE_EXPECTED)
                        .withTitle("smjtgrqgdg")
                        .withDescription("ileplk")
                        .withRationale("mknhwtbbaedor")
                        .withQueryCheck(
                            new QueryCheck()
                                .withQuery("qfloygbdgwum")
                                .withExpectedResult(Arrays.asList(Arrays.asList(), Arrays.asList(), Arrays.asList()))
                                .withColumnNames(Arrays.asList("hpabgdexjddvjs")))
                        .withBenchmarkReferences(
                            Arrays
                                .asList(
                                    new BenchmarkReference().withBenchmark("tm").withReference("llcolsrsxapte"),
                                    new BenchmarkReference()
                                        .withBenchmark("excgjokjljnhvl")
                                        .withReference("bekpeeksnbksdqhj"),
                                    new BenchmarkReference().withBenchmark("klxesl").withReference("hustcpoqmavnwqjw"),
                                    new BenchmarkReference().withBenchmark("knlejjjkxybwfd").withReference("jbzten"))));
        model = BinaryData.fromObject(model).toObject(ScanResultProperties.class);
        Assertions.assertEquals("tywatmqaq", model.ruleId());
        Assertions.assertEquals(RuleStatus.INTERNAL_ERROR, model.status());
        Assertions.assertEquals(false, model.isTrimmed());
        Assertions.assertEquals("eshoygzcb", model.queryResults().get(0).get(0));
        Assertions.assertEquals("ysfaqegplwrysh", model.remediation().description());
        Assertions.assertEquals("kvb", model.remediation().scripts().get(0));
        Assertions.assertEquals(true, model.remediation().automated());
        Assertions.assertEquals("usybwptdaca", model.remediation().portalLink());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-02T10:29:39Z"), model.baselineAdjustedResult().baseline().updatedTime());
        Assertions.assertEquals(RuleStatus.NON_FINDING, model.baselineAdjustedResult().status());
        Assertions.assertEquals("iwenazero", model.baselineAdjustedResult().resultsNotInBaseline().get(0).get(0));
        Assertions
            .assertEquals("smzhhkuuipldqqct", model.baselineAdjustedResult().resultsOnlyInBaseline().get(0).get(0));
        Assertions.assertEquals("atvfuzkaftj", model.ruleMetadata().ruleId());
        Assertions.assertEquals(RuleSeverity.HIGH, model.ruleMetadata().severity());
        Assertions.assertEquals("xwigsye", model.ruleMetadata().category());
        Assertions.assertEquals(RuleType.BASELINE_EXPECTED, model.ruleMetadata().ruleType());
        Assertions.assertEquals("smjtgrqgdg", model.ruleMetadata().title());
        Assertions.assertEquals("ileplk", model.ruleMetadata().description());
        Assertions.assertEquals("mknhwtbbaedor", model.ruleMetadata().rationale());
        Assertions.assertEquals("qfloygbdgwum", model.ruleMetadata().queryCheck().query());
        Assertions.assertEquals("hpabgdexjddvjs", model.ruleMetadata().queryCheck().columnNames().get(0));
        Assertions.assertEquals("tm", model.ruleMetadata().benchmarkReferences().get(0).benchmark());
        Assertions.assertEquals("llcolsrsxapte", model.ruleMetadata().benchmarkReferences().get(0).reference());
    }
}
