use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class CreateViewStatementTest method testCreateViewStatementBeansBuilder00.
/**
* Test the correctness of the generated beans by a CreateViewStatement with
* a SelectExtractStatement as sub-statement without a SelectPredicate nor
* ExtractPredicate.
* Get a graph by calling getInternalOperatorBeans() 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 testCreateViewStatementBeansBuilder00() {
Statement subStatement = new SelectStatement("id2", null, null, "from", null, null);
CreateViewStatement createViewStatement = new CreateViewStatement("idx", subStatement);
List<PredicateBase> expectedGeneratedBeans = Collections.emptyList();
List<String> dependencies = Arrays.asList(subStatement.getId());
Assert.assertEquals(createViewStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(createViewStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.textdb.exp.common.PredicateBase 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.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder05.
/**
* 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 testSelectStatementBeansBuilder05() {
ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b"));
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "x", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
SelectStatement selectStatement = new SelectStatement("_sid4", projectPredicate, extractPredicate, "from", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("x", Arrays.asList("a", "b"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "_sid4_e"), new ProjectionPredicate(Arrays.asList("a", "b")));
List<String> dependencies = Arrays.asList("from");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class ProjectSomeFieldsPredicateTest method testGenerateOperatorBean01.
/**
* Test the generateOperatorBean method.
* Build a SelectSomeFieldsPredicate, invoke the generateOperatorBean and check
* whether a ProjectionBean with the right attributes is returned.
* A list with some field names is used as the list of projected fields.
*/
@Test
public void testGenerateOperatorBean01() {
String operatorId = "zwx";
List<String> projectedFields = Arrays.asList("field0", "field1");
ProjectSomeFieldsPredicate projectSomeFieldsPredicate = new ProjectSomeFieldsPredicate(projectedFields);
PredicateBase computedProjectionBean = projectSomeFieldsPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new ProjectionPredicate(Arrays.asList("field0", "field1"));
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class ProjectSomeFieldsPredicateTest method testGenerateOperatorBean00.
/**
* Test the generateOperatorBean method.
* Build a SelectSomeFieldsPredicate, invoke the generateOperatorBean and check
* whether a ProjectionBean with the right attributes is returned.
* An empty list is used as the list of projected fields.
*/
@Test
public void testGenerateOperatorBean00() {
String operatorId = "xxx";
List<String> projectedFields = Collections.emptyList();
ProjectSomeFieldsPredicate projectSomeFieldsPredicate = new ProjectSomeFieldsPredicate(projectedFields);
PredicateBase computedProjectionBean = projectSomeFieldsPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new ProjectionPredicate(Arrays.asList());
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
Aggregations