// 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.AzureStorageJobExtendedInfo;
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureStorageJobTaskDetails;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class AzureStorageJobExtendedInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AzureStorageJobExtendedInfo model =
            BinaryData
                .fromString(
                    "{\"tasksList\":[{\"taskId\":\"dwvvba\",\"status\":\"lllchpodb\"},{\"taskId\":\"vwrdnhfukuvsj\",\"status\":\"wsmystuluqypf\"},{\"taskId\":\"lerchpq\",\"status\":\"f\"},{\"taskId\":\"babwidfcxss\",\"status\":\"unnoxyhk\"}],\"propertyBag\":{\"oqcaaewdaomdj\":\"ddrihpf\",\"jxxkzbrmsgei\":\"l\",\"ggcula\":\"siykzkdncjdxonbz\",\"y\":\"z\"},\"dynamicErrorMessage\":\"gogtqxepnylbf\"}")
                .toObject(AzureStorageJobExtendedInfo.class);
        Assertions.assertEquals("dwvvba", model.tasksList().get(0).taskId());
        Assertions.assertEquals("lllchpodb", model.tasksList().get(0).status());
        Assertions.assertEquals("ddrihpf", model.propertyBag().get("oqcaaewdaomdj"));
        Assertions.assertEquals("gogtqxepnylbf", model.dynamicErrorMessage());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AzureStorageJobExtendedInfo model =
            new AzureStorageJobExtendedInfo()
                .withTasksList(
                    Arrays
                        .asList(
                            new AzureStorageJobTaskDetails().withTaskId("dwvvba").withStatus("lllchpodb"),
                            new AzureStorageJobTaskDetails().withTaskId("vwrdnhfukuvsj").withStatus("wsmystuluqypf"),
                            new AzureStorageJobTaskDetails().withTaskId("lerchpq").withStatus("f"),
                            new AzureStorageJobTaskDetails().withTaskId("babwidfcxss").withStatus("unnoxyhk")))
                .withPropertyBag(
                    mapOf("oqcaaewdaomdj", "ddrihpf", "jxxkzbrmsgei", "l", "ggcula", "siykzkdncjdxonbz", "y", "z"))
                .withDynamicErrorMessage("gogtqxepnylbf");
        model = BinaryData.fromObject(model).toObject(AzureStorageJobExtendedInfo.class);
        Assertions.assertEquals("dwvvba", model.tasksList().get(0).taskId());
        Assertions.assertEquals("lllchpodb", model.tasksList().get(0).status());
        Assertions.assertEquals("ddrihpf", model.propertyBag().get("oqcaaewdaomdj"));
        Assertions.assertEquals("gogtqxepnylbf", model.dynamicErrorMessage());
    }

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