// 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.ExternalNetworkInner;
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 ExternalNetworkInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ExternalNetworkInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"networkToNetworkInterconnectId\":\"ztvbtqgsfr\",\"disabledOnResources\":[\"zkoowtlmnguxawqa\",\"dsyuuximerqfob\",\"yznkby\"],\"administrativeState\":\"Enabled\",\"provisioningState\":\"Updating\",\"peeringOption\":\"OptionB\",\"optionBProperties\":{\"importRouteTargets\":[\"gmhrskdsnfdsdoak\"],\"exportRouteTargets\":[\"lmkk\",\"evdlh\",\"wpusdsttwvogv\"]},\"optionAProperties\":{\"mtu\":2086607804,\"vlanId\":1690092543,\"fabricASN\":764265895,\"peerASN\":963593520,\"primaryIpv4Prefix\":\"akufgmjz\",\"primaryIpv6Prefix\":\"rdgrtw\",\"secondaryIpv4Prefix\":\"nuuzkopbm\",\"secondaryIpv6Prefix\":\"rfdwoyu\"},\"importRoutePolicyId\":\"ziuiefozbhdm\",\"exportRoutePolicyId\":\"l\",\"annotation\":\"qhoftrmaequiah\"},\"id\":\"cslfaoqzpiyylha\",\"name\":\"nswhcc\",\"type\":\"ph\"}")
                .toObject(ExternalNetworkInner.class);
        Assertions.assertEquals(PeeringOption.OPTIONB, model.peeringOption());
        Assertions.assertEquals("gmhrskdsnfdsdoak", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("lmkk", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("akufgmjz", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("rdgrtw", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("nuuzkopbm", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("rfdwoyu", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(2086607804, model.optionAProperties().mtu());
        Assertions.assertEquals(1690092543, model.optionAProperties().vlanId());
        Assertions.assertEquals(963593520, model.optionAProperties().peerAsn());
        Assertions.assertEquals("ziuiefozbhdm", model.importRoutePolicyId());
        Assertions.assertEquals("l", model.exportRoutePolicyId());
        Assertions.assertEquals("qhoftrmaequiah", model.annotation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ExternalNetworkInner model =
            new ExternalNetworkInner()
                .withPeeringOption(PeeringOption.OPTIONB)
                .withOptionBProperties(
                    new OptionBProperties()
                        .withImportRouteTargets(Arrays.asList("gmhrskdsnfdsdoak"))
                        .withExportRouteTargets(Arrays.asList("lmkk", "evdlh", "wpusdsttwvogv")))
                .withOptionAProperties(
                    new ExternalNetworkPropertiesOptionAProperties()
                        .withPrimaryIpv4Prefix("akufgmjz")
                        .withPrimaryIpv6Prefix("rdgrtw")
                        .withSecondaryIpv4Prefix("nuuzkopbm")
                        .withSecondaryIpv6Prefix("rfdwoyu")
                        .withMtu(2086607804)
                        .withVlanId(1690092543)
                        .withPeerAsn(963593520))
                .withImportRoutePolicyId("ziuiefozbhdm")
                .withExportRoutePolicyId("l")
                .withAnnotation("qhoftrmaequiah");
        model = BinaryData.fromObject(model).toObject(ExternalNetworkInner.class);
        Assertions.assertEquals(PeeringOption.OPTIONB, model.peeringOption());
        Assertions.assertEquals("gmhrskdsnfdsdoak", model.optionBProperties().importRouteTargets().get(0));
        Assertions.assertEquals("lmkk", model.optionBProperties().exportRouteTargets().get(0));
        Assertions.assertEquals("akufgmjz", model.optionAProperties().primaryIpv4Prefix());
        Assertions.assertEquals("rdgrtw", model.optionAProperties().primaryIpv6Prefix());
        Assertions.assertEquals("nuuzkopbm", model.optionAProperties().secondaryIpv4Prefix());
        Assertions.assertEquals("rfdwoyu", model.optionAProperties().secondaryIpv6Prefix());
        Assertions.assertEquals(2086607804, model.optionAProperties().mtu());
        Assertions.assertEquals(1690092543, model.optionAProperties().vlanId());
        Assertions.assertEquals(963593520, model.optionAProperties().peerAsn());
        Assertions.assertEquals("ziuiefozbhdm", model.importRoutePolicyId());
        Assertions.assertEquals("l", model.exportRoutePolicyId());
        Assertions.assertEquals("qhoftrmaequiah", model.annotation());
    }
}
