Search in sources :

Example 21 with TestCaseStep

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;
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) TestCaseStep(org.sakuli.datamodel.TestCaseStep) IOException(java.io.IOException) DateTime(org.joda.time.DateTime) TestCaseStepBuilder(org.sakuli.datamodel.builder.TestCaseStepBuilder)

Aggregations

TestCaseStep (org.sakuli.datamodel.TestCaseStep)21 Test (org.testng.annotations.Test)10 BaseTest (org.sakuli.BaseTest)8 TestCase (org.sakuli.datamodel.TestCase)8 TestSuite (org.sakuli.datamodel.TestSuite)6 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 DaoTestCaseStep (org.sakuli.services.forwarder.database.dao.DaoTestCaseStep)3 IOException (java.io.IOException)2 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)2 DaoTestCase (org.sakuli.services.forwarder.database.dao.DaoTestCase)2 InputStream (java.io.InputStream)1 DateTime (org.joda.time.DateTime)1 LogToResult (org.sakuli.actions.logging.LogToResult)1 SakuliForwarderException (org.sakuli.exceptions.SakuliForwarderException)1 DaoTestSuite (org.sakuli.services.forwarder.database.dao.DaoTestSuite)1 ScreenshotDiv (org.sakuli.services.forwarder.gearman.model.ScreenshotDiv)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1 SimpleJdbcInsert (org.springframework.jdbc.core.simple.SimpleJdbcInsert)1