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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.fluent.models.ServiceFabricInner;
import com.azure.resourcemanager.devtestlabs.models.ServiceFabricList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ServiceFabricListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceFabricList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"externalServiceFabricId\":\"dxmeb\",\"environmentId\":\"scjpahlxv\",\"provisioningState\":\"f\",\"uniqueIdentifier\":\"nmwmqtibx\"},\"location\":\"ijddtvqc\",\"tags\":{\"ukm\":\"dija\",\"dqmeqwigpibudq\":\"sieekpndzaapm\",\"ybpmzznrtffyaq\":\"yxeb\",\"hvseufuqyrx\":\"tmhheioqa\"},\"id\":\"dlcgqlsismjqfr\",\"name\":\"dgamquhiosrsj\",\"type\":\"ivfcdisyirnx\"}],\"nextLink\":\"czexrxzbujrtrhqv\"}")
                .toObject(ServiceFabricList.class);
        Assertions.assertEquals("ijddtvqc", model.value().get(0).location());
        Assertions.assertEquals("dija", model.value().get(0).tags().get("ukm"));
        Assertions.assertEquals("dxmeb", model.value().get(0).externalServiceFabricId());
        Assertions.assertEquals("scjpahlxv", model.value().get(0).environmentId());
        Assertions.assertEquals("czexrxzbujrtrhqv", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceFabricList model =
            new ServiceFabricList()
                .withValue(
                    Arrays
                        .asList(
                            new ServiceFabricInner()
                                .withLocation("ijddtvqc")
                                .withTags(
                                    mapOf(
                                        "ukm",
                                        "dija",
                                        "dqmeqwigpibudq",
                                        "sieekpndzaapm",
                                        "ybpmzznrtffyaq",
                                        "yxeb",
                                        "hvseufuqyrx",
                                        "tmhheioqa"))
                                .withExternalServiceFabricId("dxmeb")
                                .withEnvironmentId("scjpahlxv")))
                .withNextLink("czexrxzbujrtrhqv");
        model = BinaryData.fromObject(model).toObject(ServiceFabricList.class);
        Assertions.assertEquals("ijddtvqc", model.value().get(0).location());
        Assertions.assertEquals("dija", model.value().get(0).tags().get("ukm"));
        Assertions.assertEquals("dxmeb", model.value().get(0).externalServiceFabricId());
        Assertions.assertEquals("scjpahlxv", model.value().get(0).environmentId());
        Assertions.assertEquals("czexrxzbujrtrhqv", 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;
    }
}
