Search in sources :

Example 1 with Sequence

use of org.whole.lang.queries.model.Sequence in project whole by wholeplatform.

the class TestsHelpers method createFilterRule.

public static FilterRule createFilterRule(Collection<IEntity> entities) {
    // create the filter logic
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    Sequence sequence = qef.createSequence(0);
    Iterator<IEntity> iterator = entities.iterator();
    IEntity baseEntity = iterator.next();
    while (iterator.hasNext()) updateFilterBody(baseEntity, iterator.next(), sequence);
    if (sequence.wIsEmpty())
        return createResolver(FilterRule);
    // create the filter rule
    TestsEntityFactory tef = TestsEntityFactory.instance;
    FilterRule filterRule = tef.createFilterRule(tef.createDescription("Auto-generated filter rule"), createVariable(Name, "filterName"), sequence.wGetAdapter(Statement));
    return filterRule;
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) TestsEntityFactory(org.whole.lang.tests.factories.TestsEntityFactory) Sequence(org.whole.lang.queries.model.Sequence) FilterRule(org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule) FilterRule(org.whole.lang.tests.model.FilterRule)

Example 2 with Sequence

use of org.whole.lang.queries.model.Sequence in project whole by wholeplatform.

the class ResolversTest method testCompositeEntitySetParent.

@Test
public void testCompositeEntitySetParent() {
    Sequence sequence = qf.createSequence(0);
    org.whole.lang.queries.model.Expression expression = createResolver(QueriesEntityDescriptorEnum.Expression);
    sequence.wAdd(expression);
    Assert.assertTrue(EntityUtils.isResolver(expression));
    expression.wAdd(qf.createChildStep());
    Assert.assertTrue(EntityUtils.isResolver(expression));
    Filter filter = qf.createFilter();
    filter.wSet(QueriesFeatureDescriptorEnum.expression, EntityUtils.clone(expression));
    Assert.assertTrue(Matcher.match(QueriesEntityDescriptorEnum.Expression, filter.getExpression()));
}
Also used : Filter(org.whole.lang.queries.model.Filter) Sequence(org.whole.lang.queries.model.Sequence) Test(org.junit.Test)

Example 3 with Sequence

use of org.whole.lang.queries.model.Sequence in project whole by wholeplatform.

the class ResolversTest method testCompositeEntityResolverTighteningAddByIndexSparse.

@Category(KnownFailingTests.class)
@Test
public void testCompositeEntityResolverTighteningAddByIndexSparse() {
    org.whole.lang.queries.model.Expression expression = createResolver(QueriesEntityDescriptorEnum.Expression);
    Sequence sequence = qf.createSequence(expression);
    expression.wAdd(2, qf.createChildStep());
    Assert.assertTrue(EntityUtils.isResolver(expression));
    expression.wAdd(6, qf.createPath());
    Assert.assertTrue(Matcher.matchImpl(QueriesEntityDescriptorEnum.Sequence, sequence.wGet(0)));
}
Also used : Sequence(org.whole.lang.queries.model.Sequence) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with Sequence

use of org.whole.lang.queries.model.Sequence in project whole by wholeplatform.

the class ResolversTest method testCompositeEntityResolverTighteningAddByIndex.

@Category(KnownFailingTests.class)
@Test
public void testCompositeEntityResolverTighteningAddByIndex() {
    org.whole.lang.queries.model.Expression expression = createResolver(QueriesEntityDescriptorEnum.Expression);
    Sequence sequence = qf.createSequence(expression);
    expression.wAdd(0, qf.createChildStep());
    Assert.assertTrue(EntityUtils.isResolver(expression));
    expression.wAdd(1, qf.createPath());
    Assert.assertTrue(Matcher.matchImpl(QueriesEntityDescriptorEnum.Sequence, sequence.wGet(0)));
}
Also used : Sequence(org.whole.lang.queries.model.Sequence) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 5 with Sequence

use of org.whole.lang.queries.model.Sequence in project whole by wholeplatform.

the class ResolversTest method testCompositeEntityResolverWithResolve.

@Test
public void testCompositeEntityResolverWithResolve() {
    org.whole.lang.queries.model.Expression expression = createResolver(QueriesEntityDescriptorEnum.Expression);
    Sequence sequence = qf.createSequence(expression);
    expression.wAdd(qf.createChildStep());
    Assert.assertTrue(EntityUtils.isResolver(expression));
    expression.wResolveWith(QueriesEntityDescriptorEnum.Sequence);
    Assert.assertTrue(Matcher.matchImpl(QueriesEntityDescriptorEnum.Sequence, sequence.wGet(0)));
}
Also used : Sequence(org.whole.lang.queries.model.Sequence) Test(org.junit.Test)

Aggregations

Sequence (org.whole.lang.queries.model.Sequence)8 Test (org.junit.Test)7 Category (org.junit.experimental.categories.Category)5 IEntity (org.whole.lang.model.IEntity)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 Filter (org.whole.lang.queries.model.Filter)1 TestsEntityFactory (org.whole.lang.tests.factories.TestsEntityFactory)1 FilterRule (org.whole.lang.tests.model.FilterRule)1 FilterRule (org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule)1