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

public final class ArtifactInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ArtifactInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"title\":\"ongmtsa\",\"description\":\"cbpwxqpsrknft\",\"publisher\":\"vriuhprwmdyvx\",\"filePath\":\"ayriwwroyqbexrm\",\"icon\":\"ibycno\",\"targetOsType\":\"knme\",\"parameters\":\"datasgzvahapjyzhpv\",\"createdDate\":\"2021-11-12T18:49:52Z\"},\"location\":\"cjrvxdjzlmwlxkv\",\"tags\":{\"nnprn\":\"hzovawjvzunlut\",\"eilpjzuaejxdu\":\"i\",\"pwo\":\"tskzbbtdzumveek\",\"fpbsjyofdxl\":\"uh\"},\"id\":\"us\",\"name\":\"ttouwaboekqvkel\",\"type\":\"smv\"}")
                .toObject(ArtifactInner.class);
        Assertions.assertEquals("cjrvxdjzlmwlxkv", model.location());
        Assertions.assertEquals("hzovawjvzunlut", model.tags().get("nnprn"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ArtifactInner model =
            new ArtifactInner()
                .withLocation("cjrvxdjzlmwlxkv")
                .withTags(
                    mapOf(
                        "nnprn",
                        "hzovawjvzunlut",
                        "eilpjzuaejxdu",
                        "i",
                        "pwo",
                        "tskzbbtdzumveek",
                        "fpbsjyofdxl",
                        "uh"));
        model = BinaryData.fromObject(model).toObject(ArtifactInner.class);
        Assertions.assertEquals("cjrvxdjzlmwlxkv", model.location());
        Assertions.assertEquals("hzovawjvzunlut", model.tags().get("nnprn"));
    }

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