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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.fluent.models.JobBaseInner;
import com.azure.resourcemanager.machinelearning.models.JobBaseProperties;
import com.azure.resourcemanager.machinelearning.models.JobBaseResourceArmPaginatedResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class JobBaseResourceArmPaginatedResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JobBaseResourceArmPaginatedResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"zoggculapz\",\"value\":[{\"properties\":{\"jobType\":\"JobBaseProperties\",\"componentId\":\"gogtqxepnylbf\",\"computeId\":\"jlyjtlvofq\",\"displayName\":\"vfcibyfmowux\",\"experimentName\":\"jpvd\",\"isArchived\":true,\"services\":{},\"status\":\"Queued\",\"description\":\"wzjbh\",\"properties\":{},\"tags\":{}},\"id\":\"jrkambtrnegvmnv\",\"name\":\"q\",\"type\":\"qvldspastjbkkd\"},{\"properties\":{\"jobType\":\"JobBaseProperties\",\"componentId\":\"lves\",\"computeId\":\"jlxr\",\"displayName\":\"lozapeewchpxlk\",\"experimentName\":\"kuziycsle\",\"isArchived\":true,\"services\":{},\"status\":\"Preparing\",\"description\":\"tyh\",\"properties\":{},\"tags\":{}},\"id\":\"dcgzul\",\"name\":\"mmrqz\",\"type\":\"rr\"},{\"properties\":{\"jobType\":\"JobBaseProperties\",\"componentId\":\"pglydz\",\"computeId\":\"rvqeevtoepryutn\",\"displayName\":\"tpzdmovzvfvaawzq\",\"experimentName\":\"f\",\"isArchived\":false,\"services\":{},\"status\":\"Provisioning\",\"description\":\"aecxndtic\",\"properties\":{},\"tags\":{}},\"id\":\"zmlqtmldgxo\",\"name\":\"firclnpkciayz\",\"type\":\"iykhy\"}]}")
                .toObject(JobBaseResourceArmPaginatedResult.class);
        Assertions.assertEquals("zoggculapz", model.nextLink());
        Assertions.assertEquals("wzjbh", model.value().get(0).properties().description());
        Assertions.assertEquals("gogtqxepnylbf", model.value().get(0).properties().componentId());
        Assertions.assertEquals("jlyjtlvofq", model.value().get(0).properties().computeId());
        Assertions.assertEquals("vfcibyfmowux", model.value().get(0).properties().displayName());
        Assertions.assertEquals("jpvd", model.value().get(0).properties().experimentName());
        Assertions.assertEquals(true, model.value().get(0).properties().isArchived());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JobBaseResourceArmPaginatedResult model =
            new JobBaseResourceArmPaginatedResult()
                .withNextLink("zoggculapz")
                .withValue(
                    Arrays
                        .asList(
                            new JobBaseInner()
                                .withProperties(
                                    new JobBaseProperties()
                                        .withDescription("wzjbh")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withComponentId("gogtqxepnylbf")
                                        .withComputeId("jlyjtlvofq")
                                        .withDisplayName("vfcibyfmowux")
                                        .withExperimentName("jpvd")
                                        .withIsArchived(true)
                                        .withServices(mapOf())),
                            new JobBaseInner()
                                .withProperties(
                                    new JobBaseProperties()
                                        .withDescription("tyh")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withComponentId("lves")
                                        .withComputeId("jlxr")
                                        .withDisplayName("lozapeewchpxlk")
                                        .withExperimentName("kuziycsle")
                                        .withIsArchived(true)
                                        .withServices(mapOf())),
                            new JobBaseInner()
                                .withProperties(
                                    new JobBaseProperties()
                                        .withDescription("aecxndtic")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withComponentId("pglydz")
                                        .withComputeId("rvqeevtoepryutn")
                                        .withDisplayName("tpzdmovzvfvaawzq")
                                        .withExperimentName("f")
                                        .withIsArchived(false)
                                        .withServices(mapOf()))));
        model = BinaryData.fromObject(model).toObject(JobBaseResourceArmPaginatedResult.class);
        Assertions.assertEquals("zoggculapz", model.nextLink());
        Assertions.assertEquals("wzjbh", model.value().get(0).properties().description());
        Assertions.assertEquals("gogtqxepnylbf", model.value().get(0).properties().componentId());
        Assertions.assertEquals("jlyjtlvofq", model.value().get(0).properties().computeId());
        Assertions.assertEquals("vfcibyfmowux", model.value().get(0).properties().displayName());
        Assertions.assertEquals("jpvd", model.value().get(0).properties().experimentName());
        Assertions.assertEquals(true, model.value().get(0).properties().isArchived());
    }

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