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

public final class IotHubDataConnectionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IotHubDataConnection model =
            BinaryData
                .fromString(
                    "{\"kind\":\"IotHub\",\"properties\":{\"iotHubResourceId\":\"feo\",\"consumerGroup\":\"erqwkyhkobopg\",\"tableName\":\"dkow\",\"mappingRuleName\":\"bqpc\",\"dataFormat\":\"SCSV\",\"eventSystemProperties\":[\"ccsnjvcdwxlpq\",\"kftnkhtjsyin\",\"wfqatmtd\",\"tmdvypgikdgs\"],\"sharedAccessPolicyName\":\"ywkbirryuzhlhkjo\",\"databaseRouting\":\"Multi\",\"retrievalStartDate\":\"2021-09-24T04:17:08Z\",\"provisioningState\":\"Canceled\"},\"location\":\"jinrvgoupmfiibfg\",\"id\":\"jioolvrwxk\",\"name\":\"tkkgllqwjy\",\"type\":\"vjayvblmhvkzu\"}")
                .toObject(IotHubDataConnection.class);
        Assertions.assertEquals("jinrvgoupmfiibfg", model.location());
        Assertions.assertEquals("feo", model.iotHubResourceId());
        Assertions.assertEquals("erqwkyhkobopg", model.consumerGroup());
        Assertions.assertEquals("dkow", model.tableName());
        Assertions.assertEquals("bqpc", model.mappingRuleName());
        Assertions.assertEquals(IotHubDataFormat.SCSV, model.dataFormat());
        Assertions.assertEquals("ccsnjvcdwxlpq", model.eventSystemProperties().get(0));
        Assertions.assertEquals("ywkbirryuzhlhkjo", model.sharedAccessPolicyName());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-24T04:17:08Z"), model.retrievalStartDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IotHubDataConnection model =
            new IotHubDataConnection()
                .withLocation("jinrvgoupmfiibfg")
                .withIotHubResourceId("feo")
                .withConsumerGroup("erqwkyhkobopg")
                .withTableName("dkow")
                .withMappingRuleName("bqpc")
                .withDataFormat(IotHubDataFormat.SCSV)
                .withEventSystemProperties(Arrays.asList("ccsnjvcdwxlpq", "kftnkhtjsyin", "wfqatmtd", "tmdvypgikdgs"))
                .withSharedAccessPolicyName("ywkbirryuzhlhkjo")
                .withDatabaseRouting(DatabaseRouting.MULTI)
                .withRetrievalStartDate(OffsetDateTime.parse("2021-09-24T04:17:08Z"));
        model = BinaryData.fromObject(model).toObject(IotHubDataConnection.class);
        Assertions.assertEquals("jinrvgoupmfiibfg", model.location());
        Assertions.assertEquals("feo", model.iotHubResourceId());
        Assertions.assertEquals("erqwkyhkobopg", model.consumerGroup());
        Assertions.assertEquals("dkow", model.tableName());
        Assertions.assertEquals("bqpc", model.mappingRuleName());
        Assertions.assertEquals(IotHubDataFormat.SCSV, model.dataFormat());
        Assertions.assertEquals("ccsnjvcdwxlpq", model.eventSystemProperties().get(0));
        Assertions.assertEquals("ywkbirryuzhlhkjo", model.sharedAccessPolicyName());
        Assertions.assertEquals(DatabaseRouting.MULTI, model.databaseRouting());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-24T04:17:08Z"), model.retrievalStartDate());
    }
}
