// 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.models.RulesEngineMatchCondition;
import com.azure.resourcemanager.frontdoor.models.RulesEngineMatchVariable;
import com.azure.resourcemanager.frontdoor.models.RulesEngineOperator;
import com.azure.resourcemanager.frontdoor.models.Transform;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RulesEngineMatchConditionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RulesEngineMatchCondition model =
            BinaryData
                .fromString(
                    "{\"rulesEngineMatchVariable\":\"IsMobile\",\"selector\":\"wndnhj\",\"rulesEngineOperator\":\"Any\",\"negateCondition\":false,\"rulesEngineMatchValue\":[\"vylwzbtdhxuj\",\"nbmpowuwprzq\"],\"transforms\":[\"Lowercase\",\"Trim\",\"Trim\"]}")
                .toObject(RulesEngineMatchCondition.class);
        Assertions.assertEquals(RulesEngineMatchVariable.IS_MOBILE, model.rulesEngineMatchVariable());
        Assertions.assertEquals("wndnhj", model.selector());
        Assertions.assertEquals(RulesEngineOperator.ANY, model.rulesEngineOperator());
        Assertions.assertEquals(false, model.negateCondition());
        Assertions.assertEquals("vylwzbtdhxuj", model.rulesEngineMatchValue().get(0));
        Assertions.assertEquals(Transform.LOWERCASE, model.transforms().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RulesEngineMatchCondition model =
            new RulesEngineMatchCondition()
                .withRulesEngineMatchVariable(RulesEngineMatchVariable.IS_MOBILE)
                .withSelector("wndnhj")
                .withRulesEngineOperator(RulesEngineOperator.ANY)
                .withNegateCondition(false)
                .withRulesEngineMatchValue(Arrays.asList("vylwzbtdhxuj", "nbmpowuwprzq"))
                .withTransforms(Arrays.asList(Transform.LOWERCASE, Transform.TRIM, Transform.TRIM));
        model = BinaryData.fromObject(model).toObject(RulesEngineMatchCondition.class);
        Assertions.assertEquals(RulesEngineMatchVariable.IS_MOBILE, model.rulesEngineMatchVariable());
        Assertions.assertEquals("wndnhj", model.selector());
        Assertions.assertEquals(RulesEngineOperator.ANY, model.rulesEngineOperator());
        Assertions.assertEquals(false, model.negateCondition());
        Assertions.assertEquals("vylwzbtdhxuj", model.rulesEngineMatchValue().get(0));
        Assertions.assertEquals(Transform.LOWERCASE, model.transforms().get(0));
    }
}
