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

public final class ScanPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScanProperties model =
            BinaryData
                .fromString(
                    "{\"triggerType\":\"Recurring\",\"state\":\"Failed\",\"server\":\"dwwnl\",\"database\":\"fwxudgnhg\",\"sqlVersion\":\"krtalvn\",\"startTime\":\"2021-10-08T14:43:06Z\",\"endTime\":\"2021-07-31T12:16:21Z\",\"highSeverityFailedRulesCount\":518056276,\"mediumSeverityFailedRulesCount\":408640684,\"lowSeverityFailedRulesCount\":1742020192,\"totalPassedRulesCount\":426542999,\"totalFailedRulesCount\":1442817098,\"totalRulesCount\":1323472014,\"isBaselineApplied\":false,\"lastScanTime\":\"2021-08-28T23:34:11Z\"}")
                .toObject(ScanProperties.class);
        Assertions.assertEquals(ScanTriggerType.RECURRING, model.triggerType());
        Assertions.assertEquals(ScanState.FAILED, model.state());
        Assertions.assertEquals("dwwnl", model.server());
        Assertions.assertEquals("fwxudgnhg", model.database());
        Assertions.assertEquals("krtalvn", model.sqlVersion());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-08T14:43:06Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-31T12:16:21Z"), model.endTime());
        Assertions.assertEquals(518056276, model.highSeverityFailedRulesCount());
        Assertions.assertEquals(408640684, model.mediumSeverityFailedRulesCount());
        Assertions.assertEquals(1742020192, model.lowSeverityFailedRulesCount());
        Assertions.assertEquals(426542999, model.totalPassedRulesCount());
        Assertions.assertEquals(1442817098, model.totalFailedRulesCount());
        Assertions.assertEquals(1323472014, model.totalRulesCount());
        Assertions.assertEquals(false, model.isBaselineApplied());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-28T23:34:11Z"), model.lastScanTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScanProperties model =
            new ScanProperties()
                .withTriggerType(ScanTriggerType.RECURRING)
                .withState(ScanState.FAILED)
                .withServer("dwwnl")
                .withDatabase("fwxudgnhg")
                .withSqlVersion("krtalvn")
                .withStartTime(OffsetDateTime.parse("2021-10-08T14:43:06Z"))
                .withEndTime(OffsetDateTime.parse("2021-07-31T12:16:21Z"))
                .withHighSeverityFailedRulesCount(518056276)
                .withMediumSeverityFailedRulesCount(408640684)
                .withLowSeverityFailedRulesCount(1742020192)
                .withTotalPassedRulesCount(426542999)
                .withTotalFailedRulesCount(1442817098)
                .withTotalRulesCount(1323472014)
                .withIsBaselineApplied(false)
                .withLastScanTime(OffsetDateTime.parse("2021-08-28T23:34:11Z"));
        model = BinaryData.fromObject(model).toObject(ScanProperties.class);
        Assertions.assertEquals(ScanTriggerType.RECURRING, model.triggerType());
        Assertions.assertEquals(ScanState.FAILED, model.state());
        Assertions.assertEquals("dwwnl", model.server());
        Assertions.assertEquals("fwxudgnhg", model.database());
        Assertions.assertEquals("krtalvn", model.sqlVersion());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-08T14:43:06Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-31T12:16:21Z"), model.endTime());
        Assertions.assertEquals(518056276, model.highSeverityFailedRulesCount());
        Assertions.assertEquals(408640684, model.mediumSeverityFailedRulesCount());
        Assertions.assertEquals(1742020192, model.lowSeverityFailedRulesCount());
        Assertions.assertEquals(426542999, model.totalPassedRulesCount());
        Assertions.assertEquals(1442817098, model.totalFailedRulesCount());
        Assertions.assertEquals(1323472014, model.totalRulesCount());
        Assertions.assertEquals(false, model.isBaselineApplied());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-28T23:34:11Z"), model.lastScanTime());
    }
}
