Package org.optaplanner.test.impl.score
Class AbstractScoreVerifier<Solution_>
- java.lang.Object
- 
- org.optaplanner.test.impl.score.AbstractScoreVerifier<Solution_>
 
- 
- Type Parameters:
- Solution_- the solution type, the class with the- PlanningSolutionannotation
 - Direct Known Subclasses:
- BendableBigDecimalScoreVerifier,- BendableLongScoreVerifier,- BendableScoreVerifier,- HardMediumSoftLongScoreVerifier,- HardMediumSoftScoreVerifier,- HardSoftBigDecimalScoreVerifier,- HardSoftLongScoreVerifier,- HardSoftScoreVerifier,- SimpleBigDecimalScoreVerifier,- SimpleLongScoreVerifier,- SimpleScoreVerifier
 
 public abstract class AbstractScoreVerifier<Solution_> extends Object Used in unit tests to assert that 1 particular solution has a specific weight for a specific constraint. This works well to verify that the implementation is in sync with the business constraints. This does not work well to detect score corruption, useScoreDirectorFactoryConfig.setAssertionScoreDirectorFactory(ScoreDirectorFactoryConfig)for that instead.Do not use this class directly, instead use the specific subclass for your Scoretype, such asHardSoftScoreVerifier.- See Also:
- HardSoftScoreVerifier
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected InnerScoreDirectorFactory<Solution_,?>scoreDirectorFactory
 - 
Constructor SummaryConstructors Constructor Description AbstractScoreVerifier(SolverFactory<Solution_> solverFactory, Class<? extends Score<?>> expectedScoreClass)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertWeight(String constraintPackage, String constraintName, int scoreLevel, Number expectedWeight, Solution_ solution)Assert that the constraint ofPlanningSolutionhas the expected weight for that score level.
 
- 
- 
- 
Field Detail- 
scoreDirectorFactoryprotected final InnerScoreDirectorFactory<Solution_,?> scoreDirectorFactory 
 
- 
 - 
Constructor Detail- 
AbstractScoreVerifierpublic AbstractScoreVerifier(SolverFactory<Solution_> solverFactory, Class<? extends Score<?>> expectedScoreClass) - Parameters:
- solverFactory- never null, the- SolverFactoryof which you want to test the constraints.
- expectedScoreClass- never null, used to fail fast if a- SolverFactorywith another- Scoretype is used.
 
 
- 
 - 
Method Detail- 
assertWeightprotected void assertWeight(String constraintPackage, String constraintName, int scoreLevel, Number expectedWeight, Solution_ solution) Assert that the constraint ofPlanningSolutionhas the expected weight for that score level.- Parameters:
- constraintPackage- sometimes null. When null,- constraintNamefor the- scoreLevelmust be unique.
- scoreLevel- at least 0
- constraintName- never null, the name of the constraint
- expectedWeight- never null, the total weight for all matches of that 1 constraint
- solution- never null
 
 
- 
 
-