// 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.MatchCondition;
import com.azure.resourcemanager.frontdoor.models.MatchVariable;
import com.azure.resourcemanager.frontdoor.models.Operator;
import com.azure.resourcemanager.frontdoor.models.TransformType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class MatchConditionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MatchCondition model =
            BinaryData
                .fromString(
                    "{\"matchVariable\":\"RequestHeader\",\"selector\":\"vpjhulsuuv\",\"operator\":\"GreaterThan\",\"negateCondition\":true,\"matchValue\":[\"k\",\"wfndiodjpsl\"],\"transforms\":[\"UrlDecode\",\"Uppercase\"]}")
                .toObject(MatchCondition.class);
        Assertions.assertEquals(MatchVariable.REQUEST_HEADER, model.matchVariable());
        Assertions.assertEquals("vpjhulsuuv", model.selector());
        Assertions.assertEquals(Operator.GREATER_THAN, model.operator());
        Assertions.assertEquals(true, model.negateCondition());
        Assertions.assertEquals("k", model.matchValue().get(0));
        Assertions.assertEquals(TransformType.URL_DECODE, model.transforms().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MatchCondition model =
            new MatchCondition()
                .withMatchVariable(MatchVariable.REQUEST_HEADER)
                .withSelector("vpjhulsuuv")
                .withOperator(Operator.GREATER_THAN)
                .withNegateCondition(true)
                .withMatchValue(Arrays.asList("k", "wfndiodjpsl"))
                .withTransforms(Arrays.asList(TransformType.URL_DECODE, TransformType.UPPERCASE));
        model = BinaryData.fromObject(model).toObject(MatchCondition.class);
        Assertions.assertEquals(MatchVariable.REQUEST_HEADER, model.matchVariable());
        Assertions.assertEquals("vpjhulsuuv", model.selector());
        Assertions.assertEquals(Operator.GREATER_THAN, model.operator());
        Assertions.assertEquals(true, model.negateCondition());
        Assertions.assertEquals("k", model.matchValue().get(0));
        Assertions.assertEquals(TransformType.URL_DECODE, model.transforms().get(0));
    }
}
