// 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.fluent.models.RoutePolicyProperties;
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 RoutePolicyPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RoutePolicyProperties model =
            BinaryData
                .fromString(
                    "{\"statements\":[{\"sequenceNumber\":6974301688992111876,\"condition\":{\"ipPrefixId\":\"dabtqwp\",\"ipExtendedCommunityIds\":[],\"ipCommunityIds\":[]},\"action\":{\"localPreference\":8313394416637011338,\"actionType\":\"Deny\"},\"annotation\":\"ucljgkyexaoguya\"}],\"provisioningState\":\"Succeeded\",\"annotation\":\"sdaultxij\"}")
                .toObject(RoutePolicyProperties.class);
        Assertions.assertEquals("sdaultxij", model.annotation());
        Assertions.assertEquals("ucljgkyexaoguya", model.statements().get(0).annotation());
        Assertions.assertEquals(6974301688992111876L, model.statements().get(0).sequenceNumber());
        Assertions.assertEquals("dabtqwp", model.statements().get(0).condition().ipPrefixId());
        Assertions.assertEquals(8313394416637011338L, model.statements().get(0).action().localPreference());
        Assertions.assertEquals(CommunityActionTypes.DENY, model.statements().get(0).action().actionType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RoutePolicyProperties model =
            new RoutePolicyProperties()
                .withAnnotation("sdaultxij")
                .withStatements(
                    Arrays
                        .asList(
                            new RoutePolicyStatementProperties()
                                .withAnnotation("ucljgkyexaoguya")
                                .withSequenceNumber(6974301688992111876L)
                                .withCondition(
                                    new StatementConditionProperties()
                                        .withIpCommunityIds(Arrays.asList())
                                        .withIpPrefixId("dabtqwp")
                                        .withIpExtendedCommunityIds(Arrays.asList()))
                                .withAction(
                                    new StatementActionProperties()
                                        .withLocalPreference(8313394416637011338L)
                                        .withActionType(CommunityActionTypes.DENY))));
        model = BinaryData.fromObject(model).toObject(RoutePolicyProperties.class);
        Assertions.assertEquals("sdaultxij", model.annotation());
        Assertions.assertEquals("ucljgkyexaoguya", model.statements().get(0).annotation());
        Assertions.assertEquals(6974301688992111876L, model.statements().get(0).sequenceNumber());
        Assertions.assertEquals("dabtqwp", model.statements().get(0).condition().ipPrefixId());
        Assertions.assertEquals(8313394416637011338L, model.statements().get(0).action().localPreference());
        Assertions.assertEquals(CommunityActionTypes.DENY, model.statements().get(0).action().actionType());
    }
}
