// 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.ManagedIdentitySettings;
import com.azure.resourcemanager.signalr.models.UpstreamAuthSettings;
import com.azure.resourcemanager.signalr.models.UpstreamAuthType;
import com.azure.resourcemanager.signalr.models.UpstreamTemplate;
import org.junit.jupiter.api.Assertions;

public final class UpstreamTemplateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UpstreamTemplate model =
            BinaryData
                .fromString(
                    "{\"hubPattern\":\"bnxknalaulppg\",\"eventPattern\":\"tpnapnyiropuhpig\",\"categoryPattern\":\"gylgqgitxmedjvcs\",\"urlTemplate\":\"ynqwwncwzzhxgk\",\"auth\":{\"type\":\"ManagedIdentity\",\"managedIdentity\":{\"resource\":\"napkteoellw\"}}}")
                .toObject(UpstreamTemplate.class);
        Assertions.assertEquals("bnxknalaulppg", model.hubPattern());
        Assertions.assertEquals("tpnapnyiropuhpig", model.eventPattern());
        Assertions.assertEquals("gylgqgitxmedjvcs", model.categoryPattern());
        Assertions.assertEquals("ynqwwncwzzhxgk", model.urlTemplate());
        Assertions.assertEquals(UpstreamAuthType.MANAGED_IDENTITY, model.auth().type());
        Assertions.assertEquals("napkteoellw", model.auth().managedIdentity().resource());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UpstreamTemplate model =
            new UpstreamTemplate()
                .withHubPattern("bnxknalaulppg")
                .withEventPattern("tpnapnyiropuhpig")
                .withCategoryPattern("gylgqgitxmedjvcs")
                .withUrlTemplate("ynqwwncwzzhxgk")
                .withAuth(
                    new UpstreamAuthSettings()
                        .withType(UpstreamAuthType.MANAGED_IDENTITY)
                        .withManagedIdentity(new ManagedIdentitySettings().withResource("napkteoellw")));
        model = BinaryData.fromObject(model).toObject(UpstreamTemplate.class);
        Assertions.assertEquals("bnxknalaulppg", model.hubPattern());
        Assertions.assertEquals("tpnapnyiropuhpig", model.eventPattern());
        Assertions.assertEquals("gylgqgitxmedjvcs", model.categoryPattern());
        Assertions.assertEquals("ynqwwncwzzhxgk", model.urlTemplate());
        Assertions.assertEquals(UpstreamAuthType.MANAGED_IDENTITY, model.auth().type());
        Assertions.assertEquals("napkteoellw", model.auth().managedIdentity().resource());
    }
}
