// 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.AzureWorkloadSapHanaRestoreWithRehydrateRequest;
import com.azure.resourcemanager.recoveryservicesbackup.models.OverwriteOptions;
import com.azure.resourcemanager.recoveryservicesbackup.models.RecoveryMode;
import com.azure.resourcemanager.recoveryservicesbackup.models.RecoveryPointRehydrationInfo;
import com.azure.resourcemanager.recoveryservicesbackup.models.RecoveryType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RehydrationPriority;
import com.azure.resourcemanager.recoveryservicesbackup.models.TargetRestoreInfo;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AzureWorkloadSapHanaRestoreWithRehydrateRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureWorkloadSapHanaRestoreWithRehydrateRequest model =
            BinaryData
                .fromString(
                    "{\"objectType\":\"AzureWorkloadSAPHanaRestoreWithRehydrateRequest\",\"recoveryPointRehydrationInfo\":{\"rehydrationRetentionDuration\":\"okrtalvnb\",\"rehydrationPriority\":\"Standard\"},\"recoveryType\":\"OriginalLocation\",\"sourceResourceId\":\"eluclvdjj\",\"propertyBag\":{\"qnvzoqgyipemch\":\"rdnqodxahhxhqf\",\"lghwzhome\":\"avsczuejdtxp\"},\"targetInfo\":{\"overwriteOption\":\"Invalid\",\"containerId\":\"liuhqawmoaiancz\",\"databaseName\":\"odrrslblxyd\",\"targetDirectoryForFileRestore\":\"rxvvbxi\"},\"recoveryMode\":\"Invalid\",\"targetVirtualMachineId\":\"bqlj\"}")
                .toObject(AzureWorkloadSapHanaRestoreWithRehydrateRequest.class);
        Assertions.assertEquals(RecoveryType.ORIGINAL_LOCATION, model.recoveryType());
        Assertions.assertEquals("eluclvdjj", model.sourceResourceId());
        Assertions.assertEquals("rdnqodxahhxhqf", model.propertyBag().get("qnvzoqgyipemch"));
        Assertions.assertEquals(OverwriteOptions.INVALID, model.targetInfo().overwriteOption());
        Assertions.assertEquals("liuhqawmoaiancz", model.targetInfo().containerId());
        Assertions.assertEquals("odrrslblxyd", model.targetInfo().databaseName());
        Assertions.assertEquals("rxvvbxi", model.targetInfo().targetDirectoryForFileRestore());
        Assertions.assertEquals(RecoveryMode.INVALID, model.recoveryMode());
        Assertions.assertEquals("bqlj", model.targetVirtualMachineId());
        Assertions.assertEquals("okrtalvnb", model.recoveryPointRehydrationInfo().rehydrationRetentionDuration());
        Assertions
            .assertEquals(RehydrationPriority.STANDARD, model.recoveryPointRehydrationInfo().rehydrationPriority());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureWorkloadSapHanaRestoreWithRehydrateRequest model =
            new AzureWorkloadSapHanaRestoreWithRehydrateRequest()
                .withRecoveryType(RecoveryType.ORIGINAL_LOCATION)
                .withSourceResourceId("eluclvdjj")
                .withPropertyBag(mapOf("qnvzoqgyipemch", "rdnqodxahhxhqf", "lghwzhome", "avsczuejdtxp"))
                .withTargetInfo(
                    new TargetRestoreInfo()
                        .withOverwriteOption(OverwriteOptions.INVALID)
                        .withContainerId("liuhqawmoaiancz")
                        .withDatabaseName("odrrslblxyd")
                        .withTargetDirectoryForFileRestore("rxvvbxi"))
                .withRecoveryMode(RecoveryMode.INVALID)
                .withTargetVirtualMachineId("bqlj")
                .withRecoveryPointRehydrationInfo(
                    new RecoveryPointRehydrationInfo()
                        .withRehydrationRetentionDuration("okrtalvnb")
                        .withRehydrationPriority(RehydrationPriority.STANDARD));
        model = BinaryData.fromObject(model).toObject(AzureWorkloadSapHanaRestoreWithRehydrateRequest.class);
        Assertions.assertEquals(RecoveryType.ORIGINAL_LOCATION, model.recoveryType());
        Assertions.assertEquals("eluclvdjj", model.sourceResourceId());
        Assertions.assertEquals("rdnqodxahhxhqf", model.propertyBag().get("qnvzoqgyipemch"));
        Assertions.assertEquals(OverwriteOptions.INVALID, model.targetInfo().overwriteOption());
        Assertions.assertEquals("liuhqawmoaiancz", model.targetInfo().containerId());
        Assertions.assertEquals("odrrslblxyd", model.targetInfo().databaseName());
        Assertions.assertEquals("rxvvbxi", model.targetInfo().targetDirectoryForFileRestore());
        Assertions.assertEquals(RecoveryMode.INVALID, model.recoveryMode());
        Assertions.assertEquals("bqlj", model.targetVirtualMachineId());
        Assertions.assertEquals("okrtalvnb", model.recoveryPointRehydrationInfo().rehydrationRetentionDuration());
        Assertions
            .assertEquals(RehydrationPriority.STANDARD, model.recoveryPointRehydrationInfo().rehydrationPriority());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
