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

package com.azure.resourcemanager.support.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.support.fluent.models.CommunicationDetailsInner;
import com.azure.resourcemanager.support.models.CommunicationsListResult;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class CommunicationsListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CommunicationsListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"communicationType\":\"phone\",\"communicationDirection\":\"outbound\",\"sender\":\"cr\",\"subject\":\"czsqpjhvm\",\"body\":\"ajvnysounqe\",\"createdDate\":\"2021-08-26T21:26:20Z\"},\"id\":\"oaeupfhyhltrpmo\",\"name\":\"jmcmatuokthfu\",\"type\":\"uaodsfcpk\"},{\"properties\":{\"communicationType\":\"web\",\"communicationDirection\":\"outbound\",\"sender\":\"zmyzydagf\",\"subject\":\"axbezyiuo\",\"body\":\"ktwh\",\"createdDate\":\"2021-09-10T15:31:21Z\"},\"id\":\"wz\",\"name\":\"wqsmbsur\",\"type\":\"xim\"},{\"properties\":{\"communicationType\":\"web\",\"communicationDirection\":\"outbound\",\"sender\":\"fksymddystki\",\"subject\":\"uxh\",\"body\":\"yudxorrqnbp\",\"createdDate\":\"2021-02-11T00:33:58Z\"},\"id\":\"vyifqrvkdvjsl\",\"name\":\"rm\",\"type\":\"vdfwatkpn\"},{\"properties\":{\"communicationType\":\"phone\",\"communicationDirection\":\"outbound\",\"sender\":\"czwtruwiqzbqjv\",\"subject\":\"ovm\",\"body\":\"okacspk\",\"createdDate\":\"2021-04-15T03:02:29Z\"},\"id\":\"zdobpxjmflbvvnch\",\"name\":\"kcciwwzjuqkhr\",\"type\":\"ajiwkuo\"}],\"nextLink\":\"skghsauuimj\"}")
                .toObject(CommunicationsListResult.class);
        Assertions.assertEquals("cr", model.value().get(0).sender());
        Assertions.assertEquals("czsqpjhvm", model.value().get(0).subject());
        Assertions.assertEquals("ajvnysounqe", model.value().get(0).body());
        Assertions.assertEquals("skghsauuimj", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CommunicationsListResult model =
            new CommunicationsListResult()
                .withValue(
                    Arrays
                        .asList(
                            new CommunicationDetailsInner()
                                .withSender("cr")
                                .withSubject("czsqpjhvm")
                                .withBody("ajvnysounqe"),
                            new CommunicationDetailsInner()
                                .withSender("zmyzydagf")
                                .withSubject("axbezyiuo")
                                .withBody("ktwh"),
                            new CommunicationDetailsInner()
                                .withSender("fksymddystki")
                                .withSubject("uxh")
                                .withBody("yudxorrqnbp"),
                            new CommunicationDetailsInner()
                                .withSender("czwtruwiqzbqjv")
                                .withSubject("ovm")
                                .withBody("okacspk")))
                .withNextLink("skghsauuimj");
        model = BinaryData.fromObject(model).toObject(CommunicationsListResult.class);
        Assertions.assertEquals("cr", model.value().get(0).sender());
        Assertions.assertEquals("czsqpjhvm", model.value().get(0).subject());
        Assertions.assertEquals("ajvnysounqe", model.value().get(0).body());
        Assertions.assertEquals("skghsauuimj", model.nextLink());
    }
}
