// 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.ScheduleInner;
import com.azure.resourcemanager.machinelearning.models.ScheduleProperties;
import com.azure.resourcemanager.machinelearning.models.ScheduleResourceArmPaginatedResult;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ScheduleResourceArmPaginatedResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduleResourceArmPaginatedResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"bmhyreeudz\",\"value\":[{\"properties\":{\"displayName\":\"pdqmjxlyyzglgouw\",\"isEnabled\":false,\"provisioningState\":\"Updating\",\"description\":\"uojqt\",\"properties\":{},\"tags\":{}},\"id\":\"kjeytunl\",\"name\":\"fjkwrusnkq\",\"type\":\"hsyrqunj\"},{\"properties\":{\"displayName\":\"denxau\",\"isEnabled\":true,\"provisioningState\":\"Creating\",\"description\":\"kifmjn\",\"properties\":{},\"tags\":{}},\"id\":\"qabpxuckpggqow\",\"name\":\"yirdhlisngwflqq\",\"type\":\"pizruwnpqxpxiw\"},{\"properties\":{\"displayName\":\"ngjsaasi\",\"isEnabled\":true,\"provisioningState\":\"Failed\",\"description\":\"jvkviirhgfgrws\",\"properties\":{},\"tags\":{}},\"id\":\"atzv\",\"name\":\"bglbyvict\",\"type\":\"tbrxkjz\"},{\"properties\":{\"displayName\":\"gxffmshkwf\",\"isEnabled\":false,\"provisioningState\":\"Creating\",\"description\":\"wopdbydpiz\",\"properties\":{},\"tags\":{}},\"id\":\"napxbiygnug\",\"name\":\"knfsmfcttuxuuyil\",\"type\":\"lq\"}]}")
                .toObject(ScheduleResourceArmPaginatedResult.class);
        Assertions.assertEquals("bmhyreeudz", model.nextLink());
        Assertions.assertEquals("uojqt", model.value().get(0).properties().description());
        Assertions.assertEquals("pdqmjxlyyzglgouw", model.value().get(0).properties().displayName());
        Assertions.assertEquals(false, model.value().get(0).properties().isEnabled());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduleResourceArmPaginatedResult model =
            new ScheduleResourceArmPaginatedResult()
                .withNextLink("bmhyreeudz")
                .withValue(
                    Arrays
                        .asList(
                            new ScheduleInner()
                                .withProperties(
                                    new ScheduleProperties()
                                        .withDescription("uojqt")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withDisplayName("pdqmjxlyyzglgouw")
                                        .withIsEnabled(false)),
                            new ScheduleInner()
                                .withProperties(
                                    new ScheduleProperties()
                                        .withDescription("kifmjn")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withDisplayName("denxau")
                                        .withIsEnabled(true)),
                            new ScheduleInner()
                                .withProperties(
                                    new ScheduleProperties()
                                        .withDescription("jvkviirhgfgrws")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withDisplayName("ngjsaasi")
                                        .withIsEnabled(true)),
                            new ScheduleInner()
                                .withProperties(
                                    new ScheduleProperties()
                                        .withDescription("wopdbydpiz")
                                        .withProperties(mapOf())
                                        .withTags(mapOf())
                                        .withDisplayName("gxffmshkwf")
                                        .withIsEnabled(false))));
        model = BinaryData.fromObject(model).toObject(ScheduleResourceArmPaginatedResult.class);
        Assertions.assertEquals("bmhyreeudz", model.nextLink());
        Assertions.assertEquals("uojqt", model.value().get(0).properties().description());
        Assertions.assertEquals("pdqmjxlyyzglgouw", model.value().get(0).properties().displayName());
        Assertions.assertEquals(false, model.value().get(0).properties().isEnabled());
    }

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