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

package com.azure.resourcemanager.databoxedge.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.databoxedge.fluent.models.PeriodicTimerProperties;
import com.azure.resourcemanager.databoxedge.models.PeriodicTimerSourceInfo;
import com.azure.resourcemanager.databoxedge.models.RoleSinkInfo;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class PeriodicTimerPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PeriodicTimerProperties model =
            BinaryData
                .fromString(
                    "{\"sourceInfo\":{\"startTime\":\"2021-04-29T01:54:20Z\",\"schedule\":\"pelol\",\"topic\":\"vk\"},\"sinkInfo\":{\"roleId\":\"r\"},\"customContextTag\":\"vu\"}")
                .toObject(PeriodicTimerProperties.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-29T01:54:20Z"), model.sourceInfo().startTime());
        Assertions.assertEquals("pelol", model.sourceInfo().schedule());
        Assertions.assertEquals("vk", model.sourceInfo().topic());
        Assertions.assertEquals("r", model.sinkInfo().roleId());
        Assertions.assertEquals("vu", model.customContextTag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PeriodicTimerProperties model =
            new PeriodicTimerProperties()
                .withSourceInfo(
                    new PeriodicTimerSourceInfo()
                        .withStartTime(OffsetDateTime.parse("2021-04-29T01:54:20Z"))
                        .withSchedule("pelol")
                        .withTopic("vk"))
                .withSinkInfo(new RoleSinkInfo().withRoleId("r"))
                .withCustomContextTag("vu");
        model = BinaryData.fromObject(model).toObject(PeriodicTimerProperties.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-29T01:54:20Z"), model.sourceInfo().startTime());
        Assertions.assertEquals("pelol", model.sourceInfo().schedule());
        Assertions.assertEquals("vk", model.sourceInfo().topic());
        Assertions.assertEquals("r", model.sinkInfo().roleId());
        Assertions.assertEquals("vu", model.customContextTag());
    }
}
