// 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.models.PeriodicTimerEventTrigger;
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 PeriodicTimerEventTriggerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PeriodicTimerEventTrigger model =
            BinaryData
                .fromString(
                    "{\"kind\":\"PeriodicTimerEvent\",\"properties\":{\"sourceInfo\":{\"startTime\":\"2021-05-03T02:40:47Z\",\"schedule\":\"w\",\"topic\":\"ggicccnxqhue\"},\"sinkInfo\":{\"roleId\":\"mkttlstvlzywem\"},\"customContextTag\":\"rncsdtclu\"},\"id\":\"iypbsfgytgusl\",\"name\":\"eadcygqukyhejhz\",\"type\":\"sx\"}")
                .toObject(PeriodicTimerEventTrigger.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-03T02:40:47Z"), model.sourceInfo().startTime());
        Assertions.assertEquals("w", model.sourceInfo().schedule());
        Assertions.assertEquals("ggicccnxqhue", model.sourceInfo().topic());
        Assertions.assertEquals("mkttlstvlzywem", model.sinkInfo().roleId());
        Assertions.assertEquals("rncsdtclu", model.customContextTag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PeriodicTimerEventTrigger model =
            new PeriodicTimerEventTrigger()
                .withSourceInfo(
                    new PeriodicTimerSourceInfo()
                        .withStartTime(OffsetDateTime.parse("2021-05-03T02:40:47Z"))
                        .withSchedule("w")
                        .withTopic("ggicccnxqhue"))
                .withSinkInfo(new RoleSinkInfo().withRoleId("mkttlstvlzywem"))
                .withCustomContextTag("rncsdtclu");
        model = BinaryData.fromObject(model).toObject(PeriodicTimerEventTrigger.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-03T02:40:47Z"), model.sourceInfo().startTime());
        Assertions.assertEquals("w", model.sourceInfo().schedule());
        Assertions.assertEquals("ggicccnxqhue", model.sourceInfo().topic());
        Assertions.assertEquals("mkttlstvlzywem", model.sinkInfo().roleId());
        Assertions.assertEquals("rncsdtclu", model.customContextTag());
    }
}
