@Test public void testFromAccumulateCompositePatternMissingValues() throws Exception { FactPattern pattern1 = new FactPattern("Person"); SingleFieldConstraint constraint1 = new SingleFieldConstraint("name"); constraint1.setOperator("=="); pattern1.addConstraint(constraint1); FactPattern pattern2 = new FactPattern("Address"); SingleFieldConstraint constraint2 = new SingleFieldConstraint("street"); constraint2.setOperator("!="); pattern2.addConstraint(constraint2); FromAccumulateCompositeFactPattern fromAccumulateCompositeFactPattern = new FromAccumulateCompositeFactPattern(); fromAccumulateCompositeFactPattern.setSourcePattern(pattern1); fromAccumulateCompositeFactPattern.setFactPattern(pattern2); fromAccumulateCompositeFactPattern.setFunction("test()"); model.lhs = new IPattern[] {fromAccumulateCompositeFactPattern}; assertFalse(validator.isValid()); assertEquals(2, validator.getErrors().size()); verify(constants, never()).WhenUsingFromTheSourceNeedsToBeSet(); verify(constants) .FactType0HasAField1ThatHasAnOperatorSetButNoValuePleaseAddAValueOrRemoveTheOperator( "Person", "name"); verify(constants) .FactType0HasAField1ThatHasAnOperatorSetButNoValuePleaseAddAValueOrRemoveTheOperator( "Address", "street"); }
@Test public void testFromAccumulateCompositePatternMissingValues2() throws Exception { FactPattern pattern1 = new FactPattern("Person"); FactPattern pattern2 = new FactPattern("Address"); FromAccumulateCompositeFactPattern fromAccumulateCompositeFactPattern = new FromAccumulateCompositeFactPattern(); fromAccumulateCompositeFactPattern.setSourcePattern(pattern1); fromAccumulateCompositeFactPattern.setFactPattern(pattern2); fromAccumulateCompositeFactPattern.setFunction(""); fromAccumulateCompositeFactPattern.setReverseCode(""); fromAccumulateCompositeFactPattern.setInitCode(""); fromAccumulateCompositeFactPattern.setActionCode(""); fromAccumulateCompositeFactPattern.setResultCode(""); model.lhs = new IPattern[] {fromAccumulateCompositeFactPattern}; assertFalse(validator.isValid()); assertEquals(1, validator.getErrors().size()); verify(constants).WhenUsingFromTheSourceNeedsToBeSet(); }