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

package com.azure.resourcemanager.maintenance.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.maintenance.fluent.models.ApplyUpdateInner;
import com.azure.resourcemanager.maintenance.models.ListApplyUpdate;
import com.azure.resourcemanager.maintenance.models.UpdateStatus;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ListApplyUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ListApplyUpdate model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"status\":\"RetryNow\",\"resourceId\":\"zqqedq\",\"lastUpdateTime\":\"2021-11-23T05:43:53Z\"},\"id\":\"iqfouflmmnkz\",\"name\":\"modmglougpb\",\"type\":\"wtmutduq\"}]}")
                .toObject(ListApplyUpdate.class);
        Assertions.assertEquals(UpdateStatus.RETRY_NOW, model.value().get(0).status());
        Assertions.assertEquals("zqqedq", model.value().get(0).resourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-23T05:43:53Z"), model.value().get(0).lastUpdateTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ListApplyUpdate model =
            new ListApplyUpdate()
                .withValue(
                    Arrays
                        .asList(
                            new ApplyUpdateInner()
                                .withStatus(UpdateStatus.RETRY_NOW)
                                .withResourceId("zqqedq")
                                .withLastUpdateTime(OffsetDateTime.parse("2021-11-23T05:43:53Z"))));
        model = BinaryData.fromObject(model).toObject(ListApplyUpdate.class);
        Assertions.assertEquals(UpdateStatus.RETRY_NOW, model.value().get(0).status());
        Assertions.assertEquals("zqqedq", model.value().get(0).resourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-23T05:43:53Z"), model.value().get(0).lastUpdateTime());
    }
}
