-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathLeVADocumentUseCase.groovy
1782 lines (1506 loc) · 79.2 KB
/
LeVADocumentUseCase.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package org.ods.orchestration.usecase
import com.cloudbees.groovy.cps.NonCPS
import groovy.xml.XmlUtil
import org.ods.orchestration.scheduler.LeVADocumentScheduler
import org.ods.orchestration.service.DocGenService
import org.ods.orchestration.service.LeVADocumentChaptersFileService
import org.ods.orchestration.util.*
import org.ods.services.GitService
import org.ods.services.JenkinsService
import org.ods.services.NexusService
import org.ods.services.OpenShiftService
import org.ods.services.ServiceRegistry
import org.ods.util.IPipelineSteps
import org.ods.util.Logger
import java.time.LocalDateTime
@SuppressWarnings(['IfStatementBraces',
'LineLength',
'AbcMetric',
'Instanceof',
'VariableName',
'UnusedMethodParameter',
'UnusedVariable',
'ParameterCount',
'NonFinalPublicField',
'PropertyName',
'MethodCount',
'UseCollectMany',
'ParameterName',
'TrailingComma',
'SpaceAroundMapEntryColon'])
class LeVADocumentUseCase extends DocGenUseCase {
enum DocumentType {
CSD,
DIL,
DTP,
DTR,
RA,
CFTP,
CFTR,
IVP,
IVR,
SSDS,
TCP,
TCR,
TIP,
TIR,
TRC,
OVERALL_DTR,
OVERALL_IVR,
OVERALL_TIR
}
protected static Map DOCUMENT_TYPE_NAMES = [
(DocumentType.CSD as String) : 'Combined Specification Document',
(DocumentType.DIL as String) : 'Discrepancy Log',
(DocumentType.DTP as String) : 'Software Development Testing Plan',
(DocumentType.DTR as String) : 'Software Development Testing Report',
(DocumentType.CFTP as String) : 'Combined Functional and Requirements Testing Plan',
(DocumentType.CFTR as String) : 'Combined Functional and Requirements Testing Report',
(DocumentType.IVP as String) : 'Configuration and Installation Testing Plan',
(DocumentType.IVR as String) : 'Configuration and Installation Testing Report',
(DocumentType.RA as String) : 'Risk Assessment',
(DocumentType.TRC as String) : 'Traceability Matrix',
(DocumentType.SSDS as String) : 'System and Software Design Specification',
(DocumentType.TCP as String) : 'Test Case Plan',
(DocumentType.TCR as String) : 'Test Case Report',
(DocumentType.TIP as String) : 'Technical Installation Plan',
(DocumentType.TIR as String) : 'Technical Installation Report',
(DocumentType.OVERALL_DTR as String): 'Overall Software Development Testing Report',
(DocumentType.OVERALL_IVR as String): 'Overall Configuration and Installation Testing Report',
(DocumentType.OVERALL_TIR as String): 'Overall Technical Installation Report',
]
static GAMP_CATEGORY_SENSITIVE_DOCS = [
DocumentType.SSDS as String,
DocumentType.CSD as String,
DocumentType.CFTP as String,
DocumentType.CFTR as String
]
static Map<String, Map> DOCUMENT_TYPE_FILESTORAGE_EXCEPTIONS = [
'SCRR-MD' : [storage: 'pdf', content: 'pdf' ]
]
public static String DEVELOPER_PREVIEW_WATERMARK = 'Developer Preview'
public static String WORK_IN_PROGRESS_WATERMARK = 'Work in Progress'
public static String WORK_IN_PROGRESS_DOCUMENT_MESSAGE = 'Attention: this document is work in progress!'
private final JiraUseCase jiraUseCase
private final JUnitTestReportsUseCase junit
private final LeVADocumentChaptersFileService levaFiles
private final OpenShiftService os
private final SonarQubeUseCase sq
LeVADocumentUseCase(Project project,
IPipelineSteps steps,
MROPipelineUtil util,
DocGenService docGen,
JenkinsService jenkins,
JiraUseCase jiraUseCase,
JUnitTestReportsUseCase junit,
LeVADocumentChaptersFileService levaFiles,
NexusService nexus,
OpenShiftService os,
PDFUtil pdf,
SonarQubeUseCase sq) {
super(project, steps, util, docGen, nexus, pdf, jenkins)
this.jiraUseCase = jiraUseCase
this.junit = junit
this.levaFiles = levaFiles
this.os = os
this.sq = sq
}
@NonCPS
private def getReqsWithNoGampTopic(def requirements) {
return requirements.findAll { it.gampTopic == null }
}
@NonCPS
private def getReqsGroupedByGampTopic(def requirements) {
return requirements.findAll { it.gampTopic != null }
.groupBy { it.gampTopic.toLowerCase() }
}
@SuppressWarnings('CyclomaticComplexity')
String createCSD(Map repo = null, Map data = null) {
def documentType = DocumentType.CSD as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def requirements = this.project.getSystemRequirements()
def reqsWithNoGampTopic = getReqsWithNoGampTopic(requirements)
def reqsGroupedByGampTopic = getReqsGroupedByGampTopic(requirements)
reqsGroupedByGampTopic << ['uncategorized': reqsWithNoGampTopic ]
def requirementsForDocument = reqsGroupedByGampTopic.collectEntries { gampTopic, reqs ->
def updatedReqs = reqs.collect { req ->
def epics = req.getResolvedEpics()
def epic = !epics.isEmpty() ? epics.first() : null
return [
key : req.key,
applicability : 'Mandatory',
ursName : req.name,
ursDescription : this.convertImages(req.description ?: ''),
csName : req.configSpec.name ?: 'N/A',
csDescription : this.convertImages(req.configSpec.description ?: ''),
fsName : req.funcSpec.name ?: 'N/A',
fsDescription : this.convertImages(req.funcSpec.description ?: ''),
epic : epic?.key,
epicName : epic?.epicName,
epicTitle : epic?.title,
epicDescription : epic?.description,
]
}
def output = sortByEpicAndRequirementKeys(updatedReqs)
return [
(gampTopic.replaceAll(' ', '').toLowerCase()): output
]
}
def keysInDoc = computeKeysInDocForCSD(this.project.getRequirements())
if (project.data?.jira?.discontinuationsPerType) {
keysInDoc += project.data.jira.discontinuationsPerType.requirements*.key
keysInDoc += project.data.jira.discontinuationsPerType.epics*.key
}
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType]),
data : [
sections : sections,
requirements: requirementsForDocument,
documentHistory: docHistory?.getDocGenFormat() ?: []
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
protected Map sortByEpicAndRequirementKeys(List updatedReqs) {
def sortedUpdatedReqs = SortUtil.sortIssuesByKey(updatedReqs)
def reqsGroupByEpic = sortedUpdatedReqs.findAll {
it.epic != null }.groupBy { it.epic }.sort()
def reqsGroupByEpicUpdated = reqsGroupByEpic.values().indexed(1).collect { index, epicStories ->
def aStory = epicStories.first()
[
epicName : aStory.epicName,
epicTitle : aStory.epicTitle,
epicDescription : this.convertImages(aStory.epicDescription ?: ''),
key : aStory.epic,
epicIndex : index,
stories : epicStories,
]
}
def output = [
noepics: sortedUpdatedReqs.findAll { it.epic == null },
epics : reqsGroupByEpicUpdated
]
return output
}
@NonCPS
private def computeKeysInDocForCSD(def data) {
return data.collect { it.subMap(['key', 'epics']).values() }
.flatten().unique()
}
@NonCPS
private def computeKeysInDocForDTP(def data, def tests) {
return data.collect { 'Technology-' + it.id } + tests
.collect { [it.testKey, it.systemRequirement.split(', '), it.softwareDesignSpec.split(', ')] }
.flatten()
}
String createDTP(Map repo = null, Map data = null) {
def documentType = DocumentType.DTP as String
def sections = this.getDocumentSectionsFileOptional(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def unitTests = this.project.getAutomatedTestsTypeUnit()
def tests = this.computeTestsWithRequirementsAndSpecs(unitTests)
def modules = this.getReposWithUnitTestsInfo(unitTests)
def keysInDoc = this.computeKeysInDocForDTP(modules, tests)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType], repo),
data : [
sections: sections,
tests: tests,
modules: modules,
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
String createDTR(Map repo, Map data) {
def documentType = DocumentType.DTR as String
Map resurrectedDocument = resurrectAndStashDocument(documentType, repo)
this.steps.echo "Resurrected ${documentType} for ${repo.id} -> (${resurrectedDocument.found})"
if (resurrectedDocument.found) {
return resurrectedDocument.uri
}
def unitTestData = data.tests.unit
def sections = this.getDocumentSectionsFileOptional(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def testIssues = this.project.getAutomatedTestsTypeUnit("Technology-${repo.id}")
def discrepancies = this.computeTestDiscrepancies("Development Tests", testIssues, unitTestData.testResults)
def obtainEnum = { category, value ->
return this.project.getEnumDictionary(category)[value as String]
}
def tests = testIssues.collect { testIssue ->
def description = ''
if (testIssue.description) {
description += testIssue.description
} else {
description += testIssue.name
}
def riskLevels = testIssue.getResolvedRisks(). collect {
def value = obtainEnum("SeverityOfImpact", it.severityOfImpact)
return value ? value.text : "None"
}
def softwareDesignSpecs = testIssue.getResolvedTechnicalSpecifications()
.findAll { it.softwareDesignSpec }
.collect { it.key }
[
key : testIssue.key,
description : description ?: "N/A",
systemRequirement : testIssue.requirements.join(", "),
success : testIssue.isSuccess ? "Y" : "N",
remarks : testIssue.isUnexecuted ? "Not executed" : "N/A",
softwareDesignSpec: (softwareDesignSpecs.join(", ")) ?: "N/A",
riskLevel : riskLevels ? riskLevels.join(", ") : "N/A"
]
}
def keysInDoc = this.computeKeysInDocForDTR(tests)
def docHistory = this.getAndStoreDocumentHistory(documentType + '-' + repo.id, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType], repo),
data : [
repo : repo,
sections : sections,
tests : tests,
numAdditionalTests: junit.getNumberOfTestCases(unitTestData.testResults) - testIssues.count { !it.isUnexecuted },
testFiles : SortUtil.sortIssuesByProperties(unitTestData.testReportFiles.collect { file ->
[name: file.name, path: file.path, text: XmlUtil.serialize(file.text)]
} ?: [], ["name"]),
discrepancies : discrepancies.discrepancies,
conclusion : [
summary : discrepancies.conclusion.summary,
statement: discrepancies.conclusion.statement
],
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def files = unitTestData.testReportFiles.collectEntries { file ->
["raw/${file.getName()}", file.getBytes()]
}
def modifier = { document ->
return document
}
return this.createDocument(documentType, repo, data_, files, modifier, getDocumentTemplateName(documentType, repo), watermarkText)
}
@NonCPS
private def computeKeysInDocForDTR(def data) {
return data.collect {
[it.key, it.systemRequirement.split(', '), it.softwareDesignSpec.split(', ')]
}.flatten()
}
String createOverallDTR(Map repo = null, Map data = null) {
def documentTypeName = DOCUMENT_TYPE_NAMES[DocumentType.OVERALL_DTR as String]
def metadata = this.getDocumentMetadata(documentTypeName)
def documentType = DocumentType.DTR as String
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def uri = this.createOverallDocument('Overall-Cover', documentType, metadata, null, watermarkText)
def docVersion = this.project.getDocumentVersionFromHistories(documentType) as String
this.updateJiraDocumentationTrackingIssue(documentType, uri, docVersion)
return uri
}
String createDIL(Map repo = null, Map data = null) {
def documentType = DocumentType.DIL as String
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def bugs = this.project.getBugs().each { bug ->
bug.tests = bug.getResolvedTests()
}
def acceptanceTestBugs = bugs.findAll { bug ->
bug.tests.findAll { test ->
test.testType == Project.TestType.ACCEPTANCE
}
}
def integrationTestBugs = bugs.findAll { bug ->
bug.tests.findAll { test ->
test.testType == Project.TestType.INTEGRATION
}
}
SortUtil.sortIssuesByKey(acceptanceTestBugs)
SortUtil.sortIssuesByKey(integrationTestBugs)
def metadata = this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType])
metadata.orientation = "Landscape"
def data_ = [
metadata: metadata,
data : [:]
]
if (!integrationTestBugs.isEmpty()) {
data_.data.integrationTests = integrationTestBugs.collect { bug ->
[
//Discrepancy ID -> BUG Issue ID
discrepancyID : bug.key,
//Test Case No. -> JIRA (Test Case Key)
testcaseID : bug.tests. collect { it.key }.join(", "),
//- Level of Test Case = Unit / Integration / Acceptance / Installation
level : "Integration",
//Description of Failure or Discrepancy -> Bug Issue Summary
description : bug.name,
//Remediation Action -> "To be fixed"
remediation : "To be fixed",
//Responsible / Due Date -> JIRA (assignee, Due date)
responsibleAndDueDate: "${bug.assignee ? bug.assignee : 'N/A'} / ${bug.dueDate ? bug.dueDate : 'N/A'}",
//Outcome of the Resolution -> Bug Status
outcomeResolution : bug.status,
//Resolved Y/N -> JIRA Status -> Done = Yes
resolved : bug.status == "Done" ? "Yes" : "No"
]
}
}
if (!acceptanceTestBugs.isEmpty()) {
data_.data.acceptanceTests = acceptanceTestBugs.collect { bug ->
[
//Discrepancy ID -> BUG Issue ID
discrepancyID : bug.key,
//Test Case No. -> JIRA (Test Case Key)
testcaseID : bug.tests. collect { it.key }.join(", "),
//- Level of Test Case = Unit / Integration / Acceptance / Installation
level : "Acceptance",
//Description of Failure or Discrepancy -> Bug Issue Summary
description : bug.name,
//Remediation Action -> "To be fixed"
remediation : "To be fixed",
//Responsible / Due Date -> JIRA (assignee, Due date)
responsibleAndDueDate: "${bug.assignee ? bug.assignee : 'N/A'} / ${bug.dueDate ? bug.dueDate : 'N/A'}",
//Outcome of the Resolution -> Bug Status
outcomeResolution : bug.status,
//Resolved Y/N -> JIRA Status -> Done = Yes
resolved : bug.status == "Done" ? "Yes" : "No"
]
}
}
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri)
return uri
}
@NonCPS
private def computeKeysInDocForCFTP(def data) {
return data.collect { it.subMap(['key']).values() }.flatten()
}
String createCFTP(Map repo = null, Map data = null) {
def documentType = DocumentType.CFTP as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def acceptanceTestIssues = this.project.getAutomatedTestsTypeAcceptance()
def integrationTestIssues = this.project.getAutomatedTestsTypeIntegration()
def keysInDoc = this.computeKeysInDocForCFTP(integrationTestIssues + acceptanceTestIssues)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType]),
data : [
sections : sections,
acceptanceTests : computeTestIssueForCFTP(acceptanceTestIssues),
integrationTests: computeTestIssueForCFTP(integrationTestIssues),
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
@NonCPS
private List<LinkedHashMap<String, String>> computeTestIssueForCFTP(List<Project.JiraDataItem> testIssueList) {
testIssueList.collect { testIssue ->
[
key : testIssue.key,
description: testIssue.description ?: '',
ur_key : testIssue.requirements ? testIssue.requirements.join(', ') : 'N/A',
risk_key : testIssue.risks ? testIssue.risks.join(', ') : 'N/A'
]
}
}
@NonCPS
private def computeKeysInDocForCFTR(def data) {
return data.collect { it.subMap(['key']).values() }.flatten()
}
@SuppressWarnings('CyclomaticComplexity')
String createCFTR(Map repo, Map data) {
def documentType = DocumentType.CFTR as String
def acceptanceTestData = data.tests.acceptance
def integrationTestData = data.tests.integration
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def acceptanceTestIssues = SortUtil.sortIssuesByKey(this.project.getAutomatedTestsTypeAcceptance())
def integrationTestIssues = SortUtil.sortIssuesByKey(this.project.getAutomatedTestsTypeIntegration())
def discrepancies = this.computeTestDiscrepancies("Integration and Acceptance Tests", (acceptanceTestIssues + integrationTestIssues), junit.combineTestResults([acceptanceTestData.testResults, integrationTestData.testResults]))
def keysInDoc = this.computeKeysInDocForCFTR(integrationTestIssues + acceptanceTestIssues)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType]),
data : [
sections : sections,
numAdditionalAcceptanceTests : junit.getNumberOfTestCases(acceptanceTestData.testResults) - acceptanceTestIssues.count { !it.isUnexecuted },
numAdditionalIntegrationTests: junit.getNumberOfTestCases(integrationTestData.testResults) - integrationTestIssues.count { !it.isUnexecuted },
conclusion : [
summary : discrepancies.conclusion.summary,
statement: discrepancies.conclusion.statement
],
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
if (!acceptanceTestIssues.isEmpty()) {
data_.data.acceptanceTests = acceptanceTestIssues.collect { testIssue ->
[
key : testIssue.key,
datetime : testIssue.timestamp ? testIssue.timestamp.replaceAll("T", "</br>") : "N/A",
description: getTestDescription(testIssue),
remarks : testIssue.isUnexecuted ? "Not executed" : "",
risk_key : testIssue.risks ? testIssue.risks.join(", ") : "N/A",
success : testIssue.isSuccess ? "Y" : "N",
ur_key : testIssue.requirements ? testIssue.requirements.join(", ") : "N/A"
]
}
}
if (!integrationTestIssues.isEmpty()) {
data_.data.integrationTests = integrationTestIssues.collect { testIssue ->
[
key : testIssue.key,
datetime : testIssue.timestamp ? testIssue.timestamp.replaceAll("T", "</br>") : "N/A",
description: getTestDescription(testIssue),
remarks : testIssue.isUnexecuted ? "Not executed" : "",
risk_key : testIssue.risks ? testIssue.risks.join(", ") : "N/A",
success : testIssue.isSuccess ? "Y" : "N",
ur_key : testIssue.requirements ? testIssue.requirements.join(", ") : "N/A"
]
}
}
def files = (acceptanceTestData.testReportFiles + integrationTestData.testReportFiles).collectEntries { file ->
["raw/${file.getName()}", file.getBytes()]
}
def uri = this.createDocument(documentType, null, data_, files, null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
//TODO Use this method to generate the test description everywhere
def getTestDescription(testIssue) {
return testIssue.description ?: testIssue.name ?: 'N/A'
}
@NonCPS
private def computeKeysInDocForRA(def data) {
return data
.collect { it.subMap(['key', 'requirements', 'techSpecs', 'mitigations', 'tests']).values() }
.flatten()
}
String createRA(Map repo = null, Map data = null) {
def documentType = DocumentType.RA as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def obtainEnum = { category, value ->
return this.project.getEnumDictionary(category)[value as String]
}
def risks = this.project.getRisks().collect { r ->
def mitigationsText = this.replaceDashToNonBreakableUnicode(r.mitigations ? r.mitigations.join(", ") : "None")
def testsText = this.replaceDashToNonBreakableUnicode(r.tests ? r.tests.join(", ") : "None")
def requirements = (r.getResolvedSystemRequirements() + r.getResolvedTechnicalSpecifications())
def gxpRelevance = obtainEnum("GxPRelevance", r.gxpRelevance)
def probabilityOfOccurrence = obtainEnum("ProbabilityOfOccurrence", r.probabilityOfOccurrence)
def severityOfImpact = obtainEnum("SeverityOfImpact", r.severityOfImpact)
def probabilityOfDetection = obtainEnum("ProbabilityOfDetection", r.probabilityOfDetection)
def riskPriority = obtainEnum("RiskPriority", r.riskPriority)
return [
key: r.key,
name: r.name,
description: r.description,
proposedMeasures: "Mitigations: ${mitigationsText}<br/>Tests: ${testsText}",
requirements: requirements.findAll{it != null}.collect { it.name }.join("<br/>"),
requirementsKey: requirements.findAll{it != null}.collect { it.key }.join("<br/>"),
gxpRelevance: gxpRelevance ? gxpRelevance."short" : "None",
probabilityOfOccurrence: probabilityOfOccurrence ? probabilityOfOccurrence."short" : "None",
severityOfImpact: severityOfImpact ? severityOfImpact."short" : "None",
probabilityOfDetection: probabilityOfDetection ? probabilityOfDetection."short" : "None",
riskPriority: riskPriority ? riskPriority.value : "N/A",
riskPriorityNumber: r.riskPriorityNumber ?: "N/A",
riskComment: r.riskComment ? r.riskComment : "N/A",
]
}
def proposedMeasuresDesription = this.project.getRisks().collect { r ->
(r.getResolvedTests().collect {
if (!it) throw new IllegalArgumentException("Error: test for requirement ${r.key} could not be obtained. Check if all of ${r.tests.join(", ")} exist in JIRA")
[key: it.key, name: it.name, description: it.description, type: "test", referencesRisk: r.key]
} + r.getResolvedMitigations().collect { [key: it.key, name: it.name, description: it.description, type: "mitigation", referencesRisk: r.key] })
}.flatten()
if (!sections."sec4s2s2") sections."sec4s2s2" = [:]
if (this.project.getProjectProperties()."PROJECT.USES_POO" == "true") {
sections."sec4s2s2" = [
usesPoo : "true",
lowDescription : this.project.getProjectProperties()."PROJECT.POO_CAT.LOW",
mediumDescription: this.project.getProjectProperties()."PROJECT.POO_CAT.MEDIUM",
highDescription : this.project.getProjectProperties()."PROJECT.POO_CAT.HIGH"
]
}
if (!sections."sec5") sections."sec5" = [:]
sections."sec5".risks = SortUtil.sortIssuesByProperties(risks, ["requirementsKey", "key"])
sections."sec5".proposedMeasures = SortUtil.sortIssuesByKey(proposedMeasuresDesription)
def metadata = this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType])
metadata.orientation = "Landscape"
def keysInDoc = this.computeKeysInDocForRA(this.project.getRisks())
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: metadata,
data : [
sections: sections,
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
@NonCPS
private def computeKeysInDocForIPV(def data) {
return data
.collect { it.subMap(['key', 'components', 'techSpecs']).values() }
.flatten()
}
String createIVP(Map repo = null, Map data = null) {
def documentType = DocumentType.IVP as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def installationTestIssues = this.project.getAutomatedTestsTypeInstallation()
def testsGroupedByRepoType = groupTestsByRepoType(installationTestIssues)
def testsOfRepoTypeOdsCode = []
def testsOfRepoTypeOdsService = []
testsGroupedByRepoType.each { repoTypes, tests ->
if (repoTypes.contains(MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_CODE)) {
testsOfRepoTypeOdsCode.addAll(tests)
}
if (repoTypes.contains(MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_SERVICE)) {
testsOfRepoTypeOdsService.addAll(tests)
}
}
def keysInDoc = this.computeKeysInDocForIPV(installationTestIssues)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(DOCUMENT_TYPE_NAMES[documentType]),
data : [
repositories : this.project.repositories.collect { [id: it.id, type: it.type, data: [git: [url: it.data.git == null ? null : it.data.git.url]]] },
sections : sections,
tests : SortUtil.sortIssuesByKey(installationTestIssues.collect { testIssue ->
[
key : testIssue.key,
summary : testIssue.name,
techSpec: testIssue.techSpecs.join(", ") ?: "N/A"
]
}),
testsOdsService: testsOfRepoTypeOdsService,
testsOdsCode : testsOfRepoTypeOdsCode,
documentHistory: docHistory?.getDocGenFormat() ?: []
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
@NonCPS
private def computeKeysInDocForIVR(def data) {
return data
.collect { it.subMap(['key', 'components', 'techSpecs']).values() }
.flatten()
}
String createIVR(Map repo, Map data) {
def documentType = DocumentType.IVR as String
def installationTestData = data.tests.installation
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def installationTestIssues = this.project.getAutomatedTestsTypeInstallation()
def discrepancies = this.computeTestDiscrepancies("Installation Tests", installationTestIssues, installationTestData.testResults)
def testsOfRepoTypeOdsCode = []
def testsOfRepoTypeOdsService = []
def testsGroupedByRepoType = groupTestsByRepoType(installationTestIssues)
testsGroupedByRepoType.each { repoTypes, tests ->
if (repoTypes.contains(MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_CODE)) {
testsOfRepoTypeOdsCode.addAll(tests)
}
if (repoTypes.contains(MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_SERVICE)) {
testsOfRepoTypeOdsService.addAll(tests)
}
}
def keysInDoc = this.computeKeysInDocForIVR(installationTestIssues)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType]),
data : [
repositories : this.project.repositories.collect { [id: it.id, type: it.type, data: [git: [url: it.data.git == null ? null : it.data.git.url]]] },
sections : sections,
tests : SortUtil.sortIssuesByKey(installationTestIssues.collect { testIssue ->
[
key : testIssue.key,
description: testIssue.description ?: "",
remarks : testIssue.isUnexecuted ? "Not executed" : "",
success : testIssue.isSuccess ? "Y" : "N",
summary : testIssue.name,
techSpec : testIssue.techSpecs.join(", ") ?: "N/A"
]
}),
numAdditionalTests: junit.getNumberOfTestCases(installationTestData.testResults) - installationTestIssues.count { !it.isUnexecuted },
testFiles : SortUtil.sortIssuesByProperties(installationTestData.testReportFiles.collect { file ->
[name: file.name, path: file.path, text: file.text]
} ?: [], ["name"]),
discrepancies : discrepancies.discrepancies,
conclusion : [
summary : discrepancies.conclusion.summary,
statement: discrepancies.conclusion.statement
],
testsOdsService : testsOfRepoTypeOdsService,
testsOdsCode : testsOfRepoTypeOdsCode,
documentHistory : docHistory?.getDocGenFormat() ?: []
]
]
def files = data.tests.installation.testReportFiles.collectEntries { file ->
["raw/${file.getName()}", file.getBytes()]
}
def uri = this.createDocument(documentType, null, data_, files, null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
@NonCPS
private def computeKeysInDocForTCR(def data) {
return data.collect { it.subMap(['key', 'requirements', 'bugs']).values() }.flatten()
}
@SuppressWarnings('CyclomaticComplexity')
String createTCR(Map repo = null, Map data = null) {
String documentType = DocumentType.TCR as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def integrationTestData = data.tests.integration
def integrationTestIssues = this.project.getAutomatedTestsTypeIntegration()
def acceptanceTestData = data.tests.acceptance
def acceptanceTestIssues = this.project.getAutomatedTestsTypeAcceptance()
def matchedHandler = { result ->
result.each { testIssue, testCase ->
testIssue.isSuccess = !(testCase.error || testCase.failure || testCase.skipped
|| !testIssue.getResolvedBugs(). findAll { bug -> bug.status?.toLowerCase() != "done" }.isEmpty()
|| testIssue.isUnexecuted)
testIssue.comment = testIssue.isUnexecuted ? "This Test Case has not been executed" : ""
testIssue.timestamp = testIssue.isUnexecuted ? "N/A" : testCase.timestamp
testIssue.isUnexecuted = false
testIssue.actualResult = testIssue.isSuccess ? "Expected result verified by automated test" :
testIssue.isUnexecuted ? "Not executed" : "Test failed. Correction will be tracked by Jira issue task \"bug\" listed below."
}
}
def unmatchedHandler = { result ->
result.each { testIssue ->
testIssue.isSuccess = false
testIssue.isUnexecuted = true
testIssue.comment = testIssue.isUnexecuted ? "This Test Case has not been executed" : ""
testIssue.actualResult = !testIssue.isUnexecuted ? "Test failed. Correction will be tracked by Jira issue task \"bug\" listed below." : "Not executed"
}
}
this.jiraUseCase.matchTestIssuesAgainstTestResults(integrationTestIssues, integrationTestData?.testResults ?: [:], matchedHandler, unmatchedHandler)
this.jiraUseCase.matchTestIssuesAgainstTestResults(acceptanceTestIssues, acceptanceTestData?.testResults ?: [:], matchedHandler, unmatchedHandler)
def keysInDoc = this.computeKeysInDocForTCR(integrationTestIssues + acceptanceTestIssues)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(DOCUMENT_TYPE_NAMES[documentType]),
data : [
sections : sections,
integrationTests : SortUtil.sortIssuesByKey(integrationTestIssues.collect { testIssue ->
[
key : testIssue.key,
description : getTestDescription(testIssue),
requirements: testIssue.requirements ? testIssue.requirements.join(", ") : "N/A",
isSuccess : testIssue.isSuccess,
bugs : testIssue.bugs ? testIssue.bugs.join(", ") : (testIssue.comment ? "": "N/A"),
steps : sortTestSteps(testIssue.steps),
timestamp : testIssue.timestamp ? testIssue.timestamp.replaceAll("T", " ") : "N/A",
comment : testIssue.comment,
actualResult: testIssue.actualResult
]
}),
acceptanceTests : SortUtil.sortIssuesByKey(acceptanceTestIssues.collect { testIssue ->
[
key : testIssue.key,
description : testIssue.description,
requirements: testIssue.requirements ? testIssue.requirements.join(", ") : "N/A",
isSuccess : testIssue.isSuccess,
bugs : testIssue.bugs ? testIssue.bugs.join(", ") : (testIssue.comment ? "": "N/A"),
steps : sortTestSteps(testIssue.steps),
timestamp : testIssue.timestamp ? testIssue.timestamp.replaceAll("T", " ") : "N/A",
comment : testIssue.comment,
actualResult: testIssue.actualResult
]
}),
integrationTestFiles: SortUtil.sortIssuesByProperties(integrationTestData.testReportFiles.collect { file ->
[name: file.name, path: file.path, text: file.text]
} ?: [], ["name"]),
acceptanceTestFiles : SortUtil.sortIssuesByProperties(acceptanceTestData.testReportFiles.collect { file ->
[name: file.name, path: file.path, text: file.text]
} ?: [], ["name"]),
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
String createTCP(Map repo = null, Map data = null) {
String documentType = DocumentType.TCP as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def integrationTestIssues = this.project.getAutomatedTestsTypeIntegration()
def acceptanceTestIssues = this.project.getAutomatedTestsTypeAcceptance()
def keysInDoc = computeKeysInDocForTCP(integrationTestIssues + acceptanceTestIssues)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(DOCUMENT_TYPE_NAMES[documentType]),
data : [
sections : sections,
integrationTests: SortUtil.sortIssuesByKey(computeTestIssuesTestForTCP(integrationTestIssues)),
acceptanceTests : SortUtil.sortIssuesByKey(computeTestIssuesTestForTCP(acceptanceTestIssues)),
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def uri = this.createDocument(documentType, null, data_, [:], null, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri
}
@NonCPS
private List<Map> computeTestIssuesTestForTCP(List<Project.JiraDataItem> testIssues) {
testIssues.collect { testIssue ->
[
key : testIssue.key,
description : testIssue.description,
requirements: testIssue.requirements ? testIssue.requirements.join(", ") : "N/A",
bugs : testIssue.bugs ? testIssue.bugs.join(", ") : "N/A",
steps : sortTestSteps(testIssue.steps)
]
}
}
@NonCPS
def sortTestSteps(def testSteps) {
return testSteps?.sort(false) { it.orderId }
}
@NonCPS
private def computeKeysInDocForSSDS(def techSpecs, def componentsMetadata, def modules) {
def specs = techSpecs.collect { it.subMap(['key', 'requirements']).values() }.flatten()
def components = componentsMetadata.collect { it.key }
def mods = modules.collect { it.subMap(['requirementKeys', 'softwareDesignSpecKeys']).values() }.flatten()
return specs + components + mods
}
String createSSDS(Map repo = null, Map data = null) {
def documentType = DocumentType.SSDS as String
def sections = this.getDocumentSections(documentType)
def watermarkText = this.getWatermarkText(documentType, this.project.hasWipJiraIssues())
def componentsMetadata = SortUtil.sortIssuesByKey(this.computeComponentMetadata(documentType).values())
def systemDesignSpecifications = this.project.getTechnicalSpecifications()
.findAll { it.systemDesignSpec }
.collect { techSpec ->
[
key : techSpec.key,
req_key : techSpec.requirements?.join(", ") ?: "None",
description: this.convertImages(techSpec.systemDesignSpec)
]
}
if (!sections."sec3s1") sections."sec3s1" = [:]
sections."sec3s1".specifications = SortUtil.sortIssuesByProperties(systemDesignSpecifications, ["req_key", "key"])
if (!sections."sec5s1") sections."sec5s1" = [:]
sections."sec5s1".components = componentsMetadata.collect { c ->
[
key : c.key,
nameOfSoftware: c.nameOfSoftware,
componentType : c.componentType,
componentId : c.componentId,
description : c.description,
supplier : c.supplier,
version : c.version,
references : c.references
]
}
// Get the components that we consider modules in SSDS (the ones you have to code)
def modules = componentsMetadata
.findAll { it.odsRepoType.toLowerCase() == MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_CODE.toLowerCase() }
.collect { component ->
// We will set-up a double loop in the template. For moustache limitations we need to have lists
component.requirements = component.requirements.findAll{it != null}.collect { r ->
[key: r.key,
name: r.name,
reqDescription: this.convertImages(r.description),
gampTopic: r.gampTopic ?: "uncategorized"
]
}.groupBy { it.gampTopic.toLowerCase() }
.collect { k, v -> [gampTopic: k, requirementsofTopic: v] }
return component
}
if (!sections."sec10") sections."sec10" = [:]
sections."sec10".modules = modules
// Code review report
def codeRepos = this.project.repositories. findAll { it.type?.toLowerCase() == MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_CODE.toLowerCase() }
def codeReviewReports = obtainCodeReviewReport(codeRepos)
def modifier = { document ->
List documents = [document]
documents += codeReviewReports
// Merge the current document with the code review report
return this.pdf.merge(documents)
}
def keysInDoc = this.computeKeysInDocForSSDS(this.project.getTechnicalSpecifications(), componentsMetadata, modules)
def docHistory = this.getAndStoreDocumentHistory(documentType, keysInDoc)
def data_ = [
metadata: this.getDocumentMetadata(this.DOCUMENT_TYPE_NAMES[documentType], repo),
data : [
sections: sections,
documentHistory: docHistory?.getDocGenFormat() ?: [],
]
]
def uri = this.createDocument(documentType, null, data_, [:], modifier, getDocumentTemplateName(documentType), watermarkText)
this.updateJiraDocumentationTrackingIssue(documentType, uri, docHistory?.getVersion() as String)
return uri