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

package com.azure.resourcemanager.qumulo.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.qumulo.models.FileSystemResourceUpdate;
import com.azure.resourcemanager.qumulo.models.FileSystemResourceUpdateProperties;
import com.azure.resourcemanager.qumulo.models.ManagedServiceIdentity;
import com.azure.resourcemanager.qumulo.models.ManagedServiceIdentityType;
import com.azure.resourcemanager.qumulo.models.MarketplaceDetails;
import com.azure.resourcemanager.qumulo.models.UserAssignedIdentity;
import com.azure.resourcemanager.qumulo.models.UserDetails;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class FileSystemResourceUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        FileSystemResourceUpdate model =
            BinaryData
                .fromString(
                    "{\"identity\":{\"principalId\":\"26a53dc5-f4b6-414b-b84c-19a0b79607c0\",\"tenantId\":\"4171f035-c188-403c-a0b4-3ea1abc39872\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"ygxgispemvtz\":{\"principalId\":\"20a43eda-ae37-462d-9ba6-51e4f6734f05\",\"clientId\":\"7cb6c0f4-520d-4554-9107-d22e3f7612b7\"},\"fublj\":{\"principalId\":\"39bc2d33-f459-4f1b-adee-74f518442166\",\"clientId\":\"44d17a06-5d55-47cf-b90f-d6a0f86f86ad\"},\"qeof\":{\"principalId\":\"a0bcde25-fa6c-40cf-8fc1-930e96a24109\",\"clientId\":\"2c39cab6-d132-41f9-925d-45c91d3956b0\"}}},\"tags\":{\"msmjqulngsntn\":\"qjhqjbas\"},\"properties\":{\"marketplaceDetails\":{\"marketplaceSubscriptionId\":\"zgcwrw\",\"planId\":\"lxxwrljdouskc\",\"offerId\":\"vkocrcjdkwtn\",\"publisherId\":\"xbnjbiksq\",\"marketplaceSubscriptionStatus\":\"Subscribed\"},\"userDetails\":{\"email\":\"sainqpjwnzl\"},\"delegatedSubnetId\":\"fmppe\",\"clusterLoginUrl\":\"vmgxsab\",\"privateIPs\":[\"duuji\",\"c\",\"czdzev\",\"dhkrwpdappdsbdk\"]}}")
                .toObject(FileSystemResourceUpdate.class);
        Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals("qjhqjbas", model.tags().get("msmjqulngsntn"));
        Assertions.assertEquals("zgcwrw", model.properties().marketplaceDetails().marketplaceSubscriptionId());
        Assertions.assertEquals("lxxwrljdouskc", model.properties().marketplaceDetails().planId());
        Assertions.assertEquals("vkocrcjdkwtn", model.properties().marketplaceDetails().offerId());
        Assertions.assertEquals("xbnjbiksq", model.properties().marketplaceDetails().publisherId());
        Assertions.assertEquals("sainqpjwnzl", model.properties().userDetails().email());
        Assertions.assertEquals("fmppe", model.properties().delegatedSubnetId());
        Assertions.assertEquals("vmgxsab", model.properties().clusterLoginUrl());
        Assertions.assertEquals("duuji", model.properties().privateIPs().get(0));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        FileSystemResourceUpdate model =
            new FileSystemResourceUpdate()
                .withIdentity(
                    new ManagedServiceIdentity()
                        .withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)
                        .withUserAssignedIdentities(
                            mapOf(
                                "ygxgispemvtz",
                                new UserAssignedIdentity(),
                                "fublj",
                                new UserAssignedIdentity(),
                                "qeof",
                                new UserAssignedIdentity())))
                .withTags(mapOf("msmjqulngsntn", "qjhqjbas"))
                .withProperties(
                    new FileSystemResourceUpdateProperties()
                        .withMarketplaceDetails(
                            new MarketplaceDetails()
                                .withMarketplaceSubscriptionId("zgcwrw")
                                .withPlanId("lxxwrljdouskc")
                                .withOfferId("vkocrcjdkwtn")
                                .withPublisherId("xbnjbiksq"))
                        .withUserDetails(new UserDetails().withEmail("sainqpjwnzl"))
                        .withDelegatedSubnetId("fmppe")
                        .withClusterLoginUrl("vmgxsab")
                        .withPrivateIPs(Arrays.asList("duuji", "c", "czdzev", "dhkrwpdappdsbdk")));
        model = BinaryData.fromObject(model).toObject(FileSystemResourceUpdate.class);
        Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals("qjhqjbas", model.tags().get("msmjqulngsntn"));
        Assertions.assertEquals("zgcwrw", model.properties().marketplaceDetails().marketplaceSubscriptionId());
        Assertions.assertEquals("lxxwrljdouskc", model.properties().marketplaceDetails().planId());
        Assertions.assertEquals("vkocrcjdkwtn", model.properties().marketplaceDetails().offerId());
        Assertions.assertEquals("xbnjbiksq", model.properties().marketplaceDetails().publisherId());
        Assertions.assertEquals("sainqpjwnzl", model.properties().userDetails().email());
        Assertions.assertEquals("fmppe", model.properties().delegatedSubnetId());
        Assertions.assertEquals("vmgxsab", model.properties().clusterLoginUrl());
        Assertions.assertEquals("duuji", model.properties().privateIPs().get(0));
    }

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