// 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.models.FilteringTag;
import com.azure.resourcemanager.newrelicobservability.models.LogRules;
import com.azure.resourcemanager.newrelicobservability.models.SendAadLogsStatus;
import com.azure.resourcemanager.newrelicobservability.models.SendActivityLogsStatus;
import com.azure.resourcemanager.newrelicobservability.models.SendSubscriptionLogsStatus;
import com.azure.resourcemanager.newrelicobservability.models.TagAction;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class LogRulesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LogRules model =
            BinaryData
                .fromString(
                    "{\"sendAadLogs\":\"Enabled\",\"sendSubscriptionLogs\":\"Enabled\",\"sendActivityLogs\":\"Disabled\",\"filteringTags\":[{\"name\":\"gyxzk\",\"value\":\"ocukoklyax\",\"action\":\"Include\"},{\"name\":\"uqszfk\",\"value\":\"ypewrmjmwvvjekt\",\"action\":\"Include\"},{\"name\":\"nhwlrsffrzpwvl\",\"value\":\"q\",\"action\":\"Exclude\"},{\"name\":\"ylihkaetckt\",\"value\":\"civfsnkymuctq\",\"action\":\"Exclude\"}]}")
                .toObject(LogRules.class);
        Assertions.assertEquals(SendAadLogsStatus.ENABLED, model.sendAadLogs());
        Assertions.assertEquals(SendSubscriptionLogsStatus.ENABLED, model.sendSubscriptionLogs());
        Assertions.assertEquals(SendActivityLogsStatus.DISABLED, model.sendActivityLogs());
        Assertions.assertEquals("gyxzk", model.filteringTags().get(0).name());
        Assertions.assertEquals("ocukoklyax", model.filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.INCLUDE, model.filteringTags().get(0).action());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LogRules model =
            new LogRules()
                .withSendAadLogs(SendAadLogsStatus.ENABLED)
                .withSendSubscriptionLogs(SendSubscriptionLogsStatus.ENABLED)
                .withSendActivityLogs(SendActivityLogsStatus.DISABLED)
                .withFilteringTags(
                    Arrays
                        .asList(
                            new FilteringTag().withName("gyxzk").withValue("ocukoklyax").withAction(TagAction.INCLUDE),
                            new FilteringTag()
                                .withName("uqszfk")
                                .withValue("ypewrmjmwvvjekt")
                                .withAction(TagAction.INCLUDE),
                            new FilteringTag().withName("nhwlrsffrzpwvl").withValue("q").withAction(TagAction.EXCLUDE),
                            new FilteringTag()
                                .withName("ylihkaetckt")
                                .withValue("civfsnkymuctq")
                                .withAction(TagAction.EXCLUDE)));
        model = BinaryData.fromObject(model).toObject(LogRules.class);
        Assertions.assertEquals(SendAadLogsStatus.ENABLED, model.sendAadLogs());
        Assertions.assertEquals(SendSubscriptionLogsStatus.ENABLED, model.sendSubscriptionLogs());
        Assertions.assertEquals(SendActivityLogsStatus.DISABLED, model.sendActivityLogs());
        Assertions.assertEquals("gyxzk", model.filteringTags().get(0).name());
        Assertions.assertEquals("ocukoklyax", model.filteringTags().get(0).value());
        Assertions.assertEquals(TagAction.INCLUDE, model.filteringTags().get(0).action());
    }
}
