// 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.CommunityActionTypes;
import com.azure.resourcemanager.managednetworkfabric.models.IpCommunityIdList;
import com.azure.resourcemanager.managednetworkfabric.models.IpExtendedCommunityIdList;
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\":3509180150248793355,\"actionType\":\"Permit\",\"ipCommunityProperties\":{\"delete\":{\"ipCommunityIds\":[\"h\",\"aglkafhon\",\"juj\"]},\"set\":{\"ipCommunityIds\":[\"pzvcpopmxelnwc\",\"tyjedex\",\"mlfmkqs\",\"azuawx\"]},\"add\":{\"ipCommunityIds\":[\"uamwabzxrvxc\",\"s\",\"sphaivmxyasflvg\"]}},\"ipExtendedCommunityProperties\":{\"delete\":{\"ipExtendedCommunityIds\":[\"wakoihkn\",\"mjblmljhlny\"]},\"set\":{\"ipExtendedCommunityIds\":[\"qyryuzcbmqqvxm\",\"wfgtayxonsup\",\"ujlzqnhcvsqltn\",\"oibgsxg\"]},\"add\":{\"ipExtendedCommunityIds\":[\"qonmpqoxwdof\"]}}}")
                .toObject(StatementActionProperties.class);
        Assertions.assertEquals(3509180150248793355L, model.localPreference());
        Assertions.assertEquals(CommunityActionTypes.PERMIT, model.actionType());
        Assertions.assertEquals("uamwabzxrvxc", model.ipCommunityProperties().add().ipCommunityIds().get(0));
        Assertions.assertEquals("h", model.ipCommunityProperties().delete().ipCommunityIds().get(0));
        Assertions.assertEquals("pzvcpopmxelnwc", model.ipCommunityProperties().set().ipCommunityIds().get(0));
        Assertions
            .assertEquals("qonmpqoxwdof", model.ipExtendedCommunityProperties().add().ipExtendedCommunityIds().get(0));
        Assertions
            .assertEquals("wakoihkn", model.ipExtendedCommunityProperties().delete().ipExtendedCommunityIds().get(0));
        Assertions
            .assertEquals(
                "qyryuzcbmqqvxm", model.ipExtendedCommunityProperties().set().ipExtendedCommunityIds().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StatementActionProperties model =
            new StatementActionProperties()
                .withLocalPreference(3509180150248793355L)
                .withActionType(CommunityActionTypes.PERMIT)
                .withIpCommunityProperties(
                    new ActionIpCommunityProperties()
                        .withAdd(
                            new IpCommunityIdList()
                                .withIpCommunityIds(Arrays.asList("uamwabzxrvxc", "s", "sphaivmxyasflvg")))
                        .withDelete(new IpCommunityIdList().withIpCommunityIds(Arrays.asList("h", "aglkafhon", "juj")))
                        .withSet(
                            new IpCommunityIdList()
                                .withIpCommunityIds(Arrays.asList("pzvcpopmxelnwc", "tyjedex", "mlfmkqs", "azuawx"))))
                .withIpExtendedCommunityProperties(
                    new ActionIpExtendedCommunityProperties()
                        .withAdd(
                            new IpExtendedCommunityIdList().withIpExtendedCommunityIds(Arrays.asList("qonmpqoxwdof")))
                        .withDelete(
                            new IpExtendedCommunityIdList()
                                .withIpExtendedCommunityIds(Arrays.asList("wakoihkn", "mjblmljhlny")))
                        .withSet(
                            new IpExtendedCommunityIdList()
                                .withIpExtendedCommunityIds(
                                    Arrays.asList("qyryuzcbmqqvxm", "wfgtayxonsup", "ujlzqnhcvsqltn", "oibgsxg"))));
        model = BinaryData.fromObject(model).toObject(StatementActionProperties.class);
        Assertions.assertEquals(3509180150248793355L, model.localPreference());
        Assertions.assertEquals(CommunityActionTypes.PERMIT, model.actionType());
        Assertions.assertEquals("uamwabzxrvxc", model.ipCommunityProperties().add().ipCommunityIds().get(0));
        Assertions.assertEquals("h", model.ipCommunityProperties().delete().ipCommunityIds().get(0));
        Assertions.assertEquals("pzvcpopmxelnwc", model.ipCommunityProperties().set().ipCommunityIds().get(0));
        Assertions
            .assertEquals("qonmpqoxwdof", model.ipExtendedCommunityProperties().add().ipExtendedCommunityIds().get(0));
        Assertions
            .assertEquals("wakoihkn", model.ipExtendedCommunityProperties().delete().ipExtendedCommunityIds().get(0));
        Assertions
            .assertEquals(
                "qyryuzcbmqqvxm", model.ipExtendedCommunityProperties().set().ipExtendedCommunityIds().get(0));
    }
}
