edu.odu.cs.cs350.yellow1.jar.ExecutionResults.java Source code

Java tutorial

Introduction

Here is the source code for edu.odu.cs.cs350.yellow1.jar.ExecutionResults.java

Source

/**
 *   Copyright (C) 2014  John Berlin
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see http://www.gnu.org/licenses/
 */

package edu.odu.cs.cs350.yellow1.jar;

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

import com.google.common.collect.ArrayListMultimap;

/**
 * This class is represents the execution history of a mutant and the test suite 
 * @author jberlin
 *
 */
public class ExecutionResults {
    private int numOfSucesses = 0;
    private int numOfFailurs = 0;
    private int numOfTestTillKill = 0;
    private String jarName;
    private boolean killed;
    private File killedFile = null;
    private ArrayListMultimap<Boolean, File> jarOutPuts;

    /**
     * Construct a new instance of ExecutionResults that signifies the mutant has been killed
     * @param numOfSucesses the number of times the mutant was ran and exited no failure
     * @param numOfFailurs  the number of times the mutant was ran and exited with failure
     * @param numOfTestTillKill the test number that killed the mutant 
     * @param jarName the name of the executable jar the mutant was run in
     * @param killed true the mutant was killed
     * @param killedFile the object representing the file that killed the mutant 
     * @param outFiles List of file object representing the standard out produced by the mutant exec
     * @param errFiles List of file object representing the standard err produced by the mutant exec
     */
    public ExecutionResults(int numOfSucesses, int numOfFailurs, int numOfTestTillKill, String jarName,
            boolean killed, File killedFile, List<File> outFiles, List<File> errFiles) {
        this.numOfSucesses = numOfSucesses;
        this.numOfFailurs = numOfFailurs;
        this.numOfTestTillKill = numOfTestTillKill;
        this.jarName = jarName;
        this.killed = killed;
        this.jarOutPuts = ArrayListMultimap.create();
        this.jarOutPuts.putAll(true, outFiles);
        this.jarOutPuts.putAll(false, errFiles);
        this.killedFile = killedFile;
    }

    /**
     * Construct a new instance of ExecutionResults that signifies the mutant has not been killed
     * @param numOfSucesses the number of times the mutant was ran and exited no failure
     * @param numOfFailurs  the number of times the mutant was ran and exited with failure
     * @param numOfTestTillKill the test number that killed the mutant 
     * @param jarName the name of the executable jar the mutant was run in
     * @param killed false the mutant was not killed killed
     * @param outFiles List of file object representing the standard out produced by the mutant exec
     * @param errFiles List of file object representing the standard err produced by the mutant exec
     */
    public ExecutionResults(int numOfSucesses, int numOfFailurs, int numOfTestTillKill, String jarName,
            boolean killed, List<File> outFiles, List<File> errFiles) {
        this.numOfSucesses = numOfSucesses;
        this.numOfFailurs = numOfFailurs;
        this.numOfTestTillKill = numOfTestTillKill;
        this.jarName = jarName;
        this.killed = killed;
        this.jarOutPuts = ArrayListMultimap.create();
        this.jarOutPuts.putAll(true, outFiles);
        this.jarOutPuts.putAll(false, errFiles);
        this.killedFile = null;
    }

    /**
     * 
     * @return the number of sucesseful executions of the mutant jar for all tests
     */
    public int getNumOfSucesses() {
        return numOfSucesses;
    }

    /**
     * 
     * @return  the number of failed executions of the mutant jar for all tests
     */
    public int getNumOfFailurs() {
        return numOfFailurs;
    }

    /**
     * 
     * @return the test number that killed the mutant
     */
    public int getNumOfTestTillKill() {
        return numOfTestTillKill;
    }

    /**
     * 
     * @return the name of the mutant jar ran 
     */
    public String getJarName() {
        return jarName;
    }

    /**
     * 
     * @return true|false if the mutant was killed or not
     */
    public boolean isKilled() {
        return killed;
    }

    /**
     * 
     * @return the file that killed the mutant if any
     */
    public File getKilledFile() {
        return killedFile;
    }

    /**
     * True for secussful outputs
     * False for error outputs
     * @return multimap containing all outputs generated by the mutant jar
     */
    public ArrayListMultimap<Boolean, File> getJarOutPuts() {
        return jarOutPuts;
    }

    /**
     * Get the file objects connected to the standard out of the mutants execution life if any
     * @return List of files containing the standard out
     */
    public List<File> getStandardOutput() {
        return jarOutPuts.get(true);
    }

    /**
     * Get the file objects connected to the standard error of the mutants execution life if any
     * @return List of files containing the standard error 
     */
    public List<File> getStandardErrOutput() {
        return jarOutPuts.get(false);
    }

    @Override
    public String toString() {
        return "ExecutionResults [numOfSucesses=" + numOfSucesses + ", numOfFailurs=" + numOfFailurs
                + ", numOfTestTillKill=" + numOfTestTillKill + ", "
                + (jarName != null ? "jarName=" + jarName + ", " : "") + "killed=" + killed + ", "
                + (killedFile != null ? "killedFile=" + killedFile + " " : "") + "]";
    }

}