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

package com.azure.resourcemanager.kusto.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.kusto.models.BlobStorageEventType;
import com.azure.resourcemanager.kusto.models.DatabaseRouting;
import com.azure.resourcemanager.kusto.models.EventGridDataConnection;
import com.azure.resourcemanager.kusto.models.EventGridDataFormat;
import org.junit.jupiter.api.Assertions;

public final class EventGridDataConnectionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EventGridDataConnection model =
            BinaryData
                .fromString(
                    "{\"kind\":\"EventGrid\",\"properties\":{\"storageAccountResourceId\":\"xvvy\",\"eventGridResourceId\":\"s\",\"eventHubResourceId\":\"pbyrqufegxu\",\"consumerGroup\":\"wz\",\"tableName\":\"nhlmctlpdng\",\"mappingRuleName\":\"vgbmhr\",\"dataFormat\":\"JSON\",\"ignoreFirstRecord\":true,\"blobStorageEventType\":\"Microsoft.Storage.BlobRenamed\",\"managedIdentityResourceId\":\"ejvegrhbpnaixex\",\"managedIdentityObjectId\":\"b\",\"databaseRouting\":\"Multi\",\"provisioningState\":\"Running\"},\"location\":\"cexdrrvqa\",\"id\":\"qkghtpwijnhy\",\"name\":\"svfycxzbfv\",\"type\":\"owvrvmtgjqppyos\"}")
                .toObject(EventGridDataConnection.class);
        Assertions.assertEquals("cexdrrvqa", model.location());
        Assertions.assertEquals("xvvy", model.storageAccountResourceId());
        Assertions.assertEquals("s", model.eventGridResourceId());
        Assertions.assertEquals("pbyrqufegxu", model.eventHubResourceId());
        Assertions.assertEquals("wz", model.consumerGroup());
        Assertions.assertEquals("nhlmctlpdng", model.tableName());
        Assertions.assertEquals("vgbmhr", model.mappingRuleName());
        Assertions.assertEquals(EventGridDataFormat.JSON, model.dataFormat());
        Assertions.assertEquals(true, model.ignoreFirstRecord());
        Assertions.assertEquals(BlobStorageEventType.MICROSOFT_STORAGE_BLOB_RENAMED, model.blobStorageEventType());
        Assertions.assertEquals("ejvegrhbpnaixex", model.managedIdentityResourceId());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EventGridDataConnection model =
            new EventGridDataConnection()
                .withLocation("cexdrrvqa")
                .withStorageAccountResourceId("xvvy")
                .withEventGridResourceId("s")
                .withEventHubResourceId("pbyrqufegxu")
                .withConsumerGroup("wz")
                .withTableName("nhlmctlpdng")
                .withMappingRuleName("vgbmhr")
                .withDataFormat(EventGridDataFormat.JSON)
                .withIgnoreFirstRecord(true)
                .withBlobStorageEventType(BlobStorageEventType.MICROSOFT_STORAGE_BLOB_RENAMED)
                .withManagedIdentityResourceId("ejvegrhbpnaixex")
                .withDatabaseRouting(DatabaseRouting.MULTI);
        model = BinaryData.fromObject(model).toObject(EventGridDataConnection.class);
        Assertions.assertEquals("cexdrrvqa", model.location());
        Assertions.assertEquals("xvvy", model.storageAccountResourceId());
        Assertions.assertEquals("s", model.eventGridResourceId());
        Assertions.assertEquals("pbyrqufegxu", model.eventHubResourceId());
        Assertions.assertEquals("wz", model.consumerGroup());
        Assertions.assertEquals("nhlmctlpdng", model.tableName());
        Assertions.assertEquals("vgbmhr", model.mappingRuleName());
        Assertions.assertEquals(EventGridDataFormat.JSON, model.dataFormat());
        Assertions.assertEquals(true, model.ignoreFirstRecord());
        Assertions.assertEquals(BlobStorageEventType.MICROSOFT_STORAGE_BLOB_RENAMED, model.blobStorageEventType());
        Assertions.assertEquals("ejvegrhbpnaixex", model.managedIdentityResourceId());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
    }
}
