Search in sources :

Example 1 with FilterRule

use of org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule 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 FilterRule

use of org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule 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 FilterRule

use of org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule in project whole by wholeplatform.

the class TestsHelpers method createFilterRulesMap.

public static Map<String, FilterRule> createFilterRulesMap(TestSuite testSuite) {
    Map<String, FilterRule> filterRulesMap = new HashMap<String, FilterRule>();
    IEntityIterator<FilterFamily> filterFamilies = IteratorFactory.childIterator();
    filterFamilies.reset(testSuite.getFilterFamilies());
    for (FilterFamily filterFamily : filterFamilies) {
        IEntityIterator<FilterRule> filterRules = IteratorFactory.childIterator();
        filterRules.reset(filterFamily.getFilterRules());
        for (FilterRule filterRule : filterRules) {
            String name = filterFamily.getName().getValue() + '.' + filterRule.getName().getValue();
            if (filterRulesMap.get(name) != null)
                filterRulesMap.remove(name);
            else
                filterRulesMap.put(name, filterRule);
            PackageName packageName = filterFamily.getPackageName();
            if (DataTypeUtils.getDataKind(packageName).isString()) {
                String qualifiedName = packageName.wStringValue() + '.' + name;
                filterRulesMap.put(qualifiedName, filterRule);
            }
        }
    }
    return filterRulesMap;
}
Also used : FilterFamily(org.whole.lang.tests.model.FilterFamily) HashMap(java.util.HashMap) PackageName(org.whole.lang.tests.model.PackageName) FilterRule(org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule) FilterRule(org.whole.lang.tests.model.FilterRule)

Aggregations

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