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

package com.azure.resourcemanager.recoveryservicesbackup.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservicesbackup.models.CreateMode;
import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectedItem;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ProtectedItemTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ProtectedItem model =
            BinaryData
                .fromString(
                    "{\"protectedItemType\":\"ProtectedItem\",\"backupManagementType\":\"MAB\",\"workloadType\":\"FileFolder\",\"containerName\":\"atuokthfuiu\",\"sourceResourceId\":\"dsfcpkvxodpuoz\",\"policyId\":\"zydagfuaxbezyiuo\",\"lastRecoveryPoint\":\"2021-09-30T07:23:02Z\",\"backupSetName\":\"hrdxwzywqsmbs\",\"createMode\":\"Default\",\"deferredDeleteTimeInUTC\":\"2021-08-23T03:52:49Z\",\"isScheduledForDeferredDelete\":false,\"deferredDeleteTimeRemaining\":\"yocf\",\"isDeferredDeleteScheduleUpcoming\":false,\"isRehydrate\":false,\"resourceGuardOperationRequests\":[\"dystkiiuxhqyud\",\"o\",\"rq\",\"b\"],\"isArchiveEnabled\":false,\"policyName\":\"vyifqrvkdvjsl\",\"softDeleteRetentionPeriod\":952204067}")
                .toObject(ProtectedItem.class);
        Assertions.assertEquals("atuokthfuiu", model.containerName());
        Assertions.assertEquals("dsfcpkvxodpuoz", model.sourceResourceId());
        Assertions.assertEquals("zydagfuaxbezyiuo", model.policyId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-30T07:23:02Z"), model.lastRecoveryPoint());
        Assertions.assertEquals("hrdxwzywqsmbs", model.backupSetName());
        Assertions.assertEquals(CreateMode.DEFAULT, model.createMode());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-23T03:52:49Z"), model.deferredDeleteTimeInUtc());
        Assertions.assertEquals(false, model.isScheduledForDeferredDelete());
        Assertions.assertEquals("yocf", model.deferredDeleteTimeRemaining());
        Assertions.assertEquals(false, model.isDeferredDeleteScheduleUpcoming());
        Assertions.assertEquals(false, model.isRehydrate());
        Assertions.assertEquals("dystkiiuxhqyud", model.resourceGuardOperationRequests().get(0));
        Assertions.assertEquals(false, model.isArchiveEnabled());
        Assertions.assertEquals("vyifqrvkdvjsl", model.policyName());
        Assertions.assertEquals(952204067, model.softDeleteRetentionPeriod());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ProtectedItem model =
            new ProtectedItem()
                .withContainerName("atuokthfuiu")
                .withSourceResourceId("dsfcpkvxodpuoz")
                .withPolicyId("zydagfuaxbezyiuo")
                .withLastRecoveryPoint(OffsetDateTime.parse("2021-09-30T07:23:02Z"))
                .withBackupSetName("hrdxwzywqsmbs")
                .withCreateMode(CreateMode.DEFAULT)
                .withDeferredDeleteTimeInUtc(OffsetDateTime.parse("2021-08-23T03:52:49Z"))
                .withIsScheduledForDeferredDelete(false)
                .withDeferredDeleteTimeRemaining("yocf")
                .withIsDeferredDeleteScheduleUpcoming(false)
                .withIsRehydrate(false)
                .withResourceGuardOperationRequests(Arrays.asList("dystkiiuxhqyud", "o", "rq", "b"))
                .withIsArchiveEnabled(false)
                .withPolicyName("vyifqrvkdvjsl")
                .withSoftDeleteRetentionPeriod(952204067);
        model = BinaryData.fromObject(model).toObject(ProtectedItem.class);
        Assertions.assertEquals("atuokthfuiu", model.containerName());
        Assertions.assertEquals("dsfcpkvxodpuoz", model.sourceResourceId());
        Assertions.assertEquals("zydagfuaxbezyiuo", model.policyId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-30T07:23:02Z"), model.lastRecoveryPoint());
        Assertions.assertEquals("hrdxwzywqsmbs", model.backupSetName());
        Assertions.assertEquals(CreateMode.DEFAULT, model.createMode());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-23T03:52:49Z"), model.deferredDeleteTimeInUtc());
        Assertions.assertEquals(false, model.isScheduledForDeferredDelete());
        Assertions.assertEquals("yocf", model.deferredDeleteTimeRemaining());
        Assertions.assertEquals(false, model.isDeferredDeleteScheduleUpcoming());
        Assertions.assertEquals(false, model.isRehydrate());
        Assertions.assertEquals("dystkiiuxhqyud", model.resourceGuardOperationRequests().get(0));
        Assertions.assertEquals(false, model.isArchiveEnabled());
        Assertions.assertEquals("vyifqrvkdvjsl", model.policyName());
        Assertions.assertEquals(952204067, model.softDeleteRetentionPeriod());
    }
}
