33import io .qameta .allure .AllureResultsWriter ;
44import io .qameta .allure .model .TestResult ;
55import io .qameta .allure .model .TestResultContainer ;
6+ import org .apache .commons .io .IOUtils ;
67
8+ import java .io .IOException ;
79import java .io .InputStream ;
810import java .util .List ;
11+ import java .util .Map ;
12+ import java .util .concurrent .ConcurrentHashMap ;
913import java .util .concurrent .CopyOnWriteArrayList ;
1014
1115/**
1216 * @author Egor Borisov ehborisov@gmail.com
1317 */
18+ @ SuppressWarnings ("PMD.AvoidThrowingRawExceptionTypes" )
1419public class AllureResultsWriterStub implements AllureResultsWriter {
1520
1621 private final List <TestResult > testResults = new CopyOnWriteArrayList <>();
1722 private final List <TestResultContainer > testContainers = new CopyOnWriteArrayList <>();
23+ private final Map <String , byte []> attachments = new ConcurrentHashMap <>();
1824
1925 public void write (final TestResult testResult ) {
2026 testResults .add (testResult );
@@ -25,7 +31,12 @@ public void write(final TestResultContainer testResultContainer) {
2531 }
2632
2733 public void write (final String source , final InputStream attachment ) {
28- //not implemented
34+ try {
35+ final byte [] bytes = IOUtils .toByteArray (attachment );
36+ attachments .put (source , bytes );
37+ } catch (IOException e ) {
38+ throw new RuntimeException ("Could not read attachment content " + source , e );
39+ }
2940 }
3041
3142 public List <TestResult > getTestResults () {
@@ -35,4 +46,8 @@ public List<TestResult> getTestResults() {
3546 public List <TestResultContainer > getTestContainers () {
3647 return testContainers ;
3748 }
49+
50+ public Map <String , byte []> getAttachments () {
51+ return attachments ;
52+ }
3853}
0 commit comments