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

package com.azure.resourcemanager.managedapplications.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managedapplications.fluent.models.ApplicationDefinitionInner;
import com.azure.resourcemanager.managedapplications.models.ApplicationDefinitionListResult;
import com.azure.resourcemanager.managedapplications.models.ApplicationLockLevel;
import com.azure.resourcemanager.managedapplications.models.Identity;
import com.azure.resourcemanager.managedapplications.models.ResourceIdentityType;
import com.azure.resourcemanager.managedapplications.models.Sku;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ApplicationDefinitionListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ApplicationDefinitionListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"lockLevel\":\"ReadOnly\",\"displayName\":\"zafb\",\"isEnabled\":\"j\",\"authorizations\":[],\"artifacts\":[],\"description\":\"toqcjmklja\",\"packageFileUri\":\"qidtqajzyu\",\"mainTemplate\":\"datakudjkrlkhb\",\"createUiDefinition\":\"datafepgzgq\"},\"managedBy\":\"zloc\",\"sku\":{\"name\":\"c\",\"tier\":\"ierhhbcsglummaj\",\"size\":\"aodxo\",\"family\":\"bdxkqpxokaj\",\"model\":\"npime\",\"capacity\":1127619232},\"identity\":{\"principalId\":\"gcpo\",\"tenantId\":\"maajrmvdjwzrlo\",\"type\":\"SystemAssigned\"},\"location\":\"lwhijcoejctbzaq\",\"tags\":{\"bkbfkgukdkex\":\"y\",\"ocjjxhvpmouexh\":\"ppofmxaxcfjpgdd\"},\"id\":\"zxibqeoj\",\"name\":\"xqbzvddntwnd\",\"type\":\"icbtwnpzao\"},{\"properties\":{\"lockLevel\":\"None\",\"displayName\":\"hrhcffcyddglmjth\",\"isEnabled\":\"kw\",\"authorizations\":[],\"artifacts\":[],\"description\":\"icxm\",\"packageFileUri\":\"iwqvhkh\",\"mainTemplate\":\"datauigdtopbobjog\",\"createUiDefinition\":\"datae\"},\"managedBy\":\"a\",\"sku\":{\"name\":\"uhrzayvvt\",\"tier\":\"vdfgiotk\",\"size\":\"utqxlngx\",\"family\":\"fgugnxkrxdqmid\",\"model\":\"hzrvqd\",\"capacity\":552309473},\"identity\":{\"principalId\":\"yb\",\"tenantId\":\"ehoqfbowskan\",\"type\":\"SystemAssigned\"},\"location\":\"zlcuiywgqywgndrv\",\"tags\":{\"fvm\":\"zgpphrcgyncocpe\",\"bmqj\":\"coofsxlzev\",\"lzu\":\"abcypmivk\",\"ebxetqgtzxdp\":\"ccfwnfnbacfion\"},\"id\":\"qbqqwxr\",\"name\":\"feallnwsu\",\"type\":\"isnjampmngnz\"},{\"properties\":{\"lockLevel\":\"CanNotDelete\",\"displayName\":\"aqw\",\"isEnabled\":\"chcbonqvpkvlrxnj\",\"authorizations\":[],\"artifacts\":[],\"description\":\"eipheoflokeyy\",\"packageFileUri\":\"nj\",\"mainTemplate\":\"datalwtgrhpdj\",\"createUiDefinition\":\"dataumasxazjpq\"},\"managedBy\":\"gual\",\"sku\":{\"name\":\"xxhejjzzvd\",\"tier\":\"gwdslfhotwm\",\"size\":\"npwlbjnpg\",\"family\":\"ftadehxnltyfs\",\"model\":\"pusuesn\",\"capacity\":1828932864},\"identity\":{\"principalId\":\"bavo\",\"tenantId\":\"zdmohctbqvu\",\"type\":\"SystemAssigned\"},\"location\":\"dndnvow\",\"tags\":{\"zj\":\"jugwdkcglhsl\",\"kuofqweykhme\":\"yggdtjixh\",\"yvdcsitynnaa\":\"evfyexfwhybcib\",\"eypvhezrkg\":\"dectehfiqsc\"},\"id\":\"hcjrefovgmk\",\"name\":\"sle\",\"type\":\"yvxyqjp\"}],\"nextLink\":\"attpngjcrcczsq\"}")
                .toObject(ApplicationDefinitionListResult.class);
        Assertions.assertEquals("lwhijcoejctbzaq", model.value().get(0).location());
        Assertions.assertEquals("y", model.value().get(0).tags().get("bkbfkgukdkex"));
        Assertions.assertEquals("zloc", model.value().get(0).managedBy());
        Assertions.assertEquals("c", model.value().get(0).sku().name());
        Assertions.assertEquals("ierhhbcsglummaj", model.value().get(0).sku().tier());
        Assertions.assertEquals("aodxo", model.value().get(0).sku().size());
        Assertions.assertEquals("bdxkqpxokaj", model.value().get(0).sku().family());
        Assertions.assertEquals("npime", model.value().get(0).sku().model());
        Assertions.assertEquals(1127619232, model.value().get(0).sku().capacity());
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals(ApplicationLockLevel.READ_ONLY, model.value().get(0).lockLevel());
        Assertions.assertEquals("zafb", model.value().get(0).displayName());
        Assertions.assertEquals("j", model.value().get(0).isEnabled());
        Assertions.assertEquals("toqcjmklja", model.value().get(0).description());
        Assertions.assertEquals("qidtqajzyu", model.value().get(0).packageFileUri());
        Assertions.assertEquals("attpngjcrcczsq", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ApplicationDefinitionListResult model =
            new ApplicationDefinitionListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ApplicationDefinitionInner()
                                .withLocation("lwhijcoejctbzaq")
                                .withTags(mapOf("bkbfkgukdkex", "y", "ocjjxhvpmouexh", "ppofmxaxcfjpgdd"))
                                .withManagedBy("zloc")
                                .withSku(
                                    new Sku()
                                        .withName("c")
                                        .withTier("ierhhbcsglummaj")
                                        .withSize("aodxo")
                                        .withFamily("bdxkqpxokaj")
                                        .withModel("npime")
                                        .withCapacity(1127619232))
                                .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                                .withLockLevel(ApplicationLockLevel.READ_ONLY)
                                .withDisplayName("zafb")
                                .withIsEnabled("j")
                                .withAuthorizations(Arrays.asList())
                                .withArtifacts(Arrays.asList())
                                .withDescription("toqcjmklja")
                                .withPackageFileUri("qidtqajzyu")
                                .withMainTemplate("datakudjkrlkhb")
                                .withCreateUiDefinition("datafepgzgq"),
                            new ApplicationDefinitionInner()
                                .withLocation("zlcuiywgqywgndrv")
                                .withTags(
                                    mapOf(
                                        "fvm",
                                        "zgpphrcgyncocpe",
                                        "bmqj",
                                        "coofsxlzev",
                                        "lzu",
                                        "abcypmivk",
                                        "ebxetqgtzxdp",
                                        "ccfwnfnbacfion"))
                                .withManagedBy("a")
                                .withSku(
                                    new Sku()
                                        .withName("uhrzayvvt")
                                        .withTier("vdfgiotk")
                                        .withSize("utqxlngx")
                                        .withFamily("fgugnxkrxdqmid")
                                        .withModel("hzrvqd")
                                        .withCapacity(552309473))
                                .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                                .withLockLevel(ApplicationLockLevel.NONE)
                                .withDisplayName("hrhcffcyddglmjth")
                                .withIsEnabled("kw")
                                .withAuthorizations(Arrays.asList())
                                .withArtifacts(Arrays.asList())
                                .withDescription("icxm")
                                .withPackageFileUri("iwqvhkh")
                                .withMainTemplate("datauigdtopbobjog")
                                .withCreateUiDefinition("datae"),
                            new ApplicationDefinitionInner()
                                .withLocation("dndnvow")
                                .withTags(
                                    mapOf(
                                        "zj",
                                        "jugwdkcglhsl",
                                        "kuofqweykhme",
                                        "yggdtjixh",
                                        "yvdcsitynnaa",
                                        "evfyexfwhybcib",
                                        "eypvhezrkg",
                                        "dectehfiqsc"))
                                .withManagedBy("gual")
                                .withSku(
                                    new Sku()
                                        .withName("xxhejjzzvd")
                                        .withTier("gwdslfhotwm")
                                        .withSize("npwlbjnpg")
                                        .withFamily("ftadehxnltyfs")
                                        .withModel("pusuesn")
                                        .withCapacity(1828932864))
                                .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED))
                                .withLockLevel(ApplicationLockLevel.CAN_NOT_DELETE)
                                .withDisplayName("aqw")
                                .withIsEnabled("chcbonqvpkvlrxnj")
                                .withAuthorizations(Arrays.asList())
                                .withArtifacts(Arrays.asList())
                                .withDescription("eipheoflokeyy")
                                .withPackageFileUri("nj")
                                .withMainTemplate("datalwtgrhpdj")
                                .withCreateUiDefinition("dataumasxazjpq")))
                .withNextLink("attpngjcrcczsq");
        model = BinaryData.fromObject(model).toObject(ApplicationDefinitionListResult.class);
        Assertions.assertEquals("lwhijcoejctbzaq", model.value().get(0).location());
        Assertions.assertEquals("y", model.value().get(0).tags().get("bkbfkgukdkex"));
        Assertions.assertEquals("zloc", model.value().get(0).managedBy());
        Assertions.assertEquals("c", model.value().get(0).sku().name());
        Assertions.assertEquals("ierhhbcsglummaj", model.value().get(0).sku().tier());
        Assertions.assertEquals("aodxo", model.value().get(0).sku().size());
        Assertions.assertEquals("bdxkqpxokaj", model.value().get(0).sku().family());
        Assertions.assertEquals("npime", model.value().get(0).sku().model());
        Assertions.assertEquals(1127619232, model.value().get(0).sku().capacity());
        Assertions.assertEquals(ResourceIdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals(ApplicationLockLevel.READ_ONLY, model.value().get(0).lockLevel());
        Assertions.assertEquals("zafb", model.value().get(0).displayName());
        Assertions.assertEquals("j", model.value().get(0).isEnabled());
        Assertions.assertEquals("toqcjmklja", model.value().get(0).description());
        Assertions.assertEquals("qidtqajzyu", model.value().get(0).packageFileUri());
        Assertions.assertEquals("attpngjcrcczsq", 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;
    }
}
