All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.retest.recheck.SuiteAggregator Maven / Gradle / Ivy

There is a newer version: 1.13.0
Show newest version
package de.retest.recheck;

import java.nio.file.Path;
import java.util.ArrayList;

import de.retest.recheck.report.SuiteReplayResult;
import de.retest.recheck.report.TestReport;
import de.retest.recheck.suite.ExecutableSuite;
import de.retest.recheck.ui.descriptors.GroundState;

public class SuiteAggregator {

	private static SuiteAggregator instance;

	public static SuiteAggregator getInstance() {
		if ( instance == null ) {
			instance = new SuiteAggregator();
		}
		return instance;
	}

	static SuiteAggregator getTestInstance() {
		return new SuiteAggregator();
	}

	private SuiteAggregator() {}

	private final TestReport aggregatedTestReport = TestReport.fromApi();

	private SuiteReplayResult currentSuite;

	public TestReport getAggregatedTestReport() {
		return aggregatedTestReport;
	}

	public SuiteReplayResult getSuite( final String suiteName ) {
		return getSuite( suiteName, null );
	}

	public SuiteReplayResult getSuite( final String suiteName, final Path testSourceRoot ) {
		if ( currentSuite == null ) {
			currentSuite = createSuiteReplayResult( suiteName, testSourceRoot );
		}
		if ( !suiteName.equals( currentSuite.getName() ) ) {
			currentSuite = createSuiteReplayResult( suiteName, testSourceRoot );
		}
		return currentSuite;
	}

	private SuiteReplayResult createSuiteReplayResult( final String suiteName, final Path testSourceRoot ) {
		final GroundState groundState = new GroundState();
		final ExecutableSuite execSuite = new ExecutableSuite( groundState, 0, new ArrayList<>() );
		execSuite.setName( suiteName );
		final SuiteReplayResult suiteReplayResult =
				new SuiteReplayResult( suiteName, testSourceRoot, 0, groundState, execSuite.getUuid(), groundState );
		aggregatedTestReport.addSuite( suiteReplayResult );
		return suiteReplayResult;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy