// 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.MabJobTaskDetails;
import java.time.Duration;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class MabJobTaskDetailsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MabJobTaskDetails model =
            BinaryData
                .fromString(
                    "{\"taskId\":\"tmvcop\",\"startTime\":\"2021-04-23T10:50:57Z\",\"endTime\":\"2021-04-09T23:00Z\",\"duration\":\"PT37H20M48S\",\"status\":\"u\"}")
                .toObject(MabJobTaskDetails.class);
        Assertions.assertEquals("tmvcop", model.taskId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-23T10:50:57Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-09T23:00Z"), model.endTime());
        Assertions.assertEquals(Duration.parse("PT37H20M48S"), model.duration());
        Assertions.assertEquals("u", model.status());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MabJobTaskDetails model =
            new MabJobTaskDetails()
                .withTaskId("tmvcop")
                .withStartTime(OffsetDateTime.parse("2021-04-23T10:50:57Z"))
                .withEndTime(OffsetDateTime.parse("2021-04-09T23:00Z"))
                .withDuration(Duration.parse("PT37H20M48S"))
                .withStatus("u");
        model = BinaryData.fromObject(model).toObject(MabJobTaskDetails.class);
        Assertions.assertEquals("tmvcop", model.taskId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-23T10:50:57Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-09T23:00Z"), model.endTime());
        Assertions.assertEquals(Duration.parse("PT37H20M48S"), model.duration());
        Assertions.assertEquals("u", model.status());
    }
}
