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

nl.hsac.fitnesse.testrun.DurationBasedWikiPagePartitioner Maven / Gradle / Ivy

There is a newer version: 1.32.11
Show newest version
package nl.hsac.fitnesse.testrun;

import fitnesse.testrunner.run.PositionMapBasedWikiPagePartitioner;
import fitnesse.wiki.WikiPage;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Partitions pages based on provided DurationRecords.
 */
public class DurationBasedWikiPagePartitioner extends PositionMapBasedWikiPagePartitioner {
  private List> durationRecords;

  public DurationBasedWikiPagePartitioner(List> durationRecords) {
    if (durationRecords != null) {
      setDurationRecords(durationRecords);
    }
  }

  @Override
  public List> split(List pages, int partitionCount) {
    Map positionMap = createPartitionMap(pages, partitionCount);
    setPartitionMap(positionMap);
    return super.split(pages, partitionCount);
  }

  protected Map createPartitionMap(List pages, int partitionCount) {
    List names = getFullPaths(pages);
    return new PositionFinder().getPositionMap(names, durationRecords, partitionCount);
  }

  protected List getFullPaths(List pages) {
    return pages.stream().map(this::getFullPath).collect(Collectors.toList());
  }

  public void setDurationRecords(List> durationRecords) {
    this.durationRecords = durationRecords;
  }

  public List> getDurationRecords() {
    return durationRecords;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy