public static List<String> stripRootFromPath(String root, List<String> storyPathElements) { List<String> rootElements = pathElements(root); if (thePathIn(storyPathElements).startsWith(rootElements)) { return storyPathElements.subList(rootElements.size(), storyPathElements.size()); } else { return storyPathElements; } }
private List<String> stripRootFrom(List<String> storyPathElements) { return stripRootFromPath(rootDirectoryPath, storyPathElements); }
public Set<TestTag> getTagsFor(final TestOutcome testOutcome) { // // For the FileSystemRequirements tag provider, the test outcome provides a path, which might be: // - a feature file for Cucumber ("add_an_item.feature"), // - a story file with a path (JBehave) ("stories/manage_items/add_an_item.story") // Set<TestTag> tags = new HashSet<>(); if (testOutcome.getPath() != null) { java.util.Optional<Requirement> matchingRequirement = requirementWithMatchingFeatureFile(testOutcome); if (matchingRequirement.isPresent()) { tags.add(matchingRequirement.get().asTag()); tags.addAll(parentRequirementsOf(matchingRequirement.get().asTag())); } // Strategy used if a full path is provided List<String> storyPathElements = stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath()))); tags.addAll(getMatchingCapabilities(getRequirements(), stripStorySuffixFrom(storyPathElements))); if (tags.isEmpty() && storyOrFeatureDescribedIn(storyPathElements).isPresent()) { java.util.Optional<TestTag> matchingRequirementTag = getMatchingRequirementTagsFor(storyOrFeatureDescribedIn(storyPathElements).get()); if (matchingRequirementTag.isPresent()) { tags.add(matchingRequirementTag.get()); tags.addAll(parentRequirementsOf(matchingRequirementTag.get())); } } } return tags; }
private String directoryLevelInRequirementsHierarchy(File narrativeFile, int requirementsLevel) { String normalizedNarrativePath = normalized(narrativeFile.getAbsolutePath()); String normalizedRootPath = normalized(rootDirectory); int rootDirectoryStart = normalizedNarrativePath.lastIndexOf(normalizedRootPath); int rootDirectoryEnd = (rootDirectoryStart >= 0) ? rootDirectoryStart + normalizedRootPath.length() : 0; String relativeNarrativePath = normalizedNarrativePath.substring(rootDirectoryEnd); int directoryCount = fileSystemPathElements(relativeNarrativePath).size() - 1; int level = requirementsLevel + directoryCount - 1; return getRequirementTypeForLevel(level); }
private java.util.Optional<Requirement> parentRequirementFromPackagePath(TestOutcome testOutcome) { if (testOutcome.getPath() != null) { List<String> storyPathElements = stripStorySuffixFrom(stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath())))); return lastRequirementFrom(storyPathElements); } return Optional.empty(); }
private String directoryLevelInRequirementsHierarchy(File narrativeFile, int requirementsLevel) { String normalizedNarrativePath = normalized(narrativeFile.getAbsolutePath()); String normalizedRootPath = normalized(rootDirectory); int rootDirectoryStart = findRootDirectoryStart(normalizedNarrativePath, normalizedRootPath); int rootDirectoryEnd = findRootDirectoryEnd(rootDirectoryStart, normalizedNarrativePath, normalizedRootPath); String relativeNarrativePath = normalizedNarrativePath.substring(rootDirectoryEnd); int directoryCount = RequirementsPath.fileSystemPathElements(relativeNarrativePath).size() - 1; int level = requirementsLevel + directoryCount - 1; return getRequirementTypeForLevel(level); }
public static List<String> stripRootFromPath(String root, List<String> storyPathElements) { List<String> rootElements = pathElements(root); if (thePathIn(storyPathElements).startsWith(rootElements)) { return storyPathElements.subList(rootElements.size(), storyPathElements.size()); } else { return storyPathElements; } }
public Set<TestTag> getTagsFor(final TestOutcome testOutcome) { Set<TestTag> tags = new HashSet<>(); if (testOutcome.getPath() != null) { List<String> storyPathElements = stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath()))); addStoryTagIfPresent(tags, storyPathElements); storyPathElements = stripStorySuffixFrom(storyPathElements); tags.addAll(getMatchingCapabilities(getRequirements(), storyPathElements)); } return tags; }
private String directoryLevelInRequirementsHierarchy(File narrativeFile, int requirementsLevel) { String normalizedNarrativePath = normalized(narrativeFile.getAbsolutePath()); String normalizedRootPath = normalized(rootDirectory); int rootDirectoryStart = findRootDirectoryStart(normalizedNarrativePath, normalizedRootPath); int rootDirectoryEnd = findRootDirectoryEnd(rootDirectoryStart, normalizedNarrativePath, normalizedRootPath); String relativeNarrativePath = normalizedNarrativePath.substring(rootDirectoryEnd); int directoryCount = fileSystemPathElements(relativeNarrativePath).size() - 1; int level = requirementsLevel + directoryCount - 1; return getRequirementTypeForLevel(level); }
private List<String> stripRootFrom(List<String> storyPathElements) { return stripRootFromPath(rootDirectoryPath, storyPathElements); }
public static List<String> stripRootFromPath(String root, List<String> storyPathElements) { List<String> rootElements = pathElements(root); if (thePathIn(storyPathElements).startsWith(rootElements)) { return storyPathElements.subList(rootElements.size(), storyPathElements.size()); } else { return storyPathElements; } }
public Set<TestTag> getTagsFor(final TestOutcome testOutcome) { Set<TestTag> tags = new HashSet<>(); if (testOutcome.getPath() != null) { List<String> storyPathElements = stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath()))); addStoryTagIfPresent(tags, storyPathElements); storyPathElements = stripStorySuffixFrom(storyPathElements); tags.addAll(getMatchingCapabilities(getRequirements(), storyPathElements)); } return tags; }
private List<String> stripRootFrom(List<String> storyPathElements) { return stripRootFromPath(rootDirectory, storyPathElements); }
private java.util.Optional<Requirement> featureTagRequirementIn(TestOutcome testOutcome) { List<String> storyPathElements = stripStorySuffixFrom(stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath())))); return lastRequirementFrom(storyPathElements); }
public Optional<Requirement> getParentRequirementOf(final TestOutcome testOutcome) { if (testOutcome.getPath() != null) { List<String> storyPathElements = stripStorySuffixFrom(stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath())))); return lastRequirementFrom(storyPathElements); } else { return mostSpecificTagRequirementFor(testOutcome); } }
public Optional<Requirement> getParentRequirementOf(final TestOutcome testOutcome) { if (testOutcome.getPath() != null) { List<String> storyPathElements = stripStorySuffixFrom(stripRootFrom(pathElements(stripRootPathFrom(testOutcome.getPath())))); return lastRequirementFrom(storyPathElements); } else { return mostSpecificTagRequirementFor(testOutcome); } }