public static ProctorLoadResult verify ( @ Nonnull final TestMatrixArtifact testMatrix , final String matrixSource , @ Nonnull final Map < String , TestSpecification > requiredTests , @ Nonnull final FunctionMapper functionMapper , final ProvidedContext providedContext , @ Nonnull final Set < String > dynamicTests ) { final ProctorLoadResult . Builder resultBuilder = ProctorLoadResult . newBuilder ( ) ; final Map < String , Map < Integer , String > > allTestsKnownBuckets = Maps . newHashMapWithExpectedSize ( requiredTests . size ( ) ) ; for ( final Entry < String , TestSpecification > entry : requiredTests . entrySet ( ) ) { final Map < Integer , String > bucketValueToName = Maps . newHashMap ( ) ; for ( final Entry < String , Integer > bucket : entry . getValue ( ) . getBuckets ( ) . entrySet ( ) ) { bucketValueToName . put ( bucket . getValue ( ) , bucket . getKey ( ) ) ; } allTestsKnownBuckets . put ( entry . getKey ( ) , bucketValueToName ) ; } final Map < String , ConsumableTestDefinition > definedTests = testMatrix . getTests ( ) ; final SetView < String > missingTests = Sets . difference ( requiredTests . keySet ( ) , definedTests . keySet ( ) ) ; resultBuilder . recordAllMissing ( missingTests ) ; for ( final Entry < String , ConsumableTestDefinition > entry : definedTests . entrySet ( ) ) { final String testName = entry . getKey ( ) ; final Map < Integer , String > knownBuckets ; final TestSpecification specification ; final boolean isRequired ; if ( allTestsKnownBuckets . containsKey ( testName ) ) { // required in specification isRequired = true ; knownBuckets = allTestsKnownBuckets . remove ( testName ) ; specification = requiredTests . get ( testName ) ; } else if ( dynamicTests . contains ( testName ) ) { // resolved by dynamic filter isRequired = false ; knownBuckets = Collections . emptyMap ( ) ; specification = new TestSpecification ( ) ; } else { // we don't care about this test continue ; } final ConsumableTestDefinition testDefinition = entry . getValue ( ) ; try { verifyTest ( testName , testDefinition , specification , knownBuckets , matrixSource , functionMapper , providedContext ) ; } catch ( IncompatibleTestMatrixException e ) { if ( isRequired ) { LOGGER . error ( String . format ( "Unable to load test matrix for a required test %s" , testName ) , e ) ; resultBuilder . recordError ( testName , e ) ; } else { LOGGER . info ( String . format ( "Unable to load test matrix for a dynamic test %s" , testName ) , e ) ; resultBuilder . recordIncompatibleDynamicTest ( testName , e ) ; } } } // TODO mjs - is this check additive? resultBuilder . recordAllMissing ( allTestsKnownBuckets . keySet ( ) ) ; resultBuilder . recordVerifiedRules ( providedContext . shouldEvaluate ( ) ) ; final ProctorLoadResult loadResult = resultBuilder . build ( ) ; return loadResult ; }
Does not mutate the TestMatrix . Verifies that the test matrix contains all the required tests and that each required test is valid .