Search in sources :

Example 6 with FilterRule

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

the class TestsInterpreterVisitor method applyFilterRule.

protected IEntity applyFilterRule(IEntity entity) {
    FilterRule filterRule = (FilterRule) getBindings().wGet("activeFilterRule");
    if (filterRule == null)
        return entity;
    IEntity filteredEntity = EntityUtils.clone(entity);
    getBindings().wDef("self", filteredEntity);
    stagedVisit(filterRule.getBody());
    getResult();
    return filteredEntity;
}
Also used : IEntity(org.whole.lang.model.IEntity) FilterRule(org.whole.lang.tests.model.FilterRule)

Example 7 with FilterRule

use of org.whole.lang.tests.model.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)

Example 8 with FilterRule

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

the class TestsContentAssistVisitor method findContentAssistValues.

protected boolean findContentAssistValues(IEntity entity) {
    if (!Matcher.match(TestsEntityDescriptorEnum.Name, entity) || !EntityUtils.hasParent(entity) || !Matcher.match(TestsEntityDescriptorEnum.Filter, entity.wGetParent()))
        return false;
    TestSuite testSuite = Matcher.findAncestor(TestsEntityDescriptorEnum.TestSuite, entity);
    if (testSuite == null)
        return false;
    Map<String, FilterRule> rulesMap = TestsHelpers.createFilterRulesMap(testSuite);
    List<Name> names = new ArrayList<Name>();
    for (String key : rulesMap.keySet()) names.add(TestsEntityFactory.instance.createName(key));
    setResult(names.toArray(new Name[names.size()]));
    return true;
}
Also used : TestSuite(org.whole.lang.tests.model.TestSuite) ArrayList(java.util.ArrayList) FilterRule(org.whole.lang.tests.model.FilterRule) Name(org.whole.lang.tests.model.Name)

Aggregations

FilterRule (org.whole.lang.tests.model.FilterRule)8 IEntity (org.whole.lang.model.IEntity)4 ArrayList (java.util.ArrayList)3 FilterRule (org.whole.lang.tests.reflect.TestsEntityDescriptorEnum.FilterRule)3 HashMap (java.util.HashMap)2 TestsEntityFactory (org.whole.lang.tests.factories.TestsEntityFactory)2 FilterFamily (org.whole.lang.tests.model.FilterFamily)2 UsingFilter (org.whole.lang.tests.model.UsingFilter)2 List (java.util.List)1 Map (java.util.Map)1 ITransactionScope (org.whole.lang.bindings.ITransactionScope)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 Sequence (org.whole.lang.queries.model.Sequence)1 Filter (org.whole.lang.tests.model.Filter)1 FilterRules (org.whole.lang.tests.model.FilterRules)1 Name (org.whole.lang.tests.model.Name)1 PackageName (org.whole.lang.tests.model.PackageName)1 SubjectStatement (org.whole.lang.tests.model.SubjectStatement)1 TestSuite (org.whole.lang.tests.model.TestSuite)1 FreshNameGenerator (org.whole.lang.util.FreshNameGenerator)1