### Question:
MatrixChecker { @VisibleForTesting static String getErrorMessage(final AppVersion appVersion, final ProctorLoadResult proctorLoadResult) { final Map<String, IncompatibleTestMatrixException> testsWithErrors = proctorLoadResult.getTestErrorMap(); final Set<String> missingTests = proctorLoadResult.getMissingTests(); if (!testsWithErrors.isEmpty()) { final String testName = testsWithErrors.keySet().iterator().next(); final String errorMessage = testsWithErrors.get(testName).getMessage(); return String.format("%s cannot load test '%s': %s", appVersion, testName, errorMessage); } else if (!missingTests.isEmpty()) { return String.format("%s requires test '%s'", appVersion, missingTests.iterator().next()); } else { return ""; } } @Autowired  MatrixChecker(
            final ProctorSpecificationSource specificationSource
    ); CheckMatrixResult checkMatrix(
            final Environment targetEnvironment,
            final String targetTestName,
            @Nullable final TestDefinition newDefinition
    );  }### Answer:
@Test public void testGetErrorMessage_loadError() { final AppVersion appVersion = new AppVersion("TestApp", "a5efcc49c813e56aa7e35333aa8590515f5c061e"); final ProctorLoadResult result = new ProctorLoadResult( ImmutableMap.of( "check_tst", new IncompatibleTestMatrixException("Invalid test rule ${abc}") ), Collections.emptySet(), true ); assertEquals( "TestApp@a5efcc49c813e56aa7e35333aa8590515f5c061e cannot load test 'check_tst': Invalid test rule ${abc}", MatrixChecker.getErrorMessage(appVersion, result) ); }
@Test public void testGetErrorMessage_missingTest() { final AppVersion appVersion = new AppVersion("TestApp", "a5efcc49c813e56aa7e35333aa8590515f5c061e"); final ProctorLoadResult result = new ProctorLoadResult( Collections.emptyMap(), ImmutableSet.of("check_tst"), true ); assertEquals( "TestApp@a5efcc49c813e56aa7e35333aa8590515f5c061e requires test 'check_tst'", MatrixChecker.getErrorMessage(appVersion, result) ); }
@Test public void testGetErrorMessage_success() { final AppVersion appVersion = new AppVersion("TestApp", "a5efcc49c813e56aa7e35333aa8590515f5c061e"); final ProctorLoadResult result = new ProctorLoadResult( Collections.emptyMap(), Collections.emptySet(), true ); assertEquals( "", MatrixChecker.getErrorMessage(appVersion, result) ); }