Search in sources :

Example 1 with TestsEntityFactory

use of org.whole.lang.tests.factories.TestsEntityFactory 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 TestsEntityFactory

use of org.whole.lang.tests.factories.TestsEntityFactory in project whole by wholeplatform.

the class TestsHelpers method createFilterRulesMap.

public static Map<String, FilterRule> createFilterRulesMap(ITemplateManager templateManager) {
    Map<String, FilterRule> filterRulesMap = new HashMap<String, FilterRule>();
    TestsEntityFactory ef = TestsEntityFactory.instance;
    Class<? extends ITemplateManager> templateManagerClass = templateManager.getClass();
    for (String name : templateManager.names()) {
        FilterRule filterRule = ef.createFilterRule();
        filterRule.setName(ef.createName(name));
        filterRule.setBody(templateManager.create(name).wGetAdapter(Statement));
        filterRulesMap.put(templateManagerClass.getSimpleName() + "." + name, filterRule);
        filterRulesMap.put(templateManagerClass.getName() + "." + name, filterRule);
    }
    return filterRulesMap;
}
Also used : HashMap(java.util.HashMap) TestsEntityFactory(org.whole.lang.tests.factories.TestsEntityFactory) FilterRule(org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule) FilterRule(org.whole.lang.tests.model.FilterRule)

Example 3 with TestsEntityFactory

use of org.whole.lang.tests.factories.TestsEntityFactory in project whole by wholeplatform.

the class TestsLearningInterpreterVisitor method createUsingFilter.

protected UsingFilter createUsingFilter(String filterName) {
    TestsEntityFactory tef = TestsEntityFactory.instance;
    UsingFilter usingFilter = tef.createUsingFilter();
    usingFilter.setFilter(tef.createFilter(tef.createName(GENERATED_FAMILY_NAME + '.' + filterName)));
    return usingFilter;
}
Also used : UsingFilter(org.whole.lang.tests.model.UsingFilter) TestsEntityFactory(org.whole.lang.tests.factories.TestsEntityFactory)

Example 4 with TestsEntityFactory

use of org.whole.lang.tests.factories.TestsEntityFactory in project whole by wholeplatform.

the class TestsLearningInterpreterVisitor method getFilterFamily.

protected FilterFamily getFilterFamily(TestSuite suite) {
    FilterFamilies filterFamilies = suite.getFilterFamilies();
    FilterFamily filterFamily = null;
    for (int i = 0; i < filterFamilies.wSize(); i++) {
        FilterFamily child = (FilterFamily) filterFamilies.wGet(i);
        if (EntityUtils.isNotResolver(child) && GENERATED_FAMILY_NAME.equals(child.getName().getValue())) {
            filterFamily = child;
            break;
        }
    }
    TestsEntityFactory tef = TestsEntityFactory.instance;
    if (filterFamily == null) {
        filterFamily = tef.createFilterFamily(CommonsEntityAdapterFactory.createResolver(TestsEntityDescriptorEnum.PackageName), tef.createDescription("Auto-generated filter family"), tef.createName(GENERATED_FAMILY_NAME), tef.createFilterRules(0));
    }
    return filterFamily;
}
Also used : FilterFamily(org.whole.lang.tests.model.FilterFamily) TestsEntityFactory(org.whole.lang.tests.factories.TestsEntityFactory) FilterFamilies(org.whole.lang.tests.model.FilterFamilies)

Aggregations

TestsEntityFactory (org.whole.lang.tests.factories.TestsEntityFactory)4 FilterRule (org.whole.lang.tests.model.FilterRule)2 FilterRule (org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule)2 HashMap (java.util.HashMap)1 IEntity (org.whole.lang.model.IEntity)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 Sequence (org.whole.lang.queries.model.Sequence)1 FilterFamilies (org.whole.lang.tests.model.FilterFamilies)1 FilterFamily (org.whole.lang.tests.model.FilterFamily)1 UsingFilter (org.whole.lang.tests.model.UsingFilter)1