// 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.ExternalNetworkPatchProperties;
import com.azure.resourcemanager.managednetworkfabric.models.BfdConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.Layer3OptionAProperties;
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 ExternalNetworkPatchPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ExternalNetworkPatchProperties model =
            BinaryData
                .fromString(
                    "{\"peeringOption\":\"OptionB\",\"optionBProperties\":{\"importRouteTargets\":[\"h\",\"lsj\",\"dhszfjv\",\"bgofeljag\"],\"exportRouteTargets\":[\"qhl\",\"vriiio\",\"nalghfkvtvsexso\"]},\"optionAProperties\":{\"mtu\":404189900,\"vlanId\":2013630700,\"fabricASN\":1425531110,\"peerASN\":953928640,\"bfdConfiguration\":{\"administrativeState\":\"Enabled\",\"interval\":1049422590,\"multiplier\":695933392},\"primaryIpv4Prefix\":\"wpjgwws\",\"primaryIpv6Prefix\":\"ghftqsxhqxujxuk\",\"secondaryIpv4Prefix\":\"xdigrjg\",\"secondaryIpv6Prefix\":\"fzdm\"},\"importRoutePolicyId\":\"qtfihwhbotzinga\",\"exportRoutePolicyId\":\"pph\",\"annotation\":\"zqzudph\"}")
                .toObject(ExternalNetworkPatchProperties.class);
        Assertions.assertEquals("zqzudph", model.annotation());
        Assertions.assertEquals(PeeringOption.OPTIONB, model.peeringOption());
        Assertions.assertEquals("h", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("qhl", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("wpjgwws", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("ghftqsxhqxujxuk", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("xdigrjg", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("fzdm", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(404189900, model.optionAProperties().mtu());
        Assertions.assertEquals(2013630700, model.optionAProperties().vlanId());
        Assertions.assertEquals(953928640, model.optionAProperties().peerAsn());
        Assertions.assertEquals("qtfihwhbotzinga", model.importRoutePolicyId());
        Assertions.assertEquals("pph", model.exportRoutePolicyId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ExternalNetworkPatchProperties model =
            new ExternalNetworkPatchProperties()
                .withAnnotation("zqzudph")
                .withPeeringOption(PeeringOption.OPTIONB)
                .withOptionBProperties(
                    new OptionBProperties()
                        .withImportRouteTargets(Arrays.asList("h", "lsj", "dhszfjv", "bgofeljag"))
                        .withExportRouteTargets(Arrays.asList("qhl", "vriiio", "nalghfkvtvsexso")))
                .withOptionAProperties(
                    new Layer3OptionAProperties()
                        .withPrimaryIpv4Prefix("wpjgwws")
                        .withPrimaryIpv6Prefix("ghftqsxhqxujxuk")
                        .withSecondaryIpv4Prefix("xdigrjg")
                        .withSecondaryIpv6Prefix("fzdm")
                        .withMtu(404189900)
                        .withVlanId(2013630700)
                        .withPeerAsn(953928640)
                        .withBfdConfiguration(new BfdConfiguration()))
                .withImportRoutePolicyId("qtfihwhbotzinga")
                .withExportRoutePolicyId("pph");
        model = BinaryData.fromObject(model).toObject(ExternalNetworkPatchProperties.class);
        Assertions.assertEquals("zqzudph", model.annotation());
        Assertions.assertEquals(PeeringOption.OPTIONB, model.peeringOption());
        Assertions.assertEquals("h", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("qhl", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("wpjgwws", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("ghftqsxhqxujxuk", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("xdigrjg", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("fzdm", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(404189900, model.optionAProperties().mtu());
        Assertions.assertEquals(2013630700, model.optionAProperties().vlanId());
        Assertions.assertEquals(953928640, model.optionAProperties().peerAsn());
        Assertions.assertEquals("qtfihwhbotzinga", model.importRoutePolicyId());
        Assertions.assertEquals("pph", model.exportRoutePolicyId());
    }
}
