metanorma-iso 2.1.9 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,622 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Metanorma::Requirements::Iso::Modspec do
4
+ it "processes requirement components" do
5
+ input = <<~INPUT
6
+ <ogc-standard xmlns="https://standards.opengeospatial.org/document">
7
+ <preface><foreword id="A"><title>Preface</title>
8
+ <recommendation model="ogc" id="_">
9
+ <identifier>/ogc/recommendation/wfs/2</identifier>
10
+ <inherit>/ss/584/2015/level/1</inherit>
11
+ <subject>user</subject>
12
+ <description><p id="_">I recommend <em>1</em>.</p></description>
13
+ <component class="test-purpose" id="A1"><p>TEST PURPOSE</p></component>
14
+ <description><p id="_">I recommend <em>2</em>.</p></description>
15
+ <component class="guidance" id="A7"><p>GUIDANCE #1</p></component>
16
+ <description><p id="_">I recommend <em>2a</em>.</p></description>
17
+ <component class="conditions" id="A2"><p>CONDITIONS</p></component>
18
+ <description><p id="_">I recommend <em>3</em>.</p></description>
19
+ <component class="part" id="A3"><p>FIRST PART</p></component>
20
+ <description><p id="_">I recommend <em>4</em>.</p></description>
21
+ <component class="part" id="A4"><p>SECOND PART</p></component>
22
+ <description><p id="_">I recommend <em>5</em>.</p></description>
23
+ <component class="test-method" id="A5"><p>TEST METHOD</p></component>
24
+ <description><p id="_">I recommend <em>6</em>.</p></description>
25
+ <component class="part" id="A6"><p>THIRD PART</p></component>
26
+ <description><p id="_">I recommend <em>7</em>.</p></description>
27
+ <component class="guidance" id="A8"><p>GUIDANCE #2</p></component>
28
+ <description><p id="_">I recommend <em>7a</em>.</p></description>
29
+ <component class="panda GHz express" id="A7"><p>PANDA PART</p></component>
30
+ <description><p id="_">I recommend <em>8</em>.</p></description>
31
+ </recommendation>
32
+ </foreword>
33
+ </preface>
34
+ </ogc-standard>
35
+ INPUT
36
+ presxml = <<~OUTPUT
37
+ <ogc-standard xmlns='https://standards.opengeospatial.org/document' type='presentation'>
38
+ <preface>
39
+ <foreword id='A' displayorder='1'>
40
+ <title>Preface</title>
41
+ <table id='_' class='modspec' type='recommend'>
42
+ <name>Table 1 — Recommendation 1</name>
43
+ <tbody>
44
+ <tr>
45
+ <td>Identifier</td>
46
+ <td>
47
+ <tt>/ogc/recommendation/wfs/2</tt>
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td>Subject</td>
52
+ <td>user</td>
53
+ </tr>
54
+ <tr>
55
+ <td>Dependency</td>
56
+ <td>/ss/584/2015/level/1</td>
57
+ </tr>
58
+ <tr>
59
+ <td>Statement</td>
60
+ <td>
61
+ <p id='_'>
62
+ I recommend
63
+ <em>1</em>
64
+ .
65
+ </p>
66
+ </td>
67
+ </tr>
68
+ <tr id='A1'>
69
+ <td>Test purpose</td>
70
+ <td>
71
+ <p>TEST PURPOSE</p>
72
+ </td>
73
+ </tr>
74
+ <tr>
75
+ <td>Statement</td>
76
+ <td>
77
+ <p id='_'>
78
+ I recommend
79
+ <em>2</em>
80
+ .
81
+ </p>
82
+ </td>
83
+ </tr>
84
+ <tr>
85
+ <td>Statement</td>
86
+ <td>
87
+ <p id='_'>
88
+ I recommend
89
+ <em>2a</em>
90
+ .
91
+ </p>
92
+ </td>
93
+ </tr>
94
+ <tr id='A2'>
95
+ <td>Conditions</td>
96
+ <td>
97
+ <p>CONDITIONS</p>
98
+ </td>
99
+ </tr>
100
+ <tr>
101
+ <td>Statement</td>
102
+ <td>
103
+ <p id='_'>
104
+ I recommend
105
+ <em>3</em>
106
+ .
107
+ </p>
108
+ </td>
109
+ </tr>
110
+ <tr id='A3'>
111
+ <td>A</td>
112
+ <td>
113
+ <p>FIRST PART</p>
114
+ </td>
115
+ </tr>
116
+ <tr>
117
+ <td>Statement</td>
118
+ <td>
119
+ <p id='_'>
120
+ I recommend
121
+ <em>4</em>
122
+ .
123
+ </p>
124
+ </td>
125
+ </tr>
126
+ <tr id='A4'>
127
+ <td>B</td>
128
+ <td>
129
+ <p>SECOND PART</p>
130
+ </td>
131
+ </tr>
132
+ <tr>
133
+ <td>Statement</td>
134
+ <td>
135
+ <p id='_'>
136
+ I recommend
137
+ <em>5</em>
138
+ .
139
+ </p>
140
+ </td>
141
+ </tr>
142
+ <tr id='A5'>
143
+ <td>Test method</td>
144
+ <td>
145
+ <p>TEST METHOD</p>
146
+ </td>
147
+ </tr>
148
+ <tr>
149
+ <td>Statement</td>
150
+ <td>
151
+ <p id='_'>
152
+ I recommend
153
+ <em>6</em>
154
+ .
155
+ </p>
156
+ </td>
157
+ </tr>
158
+ <tr id='A6'>
159
+ <td>C</td>
160
+ <td>
161
+ <p>THIRD PART</p>
162
+ </td>
163
+ </tr>
164
+ <tr>
165
+ <td>Statement</td>
166
+ <td>
167
+ <p id='_'>
168
+ I recommend
169
+ <em>7</em>
170
+ .
171
+ </p>
172
+ </td>
173
+ </tr>
174
+ <tr>
175
+ <td>Statement</td>
176
+ <td>
177
+ <p id='_'>
178
+ I recommend
179
+ <em>7a</em>
180
+ .
181
+ </p>
182
+ </td>
183
+ </tr>
184
+ <tr id='A7'>
185
+ <td>Panda GHz express</td>
186
+ <td>
187
+ <p>PANDA PART</p>
188
+ </td>
189
+ </tr>
190
+ <tr>
191
+ <td>Statement</td>
192
+ <td>
193
+ <p id='_'>
194
+ I recommend
195
+ <em>8</em>
196
+ .
197
+ </p>
198
+ </td>
199
+ </tr>
200
+ <tr id='A7'>
201
+ <td>Guidance</td>
202
+ <td>
203
+ <p>GUIDANCE #1</p>
204
+ </td>
205
+ </tr>
206
+ <tr id='A8'>
207
+ <td>Guidance</td>
208
+ <td>
209
+ <p>GUIDANCE #2</p>
210
+ </td>
211
+ </tr>
212
+ </tbody>
213
+ </table>
214
+ </foreword>
215
+ </preface>
216
+ </ogc-standard>
217
+ OUTPUT
218
+
219
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
220
+ .convert("test", input, true)
221
+ .gsub(%r{^.*<body}m, "<body")
222
+ .gsub(%r{</body>.*}m, "</body>")))
223
+ .to be_equivalent_to xmlpp(presxml)
224
+ end
225
+
226
+ it "processes requirement components for recommendation classes" do
227
+ input = <<~INPUT
228
+ <ogc-standard xmlns="https://standards.opengeospatial.org/document">
229
+ <preface><foreword id="A"><title>Preface</title>
230
+ <recommendation model="ogc" id="_" type="class">
231
+ <identifier>/ogc/recommendation/wfs/2</identifier>
232
+ <inherit>/ss/584/2015/level/1</inherit>
233
+ <subject>user</subject>
234
+ <description><p id="_">I recommend <em>1</em>.</p></description>
235
+ <component class="test-purpose" id="A1"><p>TEST PURPOSE</p></component>
236
+ <description><p id="_">I recommend <em>2</em>.</p></description>
237
+ <component class="conditions" id="A2"><p>CONDITIONS</p></component>
238
+ <description><p id="_">I recommend <em>3</em>.</p></description>
239
+ <component class="part" id="A3"><p>FIRST PART</p></component>
240
+ <description><p id="_">I recommend <em>4</em>.</p></description>
241
+ <component class="part" id="A4"><p>SECOND PART</p></component>
242
+ <description><p id="_">I recommend <em>5</em>.</p></description>
243
+ <component class="test-method" id="A5"><p>TEST METHOD</p></component>
244
+ <description><p id="_">I recommend <em>6</em>.</p></description>
245
+ <component class="part" id="A6"><p>THIRD PART</p></component>
246
+ <description><p id="_">I recommend <em>7</em>.</p></description>
247
+ <component class="panda GHz express" id="A7"><p>PANDA PART</p></component>
248
+ <description><p id="_">I recommend <em>8</em>.</p></description>
249
+ </recommendation>
250
+ </foreword>
251
+ </preface>
252
+ </ogc-standard>
253
+ INPUT
254
+ presxml = <<~OUTPUT
255
+ <ogc-standard xmlns='https://standards.opengeospatial.org/document' type='presentation'>
256
+ <preface>
257
+ <foreword id='A' displayorder='1'>
258
+ <title>Preface</title>
259
+ <table id='_' class='modspec' type='recommendclass'>
260
+ <name>Table 1 — Recommendations class 1</name>
261
+ <tbody>
262
+ <tr>
263
+ <td>Identifier</td>
264
+ <td>
265
+ <tt>/ogc/recommendation/wfs/2</tt>
266
+ </td>
267
+ </tr>
268
+ <tr>
269
+ <td>Target type</td>
270
+ <td>user</td>
271
+ </tr>
272
+ <tr>
273
+ <td>Dependency</td>
274
+ <td>/ss/584/2015/level/1</td>
275
+ </tr>
276
+ <tr>
277
+ <td>Description</td>
278
+ <td>
279
+ <p id='_'>
280
+ I recommend
281
+ <em>1</em>
282
+ .
283
+ </p>
284
+ </td>
285
+ </tr>
286
+ <tr id='A1'>
287
+ <td>Test purpose</td>
288
+ <td>
289
+ <p>TEST PURPOSE</p>
290
+ </td>
291
+ </tr>
292
+ <tr>
293
+ <td>Description</td>
294
+ <td>
295
+ <p id='_'>
296
+ I recommend
297
+ <em>2</em>
298
+ .
299
+ </p>
300
+ </td>
301
+ </tr>
302
+ <tr id='A2'>
303
+ <td>Conditions</td>
304
+ <td>
305
+ <p>CONDITIONS</p>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <td>Description</td>
310
+ <td>
311
+ <p id='_'>
312
+ I recommend
313
+ <em>3</em>
314
+ .
315
+ </p>
316
+ </td>
317
+ </tr>
318
+ <tr id='A3'>
319
+ <td>A</td>
320
+ <td>
321
+ <p>FIRST PART</p>
322
+ </td>
323
+ </tr>
324
+ <tr>
325
+ <td>Description</td>
326
+ <td>
327
+ <p id='_'>
328
+ I recommend
329
+ <em>4</em>
330
+ .
331
+ </p>
332
+ </td>
333
+ </tr>
334
+ <tr id='A4'>
335
+ <td>B</td>
336
+ <td>
337
+ <p>SECOND PART</p>
338
+ </td>
339
+ </tr>
340
+ <tr>
341
+ <td>Description</td>
342
+ <td>
343
+ <p id='_'>
344
+ I recommend
345
+ <em>5</em>
346
+ .
347
+ </p>
348
+ </td>
349
+ </tr>
350
+ <tr id='A5'>
351
+ <td>Test method</td>
352
+ <td>
353
+ <p>TEST METHOD</p>
354
+ </td>
355
+ </tr>
356
+ <tr>
357
+ <td>Description</td>
358
+ <td>
359
+ <p id='_'>
360
+ I recommend
361
+ <em>6</em>
362
+ .
363
+ </p>
364
+ </td>
365
+ </tr>
366
+ <tr id='A6'>
367
+ <td>C</td>
368
+ <td>
369
+ <p>THIRD PART</p>
370
+ </td>
371
+ </tr>
372
+ <tr>
373
+ <td>Description</td>
374
+ <td>
375
+ <p id='_'>
376
+ I recommend
377
+ <em>7</em>
378
+ .
379
+ </p>
380
+ </td>
381
+ </tr>
382
+ <tr id='A7'>
383
+ <td>Panda GHz express</td>
384
+ <td>
385
+ <p>PANDA PART</p>
386
+ </td>
387
+ </tr>
388
+ <tr>
389
+ <td>Description</td>
390
+ <td>
391
+ <p id='_'>
392
+ I recommend
393
+ <em>8</em>
394
+ .
395
+ </p>
396
+ </td>
397
+ </tr>
398
+ </tbody>
399
+ </table>
400
+ </foreword>
401
+ </preface>
402
+ </ogc-standard>
403
+ OUTPUT
404
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
405
+ .convert("test", input, true)
406
+ .gsub(%r{^.*<body}m, "<body")
407
+ .gsub(%r{</body>.*}m, "</body>")))
408
+ .to be_equivalent_to xmlpp(presxml)
409
+ end
410
+
411
+ it "processes nested requirement steps" do
412
+ input = <<~INPUT
413
+ <ogc-standard xmlns="https://standards.opengeospatial.org/document">
414
+ <preface>
415
+ <foreword id="A"><title>Preface</title>
416
+ <requirement model="ogc" id='A1'>
417
+ <component exclude='false' class='test method type'>
418
+ <p id='_'>Manual Inspection</p>
419
+ </component>
420
+ <component exclude='false' class='test-method'>
421
+ <p id='1'>
422
+ <component exclude='false' class='step'>
423
+ <p id='2'>For each UML class defined or referenced in the Tunnel Package:</p>
424
+ <component exclude='false' class='step'>
425
+ <p id='3'>
426
+ Validate that the Implementation Specification contains a data
427
+ element which represents the same concept as that defined for
428
+ the UML class.
429
+ </p>
430
+ </component>
431
+ <component exclude='false' class='step'>
432
+ <p id='4'>
433
+ Validate that the data element has the same relationships with
434
+ other elements as those defined for the UML class. Validate that
435
+ those relationships have the same source, target, direction,
436
+ roles, and multiplicies as those documented in the Conceptual
437
+ Model.
438
+ </p>
439
+ </component>
440
+ </component>
441
+ </p>
442
+ </component>
443
+ </requirement>
444
+ </foreword></preface>
445
+ </ogc-standard>
446
+ INPUT
447
+ presxml = <<~PRESXML
448
+ <ogc-standard xmlns='https://standards.opengeospatial.org/document' type='presentation'>
449
+ <preface>
450
+ <foreword id='A' displayorder='1'>
451
+ <title>Preface</title>
452
+ <table id='A1' class='modspec' type='recommend'>
453
+ <name>Table 1 — Requirement 1</name>
454
+ <tbody>
455
+ <tr>
456
+ <td>Test method type</td>
457
+ <td>
458
+ <p id='_'>Manual Inspection</p>
459
+ </td>
460
+ </tr>
461
+ <tr>
462
+ <td>Test method</td>
463
+ <td>
464
+ <p id='1'>
465
+ <ol class="steps">
466
+ <li>
467
+ <p id='2'>For each UML class defined or referenced in the Tunnel Package:</p>
468
+ <ol class="steps">
469
+ <li>
470
+ <p id='3'>
471
+ Validate that the Implementation Specification
472
+ contains a data element which represents the same
473
+ concept as that defined for the UML class.
474
+ </p>
475
+ </li>
476
+ <li>
477
+ <p id='4'>
478
+ Validate that the data element has the same
479
+ relationships with other elements as those defined for
480
+ the UML class. Validate that those relationships have
481
+ the same source, target, direction, roles, and
482
+ multiplicies as those documented in the Conceptual
483
+ Model.
484
+ </p>
485
+ </li>
486
+ </ol>
487
+ </li>
488
+ </ol>
489
+ </p>
490
+ </td>
491
+ </tr>
492
+ </tbody>
493
+ </table>
494
+ </foreword>
495
+ </preface>
496
+ </ogc-standard>
497
+ PRESXML
498
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
499
+ .convert("test", input, true)))
500
+ .to be_equivalent_to xmlpp(presxml)
501
+ end
502
+
503
+ it "processes bidirectional requirement/conformance tests" do
504
+ input = <<~INPUT
505
+ <ogc-standard xmlns="https://standards.opengeospatial.org/document">
506
+ <preface>
507
+ <foreword id="A"><title>Preface</title>
508
+ <requirement model="ogc" id='A1' type="general">
509
+ <title>First</title>
510
+ <identifier>/ogc/recommendation/wfs/1</identifier>
511
+ </requirement>
512
+ <requirement model="ogc" id='A2' type="verification">
513
+ <title>Second</title>
514
+ <identifier>/ogc/recommendation/wfs/2</identifier>
515
+ <classification><tag>target</tag><value>/ogc/recommendation/wfs/1</value></classification>
516
+ </requirement>
517
+ <requirement model="ogc" id='A3' type="class">
518
+ <title>Third</title>
519
+ <identifier>/ogc/recommendation/wfs/3</identifier>
520
+ </requirement>
521
+ <requirement model="ogc" id='A4' type="conformanceclass">
522
+ <title>Fourth</title>
523
+ <identifier>/ogc/recommendation/wfs/4</identifier>
524
+ <classification><tag>target</tag><value>/ogc/recommendation/wfs/3</value></classification>
525
+ </requirement>
526
+ </foreword></preface>
527
+ </ogc-standard>
528
+ INPUT
529
+ presxml = <<~PRESXML
530
+ <ogc-standard xmlns='https://standards.opengeospatial.org/document' type='presentation'>
531
+ <preface>
532
+ <foreword id='A' displayorder='1'>
533
+ <title>Preface</title>
534
+ <table id='A1' class='modspec' type='recommend'>
535
+ <name>Table 1 — Requirement 1: First</name>
536
+ <tbody>
537
+ <tr>
538
+ <td>Identifier</td>
539
+ <td>
540
+ <tt>/ogc/recommendation/wfs/1</tt>
541
+ </td>
542
+ </tr>
543
+ <tr>
544
+ <td>Conformance test</td>
545
+ <td>
546
+ <xref target='A2'>
547
+ Conformance test 1:
548
+ Second
549
+ </xref>
550
+ </td>
551
+ </tr>
552
+ </tbody>
553
+ </table>
554
+ <table id='A2' class='modspec' type='recommendtest'>
555
+ <name>Table 2 — Conformance test 1: Second</name>
556
+ <tbody>
557
+ <tr>
558
+ <td>Identifier</td>
559
+ <td>
560
+ <tt>/ogc/recommendation/wfs/2</tt>
561
+ </td>
562
+ </tr>
563
+ <tr>
564
+ <td>Requirement</td>
565
+ <td>
566
+ <xref target='A1'>
567
+ Requirement 1:
568
+ First
569
+ </xref>
570
+ </td>
571
+ </tr>
572
+ </tbody>
573
+ </table>
574
+ <table id='A3' class='modspec' type='recommendclass'>
575
+ <name>Table 3 — Requirements class 1: Third</name>
576
+ <tbody>
577
+ <tr>
578
+ <td>Identifier</td>
579
+ <td>
580
+ <tt>/ogc/recommendation/wfs/3</tt>
581
+ </td>
582
+ </tr>
583
+ <tr>
584
+ <td>Conformance test</td>
585
+ <td>
586
+ <xref target='A4'>
587
+ Conformance class 1:
588
+ Fourth
589
+ </xref>
590
+ </td>
591
+ </tr>
592
+ </tbody>
593
+ </table>
594
+ <table id='A4' class='modspec' type='recommendclass'>
595
+ <name>Table 4 — Conformance class 1: Fourth</name>
596
+ <tbody>
597
+ <tr>
598
+ <td>Identifier</td>
599
+ <td>
600
+ <tt>/ogc/recommendation/wfs/4</tt>
601
+ </td>
602
+ </tr>
603
+ <tr>
604
+ <td>Requirements class</td>
605
+ <td>
606
+ <xref target='A3'>
607
+ Requirements class 1:
608
+ Third
609
+ </xref>
610
+ </td>
611
+ </tr>
612
+ </tbody>
613
+ </table>
614
+ </foreword>
615
+ </preface>
616
+ </ogc-standard>
617
+ PRESXML
618
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
619
+ .convert("test", input, true)))
620
+ .to be_equivalent_to xmlpp(presxml)
621
+ end
622
+ end