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

package com.azure.resourcemanager.devcenter.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devcenter.fluent.models.OperationStatusInner;
import com.azure.resourcemanager.devcenter.models.OperationStatusResult;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class OperationStatusInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        OperationStatusInner model =
            BinaryData
                .fromString(
                    "{\"resourceId\":\"rzdzucerscdnt\",\"properties\":\"datavfiwjmygtdss\",\"id\":\"wtmwerio\",\"name\":\"pyqs\",\"status\":\"mwabnetshhszhedp\",\"percentComplete\":32.709515,\"startTime\":\"2021-09-12T04:45:44Z\",\"endTime\":\"2021-11-02T03:10:18Z\",\"operations\":[{\"id\":\"besldnkwwtppjflc\",\"name\":\"gaokonzmnsikv\",\"status\":\"kqze\",\"percentComplete\":76.51815,\"startTime\":\"2021-10-18T16:10:37Z\",\"endTime\":\"2021-09-09T14:39:27Z\",\"operations\":[]},{\"id\":\"hvhgureod\",\"name\":\"obdagxtibqdxb\",\"status\":\"wakbogqxndl\",\"percentComplete\":56.968266,\"startTime\":\"2021-03-10T22:50:11Z\",\"endTime\":\"2021-10-18T16:27:54Z\",\"operations\":[]},{\"id\":\"podxunkb\",\"name\":\"xmubyyntwlrbq\",\"status\":\"koievseo\",\"percentComplete\":3.3486485,\"startTime\":\"2021-05-15T11:53:23Z\",\"endTime\":\"2021-06-26T20:58:29Z\",\"operations\":[]}]}")
                .toObject(OperationStatusInner.class);
        Assertions.assertEquals("wtmwerio", model.id());
        Assertions.assertEquals("pyqs", model.name());
        Assertions.assertEquals("mwabnetshhszhedp", model.status());
        Assertions.assertEquals(32.709515F, model.percentComplete());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-12T04:45:44Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-02T03:10:18Z"), model.endTime());
        Assertions.assertEquals("besldnkwwtppjflc", model.operations().get(0).id());
        Assertions.assertEquals("gaokonzmnsikv", model.operations().get(0).name());
        Assertions.assertEquals("kqze", model.operations().get(0).status());
        Assertions.assertEquals(76.51815F, model.operations().get(0).percentComplete());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-18T16:10:37Z"), model.operations().get(0).startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-09T14:39:27Z"), model.operations().get(0).endTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        OperationStatusInner model =
            new OperationStatusInner()
                .withId("wtmwerio")
                .withName("pyqs")
                .withStatus("mwabnetshhszhedp")
                .withPercentComplete(32.709515F)
                .withStartTime(OffsetDateTime.parse("2021-09-12T04:45:44Z"))
                .withEndTime(OffsetDateTime.parse("2021-11-02T03:10:18Z"))
                .withOperations(
                    Arrays
                        .asList(
                            new OperationStatusResult()
                                .withId("besldnkwwtppjflc")
                                .withName("gaokonzmnsikv")
                                .withStatus("kqze")
                                .withPercentComplete(76.51815F)
                                .withStartTime(OffsetDateTime.parse("2021-10-18T16:10:37Z"))
                                .withEndTime(OffsetDateTime.parse("2021-09-09T14:39:27Z"))
                                .withOperations(Arrays.asList()),
                            new OperationStatusResult()
                                .withId("hvhgureod")
                                .withName("obdagxtibqdxb")
                                .withStatus("wakbogqxndl")
                                .withPercentComplete(56.968266F)
                                .withStartTime(OffsetDateTime.parse("2021-03-10T22:50:11Z"))
                                .withEndTime(OffsetDateTime.parse("2021-10-18T16:27:54Z"))
                                .withOperations(Arrays.asList()),
                            new OperationStatusResult()
                                .withId("podxunkb")
                                .withName("xmubyyntwlrbq")
                                .withStatus("koievseo")
                                .withPercentComplete(3.3486485F)
                                .withStartTime(OffsetDateTime.parse("2021-05-15T11:53:23Z"))
                                .withEndTime(OffsetDateTime.parse("2021-06-26T20:58:29Z"))
                                .withOperations(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(OperationStatusInner.class);
        Assertions.assertEquals("wtmwerio", model.id());
        Assertions.assertEquals("pyqs", model.name());
        Assertions.assertEquals("mwabnetshhszhedp", model.status());
        Assertions.assertEquals(32.709515F, model.percentComplete());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-12T04:45:44Z"), model.startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-02T03:10:18Z"), model.endTime());
        Assertions.assertEquals("besldnkwwtppjflc", model.operations().get(0).id());
        Assertions.assertEquals("gaokonzmnsikv", model.operations().get(0).name());
        Assertions.assertEquals("kqze", model.operations().get(0).status());
        Assertions.assertEquals(76.51815F, model.operations().get(0).percentComplete());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-18T16:10:37Z"), model.operations().get(0).startTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-09T14:39:27Z"), model.operations().get(0).endTime());
    }
}
