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

public final class EventHubConnectionPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EventHubConnectionProperties model =
            BinaryData
                .fromString(
                    "{\"eventHubResourceId\":\"slfaoqzpiyyl\",\"consumerGroup\":\"alnswhccsphk\",\"tableName\":\"vwitqscyw\",\"mappingRuleName\":\"gwol\",\"dataFormat\":\"PARQUET\",\"eventSystemProperties\":[\"wem\",\"ai\",\"sbrgz\"],\"compression\":\"GZip\",\"provisioningState\":\"Deleting\",\"managedIdentityResourceId\":\"ypqwdxggiccc\",\"managedIdentityObjectId\":\"qhuexm\",\"databaseRouting\":\"Multi\",\"retrievalStartDate\":\"2021-10-24T04:49:39Z\"}")
                .toObject(EventHubConnectionProperties.class);
        Assertions.assertEquals("slfaoqzpiyyl", model.eventHubResourceId());
        Assertions.assertEquals("alnswhccsphk", model.consumerGroup());
        Assertions.assertEquals("vwitqscyw", model.tableName());
        Assertions.assertEquals("gwol", model.mappingRuleName());
        Assertions.assertEquals(EventHubDataFormat.PARQUET, model.dataFormat());
        Assertions.assertEquals("wem", model.eventSystemProperties().get(0));
        Assertions.assertEquals(Compression.GZIP, model.compression());
        Assertions.assertEquals("ypqwdxggiccc", model.managedIdentityResourceId());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-24T04:49:39Z"), model.retrievalStartDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EventHubConnectionProperties model =
            new EventHubConnectionProperties()
                .withEventHubResourceId("slfaoqzpiyyl")
                .withConsumerGroup("alnswhccsphk")
                .withTableName("vwitqscyw")
                .withMappingRuleName("gwol")
                .withDataFormat(EventHubDataFormat.PARQUET)
                .withEventSystemProperties(Arrays.asList("wem", "ai", "sbrgz"))
                .withCompression(Compression.GZIP)
                .withManagedIdentityResourceId("ypqwdxggiccc")
                .withDatabaseRouting(DatabaseRouting.MULTI)
                .withRetrievalStartDate(OffsetDateTime.parse("2021-10-24T04:49:39Z"));
        model = BinaryData.fromObject(model).toObject(EventHubConnectionProperties.class);
        Assertions.assertEquals("slfaoqzpiyyl", model.eventHubResourceId());
        Assertions.assertEquals("alnswhccsphk", model.consumerGroup());
        Assertions.assertEquals("vwitqscyw", model.tableName());
        Assertions.assertEquals("gwol", model.mappingRuleName());
        Assertions.assertEquals(EventHubDataFormat.PARQUET, model.dataFormat());
        Assertions.assertEquals("wem", model.eventSystemProperties().get(0));
        Assertions.assertEquals(Compression.GZIP, model.compression());
        Assertions.assertEquals("ypqwdxggiccc", model.managedIdentityResourceId());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-24T04:49:39Z"), model.retrievalStartDate());
    }
}
