com.aventstack.extentreports.Status Maven / Gradle / Ivy
package com.aventstack.extentreports;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* List of allowed status for {@link com.aventstack.extentreports.model.Log}
*/
public enum Status implements Serializable {
PASS,
FAIL,
FATAL,
ERROR,
WARNING,
INFO,
DEBUG,
SKIP;
private static List statusHierarchy = Arrays.asList(
Status.FATAL,
Status.FAIL,
Status.ERROR,
Status.WARNING,
Status.SKIP,
Status.PASS,
Status.INFO,
Status.DEBUG
);
/**
* Returns the hierarchical list of status, in the below order:
*
*
* - FATAL
* - FAIL
* - ERROR
* - WARNING
* - SKIP
* - PASS
* - DEBUG
* - INFO
*
*
* @return Hierarchical list of status
*/
public static List getStatusHierarchy() {
return statusHierarchy;
}
public static Status getHighestStatus(Collection statusCollection) {
Status highestStatus = Status.PASS;
if (statusCollection == null || statusCollection.isEmpty()) {
return highestStatus;
}
for (Status status : statusCollection) {
highestStatus = Status.getStatusHierarchy().indexOf(status) < Status.getStatusHierarchy().indexOf(highestStatus)
? status
: highestStatus;
}
return highestStatus;
}
static void setStatusHierarchy(List statusHierarchy) {
Status.statusHierarchy = statusHierarchy;
}
static void resetStatusHierarchy() {
List statusHierarchy = Arrays.asList(
Status.FATAL,
Status.FAIL,
Status.ERROR,
Status.WARNING,
Status.SKIP,
Status.PASS,
Status.INFO,
Status.DEBUG
);
setStatusHierarchy(statusHierarchy);
}
@Override
public String toString() {
switch (this) {
case PASS: return "pass";
case FAIL: return "fail";
case FATAL: return "fatal";
case ERROR: return "error";
case WARNING: return "warning";
case INFO: return "info";
case DEBUG: return "debug";
case SKIP: return "skip";
default: return "unknown";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy