// 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.EventSourceCommonProperties;
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 EventSourceCommonPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EventSourceCommonProperties model =
            BinaryData
                .fromString(
                    "{\"timestampPropertyName\":\"notyfjfcnjbkcn\",\"localTimestamp\":{\"format\":\"Embedded\",\"timeZoneOffset\":{\"propertyName\":\"kphywpnvjto\"}},\"ingressStartAt\":{\"type\":\"CustomEnqueuedTime\",\"time\":\"clfp\"},\"provisioningState\":\"Creating\",\"creationTime\":\"2021-02-27T06:24:12Z\"}")
                .toObject(EventSourceCommonProperties.class);
        Assertions.assertEquals("notyfjfcnjbkcn", model.timestampPropertyName());
        Assertions.assertEquals(LocalTimestampFormat.EMBEDDED, model.localTimestamp().format());
        Assertions.assertEquals("kphywpnvjto", model.localTimestamp().timeZoneOffset().propertyName());
        Assertions.assertEquals(IngressStartAtType.CUSTOM_ENQUEUED_TIME, model.type());
        Assertions.assertEquals("clfp", model.time());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EventSourceCommonProperties model =
            new EventSourceCommonProperties()
                .withTimestampPropertyName("notyfjfcnjbkcn")
                .withLocalTimestamp(
                    new LocalTimestamp()
                        .withFormat(LocalTimestampFormat.EMBEDDED)
                        .withTimeZoneOffset(new LocalTimestampTimeZoneOffset().withPropertyName("kphywpnvjto")))
                .withType(IngressStartAtType.CUSTOM_ENQUEUED_TIME)
                .withTime("clfp");
        model = BinaryData.fromObject(model).toObject(EventSourceCommonProperties.class);
        Assertions.assertEquals("notyfjfcnjbkcn", model.timestampPropertyName());
        Assertions.assertEquals(LocalTimestampFormat.EMBEDDED, model.localTimestamp().format());
        Assertions.assertEquals("kphywpnvjto", model.localTimestamp().timeZoneOffset().propertyName());
        Assertions.assertEquals(IngressStartAtType.CUSTOM_ENQUEUED_TIME, model.type());
        Assertions.assertEquals("clfp", model.time());
    }
}
