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

package com.azure.resourcemanager.recoveryservicesbackup.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservicesbackup.models.DpmJobTaskDetails;
import java.time.Duration;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class DpmJobTaskDetailsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DpmJobTaskDetails model =
            BinaryData
                .fromString(
                    "{\"taskId\":\"xk\",\"startTime\":\"2021-08-29T04:56:06Z\",\"endTime\":\"2020-12-27T09:18:38Z\",\"duration\":\"PT193H31M57S\",\"status\":\"wtswbzuwfmdur\"}")
                .toObject(DpmJobTaskDetails.class);
        Assertions.assertEquals("xk", model.taskId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-29T04:56:06Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-27T09:18:38Z"), model.endTime());
        Assertions.assertEquals(Duration.parse("PT193H31M57S"), model.duration());
        Assertions.assertEquals("wtswbzuwfmdur", model.status());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DpmJobTaskDetails model =
            new DpmJobTaskDetails()
                .withTaskId("xk")
                .withStartTime(OffsetDateTime.parse("2021-08-29T04:56:06Z"))
                .withEndTime(OffsetDateTime.parse("2020-12-27T09:18:38Z"))
                .withDuration(Duration.parse("PT193H31M57S"))
                .withStatus("wtswbzuwfmdur");
        model = BinaryData.fromObject(model).toObject(DpmJobTaskDetails.class);
        Assertions.assertEquals("xk", model.taskId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-29T04:56:06Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-27T09:18:38Z"), model.endTime());
        Assertions.assertEquals(Duration.parse("PT193H31M57S"), model.duration());
        Assertions.assertEquals("wtswbzuwfmdur", model.status());
    }
}
