// 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.Compression;
import com.azure.resourcemanager.kusto.models.DatabaseRouting;
import com.azure.resourcemanager.kusto.models.EventHubDataConnection;
import com.azure.resourcemanager.kusto.models.EventHubDataFormat;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EventHubDataConnectionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EventHubDataConnection model =
            BinaryData
                .fromString(
                    "{\"kind\":\"EventHub\",\"properties\":{\"eventHubResourceId\":\"ho\",\"consumerGroup\":\"zqzudph\",\"tableName\":\"mvdk\",\"mappingRuleName\":\"ynwcvtbv\",\"dataFormat\":\"AVRO\",\"eventSystemProperties\":[\"tnvyqiatkzwp\",\"npwzcjaes\"],\"compression\":\"None\",\"provisioningState\":\"Deleting\",\"managedIdentityResourceId\":\"yajguqfhwygzlv\",\"managedIdentityObjectId\":\"kfxu\",\"databaseRouting\":\"Multi\",\"retrievalStartDate\":\"2021-02-14T09:42:03Z\"},\"location\":\"rmuhapfcq\",\"id\":\"psqxq\",\"name\":\"psvuoymgc\",\"type\":\"elvezrypq\"}")
                .toObject(EventHubDataConnection.class);
        Assertions.assertEquals("rmuhapfcq", model.location());
        Assertions.assertEquals("ho", model.eventHubResourceId());
        Assertions.assertEquals("zqzudph", model.consumerGroup());
        Assertions.assertEquals("mvdk", model.tableName());
        Assertions.assertEquals("ynwcvtbv", model.mappingRuleName());
        Assertions.assertEquals(EventHubDataFormat.AVRO, model.dataFormat());
        Assertions.assertEquals("tnvyqiatkzwp", model.eventSystemProperties().get(0));
        Assertions.assertEquals(Compression.NONE, model.compression());
        Assertions.assertEquals("yajguqfhwygzlv", model.managedIdentityResourceId());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-14T09:42:03Z"), model.retrievalStartDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EventHubDataConnection model =
            new EventHubDataConnection()
                .withLocation("rmuhapfcq")
                .withEventHubResourceId("ho")
                .withConsumerGroup("zqzudph")
                .withTableName("mvdk")
                .withMappingRuleName("ynwcvtbv")
                .withDataFormat(EventHubDataFormat.AVRO)
                .withEventSystemProperties(Arrays.asList("tnvyqiatkzwp", "npwzcjaes"))
                .withCompression(Compression.NONE)
                .withManagedIdentityResourceId("yajguqfhwygzlv")
                .withDatabaseRouting(DatabaseRouting.MULTI)
                .withRetrievalStartDate(OffsetDateTime.parse("2021-02-14T09:42:03Z"));
        model = BinaryData.fromObject(model).toObject(EventHubDataConnection.class);
        Assertions.assertEquals("rmuhapfcq", model.location());
        Assertions.assertEquals("ho", model.eventHubResourceId());
        Assertions.assertEquals("zqzudph", model.consumerGroup());
        Assertions.assertEquals("mvdk", model.tableName());
        Assertions.assertEquals("ynwcvtbv", model.mappingRuleName());
        Assertions.assertEquals(EventHubDataFormat.AVRO, model.dataFormat());
        Assertions.assertEquals("tnvyqiatkzwp", model.eventSystemProperties().get(0));
        Assertions.assertEquals(Compression.NONE, model.compression());
        Assertions.assertEquals("yajguqfhwygzlv", model.managedIdentityResourceId());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-14T09:42:03Z"), model.retrievalStartDate());
    }
}
