// 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 java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ServiceFabricInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceFabricInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"externalServiceFabricId\":\"evkh\",\"environmentId\":\"lnzonzlrpiqywn\",\"applicableSchedule\":{\"location\":\"jtszcof\",\"tags\":{\"gbjkvreljeamur\":\"htd\"},\"id\":\"zmlovuanash\",\"name\":\"xlpm\",\"type\":\"erbdk\"},\"provisioningState\":\"vidizozsdb\",\"uniqueIdentifier\":\"xjmonf\"},\"location\":\"gnwncypuuwwlt\",\"tags\":{\"zzhmkd\":\"jctzenkei\",\"gsrboldforobw\":\"svflyhbxcudch\",\"hfovvacqpbtu\":\"lvizb\"},\"id\":\"dxe\",\"name\":\"zab\",\"type\":\"elawumu\"}")
                .toObject(ServiceFabricInner.class);
        Assertions.assertEquals("gnwncypuuwwlt", model.location());
        Assertions.assertEquals("jctzenkei", model.tags().get("zzhmkd"));
        Assertions.assertEquals("evkh", model.externalServiceFabricId());
        Assertions.assertEquals("lnzonzlrpiqywn", model.environmentId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceFabricInner model =
            new ServiceFabricInner()
                .withLocation("gnwncypuuwwlt")
                .withTags(mapOf("zzhmkd", "jctzenkei", "gsrboldforobw", "svflyhbxcudch", "hfovvacqpbtu", "lvizb"))
                .withExternalServiceFabricId("evkh")
                .withEnvironmentId("lnzonzlrpiqywn");
        model = BinaryData.fromObject(model).toObject(ServiceFabricInner.class);
        Assertions.assertEquals("gnwncypuuwwlt", model.location());
        Assertions.assertEquals("jctzenkei", model.tags().get("zzhmkd"));
        Assertions.assertEquals("evkh", model.externalServiceFabricId());
        Assertions.assertEquals("lnzonzlrpiqywn", model.environmentId());
    }

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