use of com.onespatial.jrc.tns.oml_to_rif.model.rif.filter.nonterminal.comparison.LessThanNode in project hale by halestudio.
the class TestCqlToMappingConditionTranslator method testTranslateSimpleLogical.
/**
* Test that takes a simple logical expression comprising a parent logical
* filter and for each child filter, an equality test.
*
* @throws CQLException
* if any errors occurred parsing the CQL string
* @throws TranslationException
* if any errors occurred during the translation
*/
@Test
public void testTranslateSimpleLogical() throws CQLException, TranslationException {
// $NON-NLS-1$
String cqlPredicate = "ATTR1 < 10 AND ATTR2 < 2";
ModelMappingCondition result = digester.translate(CQL.toFilter(cqlPredicate));
assertNotNull(result);
assertNotNull(result.getRoot());
assertThat(result.getRoot(), is(instanceOf(AndNode.class)));
assertNotNull(result.getRoot().getChildren());
assertThat(result.getRoot().getChildren().size(), is(equalTo(2)));
FilterNode firstNode = result.getRoot().getChildren().get(0);
assertThat(firstNode, is(instanceOf(LessThanNode.class)));
LessThanNode less1 = (LessThanNode) firstNode;
assertNotNull(less1.getLeft());
assertNotNull(less1.getLeft().getPropertyName());
// $NON-NLS-1$
assertThat(less1.getLeft().getPropertyName(), is(equalTo("ATTR1")));
assertNotNull(less1.getRight());
assertNotNull(less1.getRight().getLiteralValue());
// $NON-NLS-1$
assertThat(less1.getRight().getLiteralValue().toString(), is(equalTo("10")));
FilterNode secondNode = result.getRoot().getChildren().get(1);
assertThat(secondNode, is(instanceOf(LessThanNode.class)));
LessThanNode less2 = (LessThanNode) secondNode;
assertNotNull(less2.getLeft());
assertNotNull(less2.getLeft().getPropertyName());
// $NON-NLS-1$
assertThat(less2.getLeft().getPropertyName(), is(equalTo("ATTR2")));
assertNotNull(less2.getRight());
assertNotNull(less2.getRight().getLiteralValue());
// $NON-NLS-1$
assertThat(less2.getRight().getLiteralValue().toString(), is(equalTo("2")));
}
Aggregations