// 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.NetworkToNetworkInterconnectProperties;
import com.azure.resourcemanager.managednetworkfabric.models.BooleanEnumProperty;
import com.azure.resourcemanager.managednetworkfabric.models.Layer2Configuration;
import com.azure.resourcemanager.managednetworkfabric.models.Layer3Configuration;
import com.azure.resourcemanager.managednetworkfabric.models.NniType;
import org.junit.jupiter.api.Assertions;

public final class NetworkToNetworkInterconnectPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkToNetworkInterconnectProperties model =
            BinaryData
                .fromString(
                    "{\"nniType\":\"CE\",\"administrativeState\":\"Disabled\",\"isManagementType\":\"True\",\"useOptionB\":\"True\",\"layer2Configuration\":{\"portCount\":1308211330,\"mtu\":2075017284,\"interfaces\":[\"anokqgu\"]},\"layer3Configuration\":{\"importRoutePolicyId\":\"qnvb\",\"exportRoutePolicyId\":\"ylaxxulcdi\",\"peerASN\":2065681131,\"vlanId\":499643337,\"fabricASN\":81380434,\"primaryIpv4Prefix\":\"svgjrwhryvy\",\"primaryIpv6Prefix\":\"t\",\"secondaryIpv4Prefix\":\"lxgccknfnwmbtm\",\"secondaryIpv6Prefix\":\"dvjdhttza\"},\"provisioningState\":\"Updating\"}")
                .toObject(NetworkToNetworkInterconnectProperties.class);
        Assertions.assertEquals(NniType.CE, model.nniType());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.isManagementType());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.useOptionB());
        Assertions.assertEquals(1308211330, model.layer2Configuration().portCount());
        Assertions.assertEquals(2075017284, model.layer2Configuration().mtu());
        Assertions.assertEquals("svgjrwhryvy", model.layer3Configuration().primaryIpv4Prefix());
        Assertions.assertEquals("t", model.layer3Configuration().primaryIpv6Prefix());
        Assertions.assertEquals("lxgccknfnwmbtm", model.layer3Configuration().secondaryIpv4Prefix());
        Assertions.assertEquals("dvjdhttza", model.layer3Configuration().secondaryIpv6Prefix());
        Assertions.assertEquals("qnvb", model.layer3Configuration().importRoutePolicyId());
        Assertions.assertEquals("ylaxxulcdi", model.layer3Configuration().exportRoutePolicyId());
        Assertions.assertEquals(2065681131, model.layer3Configuration().peerAsn());
        Assertions.assertEquals(499643337, model.layer3Configuration().vlanId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkToNetworkInterconnectProperties model =
            new NetworkToNetworkInterconnectProperties()
                .withNniType(NniType.CE)
                .withIsManagementType(BooleanEnumProperty.TRUE)
                .withUseOptionB(BooleanEnumProperty.TRUE)
                .withLayer2Configuration(new Layer2Configuration().withPortCount(1308211330).withMtu(2075017284))
                .withLayer3Configuration(
                    new Layer3Configuration()
                        .withPrimaryIpv4Prefix("svgjrwhryvy")
                        .withPrimaryIpv6Prefix("t")
                        .withSecondaryIpv4Prefix("lxgccknfnwmbtm")
                        .withSecondaryIpv6Prefix("dvjdhttza")
                        .withImportRoutePolicyId("qnvb")
                        .withExportRoutePolicyId("ylaxxulcdi")
                        .withPeerAsn(2065681131)
                        .withVlanId(499643337));
        model = BinaryData.fromObject(model).toObject(NetworkToNetworkInterconnectProperties.class);
        Assertions.assertEquals(NniType.CE, model.nniType());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.isManagementType());
        Assertions.assertEquals(BooleanEnumProperty.TRUE, model.useOptionB());
        Assertions.assertEquals(1308211330, model.layer2Configuration().portCount());
        Assertions.assertEquals(2075017284, model.layer2Configuration().mtu());
        Assertions.assertEquals("svgjrwhryvy", model.layer3Configuration().primaryIpv4Prefix());
        Assertions.assertEquals("t", model.layer3Configuration().primaryIpv6Prefix());
        Assertions.assertEquals("lxgccknfnwmbtm", model.layer3Configuration().secondaryIpv4Prefix());
        Assertions.assertEquals("dvjdhttza", model.layer3Configuration().secondaryIpv6Prefix());
        Assertions.assertEquals("qnvb", model.layer3Configuration().importRoutePolicyId());
        Assertions.assertEquals("ylaxxulcdi", model.layer3Configuration().exportRoutePolicyId());
        Assertions.assertEquals(2065681131, model.layer3Configuration().peerAsn());
        Assertions.assertEquals(499643337, model.layer3Configuration().vlanId());
    }
}
