// 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.GovernanceRuleInner;
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 GovernanceRuleInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        GovernanceRuleInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"tenantId\":\"liufiqwoyxq\",\"displayName\":\"apcohhouc\",\"description\":\"q\",\"remediationTimeframe\":\"xcxzrzdcgdzben\",\"isGracePeriod\":false,\"rulePriority\":314467274,\"isDisabled\":true,\"ruleType\":\"Integrated\",\"sourceResourceType\":\"Assessments\",\"excludedScopes\":[\"ddtjwfljhznam\"],\"conditionSets\":[\"dataatmzw\",\"datajj\",\"datacqtjzmi\",\"datavgbgatzuuvbxng\"],\"includeMemberScopes\":false,\"ownerSource\":{\"type\":\"ByTag\",\"value\":\"ahttzlswvajqfut\"},\"governanceEmailNotification\":{\"disableManagerEmailNotification\":false,\"disableOwnerEmailNotification\":true},\"metadata\":{\"createdBy\":\"unwqr\",\"createdOn\":\"2021-01-05T19:17:25Z\",\"updatedBy\":\"gqhaohcmbuocn\",\"updatedOn\":\"2021-05-14T07:13:07Z\"}},\"id\":\"hmbpyryxamebly\",\"name\":\"yvk\",\"type\":\"kmrocxne\"}")
                .toObject(GovernanceRuleInner.class);
        Assertions.assertEquals("apcohhouc", model.displayName());
        Assertions.assertEquals("q", model.description());
        Assertions.assertEquals("xcxzrzdcgdzben", model.remediationTimeframe());
        Assertions.assertEquals(false, model.isGracePeriod());
        Assertions.assertEquals(314467274, model.rulePriority());
        Assertions.assertEquals(true, model.isDisabled());
        Assertions.assertEquals(GovernanceRuleType.INTEGRATED, model.ruleType());
        Assertions.assertEquals(GovernanceRuleSourceResourceType.ASSESSMENTS, model.sourceResourceType());
        Assertions.assertEquals("ddtjwfljhznam", model.excludedScopes().get(0));
        Assertions.assertEquals(false, model.includeMemberScopes());
        Assertions.assertEquals(GovernanceRuleOwnerSourceType.BY_TAG, model.ownerSource().type());
        Assertions.assertEquals("ahttzlswvajqfut", 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 {
        GovernanceRuleInner model =
            new GovernanceRuleInner()
                .withDisplayName("apcohhouc")
                .withDescription("q")
                .withRemediationTimeframe("xcxzrzdcgdzben")
                .withIsGracePeriod(false)
                .withRulePriority(314467274)
                .withIsDisabled(true)
                .withRuleType(GovernanceRuleType.INTEGRATED)
                .withSourceResourceType(GovernanceRuleSourceResourceType.ASSESSMENTS)
                .withExcludedScopes(Arrays.asList("ddtjwfljhznam"))
                .withConditionSets(Arrays.asList("dataatmzw", "datajj", "datacqtjzmi", "datavgbgatzuuvbxng"))
                .withIncludeMemberScopes(false)
                .withOwnerSource(
                    new GovernanceRuleOwnerSource()
                        .withType(GovernanceRuleOwnerSourceType.BY_TAG)
                        .withValue("ahttzlswvajqfut"))
                .withGovernanceEmailNotification(
                    new GovernanceRuleEmailNotification()
                        .withDisableManagerEmailNotification(false)
                        .withDisableOwnerEmailNotification(true))
                .withMetadata(new GovernanceRuleMetadata());
        model = BinaryData.fromObject(model).toObject(GovernanceRuleInner.class);
        Assertions.assertEquals("apcohhouc", model.displayName());
        Assertions.assertEquals("q", model.description());
        Assertions.assertEquals("xcxzrzdcgdzben", model.remediationTimeframe());
        Assertions.assertEquals(false, model.isGracePeriod());
        Assertions.assertEquals(314467274, model.rulePriority());
        Assertions.assertEquals(true, model.isDisabled());
        Assertions.assertEquals(GovernanceRuleType.INTEGRATED, model.ruleType());
        Assertions.assertEquals(GovernanceRuleSourceResourceType.ASSESSMENTS, model.sourceResourceType());
        Assertions.assertEquals("ddtjwfljhznam", model.excludedScopes().get(0));
        Assertions.assertEquals(false, model.includeMemberScopes());
        Assertions.assertEquals(GovernanceRuleOwnerSourceType.BY_TAG, model.ownerSource().type());
        Assertions.assertEquals("ahttzlswvajqfut", model.ownerSource().value());
        Assertions.assertEquals(false, model.governanceEmailNotification().disableManagerEmailNotification());
        Assertions.assertEquals(true, model.governanceEmailNotification().disableOwnerEmailNotification());
    }
}
