Skip to content

Commit

Permalink
refactor: revert setting metadataManager as field in extentReporter
Browse files Browse the repository at this point in the history
  • Loading branch information
giulong committed Aug 17, 2024
1 parent 42010d8 commit a3f4405
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public class ExtentReporter implements SessionHook, CanProduceMetadata {
protected final FileUtils fileUtils = FileUtils.getInstance();
protected final Configuration configuration = Configuration.getInstance();

private final MetadataManager metadataManager = MetadataManager.getInstance();

private ExtentReports extentReports;

public static ExtentReporter getInstance() {
Expand Down Expand Up @@ -101,6 +99,7 @@ public Retention getRetention() {

@Override
public void produceMetadata() {
final MetadataManager metadataManager = MetadataManager.getInstance();
final File file = getReportPathFrom(configuration.getExtent()).toFile();
final int maxSize = getRetention().getSuccessful();
final FixedSizeQueue<File> queue = metadataManager.getSuccessfulQueueOf(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class ExtentReporterTest {
public void beforeEach() {
Reflections.setField("fileUtils", extentReporter, fileUtils);
Reflections.setField("configuration", extentReporter, configuration);
Reflections.setField("metadataManager", extentReporter, metadataManager);
testDataMockedStatic = mockStatic(TestData.class);
freeMarkerWrapperMockedStatic = mockStatic(FreeMarkerWrapper.class);
pathMockedStatic = mockStatic(Path.class);
Expand Down Expand Up @@ -383,6 +382,7 @@ public void produceMetadata() {
when(absolutePath.toFile()).thenReturn(file1);
when(retention.getSuccessful()).thenReturn(retentionSuccessful);

when(MetadataManager.getInstance()).thenReturn(metadataManager);
when(metadataManager.getSuccessfulQueueOf(extentReporter)).thenReturn(fileFixedSizeQueue);
when(fileFixedSizeQueue.shrinkTo(retentionSuccessful - 1)).thenReturn(fileFixedSizeQueue);

Expand Down

0 comments on commit a3f4405

Please sign in to comment.