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

public final class IotHubConnectionPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IotHubConnectionProperties model =
            BinaryData
                .fromString(
                    "{\"iotHubResourceId\":\"tvlz\",\"consumerGroup\":\"wem\",\"tableName\":\"rncsdtclu\",\"mappingRuleName\":\"ypbsfgytguslfead\",\"dataFormat\":\"JSON\",\"eventSystemProperties\":[\"kyhejhzisxgf\",\"elolppvksrpqvuj\",\"raehtwdwrft\"],\"sharedAccessPolicyName\":\"wib\",\"databaseRouting\":\"Single\",\"retrievalStartDate\":\"2021-01-18T20:33:29Z\",\"provisioningState\":\"Moving\"}")
                .toObject(IotHubConnectionProperties.class);
        Assertions.assertEquals("tvlz", model.iotHubResourceId());
        Assertions.assertEquals("wem", model.consumerGroup());
        Assertions.assertEquals("rncsdtclu", model.tableName());
        Assertions.assertEquals("ypbsfgytguslfead", model.mappingRuleName());
        Assertions.assertEquals(IotHubDataFormat.JSON, model.dataFormat());
        Assertions.assertEquals("kyhejhzisxgf", model.eventSystemProperties().get(0));
        Assertions.assertEquals("wib", model.sharedAccessPolicyName());
        Assertions.assertEquals(DatabaseRouting.SINGLE, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-18T20:33:29Z"), model.retrievalStartDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IotHubConnectionProperties model =
            new IotHubConnectionProperties()
                .withIotHubResourceId("tvlz")
                .withConsumerGroup("wem")
                .withTableName("rncsdtclu")
                .withMappingRuleName("ypbsfgytguslfead")
                .withDataFormat(IotHubDataFormat.JSON)
                .withEventSystemProperties(Arrays.asList("kyhejhzisxgf", "elolppvksrpqvuj", "raehtwdwrft"))
                .withSharedAccessPolicyName("wib")
                .withDatabaseRouting(DatabaseRouting.SINGLE)
                .withRetrievalStartDate(OffsetDateTime.parse("2021-01-18T20:33:29Z"));
        model = BinaryData.fromObject(model).toObject(IotHubConnectionProperties.class);
        Assertions.assertEquals("tvlz", model.iotHubResourceId());
        Assertions.assertEquals("wem", model.consumerGroup());
        Assertions.assertEquals("rncsdtclu", model.tableName());
        Assertions.assertEquals("ypbsfgytguslfead", model.mappingRuleName());
        Assertions.assertEquals(IotHubDataFormat.JSON, model.dataFormat());
        Assertions.assertEquals("kyhejhzisxgf", model.eventSystemProperties().get(0));
        Assertions.assertEquals("wib", model.sharedAccessPolicyName());
        Assertions.assertEquals(DatabaseRouting.SINGLE, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-18T20:33:29Z"), model.retrievalStartDate());
    }
}
