Search in sources :

Example 11 with ProjectSomeFieldsPredicate

use of edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate in project textdb by TextDB.

the class SelectStatementTest method testSettersAndGetters.

/**
 * Test the setter methods and the getter methods.
 * Call the setter of SelectStatement and test if the returned
 * value by the getter is the same.
 */
@Test
public void testSettersAndGetters() {
    ProjectPredicate projectPredicate;
    ExtractPredicate extractPredicate;
    SelectStatement selectExtractStatement = new SelectStatement();
    // Tests for the id attribute
    selectExtractStatement.setId(null);
    Assert.assertEquals(selectExtractStatement.getId(), null);
    selectExtractStatement.setId("idx");
    Assert.assertEquals(selectExtractStatement.getId(), "idx");
    selectExtractStatement.setId("_sid9");
    Assert.assertEquals(selectExtractStatement.getId(), "_sid9");
    // Tests for the projectPredicate attribute
    selectExtractStatement.setProjectPredicate(null);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), null);
    projectPredicate = new ProjectAllFieldsPredicate();
    selectExtractStatement.setProjectPredicate(projectPredicate);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), projectPredicate);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b", "c"));
    selectExtractStatement.setProjectPredicate(projectPredicate);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), projectPredicate);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("f0", "f1"));
    selectExtractStatement.setProjectPredicate(projectPredicate);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), projectPredicate);
    // Tests for the extractPredicate attribute
    selectExtractStatement.setExtractPredicate(null);
    Assert.assertEquals(selectExtractStatement.getExtractPredicate(), null);
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "c"), "search", KeywordMatchingType.PHRASE_INDEXBASED.toString());
    selectExtractStatement.setExtractPredicate(extractPredicate);
    Assert.assertEquals(selectExtractStatement.getExtractPredicate(), extractPredicate);
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("u", "v"), "news", KeywordMatchingType.CONJUNCTION_INDEXBASED.toString());
    selectExtractStatement.setExtractPredicate(extractPredicate);
    Assert.assertEquals(selectExtractStatement.getExtractPredicate(), extractPredicate);
    // Tests for the fromClause attribute
    selectExtractStatement.setFromClause(null);
    Assert.assertEquals(selectExtractStatement.getFromClause(), null);
    selectExtractStatement.setFromClause("table");
    Assert.assertEquals(selectExtractStatement.getFromClause(), "table");
    selectExtractStatement.setFromClause("t3");
    Assert.assertEquals(selectExtractStatement.getFromClause(), "t3");
    // Tests for the limitClause attribute
    selectExtractStatement.setLimitClause(null);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), null);
    selectExtractStatement.setLimitClause(0);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), Integer.valueOf(0));
    selectExtractStatement.setLimitClause(5);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), Integer.valueOf(5));
    selectExtractStatement.setLimitClause(-7);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), Integer.valueOf(-7));
    // Tests for the offsetClause attribute
    selectExtractStatement.setOffsetClause(null);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), null);
    selectExtractStatement.setOffsetClause(0);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), Integer.valueOf(0));
    selectExtractStatement.setOffsetClause(-3);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), Integer.valueOf(-3));
    selectExtractStatement.setOffsetClause(58);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), Integer.valueOf(58));
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) ExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) ProjectAllFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Aggregations

SelectStatement (edu.uci.ics.texera.textql.statements.SelectStatement)11 ProjectPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate)11 ProjectSomeFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate)11 Test (org.junit.Test)11 ExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate)10 KeywordExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate)10 ProjectAllFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate)8 CreateViewStatement (edu.uci.ics.texera.textql.statements.CreateViewStatement)7 Statement (edu.uci.ics.texera.textql.statements.Statement)7 TextQLParser (edu.uci.ics.texera.textql.languageparser.TextQLParser)4 PredicateBase (edu.uci.ics.texera.dataflow.common.PredicateBase)3 ProjectionPredicate (edu.uci.ics.texera.dataflow.projection.ProjectionPredicate)2 KeywordPredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate)1 ParseException (edu.uci.ics.texera.textql.languageparser.ParseException)1 TokenMgrError (edu.uci.ics.texera.textql.languageparser.TokenMgrError)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 PrintStream (java.io.PrintStream)1