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

package com.azure.resourcemanager.managednetworkfabric.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managednetworkfabric.models.ActionIpCommunityProperties;
import com.azure.resourcemanager.managednetworkfabric.models.ActionIpExtendedCommunityProperties;
import com.azure.resourcemanager.managednetworkfabric.models.IpCommunityIdList;
import com.azure.resourcemanager.managednetworkfabric.models.IpExtendedCommunityIdList;
import com.azure.resourcemanager.managednetworkfabric.models.RoutePolicyActionType;
import com.azure.resourcemanager.managednetworkfabric.models.StatementActionProperties;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class StatementActionPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StatementActionProperties model =
            BinaryData
                .fromString(
                    "{\"localPreference\":2144559147599140910,\"actionType\":\"Deny\",\"ipCommunityProperties\":{\"delete\":{\"ipCommunityIds\":[\"hbcycgqakcsihxvt\",\"cwwfopxp\",\"yxnsbubwh\",\"qqgugwluxahtq\"]},\"set\":{\"ipCommunityIds\":[\"hwq\",\"qwebagm\",\"pkephujeucosvkke\"]},\"add\":{\"ipCommunityIds\":[\"ypaxpjp\",\"illgnu\",\"ezfpffbuqxkn\"]}},\"ipExtendedCommunityProperties\":{\"delete\":{\"ipExtendedCommunityIds\":[\"bg\",\"yojfchicpare\",\"zoksgqhb\"]},\"set\":{\"ipExtendedCommunityIds\":[\"xilozblkcrfldfl\",\"wtkbptsflot\"]},\"add\":{\"ipExtendedCommunityIds\":[\"wgftshfgmuxuqia\"]}}}")
                .toObject(StatementActionProperties.class);
        Assertions.assertEquals(2144559147599140910L, model.localPreference());
        Assertions.assertEquals(RoutePolicyActionType.DENY, model.actionType());
        Assertions.assertEquals("ypaxpjp", model.ipCommunityProperties().add().ipCommunityIds().get(0));
        Assertions.assertEquals("hbcycgqakcsihxvt", model.ipCommunityProperties().delete().ipCommunityIds().get(0));
        Assertions.assertEquals("hwq", model.ipCommunityProperties().set().ipCommunityIds().get(0));
        Assertions
            .assertEquals(
                "wgftshfgmuxuqia", model.ipExtendedCommunityProperties().add().ipExtendedCommunityIds().get(0));
        Assertions.assertEquals("bg", model.ipExtendedCommunityProperties().delete().ipExtendedCommunityIds().get(0));
        Assertions
            .assertEquals(
                "xilozblkcrfldfl", model.ipExtendedCommunityProperties().set().ipExtendedCommunityIds().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StatementActionProperties model =
            new StatementActionProperties()
                .withLocalPreference(2144559147599140910L)
                .withActionType(RoutePolicyActionType.DENY)
                .withIpCommunityProperties(
                    new ActionIpCommunityProperties()
                        .withAdd(
                            new IpCommunityIdList()
                                .withIpCommunityIds(Arrays.asList("ypaxpjp", "illgnu", "ezfpffbuqxkn")))
                        .withDelete(
                            new IpCommunityIdList()
                                .withIpCommunityIds(
                                    Arrays.asList("hbcycgqakcsihxvt", "cwwfopxp", "yxnsbubwh", "qqgugwluxahtq")))
                        .withSet(
                            new IpCommunityIdList()
                                .withIpCommunityIds(Arrays.asList("hwq", "qwebagm", "pkephujeucosvkke"))))
                .withIpExtendedCommunityProperties(
                    new ActionIpExtendedCommunityProperties()
                        .withAdd(
                            new IpExtendedCommunityIdList()
                                .withIpExtendedCommunityIds(Arrays.asList("wgftshfgmuxuqia")))
                        .withDelete(
                            new IpExtendedCommunityIdList()
                                .withIpExtendedCommunityIds(Arrays.asList("bg", "yojfchicpare", "zoksgqhb")))
                        .withSet(
                            new IpExtendedCommunityIdList()
                                .withIpExtendedCommunityIds(Arrays.asList("xilozblkcrfldfl", "wtkbptsflot"))));
        model = BinaryData.fromObject(model).toObject(StatementActionProperties.class);
        Assertions.assertEquals(2144559147599140910L, model.localPreference());
        Assertions.assertEquals(RoutePolicyActionType.DENY, model.actionType());
        Assertions.assertEquals("ypaxpjp", model.ipCommunityProperties().add().ipCommunityIds().get(0));
        Assertions.assertEquals("hbcycgqakcsihxvt", model.ipCommunityProperties().delete().ipCommunityIds().get(0));
        Assertions.assertEquals("hwq", model.ipCommunityProperties().set().ipCommunityIds().get(0));
        Assertions
            .assertEquals(
                "wgftshfgmuxuqia", model.ipExtendedCommunityProperties().add().ipExtendedCommunityIds().get(0));
        Assertions.assertEquals("bg", model.ipExtendedCommunityProperties().delete().ipExtendedCommunityIds().get(0));
        Assertions
            .assertEquals(
                "xilozblkcrfldfl", model.ipExtendedCommunityProperties().set().ipExtendedCommunityIds().get(0));
    }
}
