-
-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You can now include downloadable files in the report data
- Loading branch information
Showing
7 changed files
with
85 additions
and
16 deletions.
There are no files selected for viewing
8 changes: 1 addition & 7 deletions
8
serenity-core/src/main/java/net/serenitybdd/core/reports/AndContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
package net.serenitybdd.core.reports; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
import java.nio.file.Path; | ||
|
||
public interface AndContent { | ||
public interface AndContent extends FromFile { | ||
void andContents(String contents); | ||
void fromFile(Path source) throws IOException; | ||
void fromFile(Path source, Charset encoding) throws IOException; | ||
} |
11 changes: 11 additions & 0 deletions
11
serenity-core/src/main/java/net/serenitybdd/core/reports/FromFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.serenitybdd.core.reports; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
import java.nio.file.Path; | ||
|
||
public interface FromFile { | ||
void fromFile(Path source) throws IOException; | ||
void fromFile(Path source, Charset encoding) throws IOException; | ||
FromFile downloadable(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
serenity-model/src/main/java/net/thucydides/core/model/Downloadables.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.thucydides.core.model; | ||
|
||
import net.serenitybdd.core.environment.ConfiguredEnvironment; | ||
import net.thucydides.core.webdriver.Configuration; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.*; | ||
import java.util.UUID; | ||
|
||
public class Downloadables { | ||
public static String copyDownloadableFileFrom(Path source) throws IOException { | ||
Configuration configuration = ConfiguredEnvironment.getConfiguration(); | ||
File outputDirectory = configuration.getOutputDirectory(); | ||
|
||
Path downloadDirectory= outputDirectory.toPath().resolve("downloadable"); | ||
Files.createDirectories(downloadDirectory); | ||
|
||
Path relativePath = downloadableCopyOf(source); | ||
Path downloadablePath = outputDirectory.toPath().resolve(relativePath); | ||
|
||
Files.copy(source, downloadablePath, StandardCopyOption.REPLACE_EXISTING); | ||
|
||
return relativePath.toString(); | ||
} | ||
|
||
private static Path downloadableCopyOf(Path path) { | ||
return Paths.get("downloadable", "downloadable-" + UUID.randomUUID() + "-" + path.getFileName().toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters