// 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.fluent.models.SqlPoolInner;
import com.azure.resourcemanager.synapse.models.CreateMode;
import com.azure.resourcemanager.synapse.models.Sku;
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 SqlPoolInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SqlPoolInner model =
            BinaryData
                .fromString(
                    "{\"sku\":{\"tier\":\"hgyxzkonoc\",\"name\":\"oklyaxuconuq\",\"capacity\":1340074682},\"properties\":{\"maxSizeBytes\":3139982845212693168,\"collation\":\"ewrmjmwvvjektc\",\"sourceDatabaseId\":\"enhwlrs\",\"recoverableDatabaseId\":\"rzpwvlqdqgbiq\",\"provisioningState\":\"ihkaetcktvfc\",\"status\":\"fsnkymuctq\",\"restorePointInTime\":\"2021-09-28T09:51:37Z\",\"createMode\":\"PointInTimeRestore\",\"creationDate\":\"2021-08-08T18:22:37Z\",\"storageAccountType\":\"GRS\",\"sourceDatabaseDeletionDate\":\"2021-06-01T09:38:07Z\"},\"location\":\"rfuwutt\",\"tags\":{\"nljky\":\"vjrbirphxepcyvah\",\"ljyoxgvcltb\":\"xjvuujqgidokg\",\"bijhtxfvgxbf\":\"sncghkjeszz\",\"ec\":\"mxnehmp\"},\"id\":\"godebfqkkrbmpu\",\"name\":\"gr\",\"type\":\"wflzlfbxzpuzy\"}")
                .toObject(SqlPoolInner.class);
        Assertions.assertEquals("rfuwutt", model.location());
        Assertions.assertEquals("vjrbirphxepcyvah", model.tags().get("nljky"));
        Assertions.assertEquals("hgyxzkonoc", model.sku().tier());
        Assertions.assertEquals("oklyaxuconuq", model.sku().name());
        Assertions.assertEquals(1340074682, model.sku().capacity());
        Assertions.assertEquals(3139982845212693168L, model.maxSizeBytes());
        Assertions.assertEquals("ewrmjmwvvjektc", model.collation());
        Assertions.assertEquals("enhwlrs", model.sourceDatabaseId());
        Assertions.assertEquals("rzpwvlqdqgbiq", model.recoverableDatabaseId());
        Assertions.assertEquals("ihkaetcktvfc", model.provisioningState());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-28T09:51:37Z"), model.restorePointInTime());
        Assertions.assertEquals(CreateMode.POINT_IN_TIME_RESTORE, model.createMode());
        Assertions.assertEquals(StorageAccountType.GRS, model.storageAccountType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-01T09:38:07Z"), model.sourceDatabaseDeletionDate());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SqlPoolInner model =
            new SqlPoolInner()
                .withLocation("rfuwutt")
                .withTags(
                    mapOf(
                        "nljky",
                        "vjrbirphxepcyvah",
                        "ljyoxgvcltb",
                        "xjvuujqgidokg",
                        "bijhtxfvgxbf",
                        "sncghkjeszz",
                        "ec",
                        "mxnehmp"))
                .withSku(new Sku().withTier("hgyxzkonoc").withName("oklyaxuconuq").withCapacity(1340074682))
                .withMaxSizeBytes(3139982845212693168L)
                .withCollation("ewrmjmwvvjektc")
                .withSourceDatabaseId("enhwlrs")
                .withRecoverableDatabaseId("rzpwvlqdqgbiq")
                .withProvisioningState("ihkaetcktvfc")
                .withRestorePointInTime(OffsetDateTime.parse("2021-09-28T09:51:37Z"))
                .withCreateMode(CreateMode.POINT_IN_TIME_RESTORE)
                .withStorageAccountType(StorageAccountType.GRS)
                .withSourceDatabaseDeletionDate(OffsetDateTime.parse("2021-06-01T09:38:07Z"));
        model = BinaryData.fromObject(model).toObject(SqlPoolInner.class);
        Assertions.assertEquals("rfuwutt", model.location());
        Assertions.assertEquals("vjrbirphxepcyvah", model.tags().get("nljky"));
        Assertions.assertEquals("hgyxzkonoc", model.sku().tier());
        Assertions.assertEquals("oklyaxuconuq", model.sku().name());
        Assertions.assertEquals(1340074682, model.sku().capacity());
        Assertions.assertEquals(3139982845212693168L, model.maxSizeBytes());
        Assertions.assertEquals("ewrmjmwvvjektc", model.collation());
        Assertions.assertEquals("enhwlrs", model.sourceDatabaseId());
        Assertions.assertEquals("rzpwvlqdqgbiq", model.recoverableDatabaseId());
        Assertions.assertEquals("ihkaetcktvfc", model.provisioningState());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-28T09:51:37Z"), model.restorePointInTime());
        Assertions.assertEquals(CreateMode.POINT_IN_TIME_RESTORE, model.createMode());
        Assertions.assertEquals(StorageAccountType.GRS, model.storageAccountType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-01T09:38:07Z"), 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;
    }
}
