io.qase.commons.CasesStorage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qase-java-commons Show documentation
Show all versions of qase-java-commons Show documentation
Qase TMS Reporter's common classes
The newest version!
package io.qase.commons;
import io.qase.commons.models.domain.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class CasesStorage {
private static final Logger logger = LoggerFactory.getLogger(CasesStorage.class);
private static final ThreadLocal CURRENT_CASE = new ThreadLocal<>();
public static void startCase(TestResult resultCreate) {
checkCaseIsNotInProgress();
CURRENT_CASE.set(resultCreate);
}
public static void stopCase() {
checkCaseIsInProgress();
CURRENT_CASE.remove();
}
public static TestResult getCurrentCase() {
checkCaseIsInProgress();
return CURRENT_CASE.get();
}
public static boolean isCaseInProgress() {
return CURRENT_CASE.get() != null;
}
private static void checkCaseIsInProgress() {
if (!isCaseInProgress()) {
logger.error("A case has not been started yet.");
}
}
private static void checkCaseIsNotInProgress() {
if (isCaseInProgress()) {
logger.error("Previous case is still in progress.");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy