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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.ComputeInstanceLastOperation;
import com.azure.resourcemanager.machinelearning.models.OperationName;
import com.azure.resourcemanager.machinelearning.models.OperationStatus;
import com.azure.resourcemanager.machinelearning.models.OperationTrigger;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ComputeInstanceLastOperationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ComputeInstanceLastOperation model =
            BinaryData
                .fromString(
                    "{\"operationName\":\"Reimage\",\"operationTime\":\"2021-10-12T06:41:45Z\",\"operationStatus\":\"InProgress\",\"operationTrigger\":\"IdleShutdown\"}")
                .toObject(ComputeInstanceLastOperation.class);
        Assertions.assertEquals(OperationName.REIMAGE, model.operationName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-12T06:41:45Z"), model.operationTime());
        Assertions.assertEquals(OperationStatus.IN_PROGRESS, model.operationStatus());
        Assertions.assertEquals(OperationTrigger.IDLE_SHUTDOWN, model.operationTrigger());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ComputeInstanceLastOperation model =
            new ComputeInstanceLastOperation()
                .withOperationName(OperationName.REIMAGE)
                .withOperationTime(OffsetDateTime.parse("2021-10-12T06:41:45Z"))
                .withOperationStatus(OperationStatus.IN_PROGRESS)
                .withOperationTrigger(OperationTrigger.IDLE_SHUTDOWN);
        model = BinaryData.fromObject(model).toObject(ComputeInstanceLastOperation.class);
        Assertions.assertEquals(OperationName.REIMAGE, model.operationName());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-12T06:41:45Z"), model.operationTime());
        Assertions.assertEquals(OperationStatus.IN_PROGRESS, model.operationStatus());
        Assertions.assertEquals(OperationTrigger.IDLE_SHUTDOWN, model.operationTrigger());
    }
}
