@@ -299,8 +299,7 @@ void analyzeNonNullableWithNullValue(SolutionManagerSource SolutionManagerSource
299
299
var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY );
300
300
assertThat (solutionManager ).isNotNull ();
301
301
302
- assertThatThrownBy (() -> solutionManager .analyze (solution ))
303
- .hasMessageContaining ("not initialized" );
302
+ assertThat (solutionManager .analyze (solution )).isNotNull ();
304
303
}
305
304
306
305
@ ParameterizedTest
@@ -320,6 +319,23 @@ void analyzeNullableWithNullValue(SolutionManagerSource SolutionManagerSource) {
320
319
});
321
320
}
322
321
322
+ @ ParameterizedTest
323
+ @ EnumSource (SolutionManagerSource .class )
324
+ void analyzeWithUninitializedSolution (SolutionManagerSource SolutionManagerSource ) {
325
+ var uninitializedSolution = TestdataShadowedSolution .generateSolution (3 , 3 );
326
+ uninitializedSolution .getEntityList ().forEach (e -> e .setValue (null ));
327
+
328
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY );
329
+ assertThat (solutionManager ).isNotNull ();
330
+
331
+ var scoreAnalysis = solutionManager .analyze (uninitializedSolution );
332
+ assertThat (scoreAnalysis ).isNotNull ();
333
+ assertSoftly (softly -> {
334
+ softly .assertThat (scoreAnalysis .score ()).isNotNull ();
335
+ softly .assertThat (scoreAnalysis .constraintMap ()).isNotEmpty ();
336
+ });
337
+ }
338
+
323
339
@ ParameterizedTest
324
340
@ EnumSource (SolutionManagerSource .class )
325
341
void recommendFit (SolutionManagerSource SolutionManagerSource ) {
@@ -368,6 +384,21 @@ void recommendFit(SolutionManagerSource SolutionManagerSource) {
368
384
});
369
385
}
370
386
387
+ @ ParameterizedTest
388
+ @ EnumSource (SolutionManagerSource .class )
389
+ void recommendFitUninitializedSolution (SolutionManagerSource SolutionManagerSource ) {
390
+ int valueSize = 3 ;
391
+ var uninitializedSolution = TestdataShadowedSolution .generateSolution (valueSize , 3 );
392
+ uninitializedSolution .getEntityList ().forEach (e -> e .setValue (null ));
393
+ var uninitializedEntity = uninitializedSolution .getEntityList ().get (2 );
394
+
395
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY_SHADOWED );
396
+ assertThat (solutionManager ).isNotNull ();
397
+ assertThatThrownBy (() -> solutionManager .recommendFit (uninitializedSolution , uninitializedEntity ,
398
+ TestdataShadowedEntity ::getValue ))
399
+ .hasMessageContaining ("Solution (Generated Solution 0) has (3) uninitialized elements." );
400
+ }
401
+
371
402
@ ParameterizedTest
372
403
@ EnumSource (SolutionManagerSource .class )
373
404
void recommendFitWithUnassigned (SolutionManagerSource SolutionManagerSource ) {
@@ -426,6 +457,22 @@ void recommendFitWithUnassigned(SolutionManagerSource SolutionManagerSource) {
426
457
});
427
458
}
428
459
460
+ @ ParameterizedTest
461
+ @ EnumSource (SolutionManagerSource .class )
462
+ void recommendFitUninitializedSolutionWithUnassigned (SolutionManagerSource SolutionManagerSource ) {
463
+ int valueSize = 3 ;
464
+ var uninitializedSolution = TestdataAllowsUnassignedSolution .generateSolution (valueSize , 3 );
465
+ uninitializedSolution .getEntityList ().forEach (e -> e .setValue (null ));
466
+ var uninitializedEntity = uninitializedSolution .getEntityList ().get (2 );
467
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY_UNASSIGNED );
468
+ assertThat (solutionManager ).isNotNull ();
469
+ var recommendationList = solutionManager .recommendFit (uninitializedSolution , uninitializedEntity ,
470
+ TestdataAllowsUnassignedEntity ::getValue );
471
+
472
+ // Three values means there need to be four recommendations, one extra for unassigned.
473
+ assertThat (recommendationList ).hasSize (valueSize + 1 );
474
+ }
475
+
429
476
@ ParameterizedTest
430
477
@ EnumSource (SolutionManagerSource .class )
431
478
void recommendFitMultivar (SolutionManagerSource SolutionManagerSource ) {
@@ -517,6 +564,26 @@ void recommendFitMultivar(SolutionManagerSource SolutionManagerSource) {
517
564
});
518
565
}
519
566
567
+ @ ParameterizedTest
568
+ @ EnumSource (SolutionManagerSource .class )
569
+ void recommendFitUninitializedSolutionWithMultivar (SolutionManagerSource SolutionManagerSource ) {
570
+ var solution = new TestdataMultiVarSolution ("solution" );
571
+ var firstValue = new TestdataValue ("firstValue" );
572
+ var secondValue = new TestdataValue ("secondValue" );
573
+ solution .setValueList (List .of (firstValue , secondValue ));
574
+ var firstOtherValue = new TestdataOtherValue ("firstOtherValue" );
575
+ solution .setOtherValueList (List .of (firstOtherValue ));
576
+ var uninitializedEntity = new TestdataMultiVarEntity ("uninitialized" );
577
+ var secondUninitializedEntity = new TestdataMultiVarEntity ("uninitialized2" );
578
+ solution .setMultiVarEntityList (List .of (uninitializedEntity , secondUninitializedEntity ));
579
+
580
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY_MULTIVAR );
581
+ assertThatThrownBy (() -> solutionManager .recommendFit (solution , uninitializedEntity ,
582
+ entity -> new Triple <>(entity .getPrimaryValue (), entity .getSecondaryValue (),
583
+ entity .getTertiaryValueAllowedUnassigned ())))
584
+ .hasMessageContaining ("Solution (solution) has (2) uninitialized elements." );
585
+ }
586
+
520
587
record Triple <A , B , C >(A a , B b , C c ) {
521
588
522
589
}
@@ -589,6 +656,27 @@ void recommendFitChained(SolutionManagerSource SolutionManagerSource) {
589
656
});
590
657
}
591
658
659
+ @ ParameterizedTest
660
+ @ EnumSource (SolutionManagerSource .class )
661
+ void recommendFitTwoUninitializedEntityWithChained (SolutionManagerSource SolutionManagerSource ) {
662
+ var a0 = new TestdataShadowingChainedAnchor ("a0" );
663
+ var b0 = new TestdataShadowingChainedAnchor ("b0" );
664
+ var b1 = new TestdataShadowingChainedEntity ("b1" , b0 );
665
+ var c0 = new TestdataShadowingChainedAnchor ("c0" );
666
+ var c1 = new TestdataShadowingChainedEntity ("c1" , c0 );
667
+ var c2 = new TestdataShadowingChainedEntity ("c2" , c1 );
668
+ var uninitializedEntity = new TestdataShadowingChainedEntity ("uninitialized" );
669
+ var uninitializedEntity2 = new TestdataShadowingChainedEntity ("uninitialized2" );
670
+ var uninitializedSolution = new TestdataShadowingChainedSolution ("solution" );
671
+ uninitializedSolution .setChainedAnchorList (Arrays .asList (a0 , b0 , c0 ));
672
+ uninitializedSolution .setChainedEntityList (Arrays .asList (b1 , c1 , c2 , uninitializedEntity , uninitializedEntity2 ));
673
+
674
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY_CHAINED );
675
+ assertThatThrownBy (() -> solutionManager .recommendFit (uninitializedSolution , uninitializedEntity ,
676
+ TestdataShadowingChainedEntity ::getChainedObject ))
677
+ .hasMessageContaining ("Solution (solution) has (2) uninitialized elements." );
678
+ }
679
+
592
680
@ ParameterizedTest
593
681
@ EnumSource (SolutionManagerSource .class )
594
682
void recommendFitList (SolutionManagerSource SolutionManagerSource ) {
@@ -659,6 +747,27 @@ void recommendFitList(SolutionManagerSource SolutionManagerSource) {
659
747
});
660
748
}
661
749
750
+ @ ParameterizedTest
751
+ @ EnumSource (SolutionManagerSource .class )
752
+ void recommendFitTwoUninitializedEntityWithList (SolutionManagerSource SolutionManagerSource ) {
753
+ var a = new TestdataListEntityWithShadowHistory ("a" );
754
+ var b0 = new TestdataListValueWithShadowHistory ("b0" );
755
+ var b = new TestdataListEntityWithShadowHistory ("b" , b0 );
756
+ var c0 = new TestdataListValueWithShadowHistory ("c0" );
757
+ var c1 = new TestdataListValueWithShadowHistory ("c1" );
758
+ var c = new TestdataListEntityWithShadowHistory ("c" , c0 , c1 );
759
+ var d = new TestdataListEntityWithShadowHistory ("d" );
760
+ var solution = new TestdataListSolutionWithShadowHistory ();
761
+ TestdataListValueWithShadowHistory uninitializedValue = new TestdataListValueWithShadowHistory ("uninitialized" );
762
+ solution .setEntityList (Arrays .asList (a , b , c , d ));
763
+ solution .setValueList (Arrays .asList (b0 , c0 , c1 , uninitializedValue ));
764
+
765
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY_LIST );
766
+ var recommendationList =
767
+ solutionManager .recommendFit (solution , uninitializedValue , v -> new Pair <>(v .getEntity (), v .getIndex ()));
768
+ assertThat (recommendationList ).hasSize (7 );
769
+ }
770
+
662
771
@ ParameterizedTest
663
772
@ EnumSource (SolutionManagerSource .class )
664
773
void recommendFitListPinned (SolutionManagerSource SolutionManagerSource ) {
@@ -721,6 +830,31 @@ void recommendFitListPinned(SolutionManagerSource SolutionManagerSource) {
721
830
});
722
831
}
723
832
833
+ @ ParameterizedTest
834
+ @ EnumSource (SolutionManagerSource .class )
835
+ void recommendFitTwoUninitializedEntityWithListPinned (SolutionManagerSource SolutionManagerSource ) {
836
+ var a = new TestdataPinnedWithIndexListEntity ("a" );
837
+ var b0 = new TestdataPinnedWithIndexListValue ("b0" );
838
+ var b = new TestdataPinnedWithIndexListEntity ("b" , b0 );
839
+ b .setPinned (true ); // Entity will be unavailable.
840
+ var c0 = new TestdataPinnedWithIndexListValue ("c0" );
841
+ var c1 = new TestdataPinnedWithIndexListValue ("c1" );
842
+ var c = new TestdataPinnedWithIndexListEntity ("c" , c0 , c1 );
843
+ var d = new TestdataPinnedWithIndexListEntity ("d" );
844
+ c .setPinned (false );
845
+ c .setPlanningPinToIndex (1 ); // Destination c[0] will be unavailable.
846
+ var solution = new TestdataPinnedWithIndexListSolution ();
847
+ var uninitializedValue = new TestdataPinnedWithIndexListValue ("uninitialized" );
848
+ solution .setEntityList (Arrays .asList (a , b , c , d ));
849
+ solution .setValueList (Arrays .asList (b0 , c0 , c1 , uninitializedValue ));
850
+
851
+ var solutionManager = SolutionManagerSource .createSolutionManager (SOLVER_FACTORY_LIST_PINNED );
852
+ var recommendationList =
853
+ solutionManager .recommendFit (solution , uninitializedValue ,
854
+ v -> new Pair <>(v .getEntity (), v .getEntity ().getValueList ().indexOf (v )));
855
+ assertThat (recommendationList ).hasSize (4 );
856
+ }
857
+
724
858
public enum SolutionManagerSource {
725
859
726
860
FROM_SOLVER_FACTORY (SolutionManager ::create ),
0 commit comments