use of edu.uci.ics.texera.textql.statements.SelectStatement in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder04.
/**
* Test the correctness of the generated beans by a SelectStatement with a
* ProjectAllFieldsPredicate and a KeywordExtractPredicate.
* Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
* methods and check if the generated path form the node getInputNodeID() to
* the node getOutputNodeID() is correct. Also check whether getInputViews()
* is returning the correct dependencies.
*/
@Test
public void testSelectStatementBeansBuilder04() {
ProjectPredicate projectPredicate = new ProjectAllFieldsPredicate();
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("f1"), "keyword", KeywordMatchingType.CONJUNCTION_INDEXBASED.toString());
SelectStatement selectStatement = new SelectStatement("id", projectPredicate, extractPredicate, "source", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("keyword", Arrays.asList("f1"), null, KeywordMatchingType.CONJUNCTION_INDEXBASED, "id_e"));
List<String> dependencies = Arrays.asList("source");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.texera.textql.statements.SelectStatement in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder03.
/**
* Test the correctness of the generated beans by a SelectStatement with a
* KeywordExtractPredicate.
* Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
* methods and check if the generated path form the node getInputNodeID() to
* the node getOutputNodeID() is correct. Also check whether getInputViews()
* is returning the correct dependencies.
*/
@Test
public void testSelectStatementBeansBuilder03() {
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("c", "d"), "word", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
SelectStatement selectStatement = new SelectStatement("id", null, extractPredicate, "TableP9", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("word", Arrays.asList("c", "d"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "id_e"));
List<String> dependencies = Arrays.asList("TableP9");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.texera.textql.statements.SelectStatement in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder00.
/**
* Test the correctness of the generated beans by a SelectStatement without a
* ProjectPredicate nor ExtractPredicate.
* Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
* methods and check if the generated path form the node getInputNodeID() to
* the node getOutputNodeID() is correct. Also check whether getInputViews()
* is returning the correct dependencies.
*/
@Test
public void testSelectStatementBeansBuilder00() {
SelectStatement selectStatement = new SelectStatement("id", null, null, "tableX", null, null);
List<PredicateBase> expectedGeneratedBeans = Collections.emptyList();
List<String> dependencies = Arrays.asList("tableX");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.texera.textql.statements.SelectStatement in project textdb by TextDB.
the class CreateViewStatementTest method testGettersAndGetters.
/**
* Test the setter methods and the getter methods.
* Call the setter of CreateViewStatement and test if the
* returned value by the getter is the same.
*/
@Test
public void testGettersAndGetters() {
Statement subStatement;
ProjectPredicate projectPredicate;
ExtractPredicate extractPredicate;
CreateViewStatement createViewStatement = new CreateViewStatement(null, null);
// Tests for the id attribute
createViewStatement.setId(null);
Assert.assertEquals(createViewStatement.getId(), null);
createViewStatement.setId("statementId4");
Assert.assertEquals(createViewStatement.getId(), "statementId4");
createViewStatement.setId("_sid0");
Assert.assertEquals(createViewStatement.getId(), "_sid0");
// Tests for the subStatement attribute
createViewStatement.setSubStatement(null);
Assert.assertEquals(createViewStatement.getSubStatement(), null);
projectPredicate = new ProjectAllFieldsPredicate();
subStatement = new SelectStatement("substatementId0", projectPredicate, null, "from", null, null);
createViewStatement = new CreateViewStatement("statementId", subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
projectPredicate = new ProjectAllFieldsPredicate();
subStatement = new SelectStatement("substatementId1", projectPredicate, null, "table", null, null);
createViewStatement = new CreateViewStatement("statementId", subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("c", "d"));
extractPredicate = new KeywordExtractPredicate(Arrays.asList("f0", "f1"), "xxx", KeywordMatchingType.PHRASE_INDEXBASED.toString());
subStatement = new SelectStatement("id", projectPredicate, extractPredicate, "source", null, null);
createViewStatement.setSubStatement(subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
}
use of edu.uci.ics.texera.textql.statements.SelectStatement in project textdb by TextDB.
the class CreateViewStatementTest method testConstructorAndGetters.
/**
* Test the class constructor and the getter methods.
* Call the constructor of CreateViewStatement and test if
* the returned value by the getter is the same.
*/
@Test
public void testConstructorAndGetters() {
Statement subStatement;
ProjectPredicate projectPredicate;
ExtractPredicate extractPredicate;
CreateViewStatement createViewStatement;
// Tests for the id attribute
createViewStatement = new CreateViewStatement(null, null);
Assert.assertEquals(createViewStatement.getId(), null);
createViewStatement = new CreateViewStatement("statementId", null);
Assert.assertEquals(createViewStatement.getId(), "statementId");
createViewStatement = new CreateViewStatement("id6", null);
Assert.assertEquals(createViewStatement.getId(), "id6");
createViewStatement = new CreateViewStatement("_sid12", null);
Assert.assertEquals(createViewStatement.getId(), "_sid12");
// Tests for the subStatement attribute
createViewStatement = new CreateViewStatement("statementId", null);
Assert.assertEquals(createViewStatement.getSubStatement(), null);
subStatement = new SelectStatement("substatementId0", null, null, "source", null, null);
createViewStatement = new CreateViewStatement("statementId", subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
subStatement = new SelectStatement("substatementId1", null, null, "table", null, null);
createViewStatement = new CreateViewStatement("statementId", subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
projectPredicate = new ProjectAllFieldsPredicate();
subStatement = new SelectStatement("substatementId2", projectPredicate, null, "from", null, null);
createViewStatement = new CreateViewStatement("statementId", subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("at1", "at0"));
extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "keyword", KeywordMatchingType.CONJUNCTION_INDEXBASED.toString());
subStatement = new SelectStatement("substatementIdX", projectPredicate, extractPredicate, "t", null, null);
createViewStatement = new CreateViewStatement("statementId", subStatement);
Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
}
Aggregations