// 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.models.AzureBackupDiscreteRecoveryPoint;
import com.azure.resourcemanager.dataprotection.models.RecoveryPointDataStoreDetails;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AzureBackupDiscreteRecoveryPointTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureBackupDiscreteRecoveryPoint model =
            BinaryData
                .fromString(
                    "{\"objectType\":\"AzureBackupDiscreteRecoveryPoint\",\"friendlyName\":\"q\",\"recoveryPointDataStoresDetails\":[{\"creationTime\":\"2021-03-13T19:05:07Z\",\"expiryTime\":\"2021-01-03T10:03:07Z\",\"id\":\"baaa\",\"metaData\":\"yvayffimrzr\",\"state\":\"zqogse\",\"type\":\"evfdnwnwm\",\"visible\":true,\"rehydrationExpiryTime\":\"2021-02-11T18:35:50Z\",\"rehydrationStatus\":\"DELETED\"},{\"creationTime\":\"2021-09-10T12:45:24Z\",\"expiryTime\":\"2021-08-15T01:34:53Z\",\"id\":\"i\",\"metaData\":\"ud\",\"state\":\"rx\",\"type\":\"thzvaytdwkqbrqu\",\"visible\":true,\"rehydrationExpiryTime\":\"2021-06-19T07:52:19Z\",\"rehydrationStatus\":\"CREATE_IN_PROGRESS\"},{\"creationTime\":\"2021-01-10T17:21:26Z\",\"expiryTime\":\"2021-06-07T07:50:45Z\",\"id\":\"pdtii\",\"metaData\":\"tdqoaxoruzfgsq\",\"state\":\"fxrxxle\",\"type\":\"ramxjezwlwnw\",\"visible\":false,\"rehydrationExpiryTime\":\"2021-09-14T08:31:01Z\",\"rehydrationStatus\":\"DELETED\"},{\"creationTime\":\"2021-06-21T00:43:05Z\",\"expiryTime\":\"2021-07-15T02:51:17Z\",\"id\":\"dooaojkniodko\",\"metaData\":\"bw\",\"state\":\"jhemms\",\"type\":\"dkcrodt\",\"visible\":true,\"rehydrationExpiryTime\":\"2021-09-11T12:40:37Z\",\"rehydrationStatus\":\"FAILED\"}],\"recoveryPointTime\":\"2021-11-16T20:55:55Z\",\"policyName\":\"tkacj\",\"policyVersion\":\"f\",\"recoveryPointId\":\"lfoakg\",\"recoveryPointType\":\"fpagaowpulp\",\"retentionTagName\":\"lyls\",\"retentionTagVersion\":\"k\",\"expiryTime\":\"2021-06-29T15:40:41Z\"}")
                .toObject(AzureBackupDiscreteRecoveryPoint.class);
        Assertions.assertEquals("q", model.friendlyName());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-03-13T19:05:07Z"),
                model.recoveryPointDataStoresDetails().get(0).creationTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-01-03T10:03:07Z"),
                model.recoveryPointDataStoresDetails().get(0).expiryTime());
        Assertions.assertEquals("baaa", model.recoveryPointDataStoresDetails().get(0).id());
        Assertions.assertEquals("yvayffimrzr", model.recoveryPointDataStoresDetails().get(0).metadata());
        Assertions.assertEquals("zqogse", model.recoveryPointDataStoresDetails().get(0).state());
        Assertions.assertEquals("evfdnwnwm", model.recoveryPointDataStoresDetails().get(0).type());
        Assertions.assertEquals(true, model.recoveryPointDataStoresDetails().get(0).visible());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-16T20:55:55Z"), model.recoveryPointTime());
        Assertions.assertEquals("tkacj", model.policyName());
        Assertions.assertEquals("f", model.policyVersion());
        Assertions.assertEquals("lfoakg", model.recoveryPointId());
        Assertions.assertEquals("fpagaowpulp", model.recoveryPointType());
        Assertions.assertEquals("lyls", model.retentionTagName());
        Assertions.assertEquals("k", model.retentionTagVersion());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureBackupDiscreteRecoveryPoint model =
            new AzureBackupDiscreteRecoveryPoint()
                .withFriendlyName("q")
                .withRecoveryPointDataStoresDetails(
                    Arrays
                        .asList(
                            new RecoveryPointDataStoreDetails()
                                .withCreationTime(OffsetDateTime.parse("2021-03-13T19:05:07Z"))
                                .withExpiryTime(OffsetDateTime.parse("2021-01-03T10:03:07Z"))
                                .withId("baaa")
                                .withMetadata("yvayffimrzr")
                                .withState("zqogse")
                                .withType("evfdnwnwm")
                                .withVisible(true),
                            new RecoveryPointDataStoreDetails()
                                .withCreationTime(OffsetDateTime.parse("2021-09-10T12:45:24Z"))
                                .withExpiryTime(OffsetDateTime.parse("2021-08-15T01:34:53Z"))
                                .withId("i")
                                .withMetadata("ud")
                                .withState("rx")
                                .withType("thzvaytdwkqbrqu")
                                .withVisible(true),
                            new RecoveryPointDataStoreDetails()
                                .withCreationTime(OffsetDateTime.parse("2021-01-10T17:21:26Z"))
                                .withExpiryTime(OffsetDateTime.parse("2021-06-07T07:50:45Z"))
                                .withId("pdtii")
                                .withMetadata("tdqoaxoruzfgsq")
                                .withState("fxrxxle")
                                .withType("ramxjezwlwnw")
                                .withVisible(false),
                            new RecoveryPointDataStoreDetails()
                                .withCreationTime(OffsetDateTime.parse("2021-06-21T00:43:05Z"))
                                .withExpiryTime(OffsetDateTime.parse("2021-07-15T02:51:17Z"))
                                .withId("dooaojkniodko")
                                .withMetadata("bw")
                                .withState("jhemms")
                                .withType("dkcrodt")
                                .withVisible(true)))
                .withRecoveryPointTime(OffsetDateTime.parse("2021-11-16T20:55:55Z"))
                .withPolicyName("tkacj")
                .withPolicyVersion("f")
                .withRecoveryPointId("lfoakg")
                .withRecoveryPointType("fpagaowpulp")
                .withRetentionTagName("lyls")
                .withRetentionTagVersion("k");
        model = BinaryData.fromObject(model).toObject(AzureBackupDiscreteRecoveryPoint.class);
        Assertions.assertEquals("q", model.friendlyName());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-03-13T19:05:07Z"),
                model.recoveryPointDataStoresDetails().get(0).creationTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-01-03T10:03:07Z"),
                model.recoveryPointDataStoresDetails().get(0).expiryTime());
        Assertions.assertEquals("baaa", model.recoveryPointDataStoresDetails().get(0).id());
        Assertions.assertEquals("yvayffimrzr", model.recoveryPointDataStoresDetails().get(0).metadata());
        Assertions.assertEquals("zqogse", model.recoveryPointDataStoresDetails().get(0).state());
        Assertions.assertEquals("evfdnwnwm", model.recoveryPointDataStoresDetails().get(0).type());
        Assertions.assertEquals(true, model.recoveryPointDataStoresDetails().get(0).visible());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-16T20:55:55Z"), model.recoveryPointTime());
        Assertions.assertEquals("tkacj", model.policyName());
        Assertions.assertEquals("f", model.policyVersion());
        Assertions.assertEquals("lfoakg", model.recoveryPointId());
        Assertions.assertEquals("fpagaowpulp", model.recoveryPointType());
        Assertions.assertEquals("lyls", model.retentionTagName());
        Assertions.assertEquals("k", model.retentionTagVersion());
    }
}
