/* * 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.tests; import com.teradata.tempto.AfterTestWithContext; import com.teradata.tempto.BeforeTestWithContext; import com.teradata.tempto.ProductTest; import com.teradata.tempto.Requirement; import com.teradata.tempto.RequirementsProvider; import com.teradata.tempto.Requires; import com.teradata.tempto.assertions.QueryAssert; import com.teradata.tempto.configuration.Configuration; import com.teradata.tempto.fulfillment.table.ImmutableTableRequirement; import org.testng.annotations.Test; import static com.facebook.presto.tests.TestGroups.SIMPLE; import static com.facebook.presto.tests.TestGroups.SMOKE; import static com.teradata.tempto.assertions.QueryAssert.Row.row; import static com.teradata.tempto.context.ThreadLocalTestContextHolder.testContextIfSet; import static com.teradata.tempto.fulfillment.table.hive.tpch.TpchTableDefinitions.NATION; import static com.teradata.tempto.query.QueryExecutor.query; import static org.assertj.core.api.Assertions.assertThat; public class SimpleQueryTest extends ProductTest { private static class SimpleTestRequirements implements RequirementsProvider { @Override public Requirement getRequirements(Configuration configuration) { return new ImmutableTableRequirement(NATION); } } @BeforeTestWithContext public void beforeTest() { assertThat(testContextIfSet().isPresent()).isTrue(); } @AfterTestWithContext public void afterTest() { assertThat(testContextIfSet().isPresent()).isTrue(); } @Test(groups = {SIMPLE, SMOKE}) @Requires(SimpleTestRequirements.class) public void selectAllFromNation() { QueryAssert.assertThat(query("select * from nation")).hasRowsCount(25); } @Test(groups = {SIMPLE, SMOKE}) @Requires(SimpleTestRequirements.class) public void selectCountFromNation() { QueryAssert.assertThat(query("select count(*) from nation")) .hasRowsCount(1) .contains(row(25)); } }