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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.fluent.models.GalleryImageInner;
import com.azure.resourcemanager.devtestlabs.models.GalleryImageList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class GalleryImageListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        GalleryImageList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"author\":\"rfkbwccsnjvcdwxl\",\"createdDate\":\"2021-03-31T08:41:02Z\",\"description\":\"ftnkhtj\",\"icon\":\"ngwfqatm\",\"enabled\":false,\"planId\":\"mdvy\",\"isPlanAuthorized\":true},\"location\":\"kdgszywkbirr\",\"tags\":{\"nrvgoupmfiibfgg\":\"hlhkjoqrvqqaatj\"},\"id\":\"ioolvrwxkvtkkgll\",\"name\":\"wjygvjayvblmhvk\",\"type\":\"uhbxvvy\"}],\"nextLink\":\"s\"}")
                .toObject(GalleryImageList.class);
        Assertions.assertEquals("kdgszywkbirr", model.value().get(0).location());
        Assertions.assertEquals("hlhkjoqrvqqaatj", model.value().get(0).tags().get("nrvgoupmfiibfgg"));
        Assertions.assertEquals("rfkbwccsnjvcdwxl", model.value().get(0).author());
        Assertions.assertEquals("ftnkhtj", model.value().get(0).description());
        Assertions.assertEquals("ngwfqatm", model.value().get(0).icon());
        Assertions.assertEquals(false, model.value().get(0).enabled());
        Assertions.assertEquals("mdvy", model.value().get(0).planId());
        Assertions.assertEquals(true, model.value().get(0).isPlanAuthorized());
        Assertions.assertEquals("s", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        GalleryImageList model =
            new GalleryImageList()
                .withValue(
                    Arrays
                        .asList(
                            new GalleryImageInner()
                                .withLocation("kdgszywkbirr")
                                .withTags(mapOf("nrvgoupmfiibfgg", "hlhkjoqrvqqaatj"))
                                .withAuthor("rfkbwccsnjvcdwxl")
                                .withDescription("ftnkhtj")
                                .withIcon("ngwfqatm")
                                .withEnabled(false)
                                .withPlanId("mdvy")
                                .withIsPlanAuthorized(true)))
                .withNextLink("s");
        model = BinaryData.fromObject(model).toObject(GalleryImageList.class);
        Assertions.assertEquals("kdgszywkbirr", model.value().get(0).location());
        Assertions.assertEquals("hlhkjoqrvqqaatj", model.value().get(0).tags().get("nrvgoupmfiibfgg"));
        Assertions.assertEquals("rfkbwccsnjvcdwxl", model.value().get(0).author());
        Assertions.assertEquals("ftnkhtj", model.value().get(0).description());
        Assertions.assertEquals("ngwfqatm", model.value().get(0).icon());
        Assertions.assertEquals(false, model.value().get(0).enabled());
        Assertions.assertEquals("mdvy", model.value().get(0).planId());
        Assertions.assertEquals(true, model.value().get(0).isPlanAuthorized());
        Assertions.assertEquals("s", model.nextLink());
    }

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