From 58a1f870dd3d848134f85fa49f2687056da76b71 Mon Sep 17 00:00:00 2001 From: issacto Date: Wed, 9 Aug 2023 20:57:17 +0100 Subject: [PATCH] refactor second part Signed-off-by: issacto --- .../TestSuiteParserController.java | 1 + .../testSuiteParser/WhenOtherGenerator.java | 4 +- .../cobolcheck/MockIT.java | 57 ++++++++++--------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParserController.java b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParserController.java index 32b6be9f..aabe1568 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParserController.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/TestSuiteParserController.java @@ -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() { diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/WhenOtherGenerator.java b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/WhenOtherGenerator.java index 60b5bdf6..9165eb16 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/WhenOtherGenerator.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/testSuiteParser/WhenOtherGenerator.java @@ -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 generateWhenOther(WhenOther whenOther, boolean withComments){ List 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; diff --git a/src/test/java/org/openmainframeproject/cobolcheck/MockIT.java b/src/test/java/org/openmainframeproject/cobolcheck/MockIT.java index 152d0b5b..91c15e5e 100644 --- a/src/test/java/org/openmainframeproject/cobolcheck/MockIT.java +++ b/src/test/java/org/openmainframeproject/cobolcheck/MockIT.java @@ -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); @@ -351,16 +352,16 @@ private String removeBoilerPlateCode(String code, List 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 + @@ -514,16 +515,16 @@ private String removeBoilerPlateCode(String code, List 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 + @@ -541,16 +542,16 @@ private String removeBoilerPlateCode(String code, List 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 + @@ -566,16 +567,16 @@ private String removeBoilerPlateCode(String code, List 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 + @@ -792,16 +793,16 @@ private String removeBoilerPlateCode(String code, List 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 + @@ -818,16 +819,16 @@ private String removeBoilerPlateCode(String code, List 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 + @@ -854,16 +855,16 @@ private String removeBoilerPlateCode(String code, List 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 +