// 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.GalleryImageReference;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class GalleryImageInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        GalleryImageInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"author\":\"byrqufeg\",\"createdDate\":\"2021-08-31T05:13:54Z\",\"description\":\"zfbn\",\"imageReference\":{\"offer\":\"ctlpdngitvgb\",\"publisher\":\"rixkwmyijejve\",\"sku\":\"hbpnaixexccbd\",\"osType\":\"ax\",\"version\":\"exdrrvqahqkg\"},\"icon\":\"pwijnhy\",\"enabled\":false,\"planId\":\"ycxzbfvoo\",\"isPlanAuthorized\":false},\"location\":\"vmtgjqppy\",\"tags\":{\"sxkm\":\"ronzmyhgfip\",\"hjglikk\":\"waekrrjreafxtsgu\",\"uzlm\":\"wslolbqp\"},\"id\":\"felfktg\",\"name\":\"lcrpw\",\"type\":\"xeznoi\"}")
                .toObject(GalleryImageInner.class);
        Assertions.assertEquals("vmtgjqppy", model.location());
        Assertions.assertEquals("ronzmyhgfip", model.tags().get("sxkm"));
        Assertions.assertEquals("byrqufeg", model.author());
        Assertions.assertEquals("zfbn", model.description());
        Assertions.assertEquals("ctlpdngitvgb", model.imageReference().offer());
        Assertions.assertEquals("rixkwmyijejve", model.imageReference().publisher());
        Assertions.assertEquals("hbpnaixexccbd", model.imageReference().sku());
        Assertions.assertEquals("ax", model.imageReference().osType());
        Assertions.assertEquals("exdrrvqahqkg", model.imageReference().version());
        Assertions.assertEquals("pwijnhy", model.icon());
        Assertions.assertEquals(false, model.enabled());
        Assertions.assertEquals("ycxzbfvoo", model.planId());
        Assertions.assertEquals(false, model.isPlanAuthorized());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        GalleryImageInner model =
            new GalleryImageInner()
                .withLocation("vmtgjqppy")
                .withTags(mapOf("sxkm", "ronzmyhgfip", "hjglikk", "waekrrjreafxtsgu", "uzlm", "wslolbqp"))
                .withAuthor("byrqufeg")
                .withDescription("zfbn")
                .withImageReference(
                    new GalleryImageReference()
                        .withOffer("ctlpdngitvgb")
                        .withPublisher("rixkwmyijejve")
                        .withSku("hbpnaixexccbd")
                        .withOsType("ax")
                        .withVersion("exdrrvqahqkg"))
                .withIcon("pwijnhy")
                .withEnabled(false)
                .withPlanId("ycxzbfvoo")
                .withIsPlanAuthorized(false);
        model = BinaryData.fromObject(model).toObject(GalleryImageInner.class);
        Assertions.assertEquals("vmtgjqppy", model.location());
        Assertions.assertEquals("ronzmyhgfip", model.tags().get("sxkm"));
        Assertions.assertEquals("byrqufeg", model.author());
        Assertions.assertEquals("zfbn", model.description());
        Assertions.assertEquals("ctlpdngitvgb", model.imageReference().offer());
        Assertions.assertEquals("rixkwmyijejve", model.imageReference().publisher());
        Assertions.assertEquals("hbpnaixexccbd", model.imageReference().sku());
        Assertions.assertEquals("ax", model.imageReference().osType());
        Assertions.assertEquals("exdrrvqahqkg", model.imageReference().version());
        Assertions.assertEquals("pwijnhy", model.icon());
        Assertions.assertEquals(false, model.enabled());
        Assertions.assertEquals("ycxzbfvoo", model.planId());
        Assertions.assertEquals(false, model.isPlanAuthorized());
    }

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