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

package com.azure.resourcemanager.datamigration.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.datamigration.models.MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInput;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInputTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInput model =
            BinaryData
                .fromString(
                    "{\"name\":\"cywuggwol\",\"targetDatabaseName\":\"czbwemhairsbr\",\"migrationSetting\":{\"ggicccnxqhue\":\"wmsweypqwd\",\"zrncsdt\":\"mkttlstvlzywem\",\"bsfgytguslfea\":\"lusiy\"},\"sourceSetting\":{\"kyhejhzisxgf\":\"gq\",\"raehtwdwrft\":\"elolppvksrpqvuj\",\"rcdlbhshfwpr\":\"wib\"},\"targetSetting\":{\"c\":\"twitykhev\",\"jc\":\"edcpnmdyodnwzxl\"}}")
                .toObject(MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInput.class);
        Assertions.assertEquals("cywuggwol", model.name());
        Assertions.assertEquals("czbwemhairsbr", model.targetDatabaseName());
        Assertions.assertEquals("wmsweypqwd", model.migrationSetting().get("ggicccnxqhue"));
        Assertions.assertEquals("gq", model.sourceSetting().get("kyhejhzisxgf"));
        Assertions.assertEquals("twitykhev", model.targetSetting().get("c"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInput model =
            new MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInput()
                .withName("cywuggwol")
                .withTargetDatabaseName("czbwemhairsbr")
                .withMigrationSetting(
                    mapOf("ggicccnxqhue", "wmsweypqwd", "zrncsdt", "mkttlstvlzywem", "bsfgytguslfea", "lusiy"))
                .withSourceSetting(mapOf("kyhejhzisxgf", "gq", "raehtwdwrft", "elolppvksrpqvuj", "rcdlbhshfwpr", "wib"))
                .withTargetSetting(mapOf("c", "twitykhev", "jc", "edcpnmdyodnwzxl"));
        model = BinaryData.fromObject(model).toObject(MigratePostgreSqlAzureDbForPostgreSqlSyncDatabaseInput.class);
        Assertions.assertEquals("cywuggwol", model.name());
        Assertions.assertEquals("czbwemhairsbr", model.targetDatabaseName());
        Assertions.assertEquals("wmsweypqwd", model.migrationSetting().get("ggicccnxqhue"));
        Assertions.assertEquals("gq", model.sourceSetting().get("kyhejhzisxgf"));
        Assertions.assertEquals("twitykhev", model.targetSetting().get("c"));
    }

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