Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion allure-java-commons-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ configurations {
}

dependencies {
compile project(':allure-java-commons')
compile('commons-io:commons-io')
compile(project(':allure-java-commons'))
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
import io.qameta.allure.AllureResultsWriter;
import io.qameta.allure.model.TestResult;
import io.qameta.allure.model.TestResultContainer;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
* @author Egor Borisov ehborisov@gmail.com
*/
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public class AllureResultsWriterStub implements AllureResultsWriter {

private final List<TestResult> testResults = new CopyOnWriteArrayList<>();
private final List<TestResultContainer> testContainers = new CopyOnWriteArrayList<>();
private final Map<String, byte[]> attachments = new ConcurrentHashMap<>();

public void write(final TestResult testResult) {
testResults.add(testResult);
Expand All @@ -25,7 +31,12 @@ public void write(final TestResultContainer testResultContainer) {
}

public void write(final String source, final InputStream attachment) {
//not implemented
try {
final byte[] bytes = IOUtils.toByteArray(attachment);
attachments.put(source, bytes);
} catch (IOException e) {
throw new RuntimeException("Could not read attachment content " + source, e);
}
}

public List<TestResult> getTestResults() {
Expand All @@ -35,4 +46,8 @@ public List<TestResult> getTestResults() {
public List<TestResultContainer> getTestContainers() {
return testContainers;
}

public Map<String, byte[]> getAttachments() {
return attachments;
}
}
Loading