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

public final class MigrateMySqlAzureDbForMySqlSyncDatabaseInputTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        MigrateMySqlAzureDbForMySqlSyncDatabaseInput model =
            BinaryData
                .fromString(
                    "{\"name\":\"beddgssofw\",\"targetDatabaseName\":\"zqalkrmnjijpx\",\"migrationSetting\":{\"byxbaaabjy\":\"qudf\"},\"sourceSetting\":{\"evfdnwnwm\":\"ffimrzrtuzqogsex\",\"i\":\"wzsyyceuzs\",\"thzvaytdwkqbrqu\":\"judpfrxt\",\"xiilivpdtiirqt\":\"paxh\"},\"targetSetting\":{\"xrxxlep\":\"axoruzfgsquy\",\"uqlcvydy\":\"ramxjezwlwnw\",\"oo\":\"atdooaojkniod\"}}")
                .toObject(MigrateMySqlAzureDbForMySqlSyncDatabaseInput.class);
        Assertions.assertEquals("beddgssofw", model.name());
        Assertions.assertEquals("zqalkrmnjijpx", model.targetDatabaseName());
        Assertions.assertEquals("qudf", model.migrationSetting().get("byxbaaabjy"));
        Assertions.assertEquals("ffimrzrtuzqogsex", model.sourceSetting().get("evfdnwnwm"));
        Assertions.assertEquals("axoruzfgsquy", model.targetSetting().get("xrxxlep"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        MigrateMySqlAzureDbForMySqlSyncDatabaseInput model =
            new MigrateMySqlAzureDbForMySqlSyncDatabaseInput()
                .withName("beddgssofw")
                .withTargetDatabaseName("zqalkrmnjijpx")
                .withMigrationSetting(mapOf("byxbaaabjy", "qudf"))
                .withSourceSetting(
                    mapOf(
                        "evfdnwnwm",
                        "ffimrzrtuzqogsex",
                        "i",
                        "wzsyyceuzs",
                        "thzvaytdwkqbrqu",
                        "judpfrxt",
                        "xiilivpdtiirqt",
                        "paxh"))
                .withTargetSetting(mapOf("xrxxlep", "axoruzfgsquy", "uqlcvydy", "ramxjezwlwnw", "oo", "atdooaojkniod"));
        model = BinaryData.fromObject(model).toObject(MigrateMySqlAzureDbForMySqlSyncDatabaseInput.class);
        Assertions.assertEquals("beddgssofw", model.name());
        Assertions.assertEquals("zqalkrmnjijpx", model.targetDatabaseName());
        Assertions.assertEquals("qudf", model.migrationSetting().get("byxbaaabjy"));
        Assertions.assertEquals("ffimrzrtuzqogsex", model.sourceSetting().get("evfdnwnwm"));
        Assertions.assertEquals("axoruzfgsquy", model.targetSetting().get("xrxxlep"));
    }

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