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

package com.azure.resourcemanager.iothub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.iothub.models.AuthenticationType;
import com.azure.resourcemanager.iothub.models.ManagedIdentity;
import com.azure.resourcemanager.iothub.models.RoutingEventHubProperties;
import org.junit.jupiter.api.Assertions;

public final class RoutingEventHubPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RoutingEventHubProperties model =
            BinaryData
                .fromString(
                    "{\"id\":\"mjmvxieduugidyjr\",\"connectionString\":\"byao\",\"endpointUri\":\"e\",\"entityPath\":\"sonpclhocohs\",\"authenticationType\":\"keyBased\",\"identity\":{\"userAssignedIdentity\":\"eggzfb\"},\"name\":\"hfmvfaxkffe\",\"subscriptionId\":\"th\",\"resourceGroup\":\"m\"}")
                .toObject(RoutingEventHubProperties.class);
        Assertions.assertEquals("mjmvxieduugidyjr", model.id());
        Assertions.assertEquals("byao", model.connectionString());
        Assertions.assertEquals("e", model.endpointUri());
        Assertions.assertEquals("sonpclhocohs", model.entityPath());
        Assertions.assertEquals(AuthenticationType.KEY_BASED, model.authenticationType());
        Assertions.assertEquals("eggzfb", model.identity().userAssignedIdentity());
        Assertions.assertEquals("hfmvfaxkffe", model.name());
        Assertions.assertEquals("th", model.subscriptionId());
        Assertions.assertEquals("m", model.resourceGroup());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RoutingEventHubProperties model =
            new RoutingEventHubProperties()
                .withId("mjmvxieduugidyjr")
                .withConnectionString("byao")
                .withEndpointUri("e")
                .withEntityPath("sonpclhocohs")
                .withAuthenticationType(AuthenticationType.KEY_BASED)
                .withIdentity(new ManagedIdentity().withUserAssignedIdentity("eggzfb"))
                .withName("hfmvfaxkffe")
                .withSubscriptionId("th")
                .withResourceGroup("m");
        model = BinaryData.fromObject(model).toObject(RoutingEventHubProperties.class);
        Assertions.assertEquals("mjmvxieduugidyjr", model.id());
        Assertions.assertEquals("byao", model.connectionString());
        Assertions.assertEquals("e", model.endpointUri());
        Assertions.assertEquals("sonpclhocohs", model.entityPath());
        Assertions.assertEquals(AuthenticationType.KEY_BASED, model.authenticationType());
        Assertions.assertEquals("eggzfb", model.identity().userAssignedIdentity());
        Assertions.assertEquals("hfmvfaxkffe", model.name());
        Assertions.assertEquals("th", model.subscriptionId());
        Assertions.assertEquals("m", model.resourceGroup());
    }
}
