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

package com.azure.resourcemanager.hybridcontainerservice.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.hybridcontainerservice.fluent.models.StorageSpacesInner;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesExtendedLocation;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesProperties;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesPropertiesHciStorageProfile;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesPropertiesStatus;
import com.azure.resourcemanager.hybridcontainerservice.models.StorageSpacesPropertiesVmwareStorageProfile;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class StorageSpacesInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StorageSpacesInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"hciStorageProfile\":{\"mocGroup\":\"xpbtgiwbwo\",\"mocLocation\":\"washr\",\"mocStorageContainer\":\"tkcnqxwb\"},\"vmwareStorageProfile\":{\"datacenter\":\"ulpiuj\",\"datastore\":\"asipqiio\",\"folder\":\"uqerpqlpqwc\",\"resourcePool\":\"uqgbdbutauvfbt\"},\"provisioningState\":\"Deleting\",\"status\":{}},\"extendedLocation\":{\"type\":\"k\",\"name\":\"oxafn\"},\"location\":\"dlpichkoymkcdyhb\",\"tags\":{\"vljxywsu\":\"pwdreqnovvqf\"},\"id\":\"syrsndsytgadgvra\",\"name\":\"aeneqnzarrwl\",\"type\":\"uu\"}")
                .toObject(StorageSpacesInner.class);
        Assertions.assertEquals("dlpichkoymkcdyhb", model.location());
        Assertions.assertEquals("pwdreqnovvqf", model.tags().get("vljxywsu"));
        Assertions.assertEquals("xpbtgiwbwo", model.properties().hciStorageProfile().mocGroup());
        Assertions.assertEquals("washr", model.properties().hciStorageProfile().mocLocation());
        Assertions.assertEquals("tkcnqxwb", model.properties().hciStorageProfile().mocStorageContainer());
        Assertions.assertEquals("ulpiuj", model.properties().vmwareStorageProfile().datacenter());
        Assertions.assertEquals("asipqiio", model.properties().vmwareStorageProfile().datastore());
        Assertions.assertEquals("uqerpqlpqwc", model.properties().vmwareStorageProfile().folder());
        Assertions.assertEquals("uqgbdbutauvfbt", model.properties().vmwareStorageProfile().resourcePool());
        Assertions.assertEquals("k", model.extendedLocation().type());
        Assertions.assertEquals("oxafn", model.extendedLocation().name());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StorageSpacesInner model =
            new StorageSpacesInner()
                .withLocation("dlpichkoymkcdyhb")
                .withTags(mapOf("vljxywsu", "pwdreqnovvqf"))
                .withProperties(
                    new StorageSpacesProperties()
                        .withHciStorageProfile(
                            new StorageSpacesPropertiesHciStorageProfile()
                                .withMocGroup("xpbtgiwbwo")
                                .withMocLocation("washr")
                                .withMocStorageContainer("tkcnqxwb"))
                        .withVmwareStorageProfile(
                            new StorageSpacesPropertiesVmwareStorageProfile()
                                .withDatacenter("ulpiuj")
                                .withDatastore("asipqiio")
                                .withFolder("uqerpqlpqwc")
                                .withResourcePool("uqgbdbutauvfbt"))
                        .withStatus(new StorageSpacesPropertiesStatus()))
                .withExtendedLocation(new StorageSpacesExtendedLocation().withType("k").withName("oxafn"));
        model = BinaryData.fromObject(model).toObject(StorageSpacesInner.class);
        Assertions.assertEquals("dlpichkoymkcdyhb", model.location());
        Assertions.assertEquals("pwdreqnovvqf", model.tags().get("vljxywsu"));
        Assertions.assertEquals("xpbtgiwbwo", model.properties().hciStorageProfile().mocGroup());
        Assertions.assertEquals("washr", model.properties().hciStorageProfile().mocLocation());
        Assertions.assertEquals("tkcnqxwb", model.properties().hciStorageProfile().mocStorageContainer());
        Assertions.assertEquals("ulpiuj", model.properties().vmwareStorageProfile().datacenter());
        Assertions.assertEquals("asipqiio", model.properties().vmwareStorageProfile().datastore());
        Assertions.assertEquals("uqerpqlpqwc", model.properties().vmwareStorageProfile().folder());
        Assertions.assertEquals("uqgbdbutauvfbt", model.properties().vmwareStorageProfile().resourcePool());
        Assertions.assertEquals("k", model.extendedLocation().type());
        Assertions.assertEquals("oxafn", model.extendedLocation().name());
    }

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