use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching1.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type EQUAL_TO
*
* @throws Exception
*/
@Test
public void testIntegerMatching1() throws Exception {
// Prepare the query
int threshold = 42;
Attribute attribute = TestConstants.AGE_ATTR;
String attributeName = attribute.getName();
ComparisonType matchingType = ComparisonType.EQUAL_TO;
// Perform the query
List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(TestConstants.getSamplePeopleTuples().get(4));
expectedResults.add(TestConstants.getSamplePeopleTuples().get(5));
// check the results
Assert.assertEquals(expectedResults.size(), returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.
the class ComparableMatcherTest method testDoubleMatching2.
/**
* Verifies the behavior of ComparableMatcher<Double> with matching type LESS_THAN
*
* @throws Exception
*/
@Test
public void testDoubleMatching2() throws Exception {
// Prepare the query
double threshold = 5.75;
Attribute attribute = TestConstants.HEIGHT_ATTR;
String attributeName = attribute.getName();
ComparisonType matchingType = ComparisonType.LESS_THAN;
// Perform the query
List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(TestConstants.getSamplePeopleTuples().get(0));
// check the results
Assert.assertEquals(expectedResults.size(), returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.
the class ComparableMatcherTest method testDoubleMatching1.
/**
* Verifies the behavior of ComparableMatcher<Double> with matching type GREATER_THAN
*
* @throws Exception
*/
@Test
public void testDoubleMatching1() throws Exception {
// Prepare the query
double threshold = 6.05;
Attribute attribute = TestConstants.HEIGHT_ATTR;
String attributeName = attribute.getName();
ComparisonType matchingType = ComparisonType.GREATER_THAN;
// Perform the query
List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
// check the results
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(TestConstants.getSamplePeopleTuples().get(2));
expectedResults.add(TestConstants.getSamplePeopleTuples().get(3));
Assert.assertEquals(expectedResults.size(), returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching2.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type GREATER_THAN
*
* @throws Exception
*/
@Test
public void testIntegerMatching2() throws Exception {
// Prepare the query
int threshold = 45;
Attribute attribute = TestConstants.AGE_ATTR;
String attributeName = attribute.getName();
ComparisonType matchingType = ComparisonType.GREATER_THAN;
// Perform the query
List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(TestConstants.getSamplePeopleTuples().get(0));
// check the results
Assert.assertEquals(expectedResults.size(), returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.
the class DictionaryMatcherTest method testMultipleWordsQueryUsingPhrase.
/**
* Scenario S-10:verifies ITuple returned by DictionaryMatcher and multiple
* word queries using PHRASE OPERATOR
*/
@Test
public void testMultipleWordsQueryUsingPhrase() throws Exception {
ArrayList<String> names = new ArrayList<String>(Arrays.asList("george lin lin"));
Dictionary dictionary = new Dictionary(names);
// create a data tuple first
List<Span> list = new ArrayList<Span>();
Span span = new Span("firstName", 0, 14, "george lin lin", "george lin lin");
list.add(span);
Attribute[] schemaAttributes = new Attribute[TestConstants.ATTRIBUTES_PEOPLE.length + 1];
for (int count = 0; count < schemaAttributes.length - 1; count++) {
schemaAttributes[count] = TestConstants.ATTRIBUTES_PEOPLE[count];
}
schemaAttributes[schemaAttributes.length - 1] = RESULTS_ATTRIBUTE;
IField[] fields1 = { new StringField("george lin lin"), new StringField("lin clooney"), new IntegerField(43), new DoubleField(6.06), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1973")), new TextField("Lin Clooney is Short and lin clooney is Angry"), new ListField<Span>(list) };
Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
List<Tuple> expectedResults = new ArrayList<Tuple>();
expectedResults.add(tuple1);
List<String> attributeNames = Arrays.asList(TestConstants.FIRST_NAME, TestConstants.LAST_NAME, TestConstants.DESCRIPTION);
List<Tuple> returnedResults = DictionaryMatcherTestHelper.getQueryResults(PEOPLE_TABLE, dictionary, attributeNames, KeywordMatchingType.PHRASE_INDEXBASED);
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
Aggregations