All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.relevantcodes.extentreports.LogCounts Maven / Gradle / Ivy

There is a newer version: 2.41.2
Show newest version
package com.relevantcodes.extentreports;

import java.util.HashMap;
import java.util.Iterator;

import com.relevantcodes.extentreports.model.Log;
import com.relevantcodes.extentreports.model.Test;

public class LogCounts {
    private int pass = 0;
    private int fail = 0;
    private int fatal = 0;
    private int error = 0;
    private int warning = 0;
    private int info = 0;
    private int skip = 0;
    private int unknown = 0;
    
    // counts each type of log for the test
    public HashMap getLogCounts(Test test) {
    	Iterator iter = test.logIterator();
    	Log log;
    	
    	while (iter.hasNext()) {
    		log = iter.next();
    		
            if (log.getLogStatus() == LogStatus.PASS)
                pass++; 
            else if (log.getLogStatus() == LogStatus.FAIL)
            	fail++;
            else if (log.getLogStatus() == LogStatus.FATAL)
            	fatal++;
            else if (log.getLogStatus() == LogStatus.ERROR)
            	error++;
            else if (log.getLogStatus() == LogStatus.WARNING)
            	warning++;
            else if (log.getLogStatus() == LogStatus.INFO)
            	info++;
            else if (log.getLogStatus() == LogStatus.SKIP)
            	skip++;
            else if (log.getLogStatus() == LogStatus.UNKNOWN)
            	unknown++;
        }

        // recursively count status events
        for (Test node : test.getNodeList()) {
            getLogCounts(node);
        }
        
        HashMap logCounts = new HashMap();
    	
        logCounts.put(LogStatus.PASS, pass);
    	logCounts.put(LogStatus.FAIL, fail);
    	logCounts.put(LogStatus.FATAL, fatal);
    	logCounts.put(LogStatus.ERROR, error);
    	logCounts.put(LogStatus.WARNING, warning);
    	logCounts.put(LogStatus.INFO, info);
    	logCounts.put(LogStatus.SKIP, skip);
    	logCounts.put(LogStatus.UNKNOWN, unknown);
    	
    	return logCounts;
    }

    public LogCounts() { }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy