package urjc;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by nexmaniosis on 12/10/17.
 */
public class JUnitListing {

    private final String PROJECT_ABS_PATH = "/Users/nexmaniosis/Google Drive/Universidad/TestingLibs - DOCS/junit5-vanilla-maven/";
    private final String REPORTS_FOLDER = "target/surefire-reports/";

    private File reportsDirectory;

    private File[] reports_nofilter;

    private File[] reports_filter;

    private List reports_filter_name;

    /*

     */
    private void setReportsDirectory(String path){
        reportsDirectory = new File(path);
    }

    /*
        Get every file on the folder. No filter.
     */

    private void setFiles(File folder){
        reports_nofilter = folder.listFiles();
    }

    public File getReportsDirectory() {
        return reportsDirectory;
    }

    public File[] getReportsNoFilter() {
        return reports_nofilter;
    }

    /*

    */

    private void setTestList(){

        List testList = new ArrayList<String>();

        for(File f: getReportsNoFilter()){
            testList.add(extractName(f));
        }

        reports_filter_name = testList;

    }

    public List getReports_filter_name() {
        return reports_filter_name;
    }

    private String extractName(File f){
        return f.getName();
    }
}

package urjc;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.FilenameUtils;

/**
 * Created by nexmaniosis on 12/10/17.
 */
public class JUnitListing {

    private final String REPORTS_FOLDER = "target/surefire-reports/";

    private File reportsDirectory;

    public JUnitListing(String projectPath){
        reportsDirectory = new File(projectPath + REPORTS_FOLDER);

    }

    // --- //
    // GET //
    // --- //

    public File getReportsDirectory() {
        return reportsDirectory;
    }

    public File[] getReports_no_filter(File reportsFolder) {
        return reportsFolder.listFiles();
    }

    public List getReportsName_filter() {

        List testList = new ArrayList<String>();

        for(File f: this.getReports_no_filter(this.getReportsDirectory())){
            if(isXML(f)) testList.add(filterName(extractName(f)));
        }

        return testList;
    }

    // ------ //
    // STATIC //
    // ------ //

    private static String extractName(File f){
        return f.getName();
    }
    private static Boolean isXML(File f){ return FilenameUtils.getExtension(f.getName()).equals("xml"); }
    private static String filterName(String n){ return FilenameUtils.removeExtension(n); }
}

remove setters, added constructor. Added: extractName, isXML and FilterName. Finished getReportsName with XML filtering