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

package com.azure.resourcemanager.frontdoor.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.frontdoor.fluent.models.RulesEngineProperties;
import com.azure.resourcemanager.frontdoor.models.MatchProcessingBehavior;
import com.azure.resourcemanager.frontdoor.models.RulesEngineAction;
import com.azure.resourcemanager.frontdoor.models.RulesEngineRule;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RulesEnginePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RulesEngineProperties model =
            BinaryData
                .fromString(
                    "{\"resourceState\":\"Deleting\",\"rules\":[{\"name\":\"mtxpsiebtfh\",\"priority\":1543115619,\"action\":{\"requestHeaderActions\":[],\"responseHeaderActions\":[]},\"matchConditions\":[],\"matchProcessingBehavior\":\"Stop\"},{\"name\":\"dqmh\",\"priority\":1058725142,\"action\":{\"requestHeaderActions\":[],\"responseHeaderActions\":[]},\"matchConditions\":[],\"matchProcessingBehavior\":\"Continue\"},{\"name\":\"yzxuutkncw\",\"priority\":355088461,\"action\":{\"requestHeaderActions\":[],\"responseHeaderActions\":[]},\"matchConditions\":[],\"matchProcessingBehavior\":\"Continue\"}]}")
                .toObject(RulesEngineProperties.class);
        Assertions.assertEquals("mtxpsiebtfh", model.rules().get(0).name());
        Assertions.assertEquals(1543115619, model.rules().get(0).priority());
        Assertions.assertEquals(MatchProcessingBehavior.STOP, model.rules().get(0).matchProcessingBehavior());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RulesEngineProperties model =
            new RulesEngineProperties()
                .withRules(
                    Arrays
                        .asList(
                            new RulesEngineRule()
                                .withName("mtxpsiebtfh")
                                .withPriority(1543115619)
                                .withAction(
                                    new RulesEngineAction()
                                        .withRequestHeaderActions(Arrays.asList())
                                        .withResponseHeaderActions(Arrays.asList()))
                                .withMatchConditions(Arrays.asList())
                                .withMatchProcessingBehavior(MatchProcessingBehavior.STOP),
                            new RulesEngineRule()
                                .withName("dqmh")
                                .withPriority(1058725142)
                                .withAction(
                                    new RulesEngineAction()
                                        .withRequestHeaderActions(Arrays.asList())
                                        .withResponseHeaderActions(Arrays.asList()))
                                .withMatchConditions(Arrays.asList())
                                .withMatchProcessingBehavior(MatchProcessingBehavior.CONTINUE),
                            new RulesEngineRule()
                                .withName("yzxuutkncw")
                                .withPriority(355088461)
                                .withAction(
                                    new RulesEngineAction()
                                        .withRequestHeaderActions(Arrays.asList())
                                        .withResponseHeaderActions(Arrays.asList()))
                                .withMatchConditions(Arrays.asList())
                                .withMatchProcessingBehavior(MatchProcessingBehavior.CONTINUE)));
        model = BinaryData.fromObject(model).toObject(RulesEngineProperties.class);
        Assertions.assertEquals("mtxpsiebtfh", model.rules().get(0).name());
        Assertions.assertEquals(1543115619, model.rules().get(0).priority());
        Assertions.assertEquals(MatchProcessingBehavior.STOP, model.rules().get(0).matchProcessingBehavior());
    }
}
