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

package com.azure.resourcemanager.newrelicobservability.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.newrelicobservability.fluent.models.MetricRulesInner;
import com.azure.resourcemanager.newrelicobservability.models.FilteringTag;
import com.azure.resourcemanager.newrelicobservability.models.SendMetricsStatus;
import com.azure.resourcemanager.newrelicobservability.models.TagAction;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class MetricRulesInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MetricRulesInner model =
            BinaryData
                .fromString(
                    "{\"sendMetrics\":\"Enabled\",\"filteringTags\":[{\"name\":\"m\",\"value\":\"qabcypm\",\"action\":\"Exclude\"},{\"name\":\"lzu\",\"value\":\"c\",\"action\":\"Exclude\"},{\"name\":\"nbacfi\",\"value\":\"l\",\"action\":\"Include\"},{\"name\":\"tqgtzxdpnqbqq\",\"value\":\"rjfeallnwsubisnj\",\"action\":\"Include\"}],\"userEmail\":\"ngnzscxaqwoochc\"}")
                .toObject(MetricRulesInner.class);
        Assertions.assertEquals(SendMetricsStatus.ENABLED, model.sendMetrics());
        Assertions.assertEquals("m", model.filteringTags().get(0).name());
        Assertions.assertEquals("qabcypm", model.filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.EXCLUDE, model.filteringTags().get(0).action());
        Assertions.assertEquals("ngnzscxaqwoochc", model.userEmail());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MetricRulesInner model =
            new MetricRulesInner()
                .withSendMetrics(SendMetricsStatus.ENABLED)
                .withFilteringTags(
                    Arrays
                        .asList(
                            new FilteringTag().withName("m").withValue("qabcypm").withAction(TagAction.EXCLUDE),
                            new FilteringTag().withName("lzu").withValue("c").withAction(TagAction.EXCLUDE),
                            new FilteringTag().withName("nbacfi").withValue("l").withAction(TagAction.INCLUDE),
                            new FilteringTag()
                                .withName("tqgtzxdpnqbqq")
                                .withValue("rjfeallnwsubisnj")
                                .withAction(TagAction.INCLUDE)))
                .withUserEmail("ngnzscxaqwoochc");
        model = BinaryData.fromObject(model).toObject(MetricRulesInner.class);
        Assertions.assertEquals(SendMetricsStatus.ENABLED, model.sendMetrics());
        Assertions.assertEquals("m", model.filteringTags().get(0).name());
        Assertions.assertEquals("qabcypm", model.filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.EXCLUDE, model.filteringTags().get(0).action());
        Assertions.assertEquals("ngnzscxaqwoochc", model.userEmail());
    }
}
