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

package com.azure.resourcemanager.costmanagement.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.costmanagement.models.OperatorType;
import com.azure.resourcemanager.costmanagement.models.ReportConfigComparisonExpression;
import com.azure.resourcemanager.costmanagement.models.ReportConfigFilter;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ReportConfigFilterTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ReportConfigFilter model =
            BinaryData
                .fromString(
                    "{\"and\":[{\"and\":[],\"or\":[],\"dimensions\":{\"name\":\"krlkhbzhfepg\",\"operator\":\"Contains\",\"values\":[]},\"tags\":{\"name\":\"e\",\"operator\":\"In\",\"values\":[]}}],\"or\":[{\"and\":[],\"or\":[],\"dimensions\":{\"name\":\"aierhhb\",\"operator\":\"In\",\"values\":[]},\"tags\":{\"name\":\"l\",\"operator\":\"Contains\",\"values\":[]}},{\"and\":[],\"or\":[],\"dimensions\":{\"name\":\"aodxo\",\"operator\":\"In\",\"values\":[]},\"tags\":{\"name\":\"dxkqpx\",\"operator\":\"Contains\",\"values\":[]}},{\"and\":[],\"or\":[],\"dimensions\":{\"name\":\"pimexgstxgcpodg\",\"operator\":\"In\",\"values\":[]},\"tags\":{\"name\":\"jrmvdjwzrlo\",\"operator\":\"In\",\"values\":[]}},{\"and\":[],\"or\":[],\"dimensions\":{\"name\":\"j\",\"operator\":\"Contains\",\"values\":[]},\"tags\":{\"name\":\"jctbza\",\"operator\":\"In\",\"values\":[]}}],\"dimensions\":{\"name\":\"sycbkbfk\",\"operator\":\"Contains\",\"values\":[\"dkexxppofm\",\"axcfjpgddtocjjx\"]},\"tags\":{\"name\":\"pmouexhdz\",\"operator\":\"In\",\"values\":[\"qeojnxqbzvddntw\"]}}")
                .toObject(ReportConfigFilter.class);
        Assertions.assertEquals("krlkhbzhfepg", model.and().get(0).dimensions().name());
        Assertions.assertEquals(OperatorType.CONTAINS, model.and().get(0).dimensions().operator());
        Assertions.assertEquals("e", model.and().get(0).tags().name());
        Assertions.assertEquals(OperatorType.IN, model.and().get(0).tags().operator());
        Assertions.assertEquals("aierhhb", model.or().get(0).dimensions().name());
        Assertions.assertEquals(OperatorType.IN, model.or().get(0).dimensions().operator());
        Assertions.assertEquals("l", model.or().get(0).tags().name());
        Assertions.assertEquals(OperatorType.CONTAINS, model.or().get(0).tags().operator());
        Assertions.assertEquals("sycbkbfk", model.dimensions().name());
        Assertions.assertEquals(OperatorType.CONTAINS, model.dimensions().operator());
        Assertions.assertEquals("dkexxppofm", model.dimensions().values().get(0));
        Assertions.assertEquals("pmouexhdz", model.tags().name());
        Assertions.assertEquals(OperatorType.IN, model.tags().operator());
        Assertions.assertEquals("qeojnxqbzvddntw", model.tags().values().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ReportConfigFilter model =
            new ReportConfigFilter()
                .withAnd(
                    Arrays
                        .asList(
                            new ReportConfigFilter()
                                .withAnd(Arrays.asList())
                                .withOr(Arrays.asList())
                                .withDimensions(
                                    new ReportConfigComparisonExpression()
                                        .withName("krlkhbzhfepg")
                                        .withOperator(OperatorType.CONTAINS)
                                        .withValues(Arrays.asList()))
                                .withTags(
                                    new ReportConfigComparisonExpression()
                                        .withName("e")
                                        .withOperator(OperatorType.IN)
                                        .withValues(Arrays.asList()))))
                .withOr(
                    Arrays
                        .asList(
                            new ReportConfigFilter()
                                .withAnd(Arrays.asList())
                                .withOr(Arrays.asList())
                                .withDimensions(
                                    new ReportConfigComparisonExpression()
                                        .withName("aierhhb")
                                        .withOperator(OperatorType.IN)
                                        .withValues(Arrays.asList()))
                                .withTags(
                                    new ReportConfigComparisonExpression()
                                        .withName("l")
                                        .withOperator(OperatorType.CONTAINS)
                                        .withValues(Arrays.asList())),
                            new ReportConfigFilter()
                                .withAnd(Arrays.asList())
                                .withOr(Arrays.asList())
                                .withDimensions(
                                    new ReportConfigComparisonExpression()
                                        .withName("aodxo")
                                        .withOperator(OperatorType.IN)
                                        .withValues(Arrays.asList()))
                                .withTags(
                                    new ReportConfigComparisonExpression()
                                        .withName("dxkqpx")
                                        .withOperator(OperatorType.CONTAINS)
                                        .withValues(Arrays.asList())),
                            new ReportConfigFilter()
                                .withAnd(Arrays.asList())
                                .withOr(Arrays.asList())
                                .withDimensions(
                                    new ReportConfigComparisonExpression()
                                        .withName("pimexgstxgcpodg")
                                        .withOperator(OperatorType.IN)
                                        .withValues(Arrays.asList()))
                                .withTags(
                                    new ReportConfigComparisonExpression()
                                        .withName("jrmvdjwzrlo")
                                        .withOperator(OperatorType.IN)
                                        .withValues(Arrays.asList())),
                            new ReportConfigFilter()
                                .withAnd(Arrays.asList())
                                .withOr(Arrays.asList())
                                .withDimensions(
                                    new ReportConfigComparisonExpression()
                                        .withName("j")
                                        .withOperator(OperatorType.CONTAINS)
                                        .withValues(Arrays.asList()))
                                .withTags(
                                    new ReportConfigComparisonExpression()
                                        .withName("jctbza")
                                        .withOperator(OperatorType.IN)
                                        .withValues(Arrays.asList()))))
                .withDimensions(
                    new ReportConfigComparisonExpression()
                        .withName("sycbkbfk")
                        .withOperator(OperatorType.CONTAINS)
                        .withValues(Arrays.asList("dkexxppofm", "axcfjpgddtocjjx")))
                .withTags(
                    new ReportConfigComparisonExpression()
                        .withName("pmouexhdz")
                        .withOperator(OperatorType.IN)
                        .withValues(Arrays.asList("qeojnxqbzvddntw")));
        model = BinaryData.fromObject(model).toObject(ReportConfigFilter.class);
        Assertions.assertEquals("krlkhbzhfepg", model.and().get(0).dimensions().name());
        Assertions.assertEquals(OperatorType.CONTAINS, model.and().get(0).dimensions().operator());
        Assertions.assertEquals("e", model.and().get(0).tags().name());
        Assertions.assertEquals(OperatorType.IN, model.and().get(0).tags().operator());
        Assertions.assertEquals("aierhhb", model.or().get(0).dimensions().name());
        Assertions.assertEquals(OperatorType.IN, model.or().get(0).dimensions().operator());
        Assertions.assertEquals("l", model.or().get(0).tags().name());
        Assertions.assertEquals(OperatorType.CONTAINS, model.or().get(0).tags().operator());
        Assertions.assertEquals("sycbkbfk", model.dimensions().name());
        Assertions.assertEquals(OperatorType.CONTAINS, model.dimensions().operator());
        Assertions.assertEquals("dkexxppofm", model.dimensions().values().get(0));
        Assertions.assertEquals("pmouexhdz", model.tags().name());
        Assertions.assertEquals(OperatorType.IN, model.tags().operator());
        Assertions.assertEquals("qeojnxqbzvddntw", model.tags().values().get(0));
    }
}
