// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.peering.generated;

import com.azure.core.management.SubResource;
import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.peering.fluent.models.PeeringProperties;
import com.azure.resourcemanager.peering.models.DirectConnection;
import com.azure.resourcemanager.peering.models.DirectPeeringType;
import com.azure.resourcemanager.peering.models.ExchangeConnection;
import com.azure.resourcemanager.peering.models.PeeringPropertiesDirect;
import com.azure.resourcemanager.peering.models.PeeringPropertiesExchange;
import com.azure.resourcemanager.peering.models.SessionAddressProvider;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class PeeringPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PeeringProperties model =
            BinaryData
                .fromString(
                    "{\"direct\":{\"connections\":[{\"bandwidthInMbps\":1192352775,\"provisionedBandwidthInMbps\":49478059,\"sessionAddressProvider\":\"Microsoft\",\"useForPeeringService\":true,\"microsoftTrackingId\":\"ginuvamih\",\"peeringDBFacilityId\":774982264,\"connectionState\":\"ProvisioningFailed\",\"connectionIdentifier\":\"zxtheotusivyevcc\",\"errorMessage\":\"ihnhun\"},{\"bandwidthInMbps\":1154149650,\"provisionedBandwidthInMbps\":847367838,\"sessionAddressProvider\":\"Peer\",\"useForPeeringService\":true,\"microsoftTrackingId\":\"xgispemvtzfkufu\",\"peeringDBFacilityId\":1437097866,\"connectionState\":\"Approved\",\"connectionIdentifier\":\"eofjaeqjh\",\"errorMessage\":\"b\"}],\"useForPeeringService\":false,\"peerAsn\":{\"id\":\"mjqulngsn\"},\"directPeeringType\":\"Ix\"},\"exchange\":{\"connections\":[{\"peeringDBFacilityId\":406268406,\"connectionState\":\"ProvisioningCompleted\",\"connectionIdentifier\":\"clxxwrljdo\",\"errorMessage\":\"kcqvkocrc\"},{\"peeringDBFacilityId\":747491790,\"connectionState\":\"Approved\",\"connectionIdentifier\":\"xbnjbiksq\",\"errorMessage\":\"lssai\"},{\"peeringDBFacilityId\":229383056,\"connectionState\":\"Validating\",\"connectionIdentifier\":\"lljfmppeeb\",\"errorMessage\":\"gxsabkyq\"}],\"peerAsn\":{\"id\":\"jitcjczdzevn\"}},\"peeringLocation\":\"krwpdap\",\"provisioningState\":\"Updating\"}")
                .toObject(PeeringProperties.class);
        Assertions.assertEquals(1192352775, model.direct().connections().get(0).bandwidthInMbps());
        Assertions
            .assertEquals(
                SessionAddressProvider.MICROSOFT, model.direct().connections().get(0).sessionAddressProvider());
        Assertions.assertEquals(true, model.direct().connections().get(0).useForPeeringService());
        Assertions.assertEquals(774982264, model.direct().connections().get(0).peeringDBFacilityId());
        Assertions.assertEquals("zxtheotusivyevcc", model.direct().connections().get(0).connectionIdentifier());
        Assertions.assertEquals("mjqulngsn", model.direct().peerAsn().id());
        Assertions.assertEquals(DirectPeeringType.IX, model.direct().directPeeringType());
        Assertions.assertEquals(406268406, model.exchange().connections().get(0).peeringDBFacilityId());
        Assertions.assertEquals("clxxwrljdo", model.exchange().connections().get(0).connectionIdentifier());
        Assertions.assertEquals("jitcjczdzevn", model.exchange().peerAsn().id());
        Assertions.assertEquals("krwpdap", model.peeringLocation());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PeeringProperties model =
            new PeeringProperties()
                .withDirect(
                    new PeeringPropertiesDirect()
                        .withConnections(
                            Arrays
                                .asList(
                                    new DirectConnection()
                                        .withBandwidthInMbps(1192352775)
                                        .withSessionAddressProvider(SessionAddressProvider.MICROSOFT)
                                        .withUseForPeeringService(true)
                                        .withPeeringDBFacilityId(774982264)
                                        .withConnectionIdentifier("zxtheotusivyevcc"),
                                    new DirectConnection()
                                        .withBandwidthInMbps(1154149650)
                                        .withSessionAddressProvider(SessionAddressProvider.PEER)
                                        .withUseForPeeringService(true)
                                        .withPeeringDBFacilityId(1437097866)
                                        .withConnectionIdentifier("eofjaeqjh")))
                        .withPeerAsn(new SubResource().withId("mjqulngsn"))
                        .withDirectPeeringType(DirectPeeringType.IX))
                .withExchange(
                    new PeeringPropertiesExchange()
                        .withConnections(
                            Arrays
                                .asList(
                                    new ExchangeConnection()
                                        .withPeeringDBFacilityId(406268406)
                                        .withConnectionIdentifier("clxxwrljdo"),
                                    new ExchangeConnection()
                                        .withPeeringDBFacilityId(747491790)
                                        .withConnectionIdentifier("xbnjbiksq"),
                                    new ExchangeConnection()
                                        .withPeeringDBFacilityId(229383056)
                                        .withConnectionIdentifier("lljfmppeeb")))
                        .withPeerAsn(new SubResource().withId("jitcjczdzevn")))
                .withPeeringLocation("krwpdap");
        model = BinaryData.fromObject(model).toObject(PeeringProperties.class);
        Assertions.assertEquals(1192352775, model.direct().connections().get(0).bandwidthInMbps());
        Assertions
            .assertEquals(
                SessionAddressProvider.MICROSOFT, model.direct().connections().get(0).sessionAddressProvider());
        Assertions.assertEquals(true, model.direct().connections().get(0).useForPeeringService());
        Assertions.assertEquals(774982264, model.direct().connections().get(0).peeringDBFacilityId());
        Assertions.assertEquals("zxtheotusivyevcc", model.direct().connections().get(0).connectionIdentifier());
        Assertions.assertEquals("mjqulngsn", model.direct().peerAsn().id());
        Assertions.assertEquals(DirectPeeringType.IX, model.direct().directPeeringType());
        Assertions.assertEquals(406268406, model.exchange().connections().get(0).peeringDBFacilityId());
        Assertions.assertEquals("clxxwrljdo", model.exchange().connections().get(0).connectionIdentifier());
        Assertions.assertEquals("jitcjczdzevn", model.exchange().peerAsn().id());
        Assertions.assertEquals("krwpdap", model.peeringLocation());
    }
}
