MediumConstraintMatchPersistenceExtension implements RuleModelIActionPersistenceExtension { @Override public PluggableIAction unmarshal(final String iActionString) throws RuleModelDRLPersistenceException { String[] parameters = PersistenceExtensionUtils.unwrapParenthesis(iActionString).split("\\s*,\\s*"); if (parameters.length > 0 && "kcontext".equals(parameters[0])) { if (parameters.length == 2) { return new ActionMediumConstraintMatch(PersistenceExtensionUtils.extractConstraintMatchValue(parameters[1])); } } throw new RuleModelDRLPersistenceException(PersistenceExtensionUtils.EXCEPTION_MESSAGE_BASE + iActionString); }  @Override boolean accept(final String iActionString); @Override PluggableIAction unmarshal(final String iActionString);  }
@Test public void unmarshalMediumConstraintMatch() throws RuleModelDRLPersistenceException { String actionString = "scoreHolder.addMediumConstraintMatch(kcontext, -1);"; IAction action = extension.unmarshal(actionString); assertTrue(action instanceof ActionMediumConstraintMatch); ActionMediumConstraintMatch actionMediumConstraintMatch = (ActionMediumConstraintMatch) action; assertEquals("-1", actionMediumConstraintMatch.getConstraintMatch()); }
@Test public void unmarshalMediumConstraintMatchNull() throws RuleModelDRLPersistenceException { String actionString = "scoreHolder.addMediumConstraintMatch(kcontext, null);"; IAction action = extension.unmarshal(actionString); assertTrue(action instanceof ActionMediumConstraintMatch); ActionMediumConstraintMatch actionMediumConstraintMatch = (ActionMediumConstraintMatch) action; assertNull(actionMediumConstraintMatch.getConstraintMatch()); }