-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from Invictum/34_StepProcessors_refactoring
34 step processors refactoring
- Loading branch information
Showing
40 changed files
with
790 additions
and
559 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/github/invictum/reportportal/EnhancedMessage.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,55 @@ | ||
package com.github.invictum.reportportal; | ||
|
||
import com.epam.reportportal.message.ReportPortalMessage; | ||
import com.epam.reportportal.message.TypeAwareByteSource; | ||
import rp.com.google.common.io.ByteSource; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Improved version of {@link ReportPortalMessage} that extended with details related to log level and date. | ||
* Isolates all the date required to emit log message to Report Portal server. | ||
*/ | ||
public class EnhancedMessage extends ReportPortalMessage { | ||
|
||
private LogLevel level = LogLevel.INFO; | ||
private Date date = Calendar.getInstance().getTime(); | ||
|
||
public EnhancedMessage(String message) { | ||
super(message); | ||
} | ||
|
||
public EnhancedMessage(ByteSource data, String mediaType, String message) { | ||
super(data, mediaType, message); | ||
} | ||
|
||
public EnhancedMessage(TypeAwareByteSource data, String message) { | ||
super(data, message); | ||
} | ||
|
||
public EnhancedMessage(File file, String message) throws IOException { | ||
super(file, message); | ||
} | ||
|
||
public EnhancedMessage withLevel(LogLevel level) { | ||
this.level = Objects.requireNonNull(level, "Log level must not be null"); | ||
return this; | ||
} | ||
|
||
public EnhancedMessage withDate(Date date) { | ||
this.date = Objects.requireNonNull(date, "Message date must not be null"); | ||
return this; | ||
} | ||
|
||
public LogLevel getLevel() { | ||
return level; | ||
} | ||
|
||
public Date getDate() { | ||
return date; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/github/invictum/reportportal/StepDataExtractorsHolder.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 com.github.invictum.reportportal; | ||
|
||
import com.epam.reportportal.service.ReportPortal; | ||
import com.github.invictum.reportportal.extractor.StepDataExtractor; | ||
import net.thucydides.core.model.TestStep; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Hold all registered step extractors and proceed all passed {@link TestStep} objects | ||
* Entry point to pass {@link TestStep} through sequence of {@link StepDataExtractor} | ||
*/ | ||
public class StepDataExtractorsHolder { | ||
|
||
private Set<StepDataExtractor> processors = new HashSet<>(); | ||
|
||
public void register(StepDataExtractor... processors) { | ||
this.processors = new HashSet<>(Arrays.asList(processors)); | ||
} | ||
|
||
public void proceed(TestStep step) { | ||
processors.forEach(processor -> { | ||
Collection<EnhancedMessage> logs = processor.extract(step.clone()); | ||
logs.forEach(item -> ReportPortal.emitLog(item, item.getLevel().toString(), item.getDate())); | ||
}); | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
src/main/java/com/github/invictum/reportportal/StepProcessorsHolder.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.