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

package com.azure.resourcemanager.datadog.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.datadog.models.FilteringTag;
import com.azure.resourcemanager.datadog.models.LogRules;
import com.azure.resourcemanager.datadog.models.MetricRules;
import com.azure.resourcemanager.datadog.models.MonitoringTagRulesProperties;
import com.azure.resourcemanager.datadog.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\":\"Deleted\",\"logRules\":{\"sendAadLogs\":false,\"sendSubscriptionLogs\":false,\"sendResourceLogs\":true,\"filteringTags\":[{\"name\":\"dptkoenkouk\",\"value\":\"udwtiukbl\",\"action\":\"Exclude\"},{\"name\":\"pocipazyxoegu\",\"value\":\"jnpiucgyg\",\"action\":\"Include\"}]},\"metricRules\":{\"filteringTags\":[{\"name\":\"pmr\",\"value\":\"izcdrqjsd\",\"action\":\"Exclude\"},{\"name\":\"fyhxde\",\"value\":\"jzicwifsjt\",\"action\":\"Exclude\"},{\"name\":\"bishcbkhajdeyea\",\"value\":\"p\",\"action\":\"Include\"},{\"name\":\"lpbuxwgipwhonowk\",\"value\":\"hwankixzbinjepu\",\"action\":\"Include\"}]}}")
                .toObject(MonitoringTagRulesProperties.class);
        Assertions.assertEquals(false, model.logRules().sendAadLogs());
        Assertions.assertEquals(false, model.logRules().sendSubscriptionLogs());
        Assertions.assertEquals(true, model.logRules().sendResourceLogs());
        Assertions.assertEquals("dptkoenkouk", model.logRules().filteringTags().get(0).name());
        Assertions.assertEquals("udwtiukbl", model.logRules().filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.EXCLUDE, model.logRules().filteringTags().get(0).action());
        Assertions.assertEquals("pmr", model.metricRules().filteringTags().get(0).name());
        Assertions.assertEquals("izcdrqjsd", model.metricRules().filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.EXCLUDE, model.metricRules().filteringTags().get(0).action());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MonitoringTagRulesProperties model =
            new MonitoringTagRulesProperties()
                .withLogRules(
                    new LogRules()
                        .withSendAadLogs(false)
                        .withSendSubscriptionLogs(false)
                        .withSendResourceLogs(true)
                        .withFilteringTags(
                            Arrays
                                .asList(
                                    new FilteringTag()
                                        .withName("dptkoenkouk")
                                        .withValue("udwtiukbl")
                                        .withAction(TagAction.EXCLUDE),
                                    new FilteringTag()
                                        .withName("pocipazyxoegu")
                                        .withValue("jnpiucgyg")
                                        .withAction(TagAction.INCLUDE))))
                .withMetricRules(
                    new MetricRules()
                        .withFilteringTags(
                            Arrays
                                .asList(
                                    new FilteringTag()
                                        .withName("pmr")
                                        .withValue("izcdrqjsd")
                                        .withAction(TagAction.EXCLUDE),
                                    new FilteringTag()
                                        .withName("fyhxde")
                                        .withValue("jzicwifsjt")
                                        .withAction(TagAction.EXCLUDE),
                                    new FilteringTag()
                                        .withName("bishcbkhajdeyea")
                                        .withValue("p")
                                        .withAction(TagAction.INCLUDE),
                                    new FilteringTag()
                                        .withName("lpbuxwgipwhonowk")
                                        .withValue("hwankixzbinjepu")
                                        .withAction(TagAction.INCLUDE))));
        model = BinaryData.fromObject(model).toObject(MonitoringTagRulesProperties.class);
        Assertions.assertEquals(false, model.logRules().sendAadLogs());
        Assertions.assertEquals(false, model.logRules().sendSubscriptionLogs());
        Assertions.assertEquals(true, model.logRules().sendResourceLogs());
        Assertions.assertEquals("dptkoenkouk", model.logRules().filteringTags().get(0).name());
        Assertions.assertEquals("udwtiukbl", model.logRules().filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.EXCLUDE, model.logRules().filteringTags().get(0).action());
        Assertions.assertEquals("pmr", model.metricRules().filteringTags().get(0).name());
        Assertions.assertEquals("izcdrqjsd", model.metricRules().filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.EXCLUDE, model.metricRules().filteringTags().get(0).action());
    }
}
