private IMarker[] getSortedMarkersFromFile(String fileName) throws JavaModelException {
   IJavaElement fileToScan = TestingUtils.elementFromProject(testProject, fileName);
   IMarker[] markers = TestingUtils.getAllMarkersInResource(fileToScan.getCorrespondingResource());
   // the markers get sorted first by bug name, then by line number, just like
   // the QuickFixTestPackages, so we have a reliable way to fix them
   // so we can assert properties more accurately.
   TestingUtils.sortMarkersByPatterns(markers);
   return markers;
 }
 private void scanUntilMarkers(String testResource) throws CoreException {
   scanForBugs(testResource);
   for (int i = 0; i < 3; i++) {
     IMarker[] markers = TestingUtils.getAllMarkersInResource(testProject, testResource);
     if (markers.length > 0) {
       return;
     }
     System.out.println("Trying again for bugs...");
     clearMarkersAndBugs();
     scanForBugs(testResource);
     TestingUtils.waitForUiEvents(1000);
   }
   fail("Did not find any markers... tried 3 times");
 }
  private void assertBugPatternsMatch(List<QuickFixTestPackage> packages, String testResource)
      throws JavaModelException {
    IMarker[] markers = TestingUtils.getAllMarkersInResource(testProject, testResource);
    TestingUtils.sortMarkersByPatterns(markers);

    // packages and markers should now be lined up to match up one to one.
    assertEquals(
        "The number of markers is wrong, check your turned off detectors?",
        packages.size(),
        markers.length);

    TestingUtils.assertBugPatternsMatch(packages, markers);
    TestingUtils.assertLabelsAndDescriptionsMatch(packages, markers, resolutionSource);
    TestingUtils.assertLineNumbersMatch(packages, markers);
    TestingUtils.assertAllMarkersHaveResolutions(markers, resolutionSource);
  }