// 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.BgpConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.BooleanEnumProperty;
import com.azure.resourcemanager.managednetworkfabric.models.ConnectedSubnet;
import com.azure.resourcemanager.managednetworkfabric.models.InternalNetworkPatch;
import com.azure.resourcemanager.managednetworkfabric.models.StaticRouteConfiguration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class InternalNetworkPatchTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        InternalNetworkPatch model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"mtu\":1927044883,\"connectedIPv4Subnets\":[{\"prefix\":\"lwuip\",\"annotation\":\"cjzkzivgvvcna\"},{\"prefix\":\"hyrnxxmu\",\"annotation\":\"dndrdvstkwqqtche\"},{\"prefix\":\"mfmtdaaygdvw\",\"annotation\":\"piohgwxrtfu\"}],\"connectedIPv6Subnets\":[{\"prefix\":\"xg\",\"annotation\":\"agvrvmnpkuk\"},{\"prefix\":\"i\",\"annotation\":\"blxgwimf\"},{\"prefix\":\"hfjx\",\"annotation\":\"szkkfoqre\"}],\"staticRouteConfiguration\":{\"ipv4Routes\":[],\"ipv6Routes\":[]},\"bgpConfiguration\":{\"defaultRouteOriginate\":\"True\",\"allowAS\":113630721,\"allowASOverride\":\"Enable\",\"fabricASN\":2107457398,\"peerASN\":322973840,\"ipv4ListenRangePrefixes\":[\"lpcirelsf\",\"aenwabf\",\"tkl\",\"dxbjhwuaanozj\"],\"ipv6ListenRangePrefixes\":[\"hyoulpjr\"],\"ipv4NeighborAddress\":[],\"ipv6NeighborAddress\":[],\"annotation\":\"vimjwos\"},\"importRoutePolicyId\":\"xitc\",\"exportRoutePolicyId\":\"fcktqumiekke\",\"annotation\":\"ikh\"}}")
                .toObject(InternalNetworkPatch.class);
        Assertions.assertEquals(1927044883, model.mtu());
        Assertions.assertEquals("cjzkzivgvvcna", model.connectedIPv4Subnets().get(0).annotation());
        Assertions.assertEquals("lwuip", model.connectedIPv4Subnets().get(0).prefix());
        Assertions.assertEquals("agvrvmnpkuk", model.connectedIPv6Subnets().get(0).annotation());
        Assertions.assertEquals("xg", model.connectedIPv6Subnets().get(0).prefix());
        Assertions.assertEquals("vimjwos", model.bgpConfiguration().annotation());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.bgpConfiguration().defaultRouteOriginate());
        Assertions.assertEquals(113630721, model.bgpConfiguration().allowAS());
        Assertions.assertEquals(AllowASOverride.ENABLE, model.bgpConfiguration().allowASOverride());
        Assertions.assertEquals(322973840, model.bgpConfiguration().peerAsn());
        Assertions.assertEquals("lpcirelsf", model.bgpConfiguration().ipv4ListenRangePrefixes().get(0));
        Assertions.assertEquals("hyoulpjr", model.bgpConfiguration().ipv6ListenRangePrefixes().get(0));
        Assertions.assertEquals("xitc", model.importRoutePolicyId());
        Assertions.assertEquals("fcktqumiekke", model.exportRoutePolicyId());
        Assertions.assertEquals("ikh", model.annotation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        InternalNetworkPatch model =
            new InternalNetworkPatch()
                .withMtu(1927044883)
                .withConnectedIPv4Subnets(
                    Arrays
                        .asList(
                            new ConnectedSubnet().withAnnotation("cjzkzivgvvcna").withPrefix("lwuip"),
                            new ConnectedSubnet().withAnnotation("dndrdvstkwqqtche").withPrefix("hyrnxxmu"),
                            new ConnectedSubnet().withAnnotation("piohgwxrtfu").withPrefix("mfmtdaaygdvw")))
                .withConnectedIPv6Subnets(
                    Arrays
                        .asList(
                            new ConnectedSubnet().withAnnotation("agvrvmnpkuk").withPrefix("xg"),
                            new ConnectedSubnet().withAnnotation("blxgwimf").withPrefix("i"),
                            new ConnectedSubnet().withAnnotation("szkkfoqre").withPrefix("hfjx")))
                .withStaticRouteConfiguration(
                    new StaticRouteConfiguration().withIpv4Routes(Arrays.asList()).withIpv6Routes(Arrays.asList()))
                .withBgpConfiguration(
                    new BgpConfiguration()
                        .withAnnotation("vimjwos")
                        .withDefaultRouteOriginate(BooleanEnumProperty.TRUE)
                        .withAllowAS(113630721)
                        .withAllowASOverride(AllowASOverride.ENABLE)
                        .withPeerAsn(322973840)
                        .withIpv4ListenRangePrefixes(Arrays.asList("lpcirelsf", "aenwabf", "tkl", "dxbjhwuaanozj"))
                        .withIpv6ListenRangePrefixes(Arrays.asList("hyoulpjr"))
                        .withIpv4NeighborAddress(Arrays.asList())
                        .withIpv6NeighborAddress(Arrays.asList()))
                .withImportRoutePolicyId("xitc")
                .withExportRoutePolicyId("fcktqumiekke")
                .withAnnotation("ikh");
        model = BinaryData.fromObject(model).toObject(InternalNetworkPatch.class);
        Assertions.assertEquals(1927044883, model.mtu());
        Assertions.assertEquals("cjzkzivgvvcna", model.connectedIPv4Subnets().get(0).annotation());
        Assertions.assertEquals("lwuip", model.connectedIPv4Subnets().get(0).prefix());
        Assertions.assertEquals("agvrvmnpkuk", model.connectedIPv6Subnets().get(0).annotation());
        Assertions.assertEquals("xg", model.connectedIPv6Subnets().get(0).prefix());
        Assertions.assertEquals("vimjwos", model.bgpConfiguration().annotation());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.bgpConfiguration().defaultRouteOriginate());
        Assertions.assertEquals(113630721, model.bgpConfiguration().allowAS());
        Assertions.assertEquals(AllowASOverride.ENABLE, model.bgpConfiguration().allowASOverride());
        Assertions.assertEquals(322973840, model.bgpConfiguration().peerAsn());
        Assertions.assertEquals("lpcirelsf", model.bgpConfiguration().ipv4ListenRangePrefixes().get(0));
        Assertions.assertEquals("hyoulpjr", model.bgpConfiguration().ipv6ListenRangePrefixes().get(0));
        Assertions.assertEquals("xitc", model.importRoutePolicyId());
        Assertions.assertEquals("fcktqumiekke", model.exportRoutePolicyId());
        Assertions.assertEquals("ikh", model.annotation());
    }
}
