@Test(expected = SemanticWarning.class) public void testTicket106_2() throws SemanticWarning { err.println("testTicket106_2"); FunctionEnum funcEnum = FunctionEnum.COMPLEX_ABUNDANCE; List<BELObject> args = new ArrayList<BELObject>(); Term arg1 = new Term(FunctionEnum.ABUNDANCE); Term arg2 = new Term(FunctionEnum.BIOLOGICAL_PROCESS); args.addAll(asList(new BELObject[] { arg1, arg2 })); Term t = new Term(funcEnum, args); subject.checkParameterizedTerm(t); fail("expected semantic failure"); }
@Override public void checkParameterizedTerm(final Term term) throws SemanticWarning { final FunctionEnum funcEnum = term.getFunctionEnum(); final StringBuilder bldr = new StringBuilder(); bldr.append(funcEnum.getDisplayValue()); bldr.append("("); List<BELObject> functionArguments = term.getFunctionArguments(); if (hasItems(functionArguments)) { for (int i = 0; i < functionArguments.size(); i++) { final BELObject bo = functionArguments.get(i); String arg = null; if (bo instanceof Parameter) { arg = processParameter((Parameter) bo); } else if (bo instanceof Term) { arg = processTerm((Term) bo); if (arg == null) continue; } else { String type = bo.getClass().getName(); final String err = "unknown function argument " + type; throw new UnsupportedOperationException(err); } if (i != 0) bldr.append(","); bldr.append(arg); } } bldr.append(")"); bldr.append(funcEnum.getReturnType().getDisplayValue()); Signature sig = null; try { sig = new Signature(bldr.toString()); } catch (InvalidArgument e) { final String lf = term.toBELLongForm(); final String err = e.getMessage(); throw new SemanticWarning(lf, err); } final Function function = funcEnum.getFunction(); if (!function.validSignature(sig)) { final Map<Signature, SemanticStatus> map = function.getStatus(sig); final String lf = term.toBELLongForm(); final String err = format(SEMANTIC_TERM_FAILURE, lf); throw new SemanticWarning(null, err, sig, map); } }
SemanticServiceImpl implements SemanticService { @Override public void checkParameterizedTerm(final Term term) throws SemanticWarning { final FunctionEnum funcEnum = term.getFunctionEnum(); final StringBuilder bldr = new StringBuilder(); bldr.append(funcEnum.getDisplayValue()); bldr.append("("); List<BELObject> functionArguments = term.getFunctionArguments(); if (hasItems(functionArguments)) { for (int i = 0; i < functionArguments.size(); i++) { final BELObject bo = functionArguments.get(i); String arg = null; if (bo instanceof Parameter) { arg = processParameter((Parameter) bo); } else if (bo instanceof Term) { arg = processTerm((Term) bo); if (arg == null) continue; } else { String type = bo.getClass().getName(); final String err = "unknown function argument " + type; throw new UnsupportedOperationException(err); } if (i != 0) bldr.append(","); bldr.append(arg); } } bldr.append(")"); bldr.append(funcEnum.getReturnType().getDisplayValue()); Signature sig = null; try { sig = new Signature(bldr.toString()); } catch (InvalidArgument e) { final String lf = term.toBELLongForm(); final String err = e.getMessage(); throw new SemanticWarning(lf, err); } final Function function = funcEnum.getFunction(); if (!function.validSignature(sig)) { final Map<Signature, SemanticStatus> map = function.getStatus(sig); final String lf = term.toBELLongForm(); final String err = format(SEMANTIC_TERM_FAILURE, lf); throw new SemanticWarning(null, err, sig, map); } } }
SemanticServiceImpl implements SemanticService { @Override public void checkParameterizedTerm(final Term term) throws SemanticWarning { final FunctionEnum funcEnum = term.getFunctionEnum(); final StringBuilder bldr = new StringBuilder(); bldr.append(funcEnum.getDisplayValue()); bldr.append("("); List<BELObject> functionArguments = term.getFunctionArguments(); if (hasItems(functionArguments)) { for (int i = 0; i < functionArguments.size(); i++) { final BELObject bo = functionArguments.get(i); String arg = null; if (bo instanceof Parameter) { arg = processParameter((Parameter) bo); } else if (bo instanceof Term) { arg = processTerm((Term) bo); if (arg == null) continue; } else { String type = bo.getClass().getName(); final String err = "unknown function argument " + type; throw new UnsupportedOperationException(err); } if (i != 0) bldr.append(","); bldr.append(arg); } } bldr.append(")"); bldr.append(funcEnum.getReturnType().getDisplayValue()); Signature sig = null; try { sig = new Signature(bldr.toString()); } catch (InvalidArgument e) { final String lf = term.toBELLongForm(); final String err = e.getMessage(); throw new SemanticWarning(lf, err); } final Function function = funcEnum.getFunction(); if (!function.validSignature(sig)) { final Map<Signature, SemanticStatus> map = function.getStatus(sig); final String lf = term.toBELLongForm(); final String err = format(SEMANTIC_TERM_FAILURE, lf); throw new SemanticWarning(null, err, sig, map); } } SemanticServiceImpl(final NamespaceService nsService); }
SemanticServiceImpl implements SemanticService { @Override public void checkParameterizedTerm(final Term term) throws SemanticWarning { final FunctionEnum funcEnum = term.getFunctionEnum(); final StringBuilder bldr = new StringBuilder(); bldr.append(funcEnum.getDisplayValue()); bldr.append("("); List<BELObject> functionArguments = term.getFunctionArguments(); if (hasItems(functionArguments)) { for (int i = 0; i < functionArguments.size(); i++) { final BELObject bo = functionArguments.get(i); String arg = null; if (bo instanceof Parameter) { arg = processParameter((Parameter) bo); } else if (bo instanceof Term) { arg = processTerm((Term) bo); if (arg == null) continue; } else { String type = bo.getClass().getName(); final String err = "unknown function argument " + type; throw new UnsupportedOperationException(err); } if (i != 0) bldr.append(","); bldr.append(arg); } } bldr.append(")"); bldr.append(funcEnum.getReturnType().getDisplayValue()); Signature sig = null; try { sig = new Signature(bldr.toString()); } catch (InvalidArgument e) { final String lf = term.toBELLongForm(); final String err = e.getMessage(); throw new SemanticWarning(lf, err); } final Function function = funcEnum.getFunction(); if (!function.validSignature(sig)) { final Map<Signature, SemanticStatus> map = function.getStatus(sig); final String lf = term.toBELLongForm(); final String err = format(SEMANTIC_TERM_FAILURE, lf); throw new SemanticWarning(null, err, sig, map); } } SemanticServiceImpl(final NamespaceService nsService); @Override void checkParameterizedTerm(final Term term); @Override void checkTerm(final Term term); @Override void checkRelationship(final Statement statement); @Override void checkListUsage(final Statement statement,
            final Document document); @Override void checkNested(final Statement statement); @Override void checkMultiNested(final Statement stmt, final Document doc); @Override List<SemanticWarning> checkAbundanceSubsets(final Term term); }
SemanticServiceImpl implements SemanticService { @Override public void checkParameterizedTerm(final Term term) throws SemanticWarning { final FunctionEnum funcEnum = term.getFunctionEnum(); final StringBuilder bldr = new StringBuilder(); bldr.append(funcEnum.getDisplayValue()); bldr.append("("); List<BELObject> functionArguments = term.getFunctionArguments(); if (hasItems(functionArguments)) { for (int i = 0; i < functionArguments.size(); i++) { final BELObject bo = functionArguments.get(i); String arg = null; if (bo instanceof Parameter) { arg = processParameter((Parameter) bo); } else if (bo instanceof Term) { arg = processTerm((Term) bo); if (arg == null) continue; } else { String type = bo.getClass().getName(); final String err = "unknown function argument " + type; throw new UnsupportedOperationException(err); } if (i != 0) bldr.append(","); bldr.append(arg); } } bldr.append(")"); bldr.append(funcEnum.getReturnType().getDisplayValue()); Signature sig = null; try { sig = new Signature(bldr.toString()); } catch (InvalidArgument e) { final String lf = term.toBELLongForm(); final String err = e.getMessage(); throw new SemanticWarning(lf, err); } final Function function = funcEnum.getFunction(); if (!function.validSignature(sig)) { final Map<Signature, SemanticStatus> map = function.getStatus(sig); final String lf = term.toBELLongForm(); final String err = format(SEMANTIC_TERM_FAILURE, lf); throw new SemanticWarning(null, err, sig, map); } } SemanticServiceImpl(final NamespaceService nsService); @Override void checkParameterizedTerm(final Term term); @Override void checkTerm(final Term term); @Override void checkRelationship(final Statement statement); @Override void checkListUsage(final Statement statement,
            final Document document); @Override void checkNested(final Statement statement); @Override void checkMultiNested(final Statement stmt, final Document doc); @Override List<SemanticWarning> checkAbundanceSubsets(final Term term);  }