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

public final class PeerAsnInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PeerAsnInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"peerAsn\":1465460192,\"peerContactDetail\":[{\"role\":\"Other\",\"email\":\"vdjwzrlovm\",\"phone\":\"whijcoejctbza\"},{\"role\":\"Noc\",\"email\":\"y\",\"phone\":\"kbfkg\"},{\"role\":\"Noc\",\"email\":\"exxppofmxaxcfjp\",\"phone\":\"dtocj\"},{\"role\":\"Policy\",\"email\":\"pmouexhdz\",\"phone\":\"bqe\"}],\"peerName\":\"nxqbzvddn\",\"validationState\":\"None\",\"errorMessage\":\"eic\"},\"id\":\"twnpzaoqvuhrhcf\",\"name\":\"cyddglmjthjqk\",\"type\":\"pyeicxm\"}")
                .toObject(PeerAsnInner.class);
        Assertions.assertEquals(1465460192, model.peerAsn());
        Assertions.assertEquals(Role.OTHER, model.peerContactDetail().get(0).role());
        Assertions.assertEquals("vdjwzrlovm", model.peerContactDetail().get(0).email());
        Assertions.assertEquals("whijcoejctbza", model.peerContactDetail().get(0).phone());
        Assertions.assertEquals("nxqbzvddn", model.peerName());
        Assertions.assertEquals(ValidationState.NONE, model.validationState());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PeerAsnInner model =
            new PeerAsnInner()
                .withPeerAsn(1465460192)
                .withPeerContactDetail(
                    Arrays
                        .asList(
                            new ContactDetail().withRole(Role.OTHER).withEmail("vdjwzrlovm").withPhone("whijcoejctbza"),
                            new ContactDetail().withRole(Role.NOC).withEmail("y").withPhone("kbfkg"),
                            new ContactDetail().withRole(Role.NOC).withEmail("exxppofmxaxcfjp").withPhone("dtocj"),
                            new ContactDetail().withRole(Role.POLICY).withEmail("pmouexhdz").withPhone("bqe")))
                .withPeerName("nxqbzvddn")
                .withValidationState(ValidationState.NONE);
        model = BinaryData.fromObject(model).toObject(PeerAsnInner.class);
        Assertions.assertEquals(1465460192, model.peerAsn());
        Assertions.assertEquals(Role.OTHER, model.peerContactDetail().get(0).role());
        Assertions.assertEquals("vdjwzrlovm", model.peerContactDetail().get(0).email());
        Assertions.assertEquals("whijcoejctbza", model.peerContactDetail().get(0).phone());
        Assertions.assertEquals("nxqbzvddn", model.peerName());
        Assertions.assertEquals(ValidationState.NONE, model.validationState());
    }
}
