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

public final class SchemaComparisonValidationResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SchemaComparisonValidationResult model =
            BinaryData
                .fromString(
                    "{\"schemaDifferences\":{\"objectName\":\"hoqca\",\"objectType\":\"Function\",\"updateAction\":\"AddedOnTarget\"},\"validationErrors\":{\"text\":\"djvlpj\",\"severity\":\"Error\"},\"sourceDatabaseObjectCount\":{\"sgeivsiy\":6206470742211540343},\"targetDatabaseObjectCount\":{\"cjdx\":4044375509992632439,\"zoggculapz\":8303203525289313227}}")
                .toObject(SchemaComparisonValidationResult.class);
        Assertions.assertEquals(6206470742211540343L, model.sourceDatabaseObjectCount().get("sgeivsiy"));
        Assertions.assertEquals(4044375509992632439L, model.targetDatabaseObjectCount().get("cjdx"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SchemaComparisonValidationResult model =
            new SchemaComparisonValidationResult()
                .withSourceDatabaseObjectCount(mapOf("sgeivsiy", 6206470742211540343L))
                .withTargetDatabaseObjectCount(mapOf("cjdx", 4044375509992632439L, "zoggculapz", 8303203525289313227L));
        model = BinaryData.fromObject(model).toObject(SchemaComparisonValidationResult.class);
        Assertions.assertEquals(6206470742211540343L, model.sourceDatabaseObjectCount().get("sgeivsiy"));
        Assertions.assertEquals(4044375509992632439L, model.targetDatabaseObjectCount().get("cjdx"));
    }

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