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

package com.azure.resourcemanager.mysqlflexibleserver.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mysqlflexibleserver.fluent.models.ServerBackupInner;
import com.azure.resourcemanager.mysqlflexibleserver.models.ServerBackupListResult;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ServerBackupListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServerBackupListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"backupType\":\"t\",\"completedTime\":\"2021-02-24T11:34:50Z\",\"source\":\"hmwhfpmrqo\"},\"id\":\"tu\",\"name\":\"knryrtihfxtij\",\"type\":\"pzvgnwzsymglzufc\"},{\"properties\":{\"backupType\":\"ohdbihanufh\",\"completedTime\":\"2021-01-11T10:02:32Z\",\"source\":\"y\"},\"id\":\"git\",\"name\":\"xqhabi\",\"type\":\"pikxwczbyscnpqxu\"},{\"properties\":{\"backupType\":\"y\",\"completedTime\":\"2021-06-17T16:29:35Z\",\"source\":\"b\"},\"id\":\"rkxvdum\",\"name\":\"grtfwvu\",\"type\":\"xgaudccs\"},{\"properties\":{\"backupType\":\"jcny\",\"completedTime\":\"2021-04-04T05:13:51Z\",\"source\":\"ryhtnapczwlokjy\"},\"id\":\"kkvnipjox\",\"name\":\"jnchgej\",\"type\":\"podmailzydehojwy\"}],\"nextLink\":\"uxinpmqnjaq\"}")
                .toObject(ServerBackupListResult.class);
        Assertions.assertEquals("t", model.value().get(0).backupType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-24T11:34:50Z"), model.value().get(0).completedTime());
        Assertions.assertEquals("hmwhfpmrqo", model.value().get(0).source());
        Assertions.assertEquals("uxinpmqnjaq", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServerBackupListResult model =
            new ServerBackupListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ServerBackupInner()
                                .withBackupType("t")
                                .withCompletedTime(OffsetDateTime.parse("2021-02-24T11:34:50Z"))
                                .withSource("hmwhfpmrqo"),
                            new ServerBackupInner()
                                .withBackupType("ohdbihanufh")
                                .withCompletedTime(OffsetDateTime.parse("2021-01-11T10:02:32Z"))
                                .withSource("y"),
                            new ServerBackupInner()
                                .withBackupType("y")
                                .withCompletedTime(OffsetDateTime.parse("2021-06-17T16:29:35Z"))
                                .withSource("b"),
                            new ServerBackupInner()
                                .withBackupType("jcny")
                                .withCompletedTime(OffsetDateTime.parse("2021-04-04T05:13:51Z"))
                                .withSource("ryhtnapczwlokjy")))
                .withNextLink("uxinpmqnjaq");
        model = BinaryData.fromObject(model).toObject(ServerBackupListResult.class);
        Assertions.assertEquals("t", model.value().get(0).backupType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-24T11:34:50Z"), model.value().get(0).completedTime());
        Assertions.assertEquals("hmwhfpmrqo", model.value().get(0).source());
        Assertions.assertEquals("uxinpmqnjaq", model.nextLink());
    }
}
