// 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.GovernanceRuleProperties;
import com.azure.resourcemanager.security.models.GovernanceRuleEmailNotification;
import com.azure.resourcemanager.security.models.GovernanceRuleMetadata;
import com.azure.resourcemanager.security.models.GovernanceRuleOwnerSource;
import com.azure.resourcemanager.security.models.GovernanceRuleOwnerSourceType;
import com.azure.resourcemanager.security.models.GovernanceRuleSourceResourceType;
import com.azure.resourcemanager.security.models.GovernanceRuleType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class GovernanceRulePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        GovernanceRuleProperties model =
            BinaryData
                .fromString(
                    "{\"tenantId\":\"sm\",\"displayName\":\"odlfpyapucygvo\",\"description\":\"yunssx\",\"remediationTimeframe\":\"hi\",\"isGracePeriod\":true,\"rulePriority\":230828821,\"isDisabled\":false,\"ruleType\":\"Integrated\",\"sourceResourceType\":\"Assessments\",\"excludedScopes\":[\"seksgbux\",\"ntuygdhgaqipir\",\"iwrqofulopmjnl\",\"x\"],\"conditionSets\":[\"datacbjpibkephuu\",\"dataerctatoyin\"],\"includeMemberScopes\":true,\"ownerSource\":{\"type\":\"ByTag\",\"value\":\"cyrduczkg\"},\"governanceEmailNotification\":{\"disableManagerEmailNotification\":false,\"disableOwnerEmailNotification\":true},\"metadata\":{\"createdBy\":\"cvcrrp\",\"createdOn\":\"2021-06-14T17:45:27Z\",\"updatedBy\":\"bstvje\",\"updatedOn\":\"2021-06-06T13:44:54Z\"}}")
                .toObject(GovernanceRuleProperties.class);
        Assertions.assertEquals("odlfpyapucygvo", model.displayName());
        Assertions.assertEquals("yunssx", model.description());
        Assertions.assertEquals("hi", model.remediationTimeframe());
        Assertions.assertEquals(true, model.isGracePeriod());
        Assertions.assertEquals(230828821, model.rulePriority());
        Assertions.assertEquals(false, model.isDisabled());
        Assertions.assertEquals(GovernanceRuleType.INTEGRATED, model.ruleType());
        Assertions.assertEquals(GovernanceRuleSourceResourceType.ASSESSMENTS, model.sourceResourceType());
        Assertions.assertEquals("seksgbux", model.excludedScopes().get(0));
        Assertions.assertEquals(true, model.includeMemberScopes());
        Assertions.assertEquals(GovernanceRuleOwnerSourceType.BY_TAG, model.ownerSource().type());
        Assertions.assertEquals("cyrduczkg", model.ownerSource().value());
        Assertions.assertEquals(false, model.governanceEmailNotification().disableManagerEmailNotification());
        Assertions.assertEquals(true, model.governanceEmailNotification().disableOwnerEmailNotification());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        GovernanceRuleProperties model =
            new GovernanceRuleProperties()
                .withDisplayName("odlfpyapucygvo")
                .withDescription("yunssx")
                .withRemediationTimeframe("hi")
                .withIsGracePeriod(true)
                .withRulePriority(230828821)
                .withIsDisabled(false)
                .withRuleType(GovernanceRuleType.INTEGRATED)
                .withSourceResourceType(GovernanceRuleSourceResourceType.ASSESSMENTS)
                .withExcludedScopes(Arrays.asList("seksgbux", "ntuygdhgaqipir", "iwrqofulopmjnl", "x"))
                .withConditionSets(Arrays.asList("datacbjpibkephuu", "dataerctatoyin"))
                .withIncludeMemberScopes(true)
                .withOwnerSource(
                    new GovernanceRuleOwnerSource()
                        .withType(GovernanceRuleOwnerSourceType.BY_TAG)
                        .withValue("cyrduczkg"))
                .withGovernanceEmailNotification(
                    new GovernanceRuleEmailNotification()
                        .withDisableManagerEmailNotification(false)
                        .withDisableOwnerEmailNotification(true))
                .withMetadata(new GovernanceRuleMetadata());
        model = BinaryData.fromObject(model).toObject(GovernanceRuleProperties.class);
        Assertions.assertEquals("odlfpyapucygvo", model.displayName());
        Assertions.assertEquals("yunssx", model.description());
        Assertions.assertEquals("hi", model.remediationTimeframe());
        Assertions.assertEquals(true, model.isGracePeriod());
        Assertions.assertEquals(230828821, model.rulePriority());
        Assertions.assertEquals(false, model.isDisabled());
        Assertions.assertEquals(GovernanceRuleType.INTEGRATED, model.ruleType());
        Assertions.assertEquals(GovernanceRuleSourceResourceType.ASSESSMENTS, model.sourceResourceType());
        Assertions.assertEquals("seksgbux", model.excludedScopes().get(0));
        Assertions.assertEquals(true, model.includeMemberScopes());
        Assertions.assertEquals(GovernanceRuleOwnerSourceType.BY_TAG, model.ownerSource().type());
        Assertions.assertEquals("cyrduczkg", model.ownerSource().value());
        Assertions.assertEquals(false, model.governanceEmailNotification().disableManagerEmailNotification());
        Assertions.assertEquals(true, model.governanceEmailNotification().disableOwnerEmailNotification());
    }
}
