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

package com.azure.resourcemanager.digitaltwins.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.digitaltwins.models.AzureDataExplorerConnectionProperties;
import com.azure.resourcemanager.digitaltwins.models.IdentityType;
import com.azure.resourcemanager.digitaltwins.models.ManagedIdentityReference;
import com.azure.resourcemanager.digitaltwins.models.RecordPropertyAndItemRemovals;
import org.junit.jupiter.api.Assertions;

public final class AzureDataExplorerConnectionPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureDataExplorerConnectionProperties model =
            BinaryData
                .fromString(
                    "{\"connectionType\":\"AzureDataExplorer\",\"adxResourceId\":\"wflzlfbxzpuzy\",\"adxEndpointUri\":\"ispnqzahmgkbrp\",\"adxDatabaseName\":\"y\",\"adxTableName\":\"ibnuqqkpik\",\"adxTwinLifecycleEventsTableName\":\"rgvtqag\",\"adxRelationshipLifecycleEventsTableName\":\"uynhijg\",\"eventHubEndpointUri\":\"mebf\",\"eventHubEntityPath\":\"iarbutrcvpna\",\"eventHubNamespaceResourceId\":\"zmhjrunmp\",\"eventHubConsumerGroup\":\"tdbhrbnla\",\"recordPropertyAndItemRemovals\":\"true\",\"provisioningState\":\"Suspending\",\"identity\":{\"type\":\"SystemAssigned\",\"userAssignedIdentity\":\"henbtkcxywnytn\"}}")
                .toObject(AzureDataExplorerConnectionProperties.class);
        Assertions.assertEquals(IdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals("henbtkcxywnytn", model.identity().userAssignedIdentity());
        Assertions.assertEquals("wflzlfbxzpuzy", model.adxResourceId());
        Assertions.assertEquals("ispnqzahmgkbrp", model.adxEndpointUri());
        Assertions.assertEquals("y", model.adxDatabaseName());
        Assertions.assertEquals("ibnuqqkpik", model.adxTableName());
        Assertions.assertEquals("rgvtqag", model.adxTwinLifecycleEventsTableName());
        Assertions.assertEquals("uynhijg", model.adxRelationshipLifecycleEventsTableName());
        Assertions.assertEquals("mebf", model.eventHubEndpointUri());
        Assertions.assertEquals("iarbutrcvpna", model.eventHubEntityPath());
        Assertions.assertEquals("zmhjrunmp", model.eventHubNamespaceResourceId());
        Assertions.assertEquals("tdbhrbnla", model.eventHubConsumerGroup());
        Assertions.assertEquals(RecordPropertyAndItemRemovals.TRUE, model.recordPropertyAndItemRemovals());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureDataExplorerConnectionProperties model =
            new AzureDataExplorerConnectionProperties()
                .withIdentity(
                    new ManagedIdentityReference()
                        .withType(IdentityType.SYSTEM_ASSIGNED)
                        .withUserAssignedIdentity("henbtkcxywnytn"))
                .withAdxResourceId("wflzlfbxzpuzy")
                .withAdxEndpointUri("ispnqzahmgkbrp")
                .withAdxDatabaseName("y")
                .withAdxTableName("ibnuqqkpik")
                .withAdxTwinLifecycleEventsTableName("rgvtqag")
                .withAdxRelationshipLifecycleEventsTableName("uynhijg")
                .withEventHubEndpointUri("mebf")
                .withEventHubEntityPath("iarbutrcvpna")
                .withEventHubNamespaceResourceId("zmhjrunmp")
                .withEventHubConsumerGroup("tdbhrbnla")
                .withRecordPropertyAndItemRemovals(RecordPropertyAndItemRemovals.TRUE);
        model = BinaryData.fromObject(model).toObject(AzureDataExplorerConnectionProperties.class);
        Assertions.assertEquals(IdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals("henbtkcxywnytn", model.identity().userAssignedIdentity());
        Assertions.assertEquals("wflzlfbxzpuzy", model.adxResourceId());
        Assertions.assertEquals("ispnqzahmgkbrp", model.adxEndpointUri());
        Assertions.assertEquals("y", model.adxDatabaseName());
        Assertions.assertEquals("ibnuqqkpik", model.adxTableName());
        Assertions.assertEquals("rgvtqag", model.adxTwinLifecycleEventsTableName());
        Assertions.assertEquals("uynhijg", model.adxRelationshipLifecycleEventsTableName());
        Assertions.assertEquals("mebf", model.eventHubEndpointUri());
        Assertions.assertEquals("iarbutrcvpna", model.eventHubEntityPath());
        Assertions.assertEquals("zmhjrunmp", model.eventHubNamespaceResourceId());
        Assertions.assertEquals("tdbhrbnla", model.eventHubConsumerGroup());
        Assertions.assertEquals(RecordPropertyAndItemRemovals.TRUE, model.recordPropertyAndItemRemovals());
    }
}
