// 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.ExternalNetworkPatch;
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 ExternalNetworkPatchTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ExternalNetworkPatch model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"peeringOption\":\"OptionB\",\"optionBProperties\":{\"importRouteTargets\":[\"fxssm\",\"u\",\"wbdsr\"],\"exportRouteTargets\":[\"drhneuyow\",\"kdw\"]},\"optionAProperties\":{\"mtu\":174588693,\"vlanId\":431891008,\"fabricASN\":909535969,\"peerASN\":1043585640,\"primaryIpv4Prefix\":\"kpzi\",\"primaryIpv6Prefix\":\"j\",\"secondaryIpv4Prefix\":\"nlfzxiavrmbz\",\"secondaryIpv6Prefix\":\"okixrjqcir\"},\"importRoutePolicyId\":\"pfrlazsz\",\"exportRoutePolicyId\":\"woiindf\",\"annotation\":\"pj\"}}")
                .toObject(ExternalNetworkPatch.class);
        Assertions.assertEquals(PeeringOption.OPTIONB, model.peeringOption());
        Assertions.assertEquals("fxssm", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("drhneuyow", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("kpzi", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("j", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("nlfzxiavrmbz", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("okixrjqcir", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(174588693, model.optionAProperties().mtu());
        Assertions.assertEquals(431891008, model.optionAProperties().vlanId());
        Assertions.assertEquals(1043585640, model.optionAProperties().peerAsn());
        Assertions.assertEquals("pfrlazsz", model.importRoutePolicyId());
        Assertions.assertEquals("woiindf", model.exportRoutePolicyId());
        Assertions.assertEquals("pj", model.annotation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ExternalNetworkPatch model =
            new ExternalNetworkPatch()
                .withPeeringOption(PeeringOption.OPTIONB)
                .withOptionBProperties(
                    new OptionBProperties()
                        .withImportRouteTargets(Arrays.asList("fxssm", "u", "wbdsr"))
                        .withExportRouteTargets(Arrays.asList("drhneuyow", "kdw")))
                .withOptionAProperties(
                    new Layer3OptionAProperties()
                        .withPrimaryIpv4Prefix("kpzi")
                        .withPrimaryIpv6Prefix("j")
                        .withSecondaryIpv4Prefix("nlfzxiavrmbz")
                        .withSecondaryIpv6Prefix("okixrjqcir")
                        .withMtu(174588693)
                        .withVlanId(431891008)
                        .withPeerAsn(1043585640))
                .withImportRoutePolicyId("pfrlazsz")
                .withExportRoutePolicyId("woiindf")
                .withAnnotation("pj");
        model = BinaryData.fromObject(model).toObject(ExternalNetworkPatch.class);
        Assertions.assertEquals(PeeringOption.OPTIONB, model.peeringOption());
        Assertions.assertEquals("fxssm", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("drhneuyow", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("kpzi", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("j", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("nlfzxiavrmbz", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("okixrjqcir", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(174588693, model.optionAProperties().mtu());
        Assertions.assertEquals(431891008, model.optionAProperties().vlanId());
        Assertions.assertEquals(1043585640, model.optionAProperties().peerAsn());
        Assertions.assertEquals("pfrlazsz", model.importRoutePolicyId());
        Assertions.assertEquals("woiindf", model.exportRoutePolicyId());
        Assertions.assertEquals("pj", model.annotation());
    }
}
