private LabelledAction findByLabelledAction(List<LabelledAction> actions, String boundName) { return findByLabelledAction(actions, boundName, false); }
public static GuidedDTDRLPersistence getInstance() { return new GuidedDTDRLPersistence(); }
@Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { final String content = ioService.readAllString(path); final GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(content); final String drl = GuidedDTDRLPersistence.getInstance().marshal(model); return fillDrlIndexBuilder(path, drl); }
@Test public void allRulesHaveTheSameActivationGroup() throws Exception { dtable.setData( DataUtilities.makeDataLists( new Object[][]{ new Object[]{1, "desc-row1"}, new Object[]{2, "desc-row2"}, new Object[]{3, "desc-row3"} } ) ); final String drl = GuidedDTDRLPersistence.getInstance() .marshal( dtable ); assertContainsLinesInOrder( drl, "rule \"Row 1 Unique hit policy table\"", "activation-group \"unique-hit-policy-group Unique hit policy table\"", "rule \"Row 2 Unique hit policy table\"", "activation-group \"unique-hit-policy-group Unique hit policy table\"", "rule \"Row 3 Unique hit policy table\"", "activation-group \"unique-hit-policy-group Unique hit policy table\"" ); } }
@Test public void noPrioritiesSet() throws Exception { final String drl = GuidedDTDRLPersistence.getInstance() .marshal( dtable ); assertContainsLinesInOrder( drl, "rule \"Row 1 Resolved hit policy table\"", "activation-group \"resolved-hit-policy-group Resolved hit policy table\"", "rule \"Row 2 Resolved hit policy table\"", "activation-group \"resolved-hit-policy-group Resolved hit policy table\"", "rule \"Row 3 Resolved hit policy table\"", "activation-group \"resolved-hit-policy-group Resolved hit policy table\"" ); }
protected void analyze(String resourceName) throws Exception { final String xml = TestUtil.loadResource(resourceName); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); // First run analyzer.resetChecks(); analyzer.analyze(); }
@Test public void testBackwardsCompatibility() throws Exception { final String xml = loadResource( "ExistingDecisionTable.xml" ); final GuidedDecisionTable52 dt_ = GuidedDTXMLPersistence.getInstance() .unmarshal( xml ); assertNotNull( dt_ ); assertEquals( GuidedDecisionTable52.HitPolicy.NONE, dt_.getHitPolicy() ); }
@Override public List<ValidationMessage> validate(final Path path, final GuidedDecisionTable52 content) { try { return genericValidator.validate(path, GuidedDTXMLPersistence.getInstance().marshal(content)); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Before public void setUp() throws Exception { GuidedDTXMLPersistence.getInstance(); }
@Test public void testName() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); assertEquals("Row 42 XXX", p.getName("XXX", 42)); assertEquals("Row 42 YYY", p.getName("YYY", 42)); }
@Test public void testAttributeCellValue() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); assertFalse(p.validateAttributeCell(null)); assertFalse(p.validateAttributeCell("")); assertFalse(p.validateAttributeCell(" ")); }
@Test public void testMetadataCellValue() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); assertFalse(p.validateMetadataCell(null)); assertFalse(p.validateMetadataCell((""))); assertFalse(p.validateMetadataCell((" "))); }
@Test public void testCellCSV() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); assertEquals( "(\"Helsinki, Finland\", \"Boston\")", p.makeInList( "\"Helsinki, Finland\",Boston" ) ); assertEquals("(\"Michael\", \"Mark\", \"Peter\")", p.makeInList("Michael, Mark, Peter")); assertEquals("(\"Michael\")", p.makeInList("Michael")); assertEquals("(\"Michael\")", p.makeInList("\"Michael\"")); assertEquals("(\"Michael\", \"Ma rk\", \"Peter\")", p.makeInList("Michael, \"Ma rk\", Peter")); assertEquals("(WEE WAAH)", p.makeInList("(WEE WAAH)")); }
@Test public void testConditionAndActionCellValue() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); assertFalse(p.validCell(null, DataType.DataTypes.NUMERIC)); assertFalse(p.validCell("", DataType.DataTypes.NUMERIC)); assertFalse(p.validCell(" ", DataType.DataTypes.NUMERIC)); assertFalse(p.validCell(null, DataType.DataTypes.STRING)); assertFalse(p.validCell("", DataType.DataTypes.STRING)); assertFalse(p.validCell(" ", DataType.DataTypes.STRING)); }
private IPattern findByFactPattern(List<IPattern> patterns, Pattern52 find) { final boolean isNegated = find.isNegated(); if (isNegated) { return doFindByNegatedFactPattern(patterns, find); } else { return doFindByFactPattern(patterns, find); } }
@Override public TemplateAware cloneTemplateAware() { return new TemplateAwareIAction(value); }
private void doAction(List<LabelledAction> actions, String cell) { LabelledAction a = new LabelledAction(); a.action = new ActionRetractFact(cell); a.boundName = cell; actions.add(a); }
@Override public ResourceConversionResult loadFromInputStream(InputStream is) throws IOException { String xml = new String(IoUtils.readBytesFromInputStream(is), IoUtils.UTF8_CHARSET); GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(xml); String content = GuidedDTDRLPersistence.getInstance().marshal(model); if (hasDSLSentences(model)) { return new ResourceConversionResult(content, ResourceType.DSLR); } else { return new ResourceConversionResult(content, ResourceType.DRL); } }
@Test public void allRulesHaveTheSameActivationGroup() throws Exception { final String drl = GuidedDTDRLPersistence.getInstance() .marshal( dtable ); assertContainsLinesInOrder( drl, "rule \"Row 1 First hit policy table\"", "activation-group \"first-hit-policy-group First hit policy table\"", "rule \"Row 2 First hit policy table\"", "activation-group \"first-hit-policy-group First hit policy table\"", "rule \"Row 3 First hit policy table\"", "activation-group \"first-hit-policy-group First hit policy table\"" ); } }
protected void analyze(String resourceName) throws Exception { final String xml = TestUtil.loadResource(resourceName); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); // First run analyzer.resetChecks(); analyzer.analyze(); }