All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cucumber.guice.GuiceBackend Maven / Gradle / Ivy

There is a newer version: 7.20.1
Show newest version
package io.cucumber.guice;

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.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 GuiceBackend implements Backend {

    private final Container container;
    private final ClasspathScanner classFinder;

    GuiceBackend(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(InjectorSource.class::isAssignableFrom)
                .distinct()
                .forEach(container::addClass);
    }

    @Override
    public void buildWorld() {

    }

    @Override
    public void disposeWorld() {

    }

    @Override
    public Snippet getSnippet() {
        return null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy