Buggy code:
public class SampleEntryTestsForTypeProvider extends BaseQueryProvider { private TestDAO testDAO = new TestDAOImpl ( ) ; private PanelDAO panelDAO = new PanelDAOImpl ( ) ; private static final String USER_TEST_SECTION_ID ; private static final String VARIABLE_SAMPLE_TYPE_ID ; private boolean isVariableTypeOfSample ; @ Override public void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } private String createSearchResultXML ( String sampleType , StringBuilder xml ) { String success = VALID ; <START_BUG> List < Test > tests = TypeOfSampleUtil . getTestListBySampleTypeId ( sampleType , true ) ; <END_BUG> Collections . sort ( tests , new Comparator < Test > ( ) { @ Override public int compare ( Test t1 , Test t2 ) { if ( ( GenericValidator . isBlankOrNull ( t1 . getSortOrder ( ) ) ) || ( GenericValidator . isBlankOrNull ( t2 . getSortOrder ( ) ) ) ) { return TestService . getUserLocalizedTestName ( t1 ) . compareTo ( TestService . getUserLocalizedTestName ( t2 ) ) ; } try { int t1Sort = Integer . parseInt ( t1 . getSortOrder ( ) ) ; int t2Sort = Integer . parseInt ( t2 . getSortOrder ( ) ) ; if ( t1Sort > t2Sort ) { return 1 ; } else if ( t1Sort < t2Sort ) { return - 1 ; } else { return 0 ; } } catch ( NumberFormatException e ) { return TestService . getUserLocalizedTestName ( t1 ) . compareTo ( TestService . getUserLocalizedTestName ( t2 ) ) ; } } } ) ; if ( isVariableTypeOfSample ) { xml . append ( "<variableSampleType//>" ) ; } addTests ( tests , xml ) ; List < TypeOfSamplePanel > panelList = getPanelList ( sampleType ) ; List < SampleEntryTestsForTypeProvider . PanelTestMap > panelMap = linkTestsToPanels ( panelList , tests ) ; addPanels ( panelMap , xml ) ; return success ; } private void addTests ( List < Test > tests , StringBuilder xml ) { } private void addTest ( Test test , StringBuilder xml ) { } private void addVariableSampleTypes ( Test test , StringBuilder xml ) { } private void addPanels ( List < SampleEntryTestsForTypeProvider . PanelTestMap > panelMap , StringBuilder xml ) { } private List < SampleEntryTestsForTypeProvider . PanelTestMap > sortPanels ( List < SampleEntryTestsForTypeProvider . PanelTestMap > panelMap ) { } private void addPanel ( SampleEntryTestsForTypeProvider . PanelTestMap testMap , StringBuilder xml ) { } private List < TypeOfSamplePanel > getPanelList ( String sampleType ) { } private List < SampleEntryTestsForTypeProvider . PanelTestMap > linkTestsToPanels ( List < TypeOfSamplePanel > panelList , List < Test > tests ) { } @ SuppressWarnings ( "unchecked" ) private String getTestIndexesForPanels ( String panelId , Map < String , Integer > testIdOrderMap , PanelItemDAO panelItemDAO ) { } private String getDerivedNameFromPanel ( PanelItem item ) { } public class PanelTestMap { private String name ; private String testMaps ; private String panelId ; private int panelOrder ; public PanelTestMap ( String panelId , int panelOrder , String panelName , String map ) { } public String getName ( ) { } public String getTestMaps ( ) { } public String getPanelId ( ) { } public int getPanelOrder ( ) { } } }

Fix:
List < Test > tests = TypeOfSampleUtil . getActiveTestsBySampleTypeId ( sampleType , true ) ;