Search in sources :

Example 21 with UnavailableRuleObjectException

use of org.apache.stanbol.rules.base.api.UnavailableRuleObjectException in project stanbol by apache.

the class ClerezzaAdpterTest method wrongAdaptabeClassTest.

@SuppressWarnings("unchecked")
@Test
public void wrongAdaptabeClassTest() {
    try {
        List<Rule> rules = (List<Rule>) ruleAdapter.adaptTo(recipeGood, Rule.class);
        for (Rule rule : rules) {
            log.debug(rule.toString());
            Assert.fail("The adapter for Clerezza should not accept " + Rule.class.getCanonicalName() + " objects.");
        }
    } catch (UnavailableRuleObjectException e) {
        Assert.fail(e.getMessage());
    } catch (UnsupportedTypeForExportException e) {
        log.debug(e.getMessage());
    } catch (RuleAtomCallExeption e) {
        Assert.fail(e.getMessage());
    }
}
Also used : UnsupportedTypeForExportException(org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException) UnavailableRuleObjectException(org.apache.stanbol.rules.base.api.UnavailableRuleObjectException) List(java.util.List) Rule(com.hp.hpl.jena.reasoner.rulesys.Rule) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) Test(org.junit.Test)

Example 22 with UnavailableRuleObjectException

use of org.apache.stanbol.rules.base.api.UnavailableRuleObjectException in project stanbol by apache.

the class ClerezzaAdpterTest method test.

@SuppressWarnings("unchecked")
@Test
public void test() {
    try {
        List<ConstructQuery> constructQueries = (List<ConstructQuery>) ruleAdapter.adaptTo(recipeGood, ConstructQuery.class);
        for (ConstructQuery constructQuery : constructQueries) {
            ConstructQuery cq = (ConstructQuery) QueryParser.getInstance().parse(constructQuery.toString());
            System.out.println(cq.toString());
        }
        Assert.assertTrue(true);
    } catch (UnavailableRuleObjectException e) {
        Assert.fail(e.getMessage());
    } catch (UnsupportedTypeForExportException e) {
        Assert.fail(e.getMessage());
    } catch (RuleAtomCallExeption e) {
        Assert.fail(e.getMessage());
    } catch (ParseException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : UnsupportedTypeForExportException(org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException) UnavailableRuleObjectException(org.apache.stanbol.rules.base.api.UnavailableRuleObjectException) List(java.util.List) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) ParseException(org.apache.clerezza.rdf.core.sparql.ParseException) ConstructQuery(org.apache.clerezza.rdf.core.sparql.query.ConstructQuery) Test(org.junit.Test)

Aggregations

UnavailableRuleObjectException (org.apache.stanbol.rules.base.api.UnavailableRuleObjectException)22 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)21 UnsupportedTypeForExportException (org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)21 List (java.util.List)10 SPARQLObject (org.apache.stanbol.rules.base.api.SPARQLObject)10 Test (org.junit.Test)7 RuleAdapter (org.apache.stanbol.rules.base.api.RuleAdapter)6 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)5 SPARQLComparison (org.apache.stanbol.rules.adapters.sparql.SPARQLComparison)5 SPARQLFunction (org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)4 Recipe (org.apache.stanbol.rules.base.api.Recipe)4 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)4 Rule (com.hp.hpl.jena.reasoner.rulesys.Rule)3 IRI (org.apache.clerezza.commons.rdf.IRI)3 NoSuchRecipeException (org.apache.stanbol.rules.base.api.NoSuchRecipeException)3 RecipeConstructionException (org.apache.stanbol.rules.base.api.RecipeConstructionException)3 NumericFunctionAtom (org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom)3 Graph (org.apache.clerezza.commons.rdf.Graph)2 ImmutableGraph (org.apache.clerezza.commons.rdf.ImmutableGraph)2 SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)2