// 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.AutomationProperties;
import com.azure.resourcemanager.security.models.AutomationAction;
import com.azure.resourcemanager.security.models.AutomationScope;
import com.azure.resourcemanager.security.models.AutomationSource;
import com.azure.resourcemanager.security.models.EventSource;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AutomationPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AutomationProperties model =
            BinaryData
                .fromString(
                    "{\"description\":\"irctymoxoftpipiw\",\"isEnabled\":false,\"scopes\":[{\"description\":\"a\",\"scopePath\":\"qjlihhyuspska\"},{\"description\":\"vlmfwdgzxulucv\",\"scopePath\":\"mrsreuzvxurisjnh\"},{\"description\":\"txifqj\",\"scopePath\":\"xmrhu\"},{\"description\":\"wp\",\"scopePath\":\"sutrgjup\"}],\"sources\":[{\"eventSource\":\"SubAssessmentsSnapshot\",\"ruleSets\":[]},{\"eventSource\":\"RegulatoryComplianceAssessment\",\"ruleSets\":[]},{\"eventSource\":\"Alerts\",\"ruleSets\":[]},{\"eventSource\":\"RegulatoryComplianceAssessmentSnapshot\",\"ruleSets\":[]}],\"actions\":[{\"actionType\":\"AutomationAction\"},{\"actionType\":\"AutomationAction\"},{\"actionType\":\"AutomationAction\"},{\"actionType\":\"AutomationAction\"}]}")
                .toObject(AutomationProperties.class);
        Assertions.assertEquals("irctymoxoftpipiw", model.description());
        Assertions.assertEquals(false, model.isEnabled());
        Assertions.assertEquals("a", model.scopes().get(0).description());
        Assertions.assertEquals("qjlihhyuspska", model.scopes().get(0).scopePath());
        Assertions.assertEquals(EventSource.SUB_ASSESSMENTS_SNAPSHOT, model.sources().get(0).eventSource());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AutomationProperties model =
            new AutomationProperties()
                .withDescription("irctymoxoftpipiw")
                .withIsEnabled(false)
                .withScopes(
                    Arrays
                        .asList(
                            new AutomationScope().withDescription("a").withScopePath("qjlihhyuspska"),
                            new AutomationScope().withDescription("vlmfwdgzxulucv").withScopePath("mrsreuzvxurisjnh"),
                            new AutomationScope().withDescription("txifqj").withScopePath("xmrhu"),
                            new AutomationScope().withDescription("wp").withScopePath("sutrgjup")))
                .withSources(
                    Arrays
                        .asList(
                            new AutomationSource()
                                .withEventSource(EventSource.SUB_ASSESSMENTS_SNAPSHOT)
                                .withRuleSets(Arrays.asList()),
                            new AutomationSource()
                                .withEventSource(EventSource.REGULATORY_COMPLIANCE_ASSESSMENT)
                                .withRuleSets(Arrays.asList()),
                            new AutomationSource().withEventSource(EventSource.ALERTS).withRuleSets(Arrays.asList()),
                            new AutomationSource()
                                .withEventSource(EventSource.REGULATORY_COMPLIANCE_ASSESSMENT_SNAPSHOT)
                                .withRuleSets(Arrays.asList())))
                .withActions(
                    Arrays
                        .asList(
                            new AutomationAction(),
                            new AutomationAction(),
                            new AutomationAction(),
                            new AutomationAction()));
        model = BinaryData.fromObject(model).toObject(AutomationProperties.class);
        Assertions.assertEquals("irctymoxoftpipiw", model.description());
        Assertions.assertEquals(false, model.isEnabled());
        Assertions.assertEquals("a", model.scopes().get(0).description());
        Assertions.assertEquals("qjlihhyuspska", model.scopes().get(0).scopePath());
        Assertions.assertEquals(EventSource.SUB_ASSESSMENTS_SNAPSHOT, model.sources().get(0).eventSource());
    }
}
