src/main/java/com/openbank/util/HermesStepListener.java
@Override
    public void testSuiteFinished() {
        this.testsWithJiraId.forEach((String jiraId, TestOutcome result) -> {
            JiraXrayApi.updateTestStatus(result.getResult(), jiraId);
            String fileReportName = result.withQualifier(null).getHtmlReport();
            try {
                String filePath = DataSource.propertyReadSerenity("serenity.outputDirectory") + File.separator + fileReportName;
                File fileReport = new File(filePath);
                File fileReportBucket = new File(DataSource.propertyReadSerenity("serenity.outputDirectory") + File.separator + "report.html");
                if (fileReportBucket.exists()) {
                    fileReportBucket.delete();
                }
                if (fileReportBucket.createNewFile()) {
                    FileUtils.copyFile(fileReport, fileReportBucket);
                    String date = result.getEndTime().toString();
                    date = date.replace("/", "-");
                    URL bucketURL = new URL(DataSource.propertyReadSerenity("s3.bucket.url"));
                    Document doc = Jsoup.parse(fileReportBucket, "UTF-8");
                    Elements tagsWithHref = doc.head().getElementsByAttribute("href");
                    for (Element tagHref : tagsWithHref) {
                        tagHref.attr("href", bucketURL.toString() + tagHref.attr("href"));
                    }
                    Elements tagsWithSrc = doc.head().getElementsByAttribute("src");
                    for (Element tagSrc : tagsWithSrc) {
                        tagSrc.attr("src", bucketURL.toString() + tagSrc.attr("src"));
                    }
                    Elements tagsWithImg = doc.body().getElementsByTag("img");
                    for (Element tagSrc : tagsWithImg) {
                        if (tagSrc.hasAttr("src"))
                            tagSrc.attr("src", bucketURL.toString() + tagSrc.attr("src"));
                    }
                    FileUtils.writeStringToFile(fileReportBucket, doc.outerHtml(), "UTF-8");
                    S3API.uploadReport(jiraId + "/" + date + "/" + "report.html", DataSource.propertyReadSerenity("s3.bucket.name"), fileReportBucket);
                    JiraXrayApi.updateDescriptionWithS3Report(jiraId, bucketURL + jiraId + "/" + URLEncoder.encode(date, "UTF-8") + "/report.html");
                    FileUtils.deleteDirectory(new File(DataSource.propertyReadSerenity("serenity.tempFeaturesDirectory")));
                }

            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
/**
     * End of a test case or story.
     */
End of a test case or story.
End of a test case or story .
@Override
    public void testSuiteFinished() {
        this.testsWithJiraId.forEach((String jiraId, TestOutcome result) -> {
            JiraXrayApi.updateTestStatus(result.getResult(), jiraId);
            String fileReportName = result.withQualifier(null).getHtmlReport();
            try {
                String filePath = DataSource.propertyReadSerenity("serenity.outputDirectory") + File.separator + fileReportName;
                File fileReport = new File(filePath);
                File fileReportBucket = new File(DataSource.propertyReadSerenity("serenity.outputDirectory") + File.separator + "report.html");
                if (fileReportBucket.exists()) {
                    fileReportBucket.delete();
                }
                if (fileReportBucket.createNewFile()) {
                    FileUtils.copyFile(fileReport, fileReportBucket);
                    String date = result.getEndTime().toString();
                    date = date.replace("/", "-");
                    URL bucketURL = new URL(DataSource.propertyReadSerenity("s3.bucket.url"));
                    Document doc = Jsoup.parse(fileReportBucket, "UTF-8");
                    Elements tagsWithHref = doc.head().getElementsByAttribute("href");
                    for (Element tagHref : tagsWithHref) {
                        tagHref.attr("href", bucketURL.toString() + tagHref.attr("href"));
                    }
                    Elements tagsWithSrc = doc.head().getElementsByAttribute("src");
                    for (Element tagSrc : tagsWithSrc) {
                        tagSrc.attr("src", bucketURL.toString() + tagSrc.attr("src"));
                    }
                    Elements tagsWithImg = doc.body().getElementsByTag("img");
                    for (Element tagSrc : tagsWithImg) {
                        if (tagSrc.hasAttr("src"))
                            tagSrc.attr("src", bucketURL.toString() + tagSrc.attr("src"));
                    }
                    FileUtils.writeStringToFile(fileReportBucket, doc.outerHtml(), "UTF-8");
                    S3API.uploadReport(jiraId + "/" + date + "/" + "report.html", DataSource.propertyReadSerenity("s3.bucket.name"), fileReportBucket);
                    JiraXrayApi.updateDescriptionWithS3Report(jiraId, bucketURL + jiraId + "/" + URLEncoder.encode(date, "UTF-8") + "/report.html");
                    FileUtils.deleteDirectory(new File(DataSource.propertyReadSerenity("serenity.tempFeaturesDirectory")));
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
@ Override public void testSuiteFinished ( ) { this . testsWithJiraId . forEach ( ( String jiraId , TestOutcome result ) -> { JiraXrayApi . updateTestStatus ( result . getResult ( ) , jiraId ) ; String fileReportName = result . withQualifier ( null ) . getHtmlReport ( ) ; try { String filePath = DataSource . propertyReadSerenity ( "serenity.outputDirectory" ) + File . separator + fileReportName ; File fileReport = new File ( filePath ) ; File fileReportBucket = new File ( DataSource . propertyReadSerenity ( "serenity.outputDirectory" ) + File . separator + "report.html" ) ; if ( fileReportBucket . exists ( ) ) { fileReportBucket . delete ( ) ; } if ( fileReportBucket . createNewFile ( ) ) { FileUtils . copyFile ( fileReport , fileReportBucket ) ; String date = result . getEndTime ( ) . toString ( ) ; date = date . replace ( "/" , "-" ) ; URL bucketURL = new URL ( DataSource . propertyReadSerenity ( "s3.bucket.url" ) ) ; Document doc = Jsoup . parse ( fileReportBucket , "UTF-8" ) ; Elements tagsWithHref = doc . head ( ) . getElementsByAttribute ( "href" ) ; for ( Element tagHref : tagsWithHref ) { tagHref . attr ( "href" , bucketURL . toString ( ) + tagHref . attr ( "href" ) ) ; } Elements tagsWithSrc = doc . head ( ) . getElementsByAttribute ( "src" ) ; for ( Element tagSrc : tagsWithSrc ) { tagSrc . attr ( "src" , bucketURL . toString ( ) + tagSrc . attr ( "src" ) ) ; } Elements tagsWithImg = doc . body ( ) . getElementsByTag ( "img" ) ; for ( Element tagSrc : tagsWithImg ) { if ( tagSrc . hasAttr ( "src" ) ) tagSrc . attr ( "src" , bucketURL . toString ( ) + tagSrc . attr ( "src" ) ) ; } FileUtils . writeStringToFile ( fileReportBucket , doc . outerHtml ( ) , "UTF-8" ) ; S3API . uploadReport ( jiraId + "/" + date + "/" + "report.html" , DataSource . propertyReadSerenity ( "s3.bucket.name" ) , fileReportBucket ) ; JiraXrayApi . updateDescriptionWithS3Report ( jiraId , bucketURL + jiraId + "/" + URLEncoder . encode ( date , "UTF-8" ) + "/report.html" ) ; FileUtils . deleteDirectory ( new File ( DataSource . propertyReadSerenity ( "serenity.tempFeaturesDirectory" ) ) ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } ) ; }
End of a test case or story.
End of a test case or story .