379
388
dataElementService.updateDataElement( dataElementD );
380
389
dataElementService.updateDataElement( dataElementE );
382
validationRuleA = createValidationRule( 'A', equal_to, expressionA, expressionB, periodTypeMonthly );
383
validationRuleB = createValidationRule( 'B', greater_than, expressionB, expressionC, periodTypeMonthly );
384
validationRuleC = createValidationRule( 'C', less_than_or_equal_to, expressionB, expressionA, periodTypeMonthly );
385
validationRuleD = createValidationRule( 'D', less_than, expressionA, expressionC, periodTypeMonthly );
391
validationRuleA = createValidationRule( 'A', equal_to, expressionA, expressionB, periodTypeMonthly ); // deA + deB = deC - deD
392
validationRuleB = createValidationRule( 'B', greater_than, expressionB, expressionC, periodTypeMonthly ); // deC - deD > deB * 2
393
validationRuleC = createValidationRule( 'C', less_than_or_equal_to, expressionB, expressionA, periodTypeMonthly ); // deC - deD <= deA + deB
394
validationRuleD = createValidationRule( 'D', less_than, expressionA, expressionC, periodTypeMonthly ); // deA + deB < deB * 2
395
validationRuleX = createValidationRule( 'X', equal_to, expressionA, expressionC, periodTypeMonthly ); // deA + deB = deB * 2
387
397
// Compare dataElementB with 1.5 times itself for one sequential previous period.
388
398
monitoringRuleE = createMonitoringRule( 'E', less_than_or_equal_to, expressionD, expressionE, periodTypeMonthly, 1, 1, 0, 0, 0 );
479
491
// insures that if they are the same as the reference results, they will appear in the same order.
481
493
Collection<ValidationResult> results = validationRuleService.validate(
482
getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, false, null );
494
getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, null, null, false, null );
484
496
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
486
reference.add( new ValidationResult( periodA, sourceA, validationRuleA, 3.0, -1.0 ) );
487
reference.add( new ValidationResult( periodB, sourceA, validationRuleA, 3.0, -1.0 ) );
488
reference.add( new ValidationResult( periodA, sourceB, validationRuleA, 3.0, -1.0 ) );
489
reference.add( new ValidationResult( periodB, sourceB, validationRuleA, 3.0, -1.0 ) );
498
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
499
reference.add( new ValidationResult( periodB, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
500
reference.add( new ValidationResult( periodA, sourceB, defaultCombo, validationRuleA, 3.0, -1.0 ) );
501
reference.add( new ValidationResult( periodB, sourceB, defaultCombo, validationRuleA, 3.0, -1.0 ) );
491
reference.add( new ValidationResult( periodA, sourceA, validationRuleB, -1.0, 4.0 ) );
492
reference.add( new ValidationResult( periodB, sourceA, validationRuleB, -1.0, 4.0 ) );
493
reference.add( new ValidationResult( periodA, sourceB, validationRuleB, -1.0, 4.0 ) );
494
reference.add( new ValidationResult( periodB, sourceB, validationRuleB, -1.0, 4.0 ) );
503
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleB, -1.0, 4.0 ) );
504
reference.add( new ValidationResult( periodB, sourceA, defaultCombo, validationRuleB, -1.0, 4.0 ) );
505
reference.add( new ValidationResult( periodA, sourceB, defaultCombo, validationRuleB, -1.0, 4.0 ) );
506
reference.add( new ValidationResult( periodB, sourceB, defaultCombo, validationRuleB, -1.0, 4.0 ) );
496
508
for ( ValidationResult result : results )
537
549
validationRuleService.addValidationRuleGroup( group );
539
551
Collection<ValidationResult> results = validationRuleService.validate(
540
getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, group, false, null );
552
getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, null, group, false, null );
542
554
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
544
reference.add( new ValidationResult( periodA, sourceA, validationRuleA, 3.0, -1.0 ) );
545
reference.add( new ValidationResult( periodB, sourceA, validationRuleA, 3.0, -1.0 ) );
546
reference.add( new ValidationResult( periodA, sourceB, validationRuleA, 3.0, -1.0 ) );
547
reference.add( new ValidationResult( periodB, sourceB, validationRuleA, 3.0, -1.0 ) );
556
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
557
reference.add( new ValidationResult( periodB, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
558
reference.add( new ValidationResult( periodA, sourceB, defaultCombo, validationRuleA, 3.0, -1.0 ) );
559
reference.add( new ValidationResult( periodB, sourceB, defaultCombo, validationRuleA, 3.0, -1.0 ) );
549
561
for ( ValidationResult result : results )
580
592
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
582
reference.add( new ValidationResult( periodA, sourceA, validationRuleA, 3.0, -1.0 ) );
583
reference.add( new ValidationResult( periodB, sourceA, validationRuleA, 3.0, -1.0 ) );
584
reference.add( new ValidationResult( periodA, sourceA, validationRuleB, -1.0, 4.0 ) );
585
reference.add( new ValidationResult( periodB, sourceA, validationRuleB, -1.0, 4.0 ) );
594
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
595
reference.add( new ValidationResult( periodB, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
596
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleB, -1.0, 4.0 ) );
597
reference.add( new ValidationResult( periodB, sourceA, defaultCombo, validationRuleB, -1.0, 4.0 ) );
587
599
for ( ValidationResult result : results )
608
620
validationRuleService.saveValidationRule( validationRuleD );
610
622
Collection<ValidationResult> results = validationRuleService.validate(
611
dataSetMonthly, periodA, sourceA );
623
dataSetMonthly, periodA, sourceA, null );
613
625
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
615
reference.add( new ValidationResult( periodA, sourceA, validationRuleA, 3.0, -1.0 ) );
616
reference.add( new ValidationResult( periodA, sourceA, validationRuleB, -1.0, 4.0 ) );
627
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleA, 3.0, -1.0 ) );
628
reference.add( new ValidationResult( periodA, sourceA, defaultCombo, validationRuleB, -1.0, 4.0 ) );
618
630
for ( ValidationResult result : results )
656
668
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
658
reference.add( new ValidationResult( periodL, sourceA, monitoringRuleE, 200.0, 150.0 /* 1.5 * 100 */ ) );
659
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleE, 400.0, 300.0 /* 1.5 * 200 */ ) );
660
reference.add( new ValidationResult( periodN, sourceA, monitoringRuleE, 700.0, 600.0 /* 1.5 * 400 */ ) );
670
reference.add( new ValidationResult( periodL, sourceA, defaultCombo, monitoringRuleE, 200.0, 150.0 /* 1.5 * 100 */ ) );
671
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleE, 400.0, 300.0 /* 1.5 * 200 */ ) );
672
reference.add( new ValidationResult( periodN, sourceA, defaultCombo, monitoringRuleE, 700.0, 600.0 /* 1.5 * 400 */ ) );
662
674
for ( ValidationResult result : results )
698
710
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
700
reference.add( new ValidationResult( periodK, sourceA, monitoringRuleF, 100.0, 75.0 /* 1.5 * 50 */ ) );
701
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleF, 400.0, 300.0 /* 1.5 * 200 */ ) );
702
reference.add( new ValidationResult( periodO, sourceA, monitoringRuleF, 800.0, 600.0 /* 1.5 * 400 */ ) );
712
reference.add( new ValidationResult( periodK, sourceA, defaultCombo, monitoringRuleF, 100.0, 75.0 /* 1.5 * 50 */ ) );
713
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleF, 400.0, 300.0 /* 1.5 * 200 */ ) );
714
reference.add( new ValidationResult( periodO, sourceA, defaultCombo, monitoringRuleF, 800.0, 600.0 /* 1.5 * 400 */ ) );
704
716
for ( ValidationResult result : results )
740
752
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
742
reference.add( new ValidationResult( periodK, sourceA, monitoringRuleG, 100.0, 83.6 /* 1.5 * ( 11 + 12 + 50 + 150 ) / 4 */ ) );
743
reference.add( new ValidationResult( periodL, sourceA, monitoringRuleG, 200.0, 114.9 /* 1.5 * ( 11 + 12 + 13 + 50 + 150 + 200 + 100 ) / 7 */ ) );
744
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleG, 400.0, 254.8 /* 1.5 * ( 12 + 13 + 14 + 150 + 200 + 600 + 200 ) / 7 */ ) );
745
reference.add( new ValidationResult( periodN, sourceA, monitoringRuleG, 700.0, 351.9 /* 1.5 * ( 13 + 14 + 15 + 200 + 600 + 400 + 400 ) / 7 */ ) );
746
reference.add( new ValidationResult( periodO, sourceA, monitoringRuleG, 800.0, 518.7 /* 1.5 * ( 14 + 15 + 600 + 400 + 700 ) / 5 */ ) );
754
reference.add( new ValidationResult( periodK, sourceA, defaultCombo, monitoringRuleG, 100.0, 83.6 /* 1.5 * ( 11 + 12 + 50 + 150 ) / 4 */ ) );
755
reference.add( new ValidationResult( periodL, sourceA, defaultCombo, monitoringRuleG, 200.0, 114.9 /* 1.5 * ( 11 + 12 + 13 + 50 + 150 + 200 + 100 ) / 7 */ ) );
756
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleG, 400.0, 254.8 /* 1.5 * ( 12 + 13 + 14 + 150 + 200 + 600 + 200 ) / 7 */ ) );
757
reference.add( new ValidationResult( periodN, sourceA, defaultCombo, monitoringRuleG, 700.0, 351.9 /* 1.5 * ( 13 + 14 + 15 + 200 + 600 + 400 + 400 ) / 7 */ ) );
758
reference.add( new ValidationResult( periodO, sourceA, defaultCombo, monitoringRuleG, 800.0, 518.7 /* 1.5 * ( 14 + 15 + 600 + 400 + 700 ) / 5 */ ) );
748
760
for ( ValidationResult result : results )
784
796
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
786
798
// Not in results: reference.add( new ValidationResult( periodK, sourceA, monitoringRuleH, 100.0, 109.0 /* 1.5 * ( 11 + 12 + 13 + 50 + 150 + 200 ) / 6 */ ) );
787
reference.add( new ValidationResult( periodL, sourceA, monitoringRuleH, 200.0, 191.7 /* 1.5 * ( 11 + 12 + 13 + 14 + 50 + 150 + 200 + 600 + 100 ) / 9 */ ) );
788
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleH, 400.0, 220.6 /* 1.5 * ( 11 + 12 + 13 + 14 + 15 + 50 + 150 + 200 + 600 + 400 + 100 + 200 ) / 12 */ ) );
789
reference.add( new ValidationResult( periodN, sourceA, monitoringRuleH, 700.0, 300.6 /* 1.5 * ( 12 + 13 + 14 + 15 + 150 + 200 + 600 + 400 + 200 + 400 ) / 10 */ ) );
790
reference.add( new ValidationResult( periodO, sourceA, monitoringRuleH, 800.0, 439.1 /* 1.5 * ( 13 + 14 + 15 + 200 + 600 + 400 + 400 + 700 ) / 8 */ ) );
799
reference.add( new ValidationResult( periodL, sourceA, defaultCombo, monitoringRuleH, 200.0, 191.7 /* 1.5 * ( 11 + 12 + 13 + 14 + 50 + 150 + 200 + 600 + 100 ) / 9 */ ) );
800
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleH, 400.0, 220.6 /* 1.5 * ( 11 + 12 + 13 + 14 + 15 + 50 + 150 + 200 + 600 + 400 + 100 + 200 ) / 12 */ ) );
801
reference.add( new ValidationResult( periodN, sourceA, defaultCombo, monitoringRuleH, 700.0, 300.6 /* 1.5 * ( 12 + 13 + 14 + 15 + 150 + 200 + 600 + 400 + 200 + 400 ) / 10 */ ) );
802
reference.add( new ValidationResult( periodO, sourceA, defaultCombo, monitoringRuleH, 800.0, 439.1 /* 1.5 * ( 13 + 14 + 15 + 200 + 600 + 400 + 400 + 700 ) / 8 */ ) );
792
804
for ( ValidationResult result : results )
828
840
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
830
reference.add( new ValidationResult( periodK, sourceA, monitoringRuleI, 100.0, 32.3 /* 1.5 * ( 11 + 12 + 13 + 50 ) / 4 */ ) );
831
reference.add( new ValidationResult( periodL, sourceA, monitoringRuleI, 200.0, 75.0 /* 1.5 * ( 11 + 12 + 13 + 14 + 50 + 150 + 100 ) / 7 */ ) );
832
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleI, 400.0, 114.8 /* 1.5 * ( 11 + 12 + 13 + 14 + 15 + 50 + 150 + 200 + 100 + 200 ) / 10 */ ) );
833
reference.add( new ValidationResult( periodN, sourceA, monitoringRuleI, 700.0, 188.3 /* 1.5 * ( 12 + 13 + 14 + 15 + 150 + 200 + 200 + 400 ) / 8 */ ) );
834
reference.add( new ValidationResult( periodO, sourceA, monitoringRuleI, 800.0, 260.5 /* 1.5 * ( 13 + 14 + 15 + 200 + 400 + 400 ) / 6 */ ) );
842
reference.add( new ValidationResult( periodK, sourceA, defaultCombo, monitoringRuleI, 100.0, 32.3 /* 1.5 * ( 11 + 12 + 13 + 50 ) / 4 */ ) );
843
reference.add( new ValidationResult( periodL, sourceA, defaultCombo, monitoringRuleI, 200.0, 75.0 /* 1.5 * ( 11 + 12 + 13 + 14 + 50 + 150 + 100 ) / 7 */ ) );
844
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleI, 400.0, 114.8 /* 1.5 * ( 11 + 12 + 13 + 14 + 15 + 50 + 150 + 200 + 100 + 200 ) / 10 */ ) );
845
reference.add( new ValidationResult( periodN, sourceA, defaultCombo, monitoringRuleI, 700.0, 188.3 /* 1.5 * ( 12 + 13 + 14 + 15 + 150 + 200 + 200 + 400 ) / 8 */ ) );
846
reference.add( new ValidationResult( periodO, sourceA, defaultCombo, monitoringRuleI, 800.0, 260.5 /* 1.5 * ( 13 + 14 + 15 + 200 + 400 + 400 ) / 6 */ ) );
836
848
for ( ValidationResult result : results )
874
886
// Not in results: reference.add( new ValidationResult( periodK, sourceA, monitoringRuleH, 100.0, 154.9 /* 1.5 * ( 13 + 50 + 150 + 200 ) / 4 */ ) );
875
887
// Not in results: reference.add( new ValidationResult( periodL, sourceA, monitoringRuleJ, 200.0, 241.5 /* 1.5 * ( 13 + 14 + 50 + 150 + 200 + 600 + 100 ) / 7 */ ) );
876
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleJ, 400.0, 261.3 /* 1.5 * ( 13 + 14 + 15 + 50 + 150 + 200 + 600 + 400 + 100 + 200 ) / 10 */ ) );
877
reference.add( new ValidationResult( periodN, sourceA, monitoringRuleJ, 700.0, 371.1 /* 1.5 * ( 14 + 15 + 150 + 200 + 600 + 400 + 200 + 400 ) / 8 */ ) );
878
reference.add( new ValidationResult( periodO, sourceA, monitoringRuleJ, 800.0, 578.8 /* 1.5 * ( 15 + 200 + 600 + 400 + 400 + 700 ) / 6 */ ) );
888
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleJ, 400.0, 261.3 /* 1.5 * ( 13 + 14 + 15 + 50 + 150 + 200 + 600 + 400 + 100 + 200 ) / 10 */ ) );
889
reference.add( new ValidationResult( periodN, sourceA, defaultCombo, monitoringRuleJ, 700.0, 371.1 /* 1.5 * ( 14 + 15 + 150 + 200 + 600 + 400 + 200 + 400 ) / 8 */ ) );
890
reference.add( new ValidationResult( periodO, sourceA, defaultCombo, monitoringRuleJ, 800.0, 578.8 /* 1.5 * ( 15 + 200 + 600 + 400 + 400 + 700 ) / 6 */ ) );
880
892
for ( ValidationResult result : results )
916
928
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
918
reference.add( new ValidationResult( periodK, sourceA, monitoringRuleK, 100.0, 47.3 /* 1.5 * ( 13 + 50 ) / 2 */ ) );
919
reference.add( new ValidationResult( periodL, sourceA, monitoringRuleK, 200.0, 98.1 /* 1.5 * ( 13 + 14 + 50 + 150 + 100 ) / 5 */ ) );
920
reference.add( new ValidationResult( periodM, sourceA, monitoringRuleK, 400.0, 139.1 /* 1.5 * ( 13 + 14 + 15 + 50 + 150 + 200 + 100 + 200 ) / 8 */ ) );
921
reference.add( new ValidationResult( periodN, sourceA, monitoringRuleK, 700.0, 244.8 /* 1.5 * ( 14 + 15 + 150 + 200 + 200 + 400 ) / 6 */ ) );
922
reference.add( new ValidationResult( periodO, sourceA, monitoringRuleK, 800.0, 380.6 /* 1.5 * ( 15 + 200 + 400 + 400 ) / 4 */ ) );
930
reference.add( new ValidationResult( periodK, sourceA, defaultCombo, monitoringRuleK, 100.0, 47.3 /* 1.5 * ( 13 + 50 ) / 2 */ ) );
931
reference.add( new ValidationResult( periodL, sourceA, defaultCombo, monitoringRuleK, 200.0, 98.1 /* 1.5 * ( 13 + 14 + 50 + 150 + 100 ) / 5 */ ) );
932
reference.add( new ValidationResult( periodM, sourceA, defaultCombo, monitoringRuleK, 400.0, 139.1 /* 1.5 * ( 13 + 14 + 15 + 50 + 150 + 200 + 100 + 200 ) / 8 */ ) );
933
reference.add( new ValidationResult( periodN, sourceA, defaultCombo, monitoringRuleK, 700.0, 244.8 /* 1.5 * ( 14 + 15 + 150 + 200 + 200 + 400 ) / 6 */ ) );
934
reference.add( new ValidationResult( periodO, sourceA, defaultCombo, monitoringRuleK, 800.0, 380.6 /* 1.5 * ( 15 + 200 + 400 + 400 ) / 4 */ ) );
924
936
for ( ValidationResult result : results )
967
979
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
969
reference.add( new ValidationResult( periodK, sourceB, monitoringRuleL, 10.0 /* 100 / 10 */, 1.5 /* 1.5 * 50 / 50 */ ) );
970
reference.add( new ValidationResult( periodL, sourceB, monitoringRuleL, 20.0 /* 200 / 10 */, 4.5 /* 1.5 * 150 / 50 */ ) );
971
reference.add( new ValidationResult( periodM, sourceB, monitoringRuleL, 40.0 /* 400 / 10 */, 6.0 /* 1.5 * 200 / 50 */ ) );
972
reference.add( new ValidationResult( periodN, sourceB, monitoringRuleL, 70.0 /* 700 / 10 */, 18.0 /* 1.5 * 600 / 50 */ ) );
973
reference.add( new ValidationResult( periodO, sourceB, monitoringRuleL, 80.0 /* 800 / 10 */, 12.0 /* 1.5 * 400 / 50 */ ) );
981
reference.add( new ValidationResult( periodK, sourceB, defaultCombo, monitoringRuleL, 10.0 /* 100 / 10 */, 1.5 /* 1.5 * 50 / 50 */ ) );
982
reference.add( new ValidationResult( periodL, sourceB, defaultCombo, monitoringRuleL, 20.0 /* 200 / 10 */, 4.5 /* 1.5 * 150 / 50 */ ) );
983
reference.add( new ValidationResult( periodM, sourceB, defaultCombo, monitoringRuleL, 40.0 /* 400 / 10 */, 6.0 /* 1.5 * 200 / 50 */ ) );
984
reference.add( new ValidationResult( periodN, sourceB, defaultCombo, monitoringRuleL, 70.0 /* 700 / 10 */, 18.0 /* 1.5 * 600 / 50 */ ) );
985
reference.add( new ValidationResult( periodO, sourceB, defaultCombo, monitoringRuleL, 80.0 /* 800 / 10 */, 12.0 /* 1.5 * 400 / 50 */ ) );
975
987
for ( ValidationResult result : results )
982
994
assertEquals( orderedList( reference ), orderedList( results ) );
998
public void testValidateWithAttributeOptions()
1000
DataElementCategoryOption optionA = new DataElementCategoryOption( "CategoryOptionA" );
1001
DataElementCategoryOption optionB = new DataElementCategoryOption( "CategoryOptionB" );
1002
DataElementCategoryOption optionC = new DataElementCategoryOption( "CategoryOptionC" );
1004
categoryService.addDataElementCategoryOption( optionA );
1005
categoryService.addDataElementCategoryOption( optionB );
1006
categoryService.addDataElementCategoryOption( optionC );
1008
DataElementCategory categoryA = createDataElementCategory( 'A', optionA, optionB );
1009
DataElementCategory categoryB = createDataElementCategory( 'B', optionC );
1010
categoryA.setDataDimension( true );
1011
categoryB.setDataDimension( true );
1013
categoryService.addDataElementCategory( categoryA );
1014
categoryService.addDataElementCategory( categoryB );
1016
DataElementCategoryCombo categoryComboAB = createCategoryCombo( 'A', categoryA, categoryB );
1018
categoryService.addDataElementCategoryCombo( categoryComboAB );
1020
DataElementCategoryOptionCombo optionComboAC = createCategoryOptionCombo( 'A', categoryComboAB, optionA, optionC );
1021
DataElementCategoryOptionCombo optionComboBC = createCategoryOptionCombo( 'A', categoryComboAB, optionB, optionC );
1023
categoryService.addDataElementCategoryOptionCombo( optionComboAC );
1024
categoryService.addDataElementCategoryOptionCombo( optionComboBC );
1026
dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "4", optionCombo, optionComboAC ) );
1027
dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "3", optionCombo, optionComboAC ) );
1029
dataValueService.addDataValue( createDataValue( dataElementA, periodA, sourceA, "2", optionCombo, optionComboBC ) );
1030
dataValueService.addDataValue( createDataValue( dataElementB, periodA, sourceA, "1", optionCombo, optionComboBC ) );
1032
validationRuleService.saveValidationRule( validationRuleD ); // deA + deB < deB * 2
1033
validationRuleService.saveValidationRule( validationRuleX ); // deA + deB = deB * 2
1038
Collection<ValidationResult> results = validationRuleService.validate( dataSetMonthly, periodA, sourceA, optionComboAC );
1040
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
1042
reference.add( new ValidationResult( periodA, sourceA, optionComboAC, validationRuleD, 7.0, 6.0 ) );
1043
reference.add( new ValidationResult( periodA, sourceA, optionComboAC, validationRuleX, 7.0, 6.0 ) );
1045
for ( ValidationResult result : results )
1047
assertFalse( MathUtils.expressionIsTrue( result.getLeftsideValue(), result.getValidationRule()
1048
.getOperator(), result.getRightsideValue() ) );
1051
assertEquals( 2, results.size() );
1052
assertEquals( orderedList( reference ), orderedList( results ) );
1057
results = validationRuleService.validate( dataSetMonthly, periodA, sourceA, null );
1059
reference = new HashSet<ValidationResult>();
1061
reference.add( new ValidationResult( periodA, sourceA, optionComboAC, validationRuleD, 7.0, 6.0 ) );
1062
reference.add( new ValidationResult( periodA, sourceA, optionComboAC, validationRuleX, 7.0, 6.0 ) );
1063
reference.add( new ValidationResult( periodA, sourceA, optionComboBC, validationRuleD, 3.0, 2.0 ) );
1064
reference.add( new ValidationResult( periodA, sourceA, optionComboBC, validationRuleX, 3.0, 2.0 ) );
1066
for ( ValidationResult result : results )
1068
assertFalse( MathUtils.expressionIsTrue( result.getLeftsideValue(), result.getValidationRule()
1069
.getOperator(), result.getRightsideValue() ) );
1072
assertEquals( 4, results.size() );
1073
assertEquals( orderedList( reference ), orderedList( results ) );
1076
// Default optionCombo
1078
results = validationRuleService.validate( dataSetMonthly, periodA, sourceA, optionCombo );
1080
assertEquals( 0, results.size() );
985
1083
// -------------------------------------------------------------------------
986
1084
// CURD functionality tests
987
1085
// -------------------------------------------------------------------------