/*
 * 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.benchmark.driver;

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

import static org.testng.Assert.assertEquals;

public class RegexTemplateTest
{
    @Test
    public void test()
            throws Exception
    {
        RegexTemplate regexTemplate = new RegexTemplate("tpch_sf(?<scale>.*?)_(?<format>.*?)_(?<compression>.*?)");

        assertEquals(regexTemplate.getFieldNames(), ImmutableList.of("scale", "format", "compression"));
        assertEquals(regexTemplate.parse("tpch_sf100_orc_zlib"), Optional.of(ImmutableMap.of("scale", "100", "format", "orc", "compression", "zlib")));
        assertEquals(regexTemplate.parse("foo_tpch_sf100_orc_zlib"), Optional.absent());
        assertEquals(regexTemplate.parse("tpch_sf100_orc"), Optional.absent());
        assertEquals(regexTemplate.parse(""), Optional.absent());

        regexTemplate = new RegexTemplate("tpch_sf(?<scale>.*?)_(?<format>.*?)_(?<compression>.*?)\\.sql");
        assertEquals(regexTemplate.parse("tpch_sf100_orc_zlib.sql"), Optional.of(ImmutableMap.of("scale", "100", "format", "orc", "compression", "zlib")));
        assertEquals(regexTemplate.parse("tpch_sf100_orc_zlibXsql"), Optional.absent());
        assertEquals(regexTemplate.parse("tpch_sf100_orc_zlib.sqlFoo"), Optional.absent());
    }
}

@@ -606,48 +606,8 @@
 r;%0A%0A
-import com.google.common.base.Optional;%0A
 impo
@@ -650,16 +650,16 @@
 leList;%0A
+
 import c
@@ -734,16 +734,44 @@
 .Test;%0A%0A
+import java.util.Optional;%0A%0A
 import s
@@ -1354,38 +1354,37 @@
 lib%22), Optional.
-absent
+empty
 ());%0A        ass
@@ -1433,38 +1433,37 @@
 orc%22), Optional.
-absent
+empty
 ());%0A        ass
@@ -1502,30 +1502,29 @@
 ), Optional.
-absent
+empty
 ());%0A%0A      
@@ -1851,38 +1851,37 @@
 sql%22), Optional.
-absent
+empty
 ());%0A        ass
@@ -1954,14 +1954,13 @@
 nal.
-absent
+empty
 ());

Replace Guava Optional usage in RegexTemplateTest with Java8