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

package com.azure.resourcemanager.signalr.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.signalr.models.ServerlessUpstreamSettings;
import com.azure.resourcemanager.signalr.models.UpstreamAuthSettings;
import com.azure.resourcemanager.signalr.models.UpstreamAuthType;
import com.azure.resourcemanager.signalr.models.UpstreamTemplate;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ServerlessUpstreamSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServerlessUpstreamSettings model =
            BinaryData
                .fromString(
                    "{\"templates\":[{\"hubPattern\":\"zunlu\",\"eventPattern\":\"nnprn\",\"categoryPattern\":\"peilpjzuaejxdu\",\"urlTemplate\":\"tskzbbtdzumveek\",\"auth\":{\"type\":\"None\"}},{\"hubPattern\":\"hkfpbs\",\"eventPattern\":\"ofd\",\"categoryPattern\":\"uusdttouwa\",\"urlTemplate\":\"oekqvk\",\"auth\":{\"type\":\"None\"}},{\"hubPattern\":\"bxwyjsflhhcaa\",\"eventPattern\":\"jixisxyawjoyaqcs\",\"categoryPattern\":\"jpkiidzyexznelix\",\"urlTemplate\":\"nr\",\"auth\":{\"type\":\"None\"}}]}")
                .toObject(ServerlessUpstreamSettings.class);
        Assertions.assertEquals("zunlu", model.templates().get(0).hubPattern());
        Assertions.assertEquals("nnprn", model.templates().get(0).eventPattern());
        Assertions.assertEquals("peilpjzuaejxdu", model.templates().get(0).categoryPattern());
        Assertions.assertEquals("tskzbbtdzumveek", model.templates().get(0).urlTemplate());
        Assertions.assertEquals(UpstreamAuthType.NONE, model.templates().get(0).auth().type());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServerlessUpstreamSettings model =
            new ServerlessUpstreamSettings()
                .withTemplates(
                    Arrays
                        .asList(
                            new UpstreamTemplate()
                                .withHubPattern("zunlu")
                                .withEventPattern("nnprn")
                                .withCategoryPattern("peilpjzuaejxdu")
                                .withUrlTemplate("tskzbbtdzumveek")
                                .withAuth(new UpstreamAuthSettings().withType(UpstreamAuthType.NONE)),
                            new UpstreamTemplate()
                                .withHubPattern("hkfpbs")
                                .withEventPattern("ofd")
                                .withCategoryPattern("uusdttouwa")
                                .withUrlTemplate("oekqvk")
                                .withAuth(new UpstreamAuthSettings().withType(UpstreamAuthType.NONE)),
                            new UpstreamTemplate()
                                .withHubPattern("bxwyjsflhhcaa")
                                .withEventPattern("jixisxyawjoyaqcs")
                                .withCategoryPattern("jpkiidzyexznelix")
                                .withUrlTemplate("nr")
                                .withAuth(new UpstreamAuthSettings().withType(UpstreamAuthType.NONE))));
        model = BinaryData.fromObject(model).toObject(ServerlessUpstreamSettings.class);
        Assertions.assertEquals("zunlu", model.templates().get(0).hubPattern());
        Assertions.assertEquals("nnprn", model.templates().get(0).eventPattern());
        Assertions.assertEquals("peilpjzuaejxdu", model.templates().get(0).categoryPattern());
        Assertions.assertEquals("tskzbbtdzumveek", model.templates().get(0).urlTemplate());
        Assertions.assertEquals(UpstreamAuthType.NONE, model.templates().get(0).auth().type());
    }
}
