// 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.util.BinaryData;
import com.azure.resourcemanager.peering.fluent.models.PeerAsnInner;
import com.azure.resourcemanager.peering.models.PeerAsnListResult;
import com.azure.resourcemanager.peering.models.ValidationState;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class PeerAsnListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PeerAsnListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"peerAsn\":1408526617,\"peerContactDetail\":[],\"peerName\":\"krxd\",\"validationState\":\"None\",\"errorMessage\":\"tthzrvqd\"},\"id\":\"abhjybi\",\"name\":\"ehoqfbowskan\",\"type\":\"ktzlcuiywg\"},{\"properties\":{\"peerAsn\":1920401593,\"peerContactDetail\":[],\"peerName\":\"rvynhzgpph\",\"validationState\":\"Failed\",\"errorMessage\":\"nc\"},\"id\":\"cpecfvmmcoofs\",\"name\":\"lzevgbmqjqab\",\"type\":\"y\"},{\"properties\":{\"peerAsn\":1104674837,\"peerContactDetail\":[],\"peerName\":\"lzu\",\"validationState\":\"None\",\"errorMessage\":\"wnfnbacf\"},\"id\":\"onlebxetqgtzxdpn\",\"name\":\"bqqwxrj\",\"type\":\"eallnwsubisnj\"},{\"properties\":{\"peerAsn\":572259851,\"peerContactDetail\":[],\"peerName\":\"nzscxa\",\"validationState\":\"None\",\"errorMessage\":\"chcbonqvpkvlrxnj\"},\"id\":\"ase\",\"name\":\"pheoflokeyy\",\"type\":\"enjbdlwtgrhp\"}],\"nextLink\":\"pj\"}")
                .toObject(PeerAsnListResult.class);
        Assertions.assertEquals(1408526617, model.value().get(0).peerAsn());
        Assertions.assertEquals("krxd", model.value().get(0).peerName());
        Assertions.assertEquals(ValidationState.NONE, model.value().get(0).validationState());
        Assertions.assertEquals("pj", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PeerAsnListResult model =
            new PeerAsnListResult()
                .withValue(
                    Arrays
                        .asList(
                            new PeerAsnInner()
                                .withPeerAsn(1408526617)
                                .withPeerContactDetail(Arrays.asList())
                                .withPeerName("krxd")
                                .withValidationState(ValidationState.NONE),
                            new PeerAsnInner()
                                .withPeerAsn(1920401593)
                                .withPeerContactDetail(Arrays.asList())
                                .withPeerName("rvynhzgpph")
                                .withValidationState(ValidationState.FAILED),
                            new PeerAsnInner()
                                .withPeerAsn(1104674837)
                                .withPeerContactDetail(Arrays.asList())
                                .withPeerName("lzu")
                                .withValidationState(ValidationState.NONE),
                            new PeerAsnInner()
                                .withPeerAsn(572259851)
                                .withPeerContactDetail(Arrays.asList())
                                .withPeerName("nzscxa")
                                .withValidationState(ValidationState.NONE)))
                .withNextLink("pj");
        model = BinaryData.fromObject(model).toObject(PeerAsnListResult.class);
        Assertions.assertEquals(1408526617, model.value().get(0).peerAsn());
        Assertions.assertEquals("krxd", model.value().get(0).peerName());
        Assertions.assertEquals(ValidationState.NONE, model.value().get(0).validationState());
        Assertions.assertEquals("pj", model.nextLink());
    }
}
