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

package com.azure.resourcemanager.imagebuilder.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.imagebuilder.models.ImageTemplateLastRunStatus;
import com.azure.resourcemanager.imagebuilder.models.RunState;
import com.azure.resourcemanager.imagebuilder.models.RunSubState;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ImageTemplateLastRunStatusTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ImageTemplateLastRunStatus model =
            BinaryData
                .fromString(
                    "{\"startTime\":\"2021-11-26T09:10:23Z\",\"endTime\":\"2021-07-04T09:54:35Z\",\"runState\":\"Succeeded\",\"runSubState\":\"Optimizing\",\"message\":\"ivyevcciqihnhun\"}")
                .toObject(ImageTemplateLastRunStatus.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-26T09:10:23Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-04T09:54:35Z"), model.endTime());
        Assertions.assertEquals(RunState.SUCCEEDED, model.runState());
        Assertions.assertEquals(RunSubState.OPTIMIZING, model.runSubState());
        Assertions.assertEquals("ivyevcciqihnhun", model.message());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ImageTemplateLastRunStatus model =
            new ImageTemplateLastRunStatus()
                .withStartTime(OffsetDateTime.parse("2021-11-26T09:10:23Z"))
                .withEndTime(OffsetDateTime.parse("2021-07-04T09:54:35Z"))
                .withRunState(RunState.SUCCEEDED)
                .withRunSubState(RunSubState.OPTIMIZING)
                .withMessage("ivyevcciqihnhun");
        model = BinaryData.fromObject(model).toObject(ImageTemplateLastRunStatus.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-26T09:10:23Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-04T09:54:35Z"), model.endTime());
        Assertions.assertEquals(RunState.SUCCEEDED, model.runState());
        Assertions.assertEquals(RunSubState.OPTIMIZING, model.runSubState());
        Assertions.assertEquals("ivyevcciqihnhun", model.message());
    }
}
