use of cucumber.api.TestCase in project page-factory-2 by sbtqa.
the class CriticalStepCheckAspect method getCurrentTestCaseUid.
private String getCurrentTestCaseUid(TestCase testCase) throws IllegalAccessException {
final String testCaseLocation = testCase.getUri() + ":" + testCase.getLine();
String uid = md5(testCaseLocation);
AllureStorage allureStorage = (AllureStorage) readDeclaredField(Allure.getLifecycle(), "storage", true);
Map<String, Object> storage = (Map<String, Object>) readDeclaredField(allureStorage, "storage", true);
Collection<Object> testResults = storage.values();
Optional<Object> testResultOptional = testResults.stream().filter(Objects::nonNull).filter(o -> o instanceof TestResult && ((TestResult) o).getHistoryId().equals(uid)).findFirst();
return testResultOptional.isPresent() ? ((TestResult) testResultOptional.get()).getUuid() : uid;
}
Aggregations