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

package com.azure.resourcemanager.imagebuilder.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.imagebuilder.models.ImageTemplateManagedImageDistributor;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ImageTemplateManagedImageDistributorTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ImageTemplateManagedImageDistributor model =
            BinaryData
                .fromString(
                    "{\"type\":\"ManagedImage\",\"imageId\":\"vvdfwatkpnpul\",\"location\":\"xxbczwtr\",\"runOutputName\":\"wiqzbqjvsovmyo\",\"artifactTags\":{\"lb\":\"spkwlhzdobpxjm\",\"wzjuqk\":\"vnchrkcci\",\"iwkuofos\":\"rsa\",\"ugidyjrr\":\"ghsauuimjmvxied\"}}")
                .toObject(ImageTemplateManagedImageDistributor.class);
        Assertions.assertEquals("wiqzbqjvsovmyo", model.runOutputName());
        Assertions.assertEquals("spkwlhzdobpxjm", model.artifactTags().get("lb"));
        Assertions.assertEquals("vvdfwatkpnpul", model.imageId());
        Assertions.assertEquals("xxbczwtr", model.location());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ImageTemplateManagedImageDistributor model =
            new ImageTemplateManagedImageDistributor()
                .withRunOutputName("wiqzbqjvsovmyo")
                .withArtifactTags(
                    mapOf(
                        "lb",
                        "spkwlhzdobpxjm",
                        "wzjuqk",
                        "vnchrkcci",
                        "iwkuofos",
                        "rsa",
                        "ugidyjrr",
                        "ghsauuimjmvxied"))
                .withImageId("vvdfwatkpnpul")
                .withLocation("xxbczwtr");
        model = BinaryData.fromObject(model).toObject(ImageTemplateManagedImageDistributor.class);
        Assertions.assertEquals("wiqzbqjvsovmyo", model.runOutputName());
        Assertions.assertEquals("spkwlhzdobpxjm", model.artifactTags().get("lb"));
        Assertions.assertEquals("vvdfwatkpnpul", model.imageId());
        Assertions.assertEquals("xxbczwtr", model.location());
    }

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