// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.storageimportexport.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storageimportexport.fluent.models.JobResponseInner;
import com.azure.resourcemanager.storageimportexport.models.IdentityDetails;
import com.azure.resourcemanager.storageimportexport.models.IdentityType;
import com.azure.resourcemanager.storageimportexport.models.JobDetails;
import com.azure.resourcemanager.storageimportexport.models.ListJobsResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ListJobsResponseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ListJobsResponse model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"kuksjtxukcdm\",\"value\":[{\"properties\":{\"storageAccountId\":\"uanzwuxzdx\",\"jobType\":\"yrlhmwhfpmrqobm\",\"diagnosticsPath\":\"rtihfxtijbpz\",\"logLevel\":\"nwzsymg\",\"backupDriveManifest\":false,\"state\":\"cyzkohdbihanuf\",\"cancelRequested\":false,\"percentComplete\":9096749627848902766,\"incompleteBlobListUri\":\"a\",\"driveList\":[],\"provisioningState\":\"xqhabi\"},\"identity\":{\"type\":\"SystemAssigned\",\"principalId\":\"czbysc\",\"tenantId\":\"q\"},\"location\":\"uhivyqniw\",\"tags\":{\"grtfwvu\":\"rkxvdum\"},\"id\":\"xgaudccs\",\"name\":\"h\",\"type\":\"jcny\"},{\"properties\":{\"storageAccountId\":\"ryhtnapczwlokjy\",\"jobType\":\"kkvnipjox\",\"diagnosticsPath\":\"jspodmailzyde\",\"logLevel\":\"jwyahuxinpmqnja\",\"backupDriveManifest\":true,\"state\":\"jsprozvcpute\",\"cancelRequested\":false,\"percentComplete\":4056057439565967156,\"incompleteBlobListUri\":\"atscmd\",\"driveList\":[],\"provisioningState\":\"u\"},\"identity\":{\"type\":\"UserAssigned\",\"principalId\":\"kjozkrwfnd\",\"tenantId\":\"djpslw\"},\"location\":\"jdpvwryo\",\"tags\":{\"ljlahbcryf\":\"oacctaza\",\"ojakhmsbzjhcrze\":\"dfdosygexp\",\"qtrgqjbpfzfsinzg\":\"dphlxaolt\"},\"id\":\"f\",\"name\":\"jrwzox\",\"type\":\"j\"},{\"properties\":{\"storageAccountId\":\"luwfzitonpeqfpjk\",\"jobType\":\"xofpdvhpfxxypi\",\"diagnosticsPath\":\"uybbkpodep\",\"logLevel\":\"ginuvamih\",\"backupDriveManifest\":true,\"state\":\"arxzxtheot\",\"cancelRequested\":true,\"percentComplete\":4605749595132833196,\"incompleteBlobListUri\":\"cciqihnhungbwjz\",\"driveList\":[],\"provisioningState\":\"gxg\"},\"identity\":{\"type\":\"None\",\"principalId\":\"tzfkufubl\",\"tenantId\":\"fxqeof\"},\"location\":\"aeqjhqjbasvms\",\"tags\":{\"ybkzgcwr\":\"ulngsntn\",\"skcqvkocrcjd\":\"clxxwrljdo\",\"lssai\":\"wtnhxbnjbiksqr\",\"pee\":\"qpjwnzlljfm\"},\"id\":\"vmgxsab\",\"name\":\"yqduujit\",\"type\":\"jczdzevndh\"},{\"properties\":{\"storageAccountId\":\"d\",\"jobType\":\"p\",\"diagnosticsPath\":\"rwjfe\",\"logLevel\":\"nhutjeltmrldhugj\",\"backupDriveManifest\":true,\"state\":\"tqxhocdgeab\",\"cancelRequested\":false,\"percentComplete\":7645562741031728269,\"incompleteBlobListUri\":\"cndvkaozwyiftyhx\",\"driveList\":[],\"provisioningState\":\"k\"},\"identity\":{\"type\":\"None\",\"principalId\":\"niwpwcukj\",\"tenantId\":\"giawx\"},\"location\":\"lryplwckbasyy\",\"tags\":{\"phejkotynqgoulz\":\"dhsgcba\",\"gakeqsr\":\"dlikwyqkgfgibma\",\"qqedqytbciqfou\":\"yb\"},\"id\":\"lmmnkzsmodmglo\",\"name\":\"gpbkwtmut\",\"type\":\"uqktap\"}]}")
                .toObject(ListJobsResponse.class);
        Assertions.assertEquals("kuksjtxukcdm", model.nextLink());
        Assertions.assertEquals("uhivyqniw", model.value().get(0).location());
        Assertions.assertEquals("rkxvdum", model.value().get(0).tags().get("grtfwvu"));
        Assertions.assertEquals("uanzwuxzdx", model.value().get(0).properties().storageAccountId());
        Assertions.assertEquals("yrlhmwhfpmrqobm", model.value().get(0).properties().jobType());
        Assertions.assertEquals("rtihfxtijbpz", model.value().get(0).properties().diagnosticsPath());
        Assertions.assertEquals("nwzsymg", model.value().get(0).properties().logLevel());
        Assertions.assertEquals(false, model.value().get(0).properties().backupDriveManifest());
        Assertions.assertEquals("cyzkohdbihanuf", model.value().get(0).properties().state());
        Assertions.assertEquals(false, model.value().get(0).properties().cancelRequested());
        Assertions.assertEquals(9096749627848902766L, model.value().get(0).properties().percentComplete());
        Assertions.assertEquals("a", model.value().get(0).properties().incompleteBlobListUri());
        Assertions.assertEquals("xqhabi", model.value().get(0).properties().provisioningState());
        Assertions.assertEquals(IdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ListJobsResponse model =
            new ListJobsResponse()
                .withNextLink("kuksjtxukcdm")
                .withValue(
                    Arrays
                        .asList(
                            new JobResponseInner()
                                .withLocation("uhivyqniw")
                                .withTags(mapOf("grtfwvu", "rkxvdum"))
                                .withProperties(
                                    new JobDetails()
                                        .withStorageAccountId("uanzwuxzdx")
                                        .withJobType("yrlhmwhfpmrqobm")
                                        .withDiagnosticsPath("rtihfxtijbpz")
                                        .withLogLevel("nwzsymg")
                                        .withBackupDriveManifest(false)
                                        .withState("cyzkohdbihanuf")
                                        .withCancelRequested(false)
                                        .withPercentComplete(9096749627848902766L)
                                        .withIncompleteBlobListUri("a")
                                        .withDriveList(Arrays.asList())
                                        .withProvisioningState("xqhabi"))
                                .withIdentity(new IdentityDetails().withType(IdentityType.SYSTEM_ASSIGNED)),
                            new JobResponseInner()
                                .withLocation("jdpvwryo")
                                .withTags(
                                    mapOf(
                                        "ljlahbcryf",
                                        "oacctaza",
                                        "ojakhmsbzjhcrze",
                                        "dfdosygexp",
                                        "qtrgqjbpfzfsinzg",
                                        "dphlxaolt"))
                                .withProperties(
                                    new JobDetails()
                                        .withStorageAccountId("ryhtnapczwlokjy")
                                        .withJobType("kkvnipjox")
                                        .withDiagnosticsPath("jspodmailzyde")
                                        .withLogLevel("jwyahuxinpmqnja")
                                        .withBackupDriveManifest(true)
                                        .withState("jsprozvcpute")
                                        .withCancelRequested(false)
                                        .withPercentComplete(4056057439565967156L)
                                        .withIncompleteBlobListUri("atscmd")
                                        .withDriveList(Arrays.asList())
                                        .withProvisioningState("u"))
                                .withIdentity(new IdentityDetails().withType(IdentityType.USER_ASSIGNED)),
                            new JobResponseInner()
                                .withLocation("aeqjhqjbasvms")
                                .withTags(
                                    mapOf(
                                        "ybkzgcwr",
                                        "ulngsntn",
                                        "skcqvkocrcjd",
                                        "clxxwrljdo",
                                        "lssai",
                                        "wtnhxbnjbiksqr",
                                        "pee",
                                        "qpjwnzlljfm"))
                                .withProperties(
                                    new JobDetails()
                                        .withStorageAccountId("luwfzitonpeqfpjk")
                                        .withJobType("xofpdvhpfxxypi")
                                        .withDiagnosticsPath("uybbkpodep")
                                        .withLogLevel("ginuvamih")
                                        .withBackupDriveManifest(true)
                                        .withState("arxzxtheot")
                                        .withCancelRequested(true)
                                        .withPercentComplete(4605749595132833196L)
                                        .withIncompleteBlobListUri("cciqihnhungbwjz")
                                        .withDriveList(Arrays.asList())
                                        .withProvisioningState("gxg"))
                                .withIdentity(new IdentityDetails().withType(IdentityType.NONE)),
                            new JobResponseInner()
                                .withLocation("lryplwckbasyy")
                                .withTags(
                                    mapOf(
                                        "phejkotynqgoulz",
                                        "dhsgcba",
                                        "gakeqsr",
                                        "dlikwyqkgfgibma",
                                        "qqedqytbciqfou",
                                        "yb"))
                                .withProperties(
                                    new JobDetails()
                                        .withStorageAccountId("d")
                                        .withJobType("p")
                                        .withDiagnosticsPath("rwjfe")
                                        .withLogLevel("nhutjeltmrldhugj")
                                        .withBackupDriveManifest(true)
                                        .withState("tqxhocdgeab")
                                        .withCancelRequested(false)
                                        .withPercentComplete(7645562741031728269L)
                                        .withIncompleteBlobListUri("cndvkaozwyiftyhx")
                                        .withDriveList(Arrays.asList())
                                        .withProvisioningState("k"))
                                .withIdentity(new IdentityDetails().withType(IdentityType.NONE))));
        model = BinaryData.fromObject(model).toObject(ListJobsResponse.class);
        Assertions.assertEquals("kuksjtxukcdm", model.nextLink());
        Assertions.assertEquals("uhivyqniw", model.value().get(0).location());
        Assertions.assertEquals("rkxvdum", model.value().get(0).tags().get("grtfwvu"));
        Assertions.assertEquals("uanzwuxzdx", model.value().get(0).properties().storageAccountId());
        Assertions.assertEquals("yrlhmwhfpmrqobm", model.value().get(0).properties().jobType());
        Assertions.assertEquals("rtihfxtijbpz", model.value().get(0).properties().diagnosticsPath());
        Assertions.assertEquals("nwzsymg", model.value().get(0).properties().logLevel());
        Assertions.assertEquals(false, model.value().get(0).properties().backupDriveManifest());
        Assertions.assertEquals("cyzkohdbihanuf", model.value().get(0).properties().state());
        Assertions.assertEquals(false, model.value().get(0).properties().cancelRequested());
        Assertions.assertEquals(9096749627848902766L, model.value().get(0).properties().percentComplete());
        Assertions.assertEquals("a", model.value().get(0).properties().incompleteBlobListUri());
        Assertions.assertEquals("xqhabi", model.value().get(0).properties().provisioningState());
        Assertions.assertEquals(IdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
    }

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