private void updateParentChildren( SortedMap<String, Requirement> map, String parent, Requirement entry) { Requirement parentRequirement = map.get(parent); Requirement updatedParentRequirement = parentRequirement.withChild(entry); map.remove(parent); map.put(parent, updatedParentRequirement); }
@Override public Optional<Requirement> getRequirementFor(TestTag testTag) { Optional<Requirement> result = Optional.absent(); for (Requirement requirement : getRequirements()) { if (requirement.asTag().equals(testTag)) { return Optional.of(requirement); } } return result; }
@Override public Set<TestTag> getTagsFor(TestOutcome testOutcome) { Set<TestTag> result = new HashSet<TestTag>(); for (Requirement requirement : getAllRequirements()) { if (isMatchingRequirementFor(testOutcome, requirement)) { result.add( TestTag.withName(humanReadableVersionOf(requirement.getName())) .andType(requirement.getType())); } } return result; }
private List<Requirement> buildRequirementsTree( SortedMap<String, Requirement> requirementsByPath, Map<Requirement, String> requirementPaths) { List<Requirement> requirementsTree = Lists.newArrayList(); for (Requirement requirement : requirementsByPath.values()) { if (isRoot(requirementPaths.get(requirement))) { List<Requirement> children = findDirectChildrenFor(requirement, requirementsByPath, requirementPaths); requirementsTree.add(requirement.withChildren(children)); } } return requirementsTree; }
private Requirement getRequirement( Class candidateClass, String packageName, int level, String requirementTitle, String requirementType, String narrativeText, String cardNumber, Optional<Narrative> narrative) { if (narrative.isPresent()) { requirementTitle = narrative.get().title(); requirementType = narrative.get().type(); narrativeText = Joiner.on("\n").join(narrative.get().text()); cardNumber = narrative.get().cardNumber(); } if (StringUtils.isEmpty(requirementType)) { requirementType = getRequirementType(level, candidateClass); } return Requirement.named(humanReadableVersionOf(packageName)) .withOptionalCardNumber(cardNumber) .withOptionalDisplayName( StringUtils.isEmpty(requirementTitle) ? humanReadableVersionOf(packageName) : requirementTitle) .withType(requirementType) .withNarrativeText(narrativeText); }
private List<Requirement> findDirectChildrenFor( Requirement requirement, SortedMap<String, Requirement> requirementsByPath, Map<Requirement, String> requirementPaths) { List<Requirement> immediateChildren = Lists.newArrayList(); if (!isLeaf(requirement)) { String requirementPath = requirementPaths.get(requirement); for (String path : requirementsByPath.keySet()) { Requirement childRequirement = requirementsByPath.get(path); if ((childRequirement != requirement) && (isImmediateChild(requirementPath, path))) { if (isLeaf(childRequirement)) { immediateChildren.add(childRequirement); } else { immediateChildren.add( childRequirement.withChildren( findDirectChildrenFor(childRequirement, requirementsByPath, requirementPaths))); } } } } return immediateChildren; }
public TestOutcomes forRequirement(Requirement requirement) { return withTag(requirement.getName()); }
public String forRequirement(Requirement parentRequirement) { return reportNamer.getNormalizedTestNameFor( prefixUsing(context) + "requirement_" + parentRequirement.getName()); }