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

package com.azure.resourcemanager.synapse.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.synapse.models.CreateMode;
import com.azure.resourcemanager.synapse.models.Sku;
import com.azure.resourcemanager.synapse.models.SqlPoolPatchInfo;
import com.azure.resourcemanager.synapse.models.StorageAccountType;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class SqlPoolPatchInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SqlPoolPatchInfo model =
            BinaryData
                .fromString(
                    "{\"tags\":{\"henbtkcxywnytn\":\"xmyskp\"},\"location\":\"yn\",\"sku\":{\"tier\":\"dybyxczfclhaa\",\"name\":\"babphlwrqlfk\",\"capacity\":1003967781},\"properties\":{\"maxSizeBytes\":3711072422112516968,\"collation\":\"cmnyyazttb\",\"sourceDatabaseId\":\"wrqpue\",\"recoverableDatabaseId\":\"kzywbiex\",\"provisioningState\":\"eyueaxibxujwb\",\"status\":\"walm\",\"restorePointInTime\":\"2021-11-10T04:08:23Z\",\"createMode\":\"Restore\",\"creationDate\":\"2021-07-26T23:02:26Z\",\"storageAccountType\":\"LRS\",\"sourceDatabaseDeletionDate\":\"2021-06-08T12:36:20Z\"}}")
                .toObject(SqlPoolPatchInfo.class);
        Assertions.assertEquals("xmyskp", model.tags().get("henbtkcxywnytn"));
        Assertions.assertEquals("yn", model.location());
        Assertions.assertEquals("dybyxczfclhaa", model.sku().tier());
        Assertions.assertEquals("babphlwrqlfk", model.sku().name());
        Assertions.assertEquals(1003967781, model.sku().capacity());
        Assertions.assertEquals(3711072422112516968L, model.maxSizeBytes());
        Assertions.assertEquals("cmnyyazttb", model.collation());
        Assertions.assertEquals("wrqpue", model.sourceDatabaseId());
        Assertions.assertEquals("kzywbiex", model.recoverableDatabaseId());
        Assertions.assertEquals("eyueaxibxujwb", model.provisioningState());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-10T04:08:23Z"), model.restorePointInTime());
        Assertions.assertEquals(CreateMode.RESTORE, model.createMode());
        Assertions.assertEquals(StorageAccountType.LRS, model.storageAccountType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-08T12:36:20Z"), model.sourceDatabaseDeletionDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SqlPoolPatchInfo model =
            new SqlPoolPatchInfo()
                .withTags(mapOf("henbtkcxywnytn", "xmyskp"))
                .withLocation("yn")
                .withSku(new Sku().withTier("dybyxczfclhaa").withName("babphlwrqlfk").withCapacity(1003967781))
                .withMaxSizeBytes(3711072422112516968L)
                .withCollation("cmnyyazttb")
                .withSourceDatabaseId("wrqpue")
                .withRecoverableDatabaseId("kzywbiex")
                .withProvisioningState("eyueaxibxujwb")
                .withRestorePointInTime(OffsetDateTime.parse("2021-11-10T04:08:23Z"))
                .withCreateMode(CreateMode.RESTORE)
                .withStorageAccountType(StorageAccountType.LRS)
                .withSourceDatabaseDeletionDate(OffsetDateTime.parse("2021-06-08T12:36:20Z"));
        model = BinaryData.fromObject(model).toObject(SqlPoolPatchInfo.class);
        Assertions.assertEquals("xmyskp", model.tags().get("henbtkcxywnytn"));
        Assertions.assertEquals("yn", model.location());
        Assertions.assertEquals("dybyxczfclhaa", model.sku().tier());
        Assertions.assertEquals("babphlwrqlfk", model.sku().name());
        Assertions.assertEquals(1003967781, model.sku().capacity());
        Assertions.assertEquals(3711072422112516968L, model.maxSizeBytes());
        Assertions.assertEquals("cmnyyazttb", model.collation());
        Assertions.assertEquals("wrqpue", model.sourceDatabaseId());
        Assertions.assertEquals("kzywbiex", model.recoverableDatabaseId());
        Assertions.assertEquals("eyueaxibxujwb", model.provisioningState());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-10T04:08:23Z"), model.restorePointInTime());
        Assertions.assertEquals(CreateMode.RESTORE, model.createMode());
        Assertions.assertEquals(StorageAccountType.LRS, model.storageAccountType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-08T12:36:20Z"), model.sourceDatabaseDeletionDate());
    }

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