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

public final class CustomImageListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CustomImageList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"description\":\"wlquuijfqkace\",\"author\":\"ipfpubji\",\"creationDate\":\"2021-01-24T11:42:32Z\",\"managedImageId\":\"f\",\"managedSnapshotId\":\"hqkvpuvksgplsak\",\"dataDiskStorageInfo\":[],\"isPlanAuthorized\":true,\"provisioningState\":\"n\",\"uniqueIdentifier\":\"ph\"},\"location\":\"op\",\"tags\":{\"osjswsr\":\"lqiyntorzihl\",\"qioxi\":\"slyzrpzbchckqq\",\"wyhqmibzyhwits\":\"suiizynkedyat\"},\"id\":\"ypyynpcdpumnzg\",\"name\":\"wznm\",\"type\":\"biknsorgjhxbld\"}],\"nextLink\":\"wwrlkdmtncv\"}")
                .toObject(CustomImageList.class);
        Assertions.assertEquals("op", model.value().get(0).location());
        Assertions.assertEquals("lqiyntorzihl", model.value().get(0).tags().get("osjswsr"));
        Assertions.assertEquals("wlquuijfqkace", model.value().get(0).description());
        Assertions.assertEquals("ipfpubji", model.value().get(0).author());
        Assertions.assertEquals("f", model.value().get(0).managedImageId());
        Assertions.assertEquals("hqkvpuvksgplsak", model.value().get(0).managedSnapshotId());
        Assertions.assertEquals(true, model.value().get(0).isPlanAuthorized());
        Assertions.assertEquals("wwrlkdmtncv", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CustomImageList model =
            new CustomImageList()
                .withValue(
                    Arrays
                        .asList(
                            new CustomImageInner()
                                .withLocation("op")
                                .withTags(
                                    mapOf(
                                        "osjswsr",
                                        "lqiyntorzihl",
                                        "qioxi",
                                        "slyzrpzbchckqq",
                                        "wyhqmibzyhwits",
                                        "suiizynkedyat"))
                                .withDescription("wlquuijfqkace")
                                .withAuthor("ipfpubji")
                                .withManagedImageId("f")
                                .withManagedSnapshotId("hqkvpuvksgplsak")
                                .withDataDiskStorageInfo(Arrays.asList())
                                .withIsPlanAuthorized(true)))
                .withNextLink("wwrlkdmtncv");
        model = BinaryData.fromObject(model).toObject(CustomImageList.class);
        Assertions.assertEquals("op", model.value().get(0).location());
        Assertions.assertEquals("lqiyntorzihl", model.value().get(0).tags().get("osjswsr"));
        Assertions.assertEquals("wlquuijfqkace", model.value().get(0).description());
        Assertions.assertEquals("ipfpubji", model.value().get(0).author());
        Assertions.assertEquals("f", model.value().get(0).managedImageId());
        Assertions.assertEquals("hqkvpuvksgplsak", model.value().get(0).managedSnapshotId());
        Assertions.assertEquals(true, model.value().get(0).isPlanAuthorized());
        Assertions.assertEquals("wwrlkdmtncv", 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;
    }
}
