@Test public void testMakeBRLRuleModel() { final String factType = "FactType"; final String boundName1 = "$fact1"; final String boundName2 = "$fact2"; final Pattern52 pattern = new Pattern52() {{ setFactType(factType); setBoundName(boundName1); }}; final FactPattern factPattern = new FactPattern() {{ setFactType(factType); setBoundName(boundName2); }}; final PatternWrapper patternWrapper = mock(PatternWrapper.class); doReturn(factPattern).when(patternWrapper).makeFactPattern(); doReturn(patternWrapper).when(plugin).patternWrapper(); doReturn(Collections.singletonList(pattern)).when(model).getConditions(); doReturn(pattern).when(model).getConditionPattern(boundName1); final BRLRuleModel brlRuleModel = plugin.makeBRLRuleModel(); final List<String> expectedVariables = Arrays.asList(boundName1, boundName2); final List<String> actualVariables = brlRuleModel.getAllVariables(); assertEquals(expectedVariables, actualVariables); }
@Test public void testOnlyDecisionTableColumns() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); Pattern52 p1 = new Pattern52(); p1.setFactType("Driver"); p1.setBoundName("$p1"); ConditionCol52 c1 = new ConditionCol52(); c1.setFactField("name"); c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL); c1.setBinding("$c1"); p1.getChildColumns().add(c1); dt.getConditions().add(p1); ActionInsertFactCol52 ins = new ActionInsertFactCol52(); ins.setBoundName("$ins"); ins.setFactField("rating"); ins.setFactType("Person"); ins.setType(DataType.TYPE_STRING); dt.getActionCols().add(ins); BRLRuleModel model = new BRLRuleModel(dt); assertNotNull(model.getAllVariables()); assertEquals(3, model.getAllVariables().size()); assertTrue(model.getAllVariables().contains("$p1")); assertTrue(model.getAllVariables().contains("$c1")); assertTrue(model.getAllVariables().contains("$ins")); }
assertNotNull(model.getAllVariables()); assertEquals(5, model.getAllVariables().size()); assertTrue(model.getAllVariables().contains("$p1")); assertTrue(model.getAllVariables().contains("$c1")); assertTrue(model.getAllVariables().contains("$ins")); assertTrue(model.getAllVariables().contains("$brl1")); assertTrue(model.getAllVariables().contains("$sfc1"));
assertNotNull(model.getAllVariables()); assertEquals(4, model.getAllVariables().size()); assertTrue(model.getAllVariables().contains("$p1")); assertTrue(model.getAllVariables().contains("$c1")); assertTrue(model.getAllVariables().contains("$ins")); assertTrue(model.getAllVariables().contains("$aif"));