/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.facebook.presto.hudi;

import com.google.common.collect.ImmutableMap;
import org.testng.annotations.Test;

import java.util.Map;

import static com.facebook.airlift.configuration.testing.ConfigAssertions.assertFullMapping;
import static com.facebook.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults;
import static com.facebook.airlift.configuration.testing.ConfigAssertions.recordDefaults;

public class TestHudiConfig
{
    @Test
    public void testDefaults()
    {
        assertRecordedDefaults(recordDefaults(HudiConfig.class).setMetadataTableEnabled(false));
    }

    @Test
    public void testExplicitPropertyMappings()
    {
        Map<String, String> properties = new ImmutableMap.Builder<String, String>()
                .put("hudi.metadata-table-enabled", "true")
                .build();

        HudiConfig expected = new HudiConfig().setMetadataTableEnabled(true);

        assertFullMapping(properties, expected);
    }
}

@@ -638,16 +638,50 @@
 bleMap;%0A
+import io.airlift.units.DataSize;%0A
 import o
@@ -1012,16 +1012,71 @@
 efaults;
+%0Aimport static io.airlift.units.DataSize.Unit.MEGABYTE;
 %0A%0Apublic
@@ -1209,16 +1209,33 @@
 g.class)
+%0A                
 .setMeta
@@ -1257,16 +1257,197 @@
 d(false)
+%0A                .setSizeBasedSplitWeightsEnabled(true)%0A                .setStandardSplitWeightSize(new DataSize(128, MEGABYTE))%0A                .setMinimumAssignedSplitWeight(0.05)
 );%0A    %7D
@@ -1655,16 +1655,218 @@
 %22true%22)%0A
+                .put(%22hudi.size-based-split-weights-enabled%22, %22false%22)%0A                .put(%22hudi.standard-split-weight-size%22, %22500MB%22)%0A                .put(%22hudi.minimum-assigned-split-weight%22, %220.1%22)%0A
         
@@ -1930,16 +1930,33 @@
 Config()
+%0A                
 .setMeta
@@ -1977,16 +1977,197 @@
 ed(true)
+%0A                .setSizeBasedSplitWeightsEnabled(false)%0A                .setStandardSplitWeightSize(new DataSize(500, MEGABYTE))%0A                .setMinimumAssignedSplitWeight(0.1)
 ;%0A%0A     

Fix TestHudiConfig