// 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.AzureBackupRestoreRequest;
import com.azure.resourcemanager.dataprotection.models.RecoveryOption;
import com.azure.resourcemanager.dataprotection.models.RestoreTargetInfoBase;
import com.azure.resourcemanager.dataprotection.models.SourceDataStoreType;
import org.junit.jupiter.api.Assertions;

public final class AzureBackupRestoreRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureBackupRestoreRequest model =
            BinaryData
                .fromString(
                    "{\"objectType\":\"AzureBackupRestoreRequest\",\"restoreTargetInfo\":{\"objectType\":\"RestoreTargetInfoBase\",\"recoveryOption\":\"FailIfExists\",\"restoreLocation\":\"tsthsucocm\"},\"sourceDataStoreType\":\"SnapshotStore\",\"sourceResourceId\":\"azt\"}")
                .toObject(AzureBackupRestoreRequest.class);
        Assertions.assertEquals(RecoveryOption.FAIL_IF_EXISTS, model.restoreTargetInfo().recoveryOption());
        Assertions.assertEquals("tsthsucocm", model.restoreTargetInfo().restoreLocation());
        Assertions.assertEquals(SourceDataStoreType.SNAPSHOT_STORE, model.sourceDataStoreType());
        Assertions.assertEquals("azt", model.sourceResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureBackupRestoreRequest model =
            new AzureBackupRestoreRequest()
                .withRestoreTargetInfo(
                    new RestoreTargetInfoBase()
                        .withRecoveryOption(RecoveryOption.FAIL_IF_EXISTS)
                        .withRestoreLocation("tsthsucocm"))
                .withSourceDataStoreType(SourceDataStoreType.SNAPSHOT_STORE)
                .withSourceResourceId("azt");
        model = BinaryData.fromObject(model).toObject(AzureBackupRestoreRequest.class);
        Assertions.assertEquals(RecoveryOption.FAIL_IF_EXISTS, model.restoreTargetInfo().recoveryOption());
        Assertions.assertEquals("tsthsucocm", model.restoreTargetInfo().restoreLocation());
        Assertions.assertEquals(SourceDataStoreType.SNAPSHOT_STORE, model.sourceDataStoreType());
        Assertions.assertEquals("azt", model.sourceResourceId());
    }
}
