KiePMMLDescrLhsFactory { protected void commonDeclarePatternWithConstraint(final CEDescrBuilder<?, ?> descrBuilder, final String patternType, final String constraintString) { descrBuilder.pattern(patternType).constraint(constraintString); } private  KiePMMLDescrLhsFactory(final CEDescrBuilder<RuleDescrBuilder, AndDescr> builder); static KiePMMLDescrLhsFactory factory(final CEDescrBuilder<RuleDescrBuilder, AndDescr> builder); void declareLhs(final KiePMMLDroolsRule rule);  }
@Test public void commonDeclarePatternWithConstraint() { String patternType = "TEMPERATURE"; String constraintsString = "value < 35"; final CEDescrBuilder<CEDescrBuilder<CEDescrBuilder<RuleDescrBuilder, AndDescr>, NotDescr>, ExistsDescr> existsBuilder = lhsBuilder.not().exists(); KiePMMLDescrLhsFactory.factory(lhsBuilder).commonDeclarePatternWithConstraint(existsBuilder, patternType, constraintsString); assertNotNull(existsBuilder.getDescr()); final List<BaseDescr> descrs = existsBuilder.getDescr().getDescrs(); assertNotNull(descrs); assertEquals(1, descrs.size()); assertTrue(descrs.get(0) instanceof PatternDescr); PatternDescr patternDescr = (PatternDescr) descrs.get(0); assertEquals(patternType, patternDescr.getObjectType()); assertNull(patternDescr.getIdentifier()); assertTrue(patternDescr.getConstraint() instanceof AndDescr); AndDescr andDescr = (AndDescr) patternDescr.getConstraint(); assertEquals(1, andDescr.getDescrs().size()); assertTrue(andDescr.getDescrs().get(0) instanceof ExprConstraintDescr); ExprConstraintDescr exprConstraintDescr = (ExprConstraintDescr) andDescr.getDescrs().get(0); assertFalse(exprConstraintDescr.isNegated()); assertEquals(ExprConstraintDescr.Type.NAMED, exprConstraintDescr.getType()); assertEquals(constraintsString, exprConstraintDescr.getExpression()); }