// 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.AllowASOverride;
import com.azure.resourcemanager.managednetworkfabric.models.BfdConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.BooleanEnumProperty;
import com.azure.resourcemanager.managednetworkfabric.models.InternalNetworkPropertiesBgpConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.NeighborAddress;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class InternalNetworkPropertiesBgpConfigurationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        InternalNetworkPropertiesBgpConfiguration model =
            BinaryData
                .fromString(
                    "{\"bfdConfiguration\":{\"administrativeState\":\"Enabled\",\"intervalInMilliSeconds\":1017981463,\"multiplier\":797231309},\"defaultRouteOriginate\":\"True\",\"allowAS\":654268550,\"allowASOverride\":\"Enable\",\"fabricASN\":212980078870398723,\"peerASN\":570360669816848021,\"ipv4ListenRangePrefixes\":[\"rpejp\",\"ssanbtttkgsuxun\"],\"ipv6ListenRangePrefixes\":[\"gkp\",\"hboyikebhuhks\",\"gwl\",\"kh\"],\"ipv4NeighborAddress\":[{\"address\":\"jy\",\"configurationState\":\"Succeeded\"}],\"ipv6NeighborAddress\":[{\"address\":\"qzufgsyfejyvdwt\",\"configurationState\":\"DeferredControl\"},{\"address\":\"pqa\",\"configurationState\":\"Deprovisioning\"}],\"annotation\":\"ncfgybmxsnxoc\"}")
                .toObject(InternalNetworkPropertiesBgpConfiguration.class);
        Assertions.assertEquals("ncfgybmxsnxoc", model.annotation());
        Assertions.assertEquals(1017981463, model.bfdConfiguration().intervalInMilliSeconds());
        Assertions.assertEquals(797231309, model.bfdConfiguration().multiplier());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.defaultRouteOriginate());
        Assertions.assertEquals(654268550, model.allowAS());
        Assertions.assertEquals(AllowASOverride.ENABLE, model.allowASOverride());
        Assertions.assertEquals(570360669816848021L, model.peerAsn());
        Assertions.assertEquals("rpejp", model.ipv4ListenRangePrefixes().get(0));
        Assertions.assertEquals("gkp", model.ipv6ListenRangePrefixes().get(0));
        Assertions.assertEquals("jy", model.ipv4NeighborAddress().get(0).address());
        Assertions.assertEquals("qzufgsyfejyvdwt", model.ipv6NeighborAddress().get(0).address());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        InternalNetworkPropertiesBgpConfiguration model =
            new InternalNetworkPropertiesBgpConfiguration()
                .withAnnotation("ncfgybmxsnxoc")
                .withBfdConfiguration(
                    new BfdConfiguration().withIntervalInMilliSeconds(1017981463).withMultiplier(797231309))
                .withDefaultRouteOriginate(BooleanEnumProperty.TRUE)
                .withAllowAS(654268550)
                .withAllowASOverride(AllowASOverride.ENABLE)
                .withPeerAsn(570360669816848021L)
                .withIpv4ListenRangePrefixes(Arrays.asList("rpejp", "ssanbtttkgsuxun"))
                .withIpv6ListenRangePrefixes(Arrays.asList("gkp", "hboyikebhuhks", "gwl", "kh"))
                .withIpv4NeighborAddress(Arrays.asList(new NeighborAddress().withAddress("jy")))
                .withIpv6NeighborAddress(
                    Arrays
                        .asList(
                            new NeighborAddress().withAddress("qzufgsyfejyvdwt"),
                            new NeighborAddress().withAddress("pqa")));
        model = BinaryData.fromObject(model).toObject(InternalNetworkPropertiesBgpConfiguration.class);
        Assertions.assertEquals("ncfgybmxsnxoc", model.annotation());
        Assertions.assertEquals(1017981463, model.bfdConfiguration().intervalInMilliSeconds());
        Assertions.assertEquals(797231309, model.bfdConfiguration().multiplier());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.defaultRouteOriginate());
        Assertions.assertEquals(654268550, model.allowAS());
        Assertions.assertEquals(AllowASOverride.ENABLE, model.allowASOverride());
        Assertions.assertEquals(570360669816848021L, model.peerAsn());
        Assertions.assertEquals("rpejp", model.ipv4ListenRangePrefixes().get(0));
        Assertions.assertEquals("gkp", model.ipv6ListenRangePrefixes().get(0));
        Assertions.assertEquals("jy", model.ipv4NeighborAddress().get(0).address());
        Assertions.assertEquals("qzufgsyfejyvdwt", model.ipv6NeighborAddress().get(0).address());
    }
}
