io.cucumber.spring.SpringBackend Maven / Gradle / Ivy
package io.cucumber.spring;
import io.cucumber.core.backend.Backend;
import io.cucumber.core.backend.Container;
import io.cucumber.core.backend.Glue;
import io.cucumber.core.backend.Snippet;
import io.cucumber.core.resource.ClasspathScanner;
import io.cucumber.core.resource.ClasspathSupport;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
import static io.cucumber.core.resource.ClasspathSupport.CLASSPATH_SCHEME;
final class SpringBackend implements Backend {
private final Container container;
private final ClasspathScanner classFinder;
SpringBackend(Container container, Supplier classLoaderSupplier) {
this.container = container;
this.classFinder = new ClasspathScanner(classLoaderSupplier);
}
@Override
public void loadGlue(Glue glue, List gluePaths) {
gluePaths.stream()
.filter(gluePath -> CLASSPATH_SCHEME.equals(gluePath.getScheme()))
.map(ClasspathSupport::packageName)
.map(classFinder::scanForClassesInPackage)
.flatMap(Collection::stream)
.filter(SpringFactory::hasCucumberContextConfiguration)
.filter(this::checkIfOfClassTypeAndNotAbstract)
.distinct()
.forEach(container::addClass);
}
@Override
public void buildWorld() {
}
@Override
public void disposeWorld() {
}
@Override
public Snippet getSnippet() {
return null;
}
private boolean checkIfOfClassTypeAndNotAbstract(Class> clazz) {
return !clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy