### Question:
MatrixChecker { public CheckMatrixResult checkMatrix( final Environment targetEnvironment, final String targetTestName, @Nullable final TestDefinition newDefinition ) { final TestMatrixVersion tmv = new TestMatrixVersion(); tmv.setAuthor("author"); tmv.setVersion(""); tmv.setDescription("fake matrix for validation of " + targetTestName); tmv.setPublished(new Date()); final TestMatrixDefinition tmd = new TestMatrixDefinition(); if (newDefinition != null) { tmd.setTests(ImmutableMap.of(targetTestName, newDefinition)); } tmv.setTestMatrixDefinition(tmd); final TestMatrixArtifact artifact = ProctorUtils.convertToConsumableArtifact(tmv); final ImmutableList.Builder<String> errorsBuilder = ImmutableList.builder(); final Set<AppVersion> clients = specificationSource.activeClients(targetEnvironment, targetTestName); for (final AppVersion client : clients) { LOGGER.info("Verifying artifact against : cached " + client + " for " + targetTestName); final RemoteSpecificationResult result = specificationSource .getRemoteResult(targetEnvironment, client); final ProctorSpecifications specifications = result.getSpecifications(); if (specifications == null) { LOGGER.error( "Unexpectedly " + client + " returned null specifications" + ". Skipping validation." ); continue; } for (final ProctorSpecification specification : specifications.asSet()) { final String error = verifyAndReturnError( specification, artifact, targetTestName, client ); if (error != null) { errorsBuilder.add(error); } } } final ImmutableList<String> errors = errorsBuilder.build(); final boolean greatSuccess = errors.isEmpty(); return new CheckMatrixResult(greatSuccess, errors); } @Autowired  MatrixChecker(
            final ProctorSpecificationSource specificationSource
    ); CheckMatrixResult checkMatrix(
            final Environment targetEnvironment,
            final String targetTestName,
            @Nullable final TestDefinition newDefinition
    );  }### Answer:
@Test public void testCheckMatrix() { final Environment environment = Environment.PRODUCTION; final String targetTestName = "sample_tst"; final String unrelatedTestName = "another_test"; final AppVersion app = new AppVersion("app", "v1"); final int expectedBucketValue = 0; final int unknownBucketValue = 1; final ProctorSpecification targetSpec = stubSpecification( targetTestName, stubTestSpecification(expectedBucketValue) ); final ProctorSpecification unrelatedSpec = stubSpecification( unrelatedTestName, stubTestSpecification(expectedBucketValue) ); final ProctorSpecificationSource source = mock(ProctorSpecificationSource.class); when(source.activeClients(eq(environment), eq(targetTestName))) .thenReturn(Collections.singleton(app)); final RemoteSpecificationResult result = stubResult( unrelatedSpec, targetSpec, unrelatedSpec, unrelatedSpec, unrelatedSpec, unrelatedSpec ); when(source.getRemoteResult(eq(environment), eq(app))) .thenReturn(result); final MatrixChecker checker = new MatrixChecker(source); assertThat( checker.checkMatrix( environment, targetTestName, stubDefinition(unknownBucketValue) ).getErrors() ).containsExactly( "app@v1 cannot load test 'sample_tst':" + " Allocation range in sample_tst from app@v1 refers to" + " unknown bucket value(s) [1] with length > 0" ); assertThat( checker.checkMatrix( environment, targetTestName, stubDefinition(expectedBucketValue) ).getErrors() ).isEmpty(); assertThat( checker.checkMatrix( environment, targetTestName, null ).getErrors() ).containsExactly( "app@v1 requires test 'sample_tst'" ); }