// 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.ExternalNetworkProperties;
import com.azure.resourcemanager.managednetworkfabric.models.BfdConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.ExternalNetworkPropertiesOptionAProperties;
import com.azure.resourcemanager.managednetworkfabric.models.OptionBProperties;
import com.azure.resourcemanager.managednetworkfabric.models.PeeringOption;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ExternalNetworkPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ExternalNetworkProperties model =
            BinaryData
                .fromString(
                    "{\"networkToNetworkInterconnectId\":\"ivwitqscywugg\",\"disabledOnResources\":[\"uhczbwemh\",\"i\"],\"administrativeState\":\"Enabled\",\"provisioningState\":\"Deleting\",\"peeringOption\":\"OptionA\",\"optionBProperties\":{\"importRouteTargets\":[\"swe\",\"pqwd\",\"ggicccnxqhue\",\"mkttlstvlzywem\"],\"exportRouteTargets\":[\"ncsdtclusiyp\",\"sfgytguslfead\",\"ygqukyhejh\"]},\"optionAProperties\":{\"mtu\":581237500,\"vlanId\":883712921,\"fabricASN\":1767346003,\"peerASN\":1351567723,\"bfdConfiguration\":{\"administrativeState\":\"Enabled\",\"interval\":1515177914,\"multiplier\":43527729},\"primaryIpv4Prefix\":\"qvujzraehtwdwrf\",\"primaryIpv6Prefix\":\"wib\",\"secondaryIpv4Prefix\":\"cdl\",\"secondaryIpv6Prefix\":\"shfwpracstwity\"},\"importRoutePolicyId\":\"evxccedcp\",\"exportRoutePolicyId\":\"dyodnwzxltj\",\"annotation\":\"nhltiugcxn\"}")
                .toObject(ExternalNetworkProperties.class);
        Assertions.assertEquals("nhltiugcxn", model.annotation());
        Assertions.assertEquals(PeeringOption.OPTIONA, model.peeringOption());
        Assertions.assertEquals("swe", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("ncsdtclusiyp", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("qvujzraehtwdwrf", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("wib", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("cdl", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("shfwpracstwity", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(581237500, model.optionAProperties().mtu());
        Assertions.assertEquals(883712921, model.optionAProperties().vlanId());
        Assertions.assertEquals(1351567723, model.optionAProperties().peerAsn());
        Assertions.assertEquals("evxccedcp", model.importRoutePolicyId());
        Assertions.assertEquals("dyodnwzxltj", model.exportRoutePolicyId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ExternalNetworkProperties model =
            new ExternalNetworkProperties()
                .withAnnotation("nhltiugcxn")
                .withPeeringOption(PeeringOption.OPTIONA)
                .withOptionBProperties(
                    new OptionBProperties()
                        .withImportRouteTargets(Arrays.asList("swe", "pqwd", "ggicccnxqhue", "mkttlstvlzywem"))
                        .withExportRouteTargets(Arrays.asList("ncsdtclusiyp", "sfgytguslfead", "ygqukyhejh")))
                .withOptionAProperties(
                    new ExternalNetworkPropertiesOptionAProperties()
                        .withPrimaryIpv4Prefix("qvujzraehtwdwrf")
                        .withPrimaryIpv6Prefix("wib")
                        .withSecondaryIpv4Prefix("cdl")
                        .withSecondaryIpv6Prefix("shfwpracstwity")
                        .withMtu(581237500)
                        .withVlanId(883712921)
                        .withPeerAsn(1351567723)
                        .withBfdConfiguration(new BfdConfiguration()))
                .withImportRoutePolicyId("evxccedcp")
                .withExportRoutePolicyId("dyodnwzxltj");
        model = BinaryData.fromObject(model).toObject(ExternalNetworkProperties.class);
        Assertions.assertEquals("nhltiugcxn", model.annotation());
        Assertions.assertEquals(PeeringOption.OPTIONA, model.peeringOption());
        Assertions.assertEquals("swe", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("ncsdtclusiyp", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("qvujzraehtwdwrf", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("wib", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("cdl", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("shfwpracstwity", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(581237500, model.optionAProperties().mtu());
        Assertions.assertEquals(883712921, model.optionAProperties().vlanId());
        Assertions.assertEquals(1351567723, model.optionAProperties().peerAsn());
        Assertions.assertEquals("evxccedcp", model.importRoutePolicyId());
        Assertions.assertEquals("dyodnwzxltj", model.exportRoutePolicyId());
    }
}
