// 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.UpdateInner;
import com.azure.resourcemanager.maintenance.models.ImpactType;
import com.azure.resourcemanager.maintenance.models.ListUpdatesResult;
import com.azure.resourcemanager.maintenance.models.MaintenanceScope;
import com.azure.resourcemanager.maintenance.models.UpdateStatus;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ListUpdatesResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ListUpdatesResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"maintenanceScope\":\"SQLDB\",\"impactType\":\"Restart\",\"status\":\"Completed\",\"impactDurationInSec\":2146966484,\"notBefore\":\"2020-12-28T02:07:44Z\",\"properties\":{\"resourceId\":\"ezcxtbzsgfyccsne\"}},{\"maintenanceScope\":\"SQLDB\",\"impactType\":\"None\",\"status\":\"Completed\",\"impactDurationInSec\":479901048,\"notBefore\":\"2021-08-09T00:52:58Z\",\"properties\":{\"resourceId\":\"osfln\"}},{\"maintenanceScope\":\"SQLDB\",\"impactType\":\"Freeze\",\"status\":\"Pending\",\"impactDurationInSec\":824817069,\"notBefore\":\"2021-06-28T09:00:21Z\",\"properties\":{\"resourceId\":\"ypyqrimzinp\"}}]}")
                .toObject(ListUpdatesResult.class);
        Assertions.assertEquals(MaintenanceScope.SQLDB, model.value().get(0).maintenanceScope());
        Assertions.assertEquals(ImpactType.RESTART, model.value().get(0).impactType());
        Assertions.assertEquals(UpdateStatus.COMPLETED, model.value().get(0).status());
        Assertions.assertEquals(2146966484, model.value().get(0).impactDurationInSec());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-28T02:07:44Z"), model.value().get(0).notBefore());
        Assertions.assertEquals("ezcxtbzsgfyccsne", model.value().get(0).resourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ListUpdatesResult model =
            new ListUpdatesResult()
                .withValue(
                    Arrays
                        .asList(
                            new UpdateInner()
                                .withMaintenanceScope(MaintenanceScope.SQLDB)
                                .withImpactType(ImpactType.RESTART)
                                .withStatus(UpdateStatus.COMPLETED)
                                .withImpactDurationInSec(2146966484)
                                .withNotBefore(OffsetDateTime.parse("2020-12-28T02:07:44Z"))
                                .withResourceId("ezcxtbzsgfyccsne"),
                            new UpdateInner()
                                .withMaintenanceScope(MaintenanceScope.SQLDB)
                                .withImpactType(ImpactType.NONE)
                                .withStatus(UpdateStatus.COMPLETED)
                                .withImpactDurationInSec(479901048)
                                .withNotBefore(OffsetDateTime.parse("2021-08-09T00:52:58Z"))
                                .withResourceId("osfln"),
                            new UpdateInner()
                                .withMaintenanceScope(MaintenanceScope.SQLDB)
                                .withImpactType(ImpactType.FREEZE)
                                .withStatus(UpdateStatus.PENDING)
                                .withImpactDurationInSec(824817069)
                                .withNotBefore(OffsetDateTime.parse("2021-06-28T09:00:21Z"))
                                .withResourceId("ypyqrimzinp")));
        model = BinaryData.fromObject(model).toObject(ListUpdatesResult.class);
        Assertions.assertEquals(MaintenanceScope.SQLDB, model.value().get(0).maintenanceScope());
        Assertions.assertEquals(ImpactType.RESTART, model.value().get(0).impactType());
        Assertions.assertEquals(UpdateStatus.COMPLETED, model.value().get(0).status());
        Assertions.assertEquals(2146966484, model.value().get(0).impactDurationInSec());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-28T02:07:44Z"), model.value().get(0).notBefore());
        Assertions.assertEquals("ezcxtbzsgfyccsne", model.value().get(0).resourceId());
    }
}
