Skip to content

Commit

Permalink
refactor second part
Browse files Browse the repository at this point in the history
Signed-off-by: issacto <[email protected]>
  • Loading branch information
issacto committed Aug 9, 2023
1 parent 5e3b174 commit 58a1f87
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public TestSuiteParserController(BufferedReader reader) {
testSuiteParser = new TestSuiteParser(new KeywordExtractor(), mockRepository, beforeAfterRepo, testSuiteErrorLog);
mockGenerator = new MockGenerator();
testCodePrefix = Config.getString(Constants.COBOLCHECK_PREFIX_CONFIG_KEY, Constants.DEFAULT_COBOLCHECK_PREFIX);
whenOtherGenerator = new WhenOtherGenerator();
}

public boolean hasWorkingStorageTestCodeBeenInserted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public class WhenOtherGenerator {
private final String performFormat = " PERFORM %s";


public String generateWhenOtherCall(WhenOther whenOther) {
String generateWhenOtherCall(WhenOther whenOther) {
return String.format(performFormat, whenOther.getGeneratedWhenOtherIdentifier());
}

List<String> generateWhenOther(WhenOther whenOther, boolean withComments){
List<String> lines = new ArrayList<>();
lines.addAll(CobolGenerator.generateCommentBlock("WhenOther block called when mocking"));
lines.addAll(CobolGenerator.generateCommentBlock("WhenOther block called"));
lines.addAll(generateParagraphsForWhenOther(whenOther, withComments));
lines.add("");
return lines;
Expand Down
57 changes: 29 additions & 28 deletions src/test/java/org/openmainframeproject/cobolcheck/MockIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void it_inserts_a_mock_correctly() throws IOException {

Mockito.when(mockedInterpreterReader.readLine()).thenReturn(s1, s2, s3, s4, s5, s6, null);
Mockito.when(mockedParserReader.readLine()).thenReturn(t1, t2, t3, t4, null);


generator = new Generator(interpreterController, writerController, testSuiteParserController);

Expand Down Expand Up @@ -351,16 +352,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO ANY " + Constants.NEWLINE +
" PERFORM UT-1-0-1-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-0-2-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-0-0-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-0-2-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-0-0-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 000-START " + Constants.NEWLINE +
" *When other block of: SECTION: 000-START " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand Down Expand Up @@ -514,16 +515,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO ANY " + Constants.NEWLINE +
" PERFORM UT-1-0-1-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-2-4-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-2-0-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-2-4-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-2-0-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 000-START " + Constants.NEWLINE +
" *When other block of: SECTION: 000-START " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: \"Simply a test\" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand All @@ -541,16 +542,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO \"Simply a test\" " + Constants.NEWLINE +
" PERFORM UT-1-2-2-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-2-5-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-2-1-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE+
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-2-5-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-2-1-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 100-WELCOME " + Constants.NEWLINE +
" *When other block of: SECTION: 100-WELCOME " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: \"Simply a test\" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand All @@ -566,16 +567,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO \"Simply a test\" " + Constants.NEWLINE +
" PERFORM UT-1-2-3-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-2-6-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-2-2-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE+
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-2-6-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-2-2-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 200-GOODBYE " + Constants.NEWLINE +
" *When other block of: SECTION: 200-GOODBYE " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: \"Simply a test\" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand Down Expand Up @@ -792,16 +793,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO \"Simply a test\" " + Constants.NEWLINE +
" PERFORM UT-1-2-1-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-2-4-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-2-0-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-2-4-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-2-0-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 000-START " + Constants.NEWLINE +
" *When other block of: SECTION: 000-START " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: \"Simply a test\" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand All @@ -818,16 +819,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO ANY " + Constants.NEWLINE +
" PERFORM UT-1-0-1-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-2-5-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-2-1-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE+
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-2-5-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-2-1-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 100-WELCOME " + Constants.NEWLINE +
" *When other block of: SECTION: 100-WELCOME " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: \"Simply a test\" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand All @@ -854,16 +855,16 @@ private String removeBoilerPlateCode(String code, List<String> boilerPlateTags){
" ALSO \"Simply a test\" " + Constants.NEWLINE +
" PERFORM UT-1-2-3-MOCK " + Constants.NEWLINE +
" WHEN OTHER " + Constants.NEWLINE +
" PERFORM UT-1-2-6-MOCK " + Constants.NEWLINE +
" PERFORM UT-1-2-2-WO " + Constants.NEWLINE +
" END-EVALUATE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE+
" ***************************************************************** " + Constants.NEWLINE +
" *Paragraphs called when mocking " + Constants.NEWLINE +
" *WhenOther block called " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" UT-1-2-6-MOCK SECTION. " + Constants.NEWLINE +
" UT-1-2-2-WO SECTION. " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
" *Local mock of: SECTION: 200-GOODBYE " + Constants.NEWLINE +
" *When other block of: SECTION: 200-GOODBYE " + Constants.NEWLINE +
" *In testsuite: \"Mocking tests\" " + Constants.NEWLINE +
" *In testcase: \"Simply a test\" " + Constants.NEWLINE +
" ***************************************************************** " + Constants.NEWLINE +
Expand Down

0 comments on commit 58a1f87

Please sign in to comment.