use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class TestCaseStepHelper method readCachedStepDefinitions.
public static List<TestCaseStep> readCachedStepDefinitions(Path tcFile) throws IOException {
List<TestCaseStep> result = new ArrayList<>();
if (tcFile != null) {
Path stepsCacheFile = tcFile.getParent().resolve(STEPS_CACHE_FILE);
if (Files.exists(stepsCacheFile)) {
try {
List<String> lines = FileUtils.readLines(stepsCacheFile.toFile(), Charset.forName("UTF-8"));
DateTime creationDate = new DateTime();
for (String line : lines) {
if (StringUtils.isNotEmpty(line)) {
TestCaseStep step = new TestCaseStepBuilder(line).withCreationDate(creationDate).build();
result.add(step);
LOGGER.debug("add cached step definition: " + step);
//increase creation date to ensure correct sorting
creationDate = creationDate.plusMillis(1);
}
}
} catch (IOException e) {
throw new IOException(String.format("Can't read in cached step definitions in file '%s'", stepsCacheFile), e);
}
}
}
return result;
}
Aggregations