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

package com.azure.resourcemanager.workloads.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.workloads.fluent.models.SapCentralServerInstanceInner;
import com.azure.resourcemanager.workloads.models.EnqueueReplicationServerProperties;
import com.azure.resourcemanager.workloads.models.EnqueueServerProperties;
import com.azure.resourcemanager.workloads.models.GatewayServerProperties;
import com.azure.resourcemanager.workloads.models.MessageServerProperties;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SapCentralServerInstanceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SapCentralServerInstanceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"instanceNo\":\"pbkwtmu\",\"subnet\":\"uqktap\",\"messageServerProperties\":{\"msPort\":3469094564596058624,\"internalMsPort\":8788787487119188648,\"httpPort\":5085835917600063324,\"httpsPort\":7897278653566127978,\"hostname\":\"vqwhbmdgbbjfd\",\"ipAddress\":\"mbmbexppbh\",\"health\":\"Healthy\"},\"enqueueServerProperties\":{\"hostname\":\"lfp\",\"ipAddress\":\"s\",\"port\":9219502024356576033,\"health\":\"Unknown\"},\"gatewayServerProperties\":{\"port\":8329500561885071597,\"health\":\"Unhealthy\"},\"enqueueReplicationServerProperties\":{\"ersVersion\":\"EnqueueReplicator2\",\"instanceNo\":\"o\",\"hostname\":\"hr\",\"kernelVersion\":\"ilnerkujysvlejuv\",\"kernelPatch\":\"awrlyx\",\"ipAddress\":\"kcprbnw\",\"health\":\"Healthy\"},\"kernelVersion\":\"vtb\",\"kernelPatch\":\"ysszdnrujqguh\",\"loadBalancerDetails\":{\"id\":\"uqfprwzw\"},\"vmDetails\":[{\"type\":\"Unknown\",\"virtualMachineId\":\"nwui\",\"storageDetails\":[]}],\"status\":\"Stopping\",\"health\":\"Unhealthy\",\"provisioningState\":\"Failed\",\"errors\":{}},\"location\":\"kyfi\",\"tags\":{\"zwdzuh\":\"idf\",\"wxmnteiwao\":\"ymwisdkft\"},\"id\":\"vkmijcmmxdcuf\",\"name\":\"fsrpymzidnse\",\"type\":\"cxtbzsg\"}")
                .toObject(SapCentralServerInstanceInner.class);
        Assertions.assertEquals("kyfi", model.location());
        Assertions.assertEquals("idf", model.tags().get("zwdzuh"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SapCentralServerInstanceInner model =
            new SapCentralServerInstanceInner()
                .withLocation("kyfi")
                .withTags(mapOf("zwdzuh", "idf", "wxmnteiwao", "ymwisdkft"))
                .withMessageServerProperties(new MessageServerProperties())
                .withEnqueueServerProperties(new EnqueueServerProperties())
                .withGatewayServerProperties(new GatewayServerProperties())
                .withEnqueueReplicationServerProperties(new EnqueueReplicationServerProperties());
        model = BinaryData.fromObject(model).toObject(SapCentralServerInstanceInner.class);
        Assertions.assertEquals("kyfi", model.location());
        Assertions.assertEquals("idf", model.tags().get("zwdzuh"));
    }

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