private String getTitleFromNarrativeOrDirectoryName(Narrative requirementNarrative, String nameIfNoNarrativePresent) { if (requirementNarrative.getTitle().isPresent() && isNotBlank(requirementNarrative.getTitle().get())) { return requirementNarrative.getTitle().get(); } return nameIfNoNarrativePresent; }
public static String definedIn(Optional<Narrative> narrative) { return narrative.get().getTitle().get(); }
public static String definedIn(String fullPath, String defaultType) { Optional<String> narrativePath = narrativePathsFor(fullPath); // String narrativePath = asResourcePath(fileSystemPathOfNarrativeInPackage(fullPath)) + ".txt"; try { if (narrativePath.isPresent()) { // String narrativeFilePath = Resources.getResource(narrativePath).getFile(); // if (new File(narrativeFilePath).exists()) { Optional<Narrative> narrative = LoadedNarrative.load().fromFile(new File(narrativePath.get()), defaultType); if (narrative.isPresent()) { return (narrative.get().getTitle().orElse("") + System.lineSeparator() + narrative.get().getText()).trim(); } } } catch (IllegalArgumentException noNarrativeFileFound) { } return ""; }
private String storyNameFrom(java.util.Optional<Narrative> narrative, FeatureType type, File storyFile) { if (narrative.isPresent() && isNotBlank(narrative.get().getTitle().orElse(""))) { return narrative.get().getTitle().get(); } else { if (isSnakeCase(storyFile.getName())) { return storyFile.getName().replace(type.getExtension(), "").replace("_"," "); } else { String storyNameWithoutExtension = storyFile.getName().replace(type.getExtension(), ""); String snakeCaseStoryName = inflection().underscore(storyNameWithoutExtension); return inflection().of(snakeCaseStoryName).asATitle().toString(); } } }
public Requirement readRequirementsFromStoryOrFeatureFile(File storyFile) { FeatureType type = featureTypeOf(storyFile); String defaultStoryName = storyFile.getName().replace(type.getExtension(), ""); Optional<Narrative> optionalNarrative = (type == FeatureType.STORY) ? loadFromStoryFile(storyFile) : loadFromFeatureFile(storyFile); String storyName = (optionalNarrative.isPresent()) ? optionalNarrative.get().getTitle().or(defaultStoryName) : defaultStoryName; Requirement requirement = (optionalNarrative.isPresent()) ? leafRequirementWithNarrative(humanReadableVersionOf(storyName), optionalNarrative.get()).withType(type.toString()) : storyNamed(storyName).withType(type.toString()); return requirement.definedInFile(storyFile); }