// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.elastic.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.elastic.models.FilteringTag;
import com.azure.resourcemanager.elastic.models.LogRules;
import com.azure.resourcemanager.elastic.models.MonitoringTagRulesProperties;
import com.azure.resourcemanager.elastic.models.ProvisioningState;
import com.azure.resourcemanager.elastic.models.TagAction;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class MonitoringTagRulesPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MonitoringTagRulesProperties model =
            BinaryData
                .fromString(
                    "{\"provisioningState\":\"Deleting\",\"logRules\":{\"sendAadLogs\":false,\"sendSubscriptionLogs\":false,\"sendActivityLogs\":false,\"filteringTags\":[{\"name\":\"tqajzyulpkudjkrl\",\"value\":\"bzhfepgzgqexz\",\"action\":\"Include\"},{\"name\":\"scpai\",\"value\":\"hhbcsglummajtjao\",\"action\":\"Exclude\"},{\"name\":\"nbdxk\",\"value\":\"xo\",\"action\":\"Exclude\"}]}}")
                .toObject(MonitoringTagRulesProperties.class);
        Assertions.assertEquals(ProvisioningState.DELETING, model.provisioningState());
        Assertions.assertEquals(false, model.logRules().sendAadLogs());
        Assertions.assertEquals(false, model.logRules().sendSubscriptionLogs());
        Assertions.assertEquals(false, model.logRules().sendActivityLogs());
        Assertions.assertEquals("tqajzyulpkudjkrl", model.logRules().filteringTags().get(0).name());
        Assertions.assertEquals("bzhfepgzgqexz", model.logRules().filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.INCLUDE, model.logRules().filteringTags().get(0).action());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MonitoringTagRulesProperties model =
            new MonitoringTagRulesProperties()
                .withProvisioningState(ProvisioningState.DELETING)
                .withLogRules(
                    new LogRules()
                        .withSendAadLogs(false)
                        .withSendSubscriptionLogs(false)
                        .withSendActivityLogs(false)
                        .withFilteringTags(
                            Arrays
                                .asList(
                                    new FilteringTag()
                                        .withName("tqajzyulpkudjkrl")
                                        .withValue("bzhfepgzgqexz")
                                        .withAction(TagAction.INCLUDE),
                                    new FilteringTag()
                                        .withName("scpai")
                                        .withValue("hhbcsglummajtjao")
                                        .withAction(TagAction.EXCLUDE),
                                    new FilteringTag()
                                        .withName("nbdxk")
                                        .withValue("xo")
                                        .withAction(TagAction.EXCLUDE))));
        model = BinaryData.fromObject(model).toObject(MonitoringTagRulesProperties.class);
        Assertions.assertEquals(ProvisioningState.DELETING, model.provisioningState());
        Assertions.assertEquals(false, model.logRules().sendAadLogs());
        Assertions.assertEquals(false, model.logRules().sendSubscriptionLogs());
        Assertions.assertEquals(false, model.logRules().sendActivityLogs());
        Assertions.assertEquals("tqajzyulpkudjkrl", model.logRules().filteringTags().get(0).name());
        Assertions.assertEquals("bzhfepgzgqexz", model.logRules().filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.INCLUDE, model.logRules().filteringTags().get(0).action());
    }
}
