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

package com.azure.resourcemanager.desktopvirtualization.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.desktopvirtualization.models.ApplicationPatch;
import com.azure.resourcemanager.desktopvirtualization.models.CommandLineSetting;
import com.azure.resourcemanager.desktopvirtualization.models.RemoteApplicationType;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ApplicationPatchTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ApplicationPatch model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"yriwwroyqb\":\"prwmdyvxqt\",\"mefqsgzvahapjyzh\":\"xrmcqibycnojvk\"},\"properties\":{\"description\":\"qzcjrvxdj\",\"friendlyName\":\"mwlxk\",\"filePath\":\"gfhzovawjvzunlut\",\"commandLineSetting\":\"Allow\",\"commandLineArguments\":\"rnxipei\",\"showInPortal\":true,\"iconPath\":\"uaejxdultsk\",\"iconIndex\":618241707,\"msixPackageFamilyName\":\"dzumveekg\",\"msixPackageApplicationId\":\"ozuhkfp\",\"applicationType\":\"MsixApplication\"}}")
                .toObject(ApplicationPatch.class);
        Assertions.assertEquals("prwmdyvxqt", model.tags().get("yriwwroyqb"));
        Assertions.assertEquals("qzcjrvxdj", model.description());
        Assertions.assertEquals("mwlxk", model.friendlyName());
        Assertions.assertEquals("gfhzovawjvzunlut", model.filePath());
        Assertions.assertEquals(CommandLineSetting.ALLOW, model.commandLineSetting());
        Assertions.assertEquals("rnxipei", model.commandLineArguments());
        Assertions.assertEquals(true, model.showInPortal());
        Assertions.assertEquals("uaejxdultsk", model.iconPath());
        Assertions.assertEquals(618241707, model.iconIndex());
        Assertions.assertEquals("dzumveekg", model.msixPackageFamilyName());
        Assertions.assertEquals("ozuhkfp", model.msixPackageApplicationId());
        Assertions.assertEquals(RemoteApplicationType.MSIX_APPLICATION, model.applicationType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ApplicationPatch model =
            new ApplicationPatch()
                .withTags(mapOf("yriwwroyqb", "prwmdyvxqt", "mefqsgzvahapjyzh", "xrmcqibycnojvk"))
                .withDescription("qzcjrvxdj")
                .withFriendlyName("mwlxk")
                .withFilePath("gfhzovawjvzunlut")
                .withCommandLineSetting(CommandLineSetting.ALLOW)
                .withCommandLineArguments("rnxipei")
                .withShowInPortal(true)
                .withIconPath("uaejxdultsk")
                .withIconIndex(618241707)
                .withMsixPackageFamilyName("dzumveekg")
                .withMsixPackageApplicationId("ozuhkfp")
                .withApplicationType(RemoteApplicationType.MSIX_APPLICATION);
        model = BinaryData.fromObject(model).toObject(ApplicationPatch.class);
        Assertions.assertEquals("prwmdyvxqt", model.tags().get("yriwwroyqb"));
        Assertions.assertEquals("qzcjrvxdj", model.description());
        Assertions.assertEquals("mwlxk", model.friendlyName());
        Assertions.assertEquals("gfhzovawjvzunlut", model.filePath());
        Assertions.assertEquals(CommandLineSetting.ALLOW, model.commandLineSetting());
        Assertions.assertEquals("rnxipei", model.commandLineArguments());
        Assertions.assertEquals(true, model.showInPortal());
        Assertions.assertEquals("uaejxdultsk", model.iconPath());
        Assertions.assertEquals(618241707, model.iconIndex());
        Assertions.assertEquals("dzumveekg", model.msixPackageFamilyName());
        Assertions.assertEquals("ozuhkfp", model.msixPackageApplicationId());
        Assertions.assertEquals(RemoteApplicationType.MSIX_APPLICATION, model.applicationType());
    }

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