// 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.RoutePolicyStatementProperties;
import com.azure.resourcemanager.managednetworkfabric.models.StatementActionProperties;
import com.azure.resourcemanager.managednetworkfabric.models.StatementConditionProperties;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RoutePolicyStatementPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RoutePolicyStatementProperties model =
            BinaryData
                .fromString(
                    "{\"sequenceNumber\":1316152777168081705,\"condition\":{\"ipPrefixId\":\"qwazlnqnmcjngzq\",\"ipExtendedCommunityIds\":[\"tb\",\"wgnyfusfzsvtui\",\"zh\",\"jqg\"],\"ipCommunityIds\":[\"hm\"]},\"action\":{\"localPreference\":6648099911954184896,\"actionType\":\"Permit\",\"ipCommunityProperties\":{},\"ipExtendedCommunityProperties\":{}},\"annotation\":\"sovwxznptgoeiyb\"}")
                .toObject(RoutePolicyStatementProperties.class);
        Assertions.assertEquals("sovwxznptgoeiyb", model.annotation());
        Assertions.assertEquals(1316152777168081705L, model.sequenceNumber());
        Assertions.assertEquals("hm", model.condition().ipCommunityIds().get(0));
        Assertions.assertEquals("qwazlnqnmcjngzq", model.condition().ipPrefixId());
        Assertions.assertEquals("tb", model.condition().ipExtendedCommunityIds().get(0));
        Assertions.assertEquals(6648099911954184896L, model.action().localPreference());
        Assertions.assertEquals(CommunityActionTypes.PERMIT, model.action().actionType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RoutePolicyStatementProperties model =
            new RoutePolicyStatementProperties()
                .withAnnotation("sovwxznptgoeiyb")
                .withSequenceNumber(1316152777168081705L)
                .withCondition(
                    new StatementConditionProperties()
                        .withIpCommunityIds(Arrays.asList("hm"))
                        .withIpPrefixId("qwazlnqnmcjngzq")
                        .withIpExtendedCommunityIds(Arrays.asList("tb", "wgnyfusfzsvtui", "zh", "jqg")))
                .withAction(
                    new StatementActionProperties()
                        .withLocalPreference(6648099911954184896L)
                        .withActionType(CommunityActionTypes.PERMIT)
                        .withIpCommunityProperties(new ActionIpCommunityProperties())
                        .withIpExtendedCommunityProperties(new ActionIpExtendedCommunityProperties()));
        model = BinaryData.fromObject(model).toObject(RoutePolicyStatementProperties.class);
        Assertions.assertEquals("sovwxznptgoeiyb", model.annotation());
        Assertions.assertEquals(1316152777168081705L, model.sequenceNumber());
        Assertions.assertEquals("hm", model.condition().ipCommunityIds().get(0));
        Assertions.assertEquals("qwazlnqnmcjngzq", model.condition().ipPrefixId());
        Assertions.assertEquals("tb", model.condition().ipExtendedCommunityIds().get(0));
        Assertions.assertEquals(6648099911954184896L, model.action().localPreference());
        Assertions.assertEquals(CommunityActionTypes.PERMIT, model.action().actionType());
    }
}
