package com.facebook.presto.execution;

import com.google.common.collect.ImmutableMap;
import io.airlift.configuration.testing.ConfigAssertions;
import io.airlift.units.DataSize;
import io.airlift.units.DataSize.Unit;
import io.airlift.units.Duration;
import org.testng.annotations.Test;

import java.util.Map;
import java.util.concurrent.TimeUnit;

public class TestQueryManagerConfig
{
    @Test
    public void testDefaults()
    {
        ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(QueryManagerConfig.class)
                .setCoordinator(true)
                .setImportsEnabled(true)
                .setMaxShardProcessorThreads(Runtime.getRuntime().availableProcessors() * 4)
                .setMaxQueryAge(new Duration(15, TimeUnit.MINUTES))
                .setClientTimeout(new Duration(1, TimeUnit.MINUTES))
                .setMaxOperatorMemoryUsage(new DataSize(256, Unit.MEGABYTE)));
    }

    @Test
    public void testExplicitPropertyMappings()
    {
        Map<String, String> properties = new ImmutableMap.Builder<String, String>()
                .put("coordinator", "false")
                .put("import.enabled", "false")
                .put("query.operator.max-memory", "1GB")
                .put("query.shard.max-threads", "3")
                .put("query.client.timeout", "10s")
                .put("query.max-age", "30s")
                .build();

        QueryManagerConfig expected = new QueryManagerConfig()
                .setCoordinator(false)
                .setMaxOperatorMemoryUsage(new DataSize(1, Unit.GIGABYTE))
                .setMaxShardProcessorThreads(3)
                .setMaxQueryAge(new Duration(30, TimeUnit.SECONDS))
                .setClientTimeout(new Duration(10, TimeUnit.SECONDS))
                .setImportsEnabled(false);

        ConfigAssertions.assertFullMapping(properties, expected);
    }
}

@@ -919,19 +919,62 @@
 GABYTE))
+%0A                .setMaxSplitCount(100_000)
 );%0A
-
     %7D%0A%0A 
@@ -1415,24 +1415,72 @@
 ge%22, %2230s%22)%0A
+                .put(%22query.max-splits%22, %22100%22)%0A
             
@@ -1849,32 +1849,32 @@
 eUnit.SECONDS))%0A
-
                 
@@ -1898,16 +1898,55 @@
 d(false)
+%0A                .setMaxSplitCount(100)
 ;%0A%0A     

Fix TestQueryManagerConfig test