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

package com.azure.resourcemanager.azurestack.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.azurestack.fluent.models.RegistrationInner;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class RegistrationInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RegistrationInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"objectId\":\"kyqxjvuujqgidokg\",\"cloudId\":\"jyoxgvclt\",\"billingModel\":\"sncghkjeszz\"},\"etag\":\"ijhtxf\",\"location\":\"gx\",\"tags\":{\"ec\":\"mxnehmp\"},\"id\":\"godebfqkkrbmpu\",\"name\":\"gr\",\"type\":\"wflzlfbxzpuzy\"}")
                .toObject(RegistrationInner.class);
        Assertions.assertEquals("gx", model.location());
        Assertions.assertEquals("mxnehmp", model.tags().get("ec"));
        Assertions.assertEquals("ijhtxf", model.etag());
        Assertions.assertEquals("kyqxjvuujqgidokg", model.objectId());
        Assertions.assertEquals("jyoxgvclt", model.cloudId());
        Assertions.assertEquals("sncghkjeszz", model.billingModel());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RegistrationInner model =
            new RegistrationInner()
                .withLocation("gx")
                .withTags(mapOf("ec", "mxnehmp"))
                .withEtag("ijhtxf")
                .withObjectId("kyqxjvuujqgidokg")
                .withCloudId("jyoxgvclt")
                .withBillingModel("sncghkjeszz");
        model = BinaryData.fromObject(model).toObject(RegistrationInner.class);
        Assertions.assertEquals("gx", model.location());
        Assertions.assertEquals("mxnehmp", model.tags().get("ec"));
        Assertions.assertEquals("ijhtxf", model.etag());
        Assertions.assertEquals("kyqxjvuujqgidokg", model.objectId());
        Assertions.assertEquals("jyoxgvclt", model.cloudId());
        Assertions.assertEquals("sncghkjeszz", model.billingModel());
    }

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