// 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.ScanInner;
import com.azure.resourcemanager.security.fluent.models.ScansInner;
import com.azure.resourcemanager.security.models.ScanProperties;
import com.azure.resourcemanager.security.models.ScanState;
import com.azure.resourcemanager.security.models.ScanTriggerType;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ScansInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScansInner model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"triggerType\":\"Recurring\",\"state\":\"FailedToRun\",\"server\":\"xhqf\",\"database\":\"nvzoqgyipemch\",\"sqlVersion\":\"v\",\"startTime\":\"2021-05-29T11:47:50Z\",\"endTime\":\"2021-06-19T08:23:04Z\",\"highSeverityFailedRulesCount\":734341991,\"mediumSeverityFailedRulesCount\":345092138,\"lowSeverityFailedRulesCount\":791767971,\"totalPassedRulesCount\":1804607166,\"totalFailedRulesCount\":1022480930,\"totalRulesCount\":855952943,\"isBaselineApplied\":true,\"lastScanTime\":\"2021-07-01T01:57:52Z\"},\"id\":\"jjstliuhqawmo\",\"name\":\"ia\",\"type\":\"cz\"}]}")
                .toObject(ScansInner.class);
        Assertions.assertEquals(ScanTriggerType.RECURRING, model.value().get(0).properties().triggerType());
        Assertions.assertEquals(ScanState.FAILED_TO_RUN, model.value().get(0).properties().state());
        Assertions.assertEquals("xhqf", model.value().get(0).properties().server());
        Assertions.assertEquals("nvzoqgyipemch", model.value().get(0).properties().database());
        Assertions.assertEquals("v", model.value().get(0).properties().sqlVersion());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-05-29T11:47:50Z"), model.value().get(0).properties().startTime());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-06-19T08:23:04Z"), model.value().get(0).properties().endTime());
        Assertions.assertEquals(734341991, model.value().get(0).properties().highSeverityFailedRulesCount());
        Assertions.assertEquals(345092138, model.value().get(0).properties().mediumSeverityFailedRulesCount());
        Assertions.assertEquals(791767971, model.value().get(0).properties().lowSeverityFailedRulesCount());
        Assertions.assertEquals(1804607166, model.value().get(0).properties().totalPassedRulesCount());
        Assertions.assertEquals(1022480930, model.value().get(0).properties().totalFailedRulesCount());
        Assertions.assertEquals(855952943, model.value().get(0).properties().totalRulesCount());
        Assertions.assertEquals(true, model.value().get(0).properties().isBaselineApplied());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-07-01T01:57:52Z"), model.value().get(0).properties().lastScanTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScansInner model =
            new ScansInner()
                .withValue(
                    Arrays
                        .asList(
                            new ScanInner()
                                .withProperties(
                                    new ScanProperties()
                                        .withTriggerType(ScanTriggerType.RECURRING)
                                        .withState(ScanState.FAILED_TO_RUN)
                                        .withServer("xhqf")
                                        .withDatabase("nvzoqgyipemch")
                                        .withSqlVersion("v")
                                        .withStartTime(OffsetDateTime.parse("2021-05-29T11:47:50Z"))
                                        .withEndTime(OffsetDateTime.parse("2021-06-19T08:23:04Z"))
                                        .withHighSeverityFailedRulesCount(734341991)
                                        .withMediumSeverityFailedRulesCount(345092138)
                                        .withLowSeverityFailedRulesCount(791767971)
                                        .withTotalPassedRulesCount(1804607166)
                                        .withTotalFailedRulesCount(1022480930)
                                        .withTotalRulesCount(855952943)
                                        .withIsBaselineApplied(true)
                                        .withLastScanTime(OffsetDateTime.parse("2021-07-01T01:57:52Z")))));
        model = BinaryData.fromObject(model).toObject(ScansInner.class);
        Assertions.assertEquals(ScanTriggerType.RECURRING, model.value().get(0).properties().triggerType());
        Assertions.assertEquals(ScanState.FAILED_TO_RUN, model.value().get(0).properties().state());
        Assertions.assertEquals("xhqf", model.value().get(0).properties().server());
        Assertions.assertEquals("nvzoqgyipemch", model.value().get(0).properties().database());
        Assertions.assertEquals("v", model.value().get(0).properties().sqlVersion());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-05-29T11:47:50Z"), model.value().get(0).properties().startTime());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-06-19T08:23:04Z"), model.value().get(0).properties().endTime());
        Assertions.assertEquals(734341991, model.value().get(0).properties().highSeverityFailedRulesCount());
        Assertions.assertEquals(345092138, model.value().get(0).properties().mediumSeverityFailedRulesCount());
        Assertions.assertEquals(791767971, model.value().get(0).properties().lowSeverityFailedRulesCount());
        Assertions.assertEquals(1804607166, model.value().get(0).properties().totalPassedRulesCount());
        Assertions.assertEquals(1022480930, model.value().get(0).properties().totalFailedRulesCount());
        Assertions.assertEquals(855952943, model.value().get(0).properties().totalRulesCount());
        Assertions.assertEquals(true, model.value().get(0).properties().isBaselineApplied());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-07-01T01:57:52Z"), model.value().get(0).properties().lastScanTime());
    }
}
