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

public final class MigrateSqlServerSqlDbSyncDatabaseInputTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MigrateSqlServerSqlDbSyncDatabaseInput model =
            BinaryData
                .fromString(
                    "{\"id\":\"k\",\"name\":\"lqwjygvjayvblm\",\"targetDatabaseName\":\"k\",\"schemaName\":\"hbxvvyhgsopbyrqu\",\"tableMap\":{\"fbn\":\"xuvw\"},\"migrationSetting\":{\"hrixkwmy\":\"ctlpdngitvgb\",\"hbpnaixexccbd\":\"jejveg\",\"htpwij\":\"eaxhcexdrrvqahqk\"},\"sourceSetting\":{\"vmtgjqppy\":\"jsvfycxzbfvoowv\",\"ronzmyhgfip\":\"s\"},\"targetSetting\":{\"sgumhjglikkxwsl\":\"kmcwaekrrjreafx\",\"tgp\":\"lbqpvuzlmvfelf\",\"xeznoi\":\"crpw\",\"pn\":\"brnjwmw\"}}")
                .toObject(MigrateSqlServerSqlDbSyncDatabaseInput.class);
        Assertions.assertEquals("k", model.id());
        Assertions.assertEquals("lqwjygvjayvblm", model.name());
        Assertions.assertEquals("k", model.targetDatabaseName());
        Assertions.assertEquals("hbxvvyhgsopbyrqu", model.schemaName());
        Assertions.assertEquals("xuvw", model.tableMap().get("fbn"));
        Assertions.assertEquals("ctlpdngitvgb", model.migrationSetting().get("hrixkwmy"));
        Assertions.assertEquals("jsvfycxzbfvoowv", model.sourceSetting().get("vmtgjqppy"));
        Assertions.assertEquals("kmcwaekrrjreafx", model.targetSetting().get("sgumhjglikkxwsl"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MigrateSqlServerSqlDbSyncDatabaseInput model =
            new MigrateSqlServerSqlDbSyncDatabaseInput()
                .withId("k")
                .withName("lqwjygvjayvblm")
                .withTargetDatabaseName("k")
                .withSchemaName("hbxvvyhgsopbyrqu")
                .withTableMap(mapOf("fbn", "xuvw"))
                .withMigrationSetting(
                    mapOf("hrixkwmy", "ctlpdngitvgb", "hbpnaixexccbd", "jejveg", "htpwij", "eaxhcexdrrvqahqk"))
                .withSourceSetting(mapOf("vmtgjqppy", "jsvfycxzbfvoowv", "ronzmyhgfip", "s"))
                .withTargetSetting(
                    mapOf(
                        "sgumhjglikkxwsl",
                        "kmcwaekrrjreafx",
                        "tgp",
                        "lbqpvuzlmvfelf",
                        "xeznoi",
                        "crpw",
                        "pn",
                        "brnjwmw"));
        model = BinaryData.fromObject(model).toObject(MigrateSqlServerSqlDbSyncDatabaseInput.class);
        Assertions.assertEquals("k", model.id());
        Assertions.assertEquals("lqwjygvjayvblm", model.name());
        Assertions.assertEquals("k", model.targetDatabaseName());
        Assertions.assertEquals("hbxvvyhgsopbyrqu", model.schemaName());
        Assertions.assertEquals("xuvw", model.tableMap().get("fbn"));
        Assertions.assertEquals("ctlpdngitvgb", model.migrationSetting().get("hrixkwmy"));
        Assertions.assertEquals("jsvfycxzbfvoowv", model.sourceSetting().get("vmtgjqppy"));
        Assertions.assertEquals("kmcwaekrrjreafx", model.targetSetting().get("sgumhjglikkxwsl"));
    }

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