// 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.JobExtendedInfo;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class JobExtendedInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JobExtendedInfo model =
            BinaryData
                .fromString(
                    "{\"additionalDetails\":{\"deemao\":\"yvjusrtslhsp\",\"gkvtmelmqkrhah\":\"mx\",\"duala\":\"ljuahaquhcdh\",\"rcrgvx\":\"xqpvfadmw\"},\"backupInstanceState\":\"gomz\",\"dataTransferredInBytes\":46.13873642470099,\"recoveryDestination\":\"gwb\",\"sourceRecoverPoint\":{\"recoveryPointID\":\"e\",\"recoveryPointTime\":\"2021-04-09T03:27:31Z\"},\"subTasks\":[{\"additionalDetails\":{\"urqhaka\":\"ali\",\"xcug\":\"hashsfwxosow\",\"ovbvmeueciv\":\"cjooxdjebwpucwwf\",\"otwmcdyt\":\"hzceuojgjrwjue\"},\"taskId\":17080551,\"taskName\":\"wit\",\"taskProgress\":\"rjaw\",\"taskStatus\":\"qwgxhniskx\"}],\"targetRecoverPoint\":{\"recoveryPointID\":\"py\",\"recoveryPointTime\":\"2021-02-14T18:57Z\"}}")
                .toObject(JobExtendedInfo.class);
        Assertions.assertEquals("yvjusrtslhsp", model.additionalDetails().get("deemao"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JobExtendedInfo model =
            new JobExtendedInfo()
                .withAdditionalDetails(
                    mapOf(
                        "deemao",
                        "yvjusrtslhsp",
                        "gkvtmelmqkrhah",
                        "mx",
                        "duala",
                        "ljuahaquhcdh",
                        "rcrgvx",
                        "xqpvfadmw"));
        model = BinaryData.fromObject(model).toObject(JobExtendedInfo.class);
        Assertions.assertEquals("yvjusrtslhsp", model.additionalDetails().get("deemao"));
    }

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