// 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.RulesEngineInner;
import com.azure.resourcemanager.frontdoor.models.MatchProcessingBehavior;
import com.azure.resourcemanager.frontdoor.models.RulesEngineRule;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RulesEngineInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RulesEngineInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"resourceState\":\"Enabled\",\"rules\":[{\"name\":\"lpvlopw\",\"priority\":1665401728,\"matchConditions\":[],\"matchProcessingBehavior\":\"Continue\"},{\"name\":\"xpkd\",\"priority\":344801541,\"matchConditions\":[],\"matchProcessingBehavior\":\"Stop\"}]},\"id\":\"uebbaumnyqup\",\"name\":\"deoj\",\"type\":\"a\"}")
                .toObject(RulesEngineInner.class);
        Assertions.assertEquals("lpvlopw", model.rules().get(0).name());
        Assertions.assertEquals(1665401728, model.rules().get(0).priority());
        Assertions.assertEquals(MatchProcessingBehavior.CONTINUE, model.rules().get(0).matchProcessingBehavior());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RulesEngineInner model =
            new RulesEngineInner()
                .withRules(
                    Arrays
                        .asList(
                            new RulesEngineRule()
                                .withName("lpvlopw")
                                .withPriority(1665401728)
                                .withMatchConditions(Arrays.asList())
                                .withMatchProcessingBehavior(MatchProcessingBehavior.CONTINUE),
                            new RulesEngineRule()
                                .withName("xpkd")
                                .withPriority(344801541)
                                .withMatchConditions(Arrays.asList())
                                .withMatchProcessingBehavior(MatchProcessingBehavior.STOP)));
        model = BinaryData.fromObject(model).toObject(RulesEngineInner.class);
        Assertions.assertEquals("lpvlopw", model.rules().get(0).name());
        Assertions.assertEquals(1665401728, model.rules().get(0).priority());
        Assertions.assertEquals(MatchProcessingBehavior.CONTINUE, model.rules().get(0).matchProcessingBehavior());
    }
}
