// 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.HeaderAction;
import com.azure.resourcemanager.frontdoor.models.HeaderActionType;
import com.azure.resourcemanager.frontdoor.models.RouteConfiguration;
import com.azure.resourcemanager.frontdoor.models.RulesEngineAction;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RulesEngineActionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RulesEngineAction model =
            BinaryData
                .fromString(
                    "{\"requestHeaderActions\":[{\"headerActionType\":\"Delete\",\"headerName\":\"beldawkzbaliourq\",\"value\":\"kauhashsfwxo\"},{\"headerActionType\":\"Overwrite\",\"headerName\":\"w\",\"value\":\"cugicjoox\"}],\"responseHeaderActions\":[{\"headerActionType\":\"Delete\",\"headerName\":\"wpucwwfvovbv\",\"value\":\"uecivyhz\"},{\"headerActionType\":\"Append\",\"headerName\":\"uojgj\",\"value\":\"jueiotwmcdytd\"},{\"headerActionType\":\"Append\",\"headerName\":\"it\",\"value\":\"rjaw\"}],\"routeConfigurationOverride\":{\"@odata.type\":\"RouteConfiguration\"}}")
                .toObject(RulesEngineAction.class);
        Assertions.assertEquals(HeaderActionType.DELETE, model.requestHeaderActions().get(0).headerActionType());
        Assertions.assertEquals("beldawkzbaliourq", model.requestHeaderActions().get(0).headerName());
        Assertions.assertEquals("kauhashsfwxo", model.requestHeaderActions().get(0).value());
        Assertions.assertEquals(HeaderActionType.DELETE, model.responseHeaderActions().get(0).headerActionType());
        Assertions.assertEquals("wpucwwfvovbv", model.responseHeaderActions().get(0).headerName());
        Assertions.assertEquals("uecivyhz", model.responseHeaderActions().get(0).value());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RulesEngineAction model =
            new RulesEngineAction()
                .withRequestHeaderActions(
                    Arrays
                        .asList(
                            new HeaderAction()
                                .withHeaderActionType(HeaderActionType.DELETE)
                                .withHeaderName("beldawkzbaliourq")
                                .withValue("kauhashsfwxo"),
                            new HeaderAction()
                                .withHeaderActionType(HeaderActionType.OVERWRITE)
                                .withHeaderName("w")
                                .withValue("cugicjoox")))
                .withResponseHeaderActions(
                    Arrays
                        .asList(
                            new HeaderAction()
                                .withHeaderActionType(HeaderActionType.DELETE)
                                .withHeaderName("wpucwwfvovbv")
                                .withValue("uecivyhz"),
                            new HeaderAction()
                                .withHeaderActionType(HeaderActionType.APPEND)
                                .withHeaderName("uojgj")
                                .withValue("jueiotwmcdytd"),
                            new HeaderAction()
                                .withHeaderActionType(HeaderActionType.APPEND)
                                .withHeaderName("it")
                                .withValue("rjaw")))
                .withRouteConfigurationOverride(new RouteConfiguration());
        model = BinaryData.fromObject(model).toObject(RulesEngineAction.class);
        Assertions.assertEquals(HeaderActionType.DELETE, model.requestHeaderActions().get(0).headerActionType());
        Assertions.assertEquals("beldawkzbaliourq", model.requestHeaderActions().get(0).headerName());
        Assertions.assertEquals("kauhashsfwxo", model.requestHeaderActions().get(0).value());
        Assertions.assertEquals(HeaderActionType.DELETE, model.responseHeaderActions().get(0).headerActionType());
        Assertions.assertEquals("wpucwwfvovbv", model.responseHeaderActions().get(0).headerName());
        Assertions.assertEquals("uecivyhz", model.responseHeaderActions().get(0).value());
    }
}
