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

package com.azure.resourcemanager.timeseriesinsights.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.timeseriesinsights.models.AzureEventSourceProperties;
import com.azure.resourcemanager.timeseriesinsights.models.IngressStartAtType;
import com.azure.resourcemanager.timeseriesinsights.models.LocalTimestamp;
import com.azure.resourcemanager.timeseriesinsights.models.LocalTimestampFormat;
import com.azure.resourcemanager.timeseriesinsights.models.LocalTimestampTimeZoneOffset;
import org.junit.jupiter.api.Assertions;

public final class AzureEventSourcePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureEventSourceProperties model =
            BinaryData
                .fromString(
                    "{\"eventSourceResourceId\":\"kyzxuutk\",\"timestampPropertyName\":\"ws\",\"localTimestamp\":{\"format\":\"Embedded\",\"timeZoneOffset\":{\"propertyName\":\"otogtwrupqs\"}},\"ingressStartAt\":{\"type\":\"EventSourceCreationTime\",\"time\":\"cykvceo\"},\"provisioningState\":\"Failed\",\"creationTime\":\"2021-05-12T18:53:43Z\"}")
                .toObject(AzureEventSourceProperties.class);
        Assertions.assertEquals("ws", model.timestampPropertyName());
        Assertions.assertEquals(LocalTimestampFormat.EMBEDDED, model.localTimestamp().format());
        Assertions.assertEquals("otogtwrupqs", model.localTimestamp().timeZoneOffset().propertyName());
        Assertions.assertEquals(IngressStartAtType.EVENT_SOURCE_CREATION_TIME, model.type());
        Assertions.assertEquals("cykvceo", model.time());
        Assertions.assertEquals("kyzxuutk", model.eventSourceResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureEventSourceProperties model =
            new AzureEventSourceProperties()
                .withTimestampPropertyName("ws")
                .withLocalTimestamp(
                    new LocalTimestamp()
                        .withFormat(LocalTimestampFormat.EMBEDDED)
                        .withTimeZoneOffset(new LocalTimestampTimeZoneOffset().withPropertyName("otogtwrupqs")))
                .withType(IngressStartAtType.EVENT_SOURCE_CREATION_TIME)
                .withTime("cykvceo")
                .withEventSourceResourceId("kyzxuutk");
        model = BinaryData.fromObject(model).toObject(AzureEventSourceProperties.class);
        Assertions.assertEquals("ws", model.timestampPropertyName());
        Assertions.assertEquals(LocalTimestampFormat.EMBEDDED, model.localTimestamp().format());
        Assertions.assertEquals("otogtwrupqs", model.localTimestamp().timeZoneOffset().propertyName());
        Assertions.assertEquals(IngressStartAtType.EVENT_SOURCE_CREATION_TIME, model.type());
        Assertions.assertEquals("cykvceo", model.time());
        Assertions.assertEquals("kyzxuutk", model.eventSourceResourceId());
    }
}
