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

package com.azure.resourcemanager.dataprotection.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.dataprotection.fluent.models.AzureBackupJobResourceInner;
import com.azure.resourcemanager.dataprotection.models.AzureBackupJob;
import com.azure.resourcemanager.dataprotection.models.AzureBackupJobResourceList;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AzureBackupJobResourceListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureBackupJobResourceList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"activityID\":\"lmuzy\",\"backupInstanceFriendlyName\":\"xaepdkzjancuxr\",\"backupInstanceId\":\"wbavxbniwdj\",\"dataSourceId\":\"wz\",\"dataSourceLocation\":\"s\",\"dataSourceName\":\"bpg\",\"dataSourceSetName\":\"ytxhp\",\"dataSourceType\":\"xbzpfzab\",\"duration\":\"cuh\",\"endTime\":\"2021-05-12T02:13:10Z\",\"errorDetails\":[],\"isUserTriggered\":true,\"operation\":\"qik\",\"operationCategory\":\"bbovplwzbhvgyugu\",\"policyId\":\"vmkfssxqu\",\"policyName\":\"fpl\",\"progressEnabled\":false,\"progressUrl\":\"sxnkjzkdeslpvlo\",\"restoreType\":\"i\",\"sourceResourceGroup\":\"ighxpk\",\"sourceSubscriptionID\":\"wzbaiue\",\"startTime\":\"2021-01-02T09:55:27Z\",\"status\":\"a\",\"subscriptionId\":\"m\",\"supportedActions\":[],\"vaultName\":\"yqupedeojnabckh\",\"etag\":\"txp\",\"sourceDataStoreName\":\"ebtfhvpesap\",\"destinationDataStoreName\":\"rdqmhjjdhtldwkyz\"},\"id\":\"utknc\",\"name\":\"scwsv\",\"type\":\"xotogtwrupqsxv\"}],\"nextLink\":\"i\"}")
                .toObject(AzureBackupJobResourceList.class);
        Assertions.assertEquals("i", model.nextLink());
        Assertions.assertEquals("lmuzy", model.value().get(0).properties().activityId());
        Assertions.assertEquals("xaepdkzjancuxr", model.value().get(0).properties().backupInstanceFriendlyName());
        Assertions.assertEquals("wz", model.value().get(0).properties().dataSourceId());
        Assertions.assertEquals("s", model.value().get(0).properties().dataSourceLocation());
        Assertions.assertEquals("bpg", model.value().get(0).properties().dataSourceName());
        Assertions.assertEquals("ytxhp", model.value().get(0).properties().dataSourceSetName());
        Assertions.assertEquals("xbzpfzab", model.value().get(0).properties().dataSourceType());
        Assertions.assertEquals("cuh", model.value().get(0).properties().duration());
        Assertions.assertEquals(true, model.value().get(0).properties().isUserTriggered());
        Assertions.assertEquals("qik", model.value().get(0).properties().operation());
        Assertions.assertEquals("bbovplwzbhvgyugu", model.value().get(0).properties().operationCategory());
        Assertions.assertEquals(false, model.value().get(0).properties().progressEnabled());
        Assertions.assertEquals("ighxpk", model.value().get(0).properties().sourceResourceGroup());
        Assertions.assertEquals("wzbaiue", model.value().get(0).properties().sourceSubscriptionId());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-01-02T09:55:27Z"), model.value().get(0).properties().startTime());
        Assertions.assertEquals("a", model.value().get(0).properties().status());
        Assertions.assertEquals("m", model.value().get(0).properties().subscriptionId());
        Assertions.assertEquals("yqupedeojnabckh", model.value().get(0).properties().vaultName());
        Assertions.assertEquals("txp", model.value().get(0).properties().etag());
        Assertions.assertEquals("ebtfhvpesap", model.value().get(0).properties().sourceDataStoreName());
        Assertions.assertEquals("rdqmhjjdhtldwkyz", model.value().get(0).properties().destinationDataStoreName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureBackupJobResourceList model =
            new AzureBackupJobResourceList()
                .withNextLink("i")
                .withValue(
                    Arrays
                        .asList(
                            new AzureBackupJobResourceInner()
                                .withProperties(
                                    new AzureBackupJob()
                                        .withActivityId("lmuzy")
                                        .withBackupInstanceFriendlyName("xaepdkzjancuxr")
                                        .withDataSourceId("wz")
                                        .withDataSourceLocation("s")
                                        .withDataSourceName("bpg")
                                        .withDataSourceSetName("ytxhp")
                                        .withDataSourceType("xbzpfzab")
                                        .withDuration("cuh")
                                        .withIsUserTriggered(true)
                                        .withOperation("qik")
                                        .withOperationCategory("bbovplwzbhvgyugu")
                                        .withProgressEnabled(false)
                                        .withSourceResourceGroup("ighxpk")
                                        .withSourceSubscriptionId("wzbaiue")
                                        .withStartTime(OffsetDateTime.parse("2021-01-02T09:55:27Z"))
                                        .withStatus("a")
                                        .withSubscriptionId("m")
                                        .withSupportedActions(Arrays.asList())
                                        .withVaultName("yqupedeojnabckh")
                                        .withEtag("txp")
                                        .withSourceDataStoreName("ebtfhvpesap")
                                        .withDestinationDataStoreName("rdqmhjjdhtldwkyz"))));
        model = BinaryData.fromObject(model).toObject(AzureBackupJobResourceList.class);
        Assertions.assertEquals("i", model.nextLink());
        Assertions.assertEquals("lmuzy", model.value().get(0).properties().activityId());
        Assertions.assertEquals("xaepdkzjancuxr", model.value().get(0).properties().backupInstanceFriendlyName());
        Assertions.assertEquals("wz", model.value().get(0).properties().dataSourceId());
        Assertions.assertEquals("s", model.value().get(0).properties().dataSourceLocation());
        Assertions.assertEquals("bpg", model.value().get(0).properties().dataSourceName());
        Assertions.assertEquals("ytxhp", model.value().get(0).properties().dataSourceSetName());
        Assertions.assertEquals("xbzpfzab", model.value().get(0).properties().dataSourceType());
        Assertions.assertEquals("cuh", model.value().get(0).properties().duration());
        Assertions.assertEquals(true, model.value().get(0).properties().isUserTriggered());
        Assertions.assertEquals("qik", model.value().get(0).properties().operation());
        Assertions.assertEquals("bbovplwzbhvgyugu", model.value().get(0).properties().operationCategory());
        Assertions.assertEquals(false, model.value().get(0).properties().progressEnabled());
        Assertions.assertEquals("ighxpk", model.value().get(0).properties().sourceResourceGroup());
        Assertions.assertEquals("wzbaiue", model.value().get(0).properties().sourceSubscriptionId());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-01-02T09:55:27Z"), model.value().get(0).properties().startTime());
        Assertions.assertEquals("a", model.value().get(0).properties().status());
        Assertions.assertEquals("m", model.value().get(0).properties().subscriptionId());
        Assertions.assertEquals("yqupedeojnabckh", model.value().get(0).properties().vaultName());
        Assertions.assertEquals("txp", model.value().get(0).properties().etag());
        Assertions.assertEquals("ebtfhvpesap", model.value().get(0).properties().sourceDataStoreName());
        Assertions.assertEquals("rdqmhjjdhtldwkyz", model.value().get(0).properties().destinationDataStoreName());
    }
}
