net.serenitybdd.plugins.jirarequirements.SerialRequirementsLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-jira-requirements-provider Show documentation
Show all versions of serenity-jira-requirements-provider Show documentation
Read Serenity requirements from JIRA Story and Epic cards
The newest version!
package net.serenitybdd.plugins.jirarequirements;
import net.serenitybdd.plugins.jira.domain.IssueSummary;
import net.thucydides.model.requirements.model.Requirement;
import net.thucydides.model.util.EnvironmentVariables;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Created by john on 28/01/2016.
*/
public class SerialRequirementsLoader implements RequirementsLoader {
private final EnvironmentVariables environmentVariables;
private final RequirementsAdaptor adaptor;
private final JIRARequirementsProvider requirementsProvider;
public SerialRequirementsLoader(EnvironmentVariables environmentVariables, JIRARequirementsProvider requirementsProvider) {
this.environmentVariables = environmentVariables;
this.adaptor = new RequirementsAdaptor(environmentVariables);
this.requirementsProvider = requirementsProvider;
}
private final org.slf4j.Logger logger = LoggerFactory.getLogger(SerialRequirementsLoader.class);
public List loadFrom(List rootRequirementIssues) {
final List requirements = Collections.synchronizedList(new ArrayList());
long t0 = System.currentTimeMillis();
logger.debug("Loading {} requirements", rootRequirementIssues.size());
for (final IssueSummary issueSummary : rootRequirementIssues) {
Requirement requirement = adaptor.requirementFrom(issueSummary);
List childRequirements = requirementsProvider.findChildrenFor(requirement, 0);
requirements.add(requirement.withChildren(childRequirements));
}
logger.debug("Loading requirements done in {} ms", System.currentTimeMillis() - t0);
return requirements;
}
}