// 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.MetricRules;
import com.azure.resourcemanager.datadog.models.TagAction;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class MetricRulesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MetricRules model =
            BinaryData
                .fromString(
                    "{\"filteringTags\":[{\"name\":\"xzko\",\"value\":\"cukoklyaxuconu\",\"action\":\"Include\"},{\"name\":\"kbeype\",\"value\":\"mjmwvvjektcx\",\"action\":\"Exclude\"}]}")
                .toObject(MetricRules.class);
        Assertions.assertEquals("xzko", model.filteringTags().get(0).name());
        Assertions.assertEquals("cukoklyaxuconu", model.filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.INCLUDE, model.filteringTags().get(0).action());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MetricRules model =
            new MetricRules()
                .withFilteringTags(
                    Arrays
                        .asList(
                            new FilteringTag()
                                .withName("xzko")
                                .withValue("cukoklyaxuconu")
                                .withAction(TagAction.INCLUDE),
                            new FilteringTag()
                                .withName("kbeype")
                                .withValue("mjmwvvjektcx")
                                .withAction(TagAction.EXCLUDE)));
        model = BinaryData.fromObject(model).toObject(MetricRules.class);
        Assertions.assertEquals("xzko", model.filteringTags().get(0).name());
        Assertions.assertEquals("cukoklyaxuconu", model.filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.INCLUDE, model.filteringTags().get(0).action());
    }
}
