@@ -14,7 +14,7 @@ object TestRequirementMapper {
1414 // read program parameters
1515 val (testResultsFile, requirementsFile, outputPath) = args.toList match {
1616 case t :: r :: o :: Nil => (t, r, o)
17- case _ =>
17+ case _ =>
1818 throw new RuntimeException (
1919 " **** Provide appropriate parameters. **** \n " +
2020 " Required parameters : <file with test-story mapping> <file with story-requirement mapping> <output file>"
@@ -24,11 +24,11 @@ object TestRequirementMapper {
2424 // read test-story mapping
2525 val testResultsPath = new File (testResultsFile).toPath.toAbsolutePath
2626 println(" [INFO] Reading test-story mapping file - " + testResultsPath)
27- val testResults = Files .readAllLines(new File (testResultsFile).toPath)
28- val storyResults = testResults.asScala.toList.map { line =>
27+ val testResults = Files .readAllLines(new File (testResultsFile).toPath)
28+ val storyResults = testResults.asScala.toList.map { line =>
2929 val (story, test, status) = line.split(PIPE ).toList match {
3030 case s :: t :: st :: Nil => (s, t, st)
31- case _ =>
31+ case _ =>
3232 throw new RuntimeException (
3333 s " **** Provided data is not in valid format : ' $line' **** \n " +
3434 " Test-Story mapping should be in 'story number | test name | test status' format (Pipe '|' separated format)"
@@ -37,22 +37,29 @@ object TestRequirementMapper {
3737 StoryResult (story.strip(), test.strip(), status.strip())
3838 }
3939
40+ if (storyResults.isEmpty) throw new RuntimeException ((" test-story mapping file is empty." ))
41+
4042 // read story-requirement mapping
4143 println(" [INFO] Reading story-requirement mapping file - " + new File (requirementsFile).toPath.toAbsolutePath)
4244 val requirementsContent = Files .readAllLines(new File (requirementsFile).toPath)
4345
44- val requirements = requirementsContent.asScala.toList.map { line =>
45- val (story, requirement) = line.splitAt(line.indexOf(COMMA )) match {
46- case (s, req) if s.nonEmpty => (s, req.drop(1 )) // drop to remove the first comma & requirement can be empty.
47- case _ =>
48- throw new RuntimeException (
49- s " **** Provided data is not in valid format : ' $line' **** \n " +
50- s " Story-Requirement mapping should be in 'story number $COMMA requirement' format (Comma ',' separated format) "
51- )
46+ val requirements = requirementsContent
47+ .asScala
48+ .toList
49+ .filter(_.strip.nonEmpty)
50+ .map { line =>
51+ val (story, requirement) = line.splitAt(line.indexOf(COMMA )) match {
52+ case (s, req) if s.nonEmpty => (s, req.drop(1 )) // drop to remove the first comma & requirement can be empty.
53+ case _ =>
54+ throw new RuntimeException (
55+ s " **** Provided data is not in valid format : ' $line' **** \n " +
56+ s " Story-Requirement mapping should be in 'story number $COMMA requirement' format (Comma ',' separated format) "
57+ )
58+ }
59+ Requirement (story.strip(), requirement.strip().replaceAll(" \" " , " " ))
5260 }
5361
54- Requirement (story.strip(), requirement.strip().replaceAll(" \" " , " " ))
55- }
62+ if (requirements.isEmpty) throw new RuntimeException ((" Story-requirement mapping file is empty." ))
5663
5764 // map tests to requirements and sort by story ID
5865 val testAndReqMapped = storyResults.map { storyResult =>
0 commit comments