diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java index 5c266f2f..5ab11a88 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/CobolGenerator.java @@ -75,17 +75,28 @@ static void addStartAndEndTags(List lines){ lines.add(getInjectEndTagComment()); } - static List generateWhenOtherLines(String identifier, String type, List commentLines, List bodyLines){ + static List generateWhenOtherLines(String identifier, String type, List commentLines, List bodyLines) { List lines = new ArrayList<>(); - if(type.equals(Constants.SECTION_TOKEN)) + if (type.equals(Constants.SECTION_TOKEN)) lines.add(String.format(WHEN_OTHER_SECTION_HEADER_FORMAT, identifier)); - else lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier)); + else + lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier)); + if (commentLines != null) lines.addAll(commentLines); - if (bodyLines != null) + + if (bodyLines != null) { lines.addAll(bodyLines); - lines.add(ENDING_PERIOD); + // Check if the last line in bodyLines ends with a period + if (!bodyLines.get(bodyLines.size() - 1).endsWith(".")) { + lines.add(ENDING_PERIOD); + } + } else { + // If bodyLines is null, add ENDING_PERIOD + lines.add(ENDING_PERIOD); + } return lines; } + }