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

package com.azure.resourcemanager.containerservicefleet.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.containerservicefleet.fluent.models.FleetInner;
import com.azure.resourcemanager.containerservicefleet.models.FleetHubProfile;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class FleetInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        FleetInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"Succeeded\",\"hubProfile\":{\"dnsPrefix\":\"emkkvnipjox\",\"fqdn\":\"nchgej\",\"kubernetesVersion\":\"odmailzyd\"}},\"eTag\":\"o\",\"location\":\"yahux\",\"tags\":{\"xj\":\"mqnjaqw\",\"atscmd\":\"prozvcputegjvwmf\"},\"id\":\"pjhulsuuvmkj\",\"name\":\"zkrwfn\",\"type\":\"iodjp\"}")
                .toObject(FleetInner.class);
        Assertions.assertEquals("yahux", model.location());
        Assertions.assertEquals("mqnjaqw", model.tags().get("xj"));
        Assertions.assertEquals("emkkvnipjox", model.hubProfile().dnsPrefix());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        FleetInner model =
            new FleetInner()
                .withLocation("yahux")
                .withTags(mapOf("xj", "mqnjaqw", "atscmd", "prozvcputegjvwmf"))
                .withHubProfile(new FleetHubProfile().withDnsPrefix("emkkvnipjox"));
        model = BinaryData.fromObject(model).toObject(FleetInner.class);
        Assertions.assertEquals("yahux", model.location());
        Assertions.assertEquals("mqnjaqw", model.tags().get("xj"));
        Assertions.assertEquals("emkkvnipjox", model.hubProfile().dnsPrefix());
    }

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