Skip to content

Commit

Permalink
#335: enhance use case diagram with notes containing meta-data (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-ka authored Jul 23, 2023
1 parent c0208b4 commit 2e688ba
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public void canCreateUseCaseDiagram() throws IOException {
+ "Actor_0 -- Order_Offer_for_new_Insurance" + System.lineSeparator()
+ "Actor_1 -- Just_do_something" + System.lineSeparator()
+ System.lineSeparator()
+ "note bottom of (Get_paid_for_car_accident)" + System.lineSeparator()
+ " //Benefit:// A claimant submits a claim and and gets paid from the insurance company." + System.lineSeparator()
+ " //Level:// Summary" + System.lineSeparator()
+ " //Scope:// Insurance company" + System.lineSeparator()
+ "end note"
+ System.lineSeparator()
+ System.lineSeparator()
+ System.lineSeparator()
+ "@enduml" + System.lineSeparator(), useCaseDiagram);
Expand Down Expand Up @@ -91,6 +97,12 @@ public void canCreateUseCaseDiagramWithSecondaryActors() throws IOException {
+ "Get_paid_for_car_accident -- Actor_1" + System.lineSeparator()
+ "Get_paid_for_car_accident -- Actor_2" + System.lineSeparator()
+ System.lineSeparator()
+ "note bottom of (Get_paid_for_car_accident)" + System.lineSeparator()
+ " //Benefit:// A claimant submits a claim and and gets paid from the insurance company." + System.lineSeparator()
+ " //Level:// Summary" + System.lineSeparator()
+ " //Scope:// Insurance company" + System.lineSeparator()
+ "end note"
+ System.lineSeparator()
+ System.lineSeparator()
+ System.lineSeparator()
+ "@enduml" + System.lineSeparator(), useCaseDiagram);
Expand Down Expand Up @@ -121,6 +133,15 @@ public void canCreateUseCaseDiagramForMixedUseCasesAndUserStories() throws IOExc
+ "Actor_0 -- Order_Offer_for_new_Insurance" + System.lineSeparator()
+ "Actor_1 -- Just_do_something" + System.lineSeparator()
+ System.lineSeparator()
+ "note bottom of (Get_paid_for_car_accident)" + System.lineSeparator()
+ " //Benefit:// A claimant submits a claim and and gets paid from the insurance company." + System.lineSeparator()
+ " //Level:// Summary" + System.lineSeparator()
+ " //Scope:// Insurance company" + System.lineSeparator()
+ "end note" + System.lineSeparator()
+ "note bottom of (Just_do_something)" + System.lineSeparator()
+ " //Benefit:// I earn my name" + System.lineSeparator()
+ "end note"
+ System.lineSeparator()
+ System.lineSeparator()
+ System.lineSeparator()
+ "@enduml" + System.lineSeparator(), useCaseDiagram);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected void printDiagramContent(ContextMappingModel model) {
printConnections(actors, false);
printConnections(secondaryActors, true);
linebreak();
printNotes(model.getUserRequirements());
}

private void printUseCases() {
Expand Down Expand Up @@ -81,6 +82,37 @@ private void printActorsConnections(final Actor actor, final boolean secondaryAc
}
}

private void printNotes(final List<UserRequirement> userRequirements) {
for (UserRequirement req : userRequirements) {
printNoteIfAvailable(req);
}
}

private void printNoteIfAvailable(final UserRequirement requirement) {
final Set<String> lines = new TreeSet<>();
if (requirement instanceof UseCase && ((UseCase) requirement).getScope() != null
&& !"".equals(((UseCase) requirement).getScope())) {
lines.add("//Scope:// " + ((UseCase) requirement).getScope());
}
if (requirement instanceof UseCase && ((UseCase) requirement).getLevel() != null
&& !"".equals(((UseCase) requirement).getLevel())) {
lines.add("//Level:// " + ((UseCase) requirement).getLevel());
}
if (requirement.getBenefit() != null && !"".equals(requirement.getBenefit())) {
lines.add("//Benefit:// " + requirement.getBenefit());
}
if (!lines.isEmpty()) {
sb.append("note bottom of (").append(requirement.getName().trim()).append(")");
linebreak();
for (String line : lines) {
sb.append(" ").append(line);
linebreak();
}
sb.append("end note");
linebreak();
}
}

private void prepareData(final List<UserRequirement> userRequirements) {
initializeDataStructures();
for (UserRequirement req : userRequirements) {
Expand Down

0 comments on commit 2e688ba

Please sign in to comment.