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

package com.azure.resourcemanager.vmwarecloudsimple.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.vmwarecloudsimple.fluent.models.DedicatedCloudServiceInner;
import com.azure.resourcemanager.vmwarecloudsimple.models.DedicatedCloudServiceListResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DedicatedCloudServiceListResponseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DedicatedCloudServiceListResponse model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"znorcj\",\"value\":[{\"properties\":{\"gatewaySubnet\":\"byxqabn\",\"isAccountOnboarded\":\"notOnBoarded\",\"nodes\":1668091107,\"serviceURL\":\"shurzafbljjgpbto\"},\"location\":\"c\",\"tags\":{\"qajzyulpkudjkr\":\"ljavbqid\"},\"id\":\"khbzhfepgzg\",\"name\":\"e\",\"type\":\"zloc\"}]}")
                .toObject(DedicatedCloudServiceListResponse.class);
        Assertions.assertEquals("znorcj", model.nextLink());
        Assertions.assertEquals("c", model.value().get(0).location());
        Assertions.assertEquals("ljavbqid", model.value().get(0).tags().get("qajzyulpkudjkr"));
        Assertions.assertEquals("byxqabn", model.value().get(0).gatewaySubnet());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DedicatedCloudServiceListResponse model =
            new DedicatedCloudServiceListResponse()
                .withNextLink("znorcj")
                .withValue(
                    Arrays
                        .asList(
                            new DedicatedCloudServiceInner()
                                .withLocation("c")
                                .withTags(mapOf("qajzyulpkudjkr", "ljavbqid"))
                                .withGatewaySubnet("byxqabn")));
        model = BinaryData.fromObject(model).toObject(DedicatedCloudServiceListResponse.class);
        Assertions.assertEquals("znorcj", model.nextLink());
        Assertions.assertEquals("c", model.value().get(0).location());
        Assertions.assertEquals("ljavbqid", model.value().get(0).tags().get("qajzyulpkudjkr"));
        Assertions.assertEquals("byxqabn", model.value().get(0).gatewaySubnet());
    }

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