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

public final class AzureWorkloadSapHanaRestoreRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureWorkloadSapHanaRestoreRequest model =
            BinaryData
                .fromString(
                    "{\"objectType\":\"AzureWorkloadSAPHanaRestoreRequest\",\"recoveryType\":\"Invalid\",\"sourceResourceId\":\"mes\",\"propertyBag\":{\"a\":\"lpagzrcx\",\"xwmdboxd\":\"lc\",\"ckknhxkizvy\":\"gsftufqobrjlnacg\",\"nok\":\"nrzvuljraaer\"},\"targetInfo\":{\"overwriteOption\":\"Invalid\",\"containerId\":\"jqnv\",\"databaseName\":\"oylaxxul\",\"targetDirectoryForFileRestore\":\"isdos\"},\"recoveryMode\":\"WorkloadRecovery\",\"targetVirtualMachineId\":\"svgjrwhryvy\"}")
                .toObject(AzureWorkloadSapHanaRestoreRequest.class);
        Assertions.assertEquals(RecoveryType.INVALID, model.recoveryType());
        Assertions.assertEquals("mes", model.sourceResourceId());
        Assertions.assertEquals("lpagzrcx", model.propertyBag().get("a"));
        Assertions.assertEquals(OverwriteOptions.INVALID, model.targetInfo().overwriteOption());
        Assertions.assertEquals("jqnv", model.targetInfo().containerId());
        Assertions.assertEquals("oylaxxul", model.targetInfo().databaseName());
        Assertions.assertEquals("isdos", model.targetInfo().targetDirectoryForFileRestore());
        Assertions.assertEquals(RecoveryMode.WORKLOAD_RECOVERY, model.recoveryMode());
        Assertions.assertEquals("svgjrwhryvy", model.targetVirtualMachineId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureWorkloadSapHanaRestoreRequest model =
            new AzureWorkloadSapHanaRestoreRequest()
                .withRecoveryType(RecoveryType.INVALID)
                .withSourceResourceId("mes")
                .withPropertyBag(
                    mapOf("a", "lpagzrcx", "xwmdboxd", "lc", "ckknhxkizvy", "gsftufqobrjlnacg", "nok", "nrzvuljraaer"))
                .withTargetInfo(
                    new TargetRestoreInfo()
                        .withOverwriteOption(OverwriteOptions.INVALID)
                        .withContainerId("jqnv")
                        .withDatabaseName("oylaxxul")
                        .withTargetDirectoryForFileRestore("isdos"))
                .withRecoveryMode(RecoveryMode.WORKLOAD_RECOVERY)
                .withTargetVirtualMachineId("svgjrwhryvy");
        model = BinaryData.fromObject(model).toObject(AzureWorkloadSapHanaRestoreRequest.class);
        Assertions.assertEquals(RecoveryType.INVALID, model.recoveryType());
        Assertions.assertEquals("mes", model.sourceResourceId());
        Assertions.assertEquals("lpagzrcx", model.propertyBag().get("a"));
        Assertions.assertEquals(OverwriteOptions.INVALID, model.targetInfo().overwriteOption());
        Assertions.assertEquals("jqnv", model.targetInfo().containerId());
        Assertions.assertEquals("oylaxxul", model.targetInfo().databaseName());
        Assertions.assertEquals("isdos", model.targetInfo().targetDirectoryForFileRestore());
        Assertions.assertEquals(RecoveryMode.WORKLOAD_RECOVERY, model.recoveryMode());
        Assertions.assertEquals("svgjrwhryvy", model.targetVirtualMachineId());
    }

    @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;
    }
}
