Search in sources :

Example 1 with ResourceExporter

use of org.jbehave.core.io.rest.ResourceExporter in project jbehave-core by jbehave.

the class RESTSteps method whenStoriesAreExported.

@When("stories in $sourcePath are exported to $rootURI")
public void whenStoriesAreExported(String sourcePath, String rootURI) {
    ResourceExporter exporter = new ExportFromFilesystem(resourceIndexer(), resourceupLoader(), sourcePath, ".story", "", "**/*.story");
    exporter.exportResources(rootURI);
}
Also used : ResourceExporter(org.jbehave.core.io.rest.ResourceExporter) ExportFromFilesystem(org.jbehave.core.io.rest.filesystem.ExportFromFilesystem) When(org.jbehave.core.annotations.When)

Example 2 with ResourceExporter

use of org.jbehave.core.io.rest.ResourceExporter in project jbehave-core by jbehave.

the class ExportFromFilesystemBehaviour method canExportFromFilesystem.

@Test
public void canExportFromFilesystem() throws IOException {
    // Given
    ResourceIndexer indexer = mock(ResourceIndexer.class);
    ResourceUploader uploader = mock(ResourceUploader.class);
    String rootURI = "http://wiki";
    String text1 = "story1";
    String text2 = "story2";
    String sourcePath = "target/stories";
    String sourceExt = ".story";
    String sourceSyntax = "jbehave/3.0";
    File file1 = new File(sourcePath + "/A_story" + sourceExt);
    write(text1, file1);
    File file2 = new File(sourcePath + "/Another_story" + sourceExt);
    write(text2, file2);
    Map<String, Resource> index = new HashMap<>();
    Resource aResource = new Resource(rootURI + "/A_story");
    index.put("A_story", aResource);
    Resource anotherResource = new Resource(rootURI + "/Another_story");
    index.put("Another_story", anotherResource);
    String includes = "**";
    when(indexer.indexResources(rootURI, sourcePath, sourceSyntax, includes)).thenReturn(index);
    // When
    ResourceExporter exporter = new ExportFromFilesystem(indexer, uploader, sourcePath, sourceExt, sourceSyntax, includes);
    exporter.exportResources(rootURI);
    // Then
    verify(uploader).uploadResource(aResource);
    verify(uploader).uploadResource(anotherResource);
}
Also used : ResourceUploader(org.jbehave.core.io.rest.ResourceUploader) HashMap(java.util.HashMap) Resource(org.jbehave.core.io.rest.Resource) ResourceExporter(org.jbehave.core.io.rest.ResourceExporter) File(java.io.File) ResourceIndexer(org.jbehave.core.io.rest.ResourceIndexer) Test(org.junit.Test)

Example 3 with ResourceExporter

use of org.jbehave.core.io.rest.ResourceExporter in project jbehave-core by jbehave.

the class ExportFromFilesystemMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        getLog().info("Exporting from filesystem resources to REST root URI " + restRootURI);
        ResourceExporter exporter = createExporter();
        exporter.exportResources(restRootURI);
    } catch (Exception e) {
        String message = "Failed to export from filesystem resources to REST root URI " + restRootURI;
        getLog().warn(message);
        throw new MojoExecutionException(message, e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ResourceExporter(org.jbehave.core.io.rest.ResourceExporter) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

ResourceExporter (org.jbehave.core.io.rest.ResourceExporter)3 File (java.io.File)1 HashMap (java.util.HashMap)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 When (org.jbehave.core.annotations.When)1 Resource (org.jbehave.core.io.rest.Resource)1 ResourceIndexer (org.jbehave.core.io.rest.ResourceIndexer)1 ResourceUploader (org.jbehave.core.io.rest.ResourceUploader)1 ExportFromFilesystem (org.jbehave.core.io.rest.filesystem.ExportFromFilesystem)1 Test (org.junit.Test)1