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

package com.azure.resourcemanager.webpubsub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.webpubsub.fluent.models.WebPubSubHubInner;
import com.azure.resourcemanager.webpubsub.models.EventHandler;
import com.azure.resourcemanager.webpubsub.models.EventListener;
import com.azure.resourcemanager.webpubsub.models.WebPubSubHubProperties;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class WebPubSubHubInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        WebPubSubHubInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"eventHandlers\":[{\"urlTemplate\":\"iidzyexzne\",\"userEventPattern\":\"xhnrztfolhb\",\"systemEvents\":[]},{\"urlTemplate\":\"nalaulppg\",\"userEventPattern\":\"tpnapnyiropuhpig\",\"systemEvents\":[]}],\"eventListeners\":[{}],\"anonymousConnectPolicy\":\"qgitxmed\"},\"id\":\"v\",\"name\":\"slynqwwnc\",\"type\":\"zzhxgktrm\"}")
                .toObject(WebPubSubHubInner.class);
        Assertions.assertEquals("iidzyexzne", model.properties().eventHandlers().get(0).urlTemplate());
        Assertions.assertEquals("xhnrztfolhb", model.properties().eventHandlers().get(0).userEventPattern());
        Assertions.assertEquals("qgitxmed", model.properties().anonymousConnectPolicy());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        WebPubSubHubInner model =
            new WebPubSubHubInner()
                .withProperties(
                    new WebPubSubHubProperties()
                        .withEventHandlers(
                            Arrays
                                .asList(
                                    new EventHandler()
                                        .withUrlTemplate("iidzyexzne")
                                        .withUserEventPattern("xhnrztfolhb")
                                        .withSystemEvents(Arrays.asList()),
                                    new EventHandler()
                                        .withUrlTemplate("nalaulppg")
                                        .withUserEventPattern("tpnapnyiropuhpig")
                                        .withSystemEvents(Arrays.asList())))
                        .withEventListeners(Arrays.asList(new EventListener()))
                        .withAnonymousConnectPolicy("qgitxmed"));
        model = BinaryData.fromObject(model).toObject(WebPubSubHubInner.class);
        Assertions.assertEquals("iidzyexzne", model.properties().eventHandlers().get(0).urlTemplate());
        Assertions.assertEquals("xhnrztfolhb", model.properties().eventHandlers().get(0).userEventPattern());
        Assertions.assertEquals("qgitxmed", model.properties().anonymousConnectPolicy());
    }
}
