ru.yandex.qatools.allure.utils.AnnotationManager Maven / Gradle / Ivy
package ru.yandex.qatools.allure.utils;
import ru.yandex.qatools.allure.annotations.*;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.events.TestCaseStartedEvent;
import ru.yandex.qatools.allure.events.TestSuiteStartedEvent;
import ru.yandex.qatools.allure.model.*;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import static ru.yandex.qatools.allure.config.AllureModelUtils.createFeatureLabel;
import static ru.yandex.qatools.allure.config.AllureModelUtils.createSeverityLabel;
import static ru.yandex.qatools.allure.config.AllureModelUtils.createStoryLabel;
/**
* @author Dmitry Baev [email protected]
* Date: 13.12.13
*/
public class AnnotationManager {
private Collection annotations;
public AnnotationManager(Collection annotations) {
this.annotations = annotations;
}
public AnnotationManager(Annotation... annotations) {
this.annotations = Arrays.asList(annotations);
}
public void update(TestSuiteStartedEvent event) {
if (isTitleAnnotationPresent()) {
event.setTitle(getTitle());
}
if (isDescriptionAnnotationPresent()) {
event.setDescription(getDescription());
}
if (isStoriesAnnotationPresent()) {
event.getLabels().addAll(getStoryLabels());
}
if (isFeaturesAnnotationPresent()) {
event.getLabels().addAll(getFeatureLabels());
}
}
public void update(TestCaseStartedEvent event) {
if (isTitleAnnotationPresent()) {
event.setTitle(getTitle());
}
if (isDescriptionAnnotationPresent()) {
event.setDescription(getDescription());
}
if (isStoriesAnnotationPresent()) {
event.getLabels().addAll(getStoryLabels());
}
if (isFeaturesAnnotationPresent()) {
event.getLabels().addAll(getFeatureLabels());
}
if (isSeverityAnnotationPresent()) {
event.getLabels().add(createSeverityLabel(getSeverity()));
}
}
public boolean isTitleAnnotationPresent() {
return isAnnotationPresent(Title.class);
}
public boolean isDescriptionAnnotationPresent() {
return isAnnotationPresent(Description.class);
}
public boolean isSeverityAnnotationPresent() {
return isAnnotationPresent(Severity.class);
}
public boolean isStoriesAnnotationPresent() {
return isAnnotationPresent(Stories.class);
}
public boolean isFeaturesAnnotationPresent() {
return isAnnotationPresent(Features.class);
}
public String getTitle() {
return getAnnotation(Title.class).value();
}
public ru.yandex.qatools.allure.model.Description getDescription() {
Description description = getAnnotation(Description.class);
return new ru.yandex.qatools.allure.model.Description()
.withValue(description.value())
.withType(description.type());
}
public SeverityLevel getSeverity() {
return getAnnotation(Severity.class).value();
}
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy