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

package com.azure.resourcemanager.nginx.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.nginx.fluent.models.NginxDeploymentInner;
import com.azure.resourcemanager.nginx.models.IdentityProperties;
import com.azure.resourcemanager.nginx.models.IdentityType;
import com.azure.resourcemanager.nginx.models.NginxDeploymentListResponse;
import com.azure.resourcemanager.nginx.models.NginxDeploymentProperties;
import com.azure.resourcemanager.nginx.models.ResourceSku;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class NginxDeploymentListResponseTests {
    @Test
    public void testDeserialize() {
        NginxDeploymentListResponse model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"identity\":{\"principalId\":\"gnxkrxdqmidtth\",\"tenantId\":\"vqdra\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{}},\"properties\":{\"provisioningState\":\"Deleted\",\"nginxVersion\":\"h\",\"managedResourceGroup\":\"fbowskanyk\",\"ipAddress\":\"cuiywgqyw\",\"enableDiagnosticsSupport\":false},\"sku\":{\"name\":\"ynhz\"},\"location\":\"phrcgyncoc\",\"tags\":{\"coofsxlzev\":\"fvm\",\"abcypmivk\":\"bmqj\"},\"id\":\"lzu\",\"name\":\"ccfwnfnbacfion\",\"type\":\"ebxetqgtzxdp\"},{\"identity\":{\"principalId\":\"qqwx\",\"tenantId\":\"feallnwsu\",\"type\":\"SystemAssigned,"
                        + " UserAssigned\",\"userAssignedIdentities\":{}},\"properties\":{\"provisioningState\":\"Deleted\",\"nginxVersion\":\"mngnzscxaqw\",\"managedResourceGroup\":\"chcbonqvpkvlrxnj\",\"ipAddress\":\"eipheoflokeyy\",\"enableDiagnosticsSupport\":false},\"sku\":{\"name\":\"dlwtgrhpdj\"},\"location\":\"umasxazjpq\",\"tags\":{\"zvdudgwdslfhotwm\":\"ualhbxxhejj\"},\"id\":\"ynpwlbj\",\"name\":\"pgacftadehxnlty\",\"type\":\"sop\"},{\"identity\":{\"principalId\":\"uesnzwdejbavo\",\"tenantId\":\"zdmohctbqvu\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"properties\":{\"provisioningState\":\"Accepted\",\"nginxVersion\":\"owgujjugwdkcglhs\",\"managedResourceGroup\":\"zj\",\"ipAddress\":\"gdtjixhbkuofqwey\",\"enableDiagnosticsSupport\":true},\"sku\":{\"name\":\"evfyexfwhybcib\"},\"location\":\"vdcsitynn\",\"tags\":{\"eypvhezrkg\":\"dectehfiqsc\",\"sle\":\"hcjrefovgmk\",\"cattpngjcrcczsq\":\"yvxyqjp\",\"mdajv\":\"jh\"},\"id\":\"ysou\",\"name\":\"q\",\"type\":\"canoaeupf\"},{\"identity\":{\"principalId\":\"ltrpmopj\",\"tenantId\":\"matuok\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"properties\":{\"provisioningState\":\"Deleting\",\"nginxVersion\":\"dsfcpkvxodpuoz\",\"managedResourceGroup\":\"zydagfuaxbezyiuo\",\"ipAddress\":\"whrdxwzywqsmbsu\",\"enableDiagnosticsSupport\":false},\"sku\":{\"name\":\"o\"},\"location\":\"ocfs\",\"tags\":{\"kiiuxhqyudxor\":\"ymddys\"},\"id\":\"qn\",\"name\":\"poczvyifqrvkdvjs\",\"type\":\"lrmv\"}],\"nextLink\":\"f\"}")
                .toObject(NginxDeploymentListResponse.class);
        Assertions.assertEquals("phrcgyncoc", model.value().get(0).location());
        Assertions.assertEquals("fvm", model.value().get(0).tags().get("coofsxlzev"));
        Assertions.assertEquals(IdentityType.USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("fbowskanyk", model.value().get(0).properties().managedResourceGroup());
        Assertions.assertEquals(false, model.value().get(0).properties().enableDiagnosticsSupport());
        Assertions.assertEquals("ynhz", model.value().get(0).sku().name());
        Assertions.assertEquals("f", model.nextLink());
    }

    @Test
    public void testSerialize() {
        NginxDeploymentListResponse model =
            new NginxDeploymentListResponse()
                .withValue(
                    Arrays
                        .asList(
                            new NginxDeploymentInner()
                                .withLocation("phrcgyncoc")
                                .withTags(mapOf("coofsxlzev", "fvm", "abcypmivk", "bmqj"))
                                .withIdentity(
                                    new IdentityProperties()
                                        .withType(IdentityType.USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withProperties(
                                    new NginxDeploymentProperties()
                                        .withManagedResourceGroup("fbowskanyk")
                                        .withEnableDiagnosticsSupport(false))
                                .withSku(new ResourceSku().withName("ynhz")),
                            new NginxDeploymentInner()
                                .withLocation("umasxazjpq")
                                .withTags(mapOf("zvdudgwdslfhotwm", "ualhbxxhejj"))
                                .withIdentity(
                                    new IdentityProperties()
                                        .withType(IdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withProperties(
                                    new NginxDeploymentProperties()
                                        .withManagedResourceGroup("chcbonqvpkvlrxnj")
                                        .withEnableDiagnosticsSupport(false))
                                .withSku(new ResourceSku().withName("dlwtgrhpdj")),
                            new NginxDeploymentInner()
                                .withLocation("vdcsitynn")
                                .withTags(
                                    mapOf(
                                        "eypvhezrkg",
                                        "dectehfiqsc",
                                        "sle",
                                        "hcjrefovgmk",
                                        "cattpngjcrcczsq",
                                        "yvxyqjp",
                                        "mdajv",
                                        "jh"))
                                .withIdentity(
                                    new IdentityProperties()
                                        .withType(IdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withProperties(
                                    new NginxDeploymentProperties()
                                        .withManagedResourceGroup("zj")
                                        .withEnableDiagnosticsSupport(true))
                                .withSku(new ResourceSku().withName("evfyexfwhybcib")),
                            new NginxDeploymentInner()
                                .withLocation("ocfs")
                                .withTags(mapOf("kiiuxhqyudxor", "ymddys"))
                                .withIdentity(
                                    new IdentityProperties()
                                        .withType(IdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withProperties(
                                    new NginxDeploymentProperties()
                                        .withManagedResourceGroup("zydagfuaxbezyiuo")
                                        .withEnableDiagnosticsSupport(false))
                                .withSku(new ResourceSku().withName("o"))))
                .withNextLink("f");
        model = BinaryData.fromObject(model).toObject(NginxDeploymentListResponse.class);
        Assertions.assertEquals("phrcgyncoc", model.value().get(0).location());
        Assertions.assertEquals("fvm", model.value().get(0).tags().get("coofsxlzev"));
        Assertions.assertEquals(IdentityType.USER_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("fbowskanyk", model.value().get(0).properties().managedResourceGroup());
        Assertions.assertEquals(false, model.value().get(0).properties().enableDiagnosticsSupport());
        Assertions.assertEquals("ynhz", model.value().get(0).sku().name());
        Assertions.assertEquals("f", 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;
    }
}
