@@ -339,7 +339,7 @@ class BinaryArrayConvertCliTest {
339
339
* Requirements class E-1, E-2
340
340
*/
341
341
@Test
342
- fun run_withVariableReferenceAttributes_outputsVariableReferences () {
342
+ fun run_withVariableValueAttributes_outputsVariableValues () {
343
343
val inputFile = writeToNetCdf(" /netcdf/var-ref.cdl" )
344
344
val outputFile = createTempFile()
345
345
val contextFile = ResourceFileConverter .toFile(" /jsonld/context.json" )
@@ -393,9 +393,9 @@ class BinaryArrayConvertCliTest {
393
393
}
394
394
}
395
395
statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/foo/var1" )) {
396
+ statement(TestVocab .references, createPlainLiteral(" var9" ))
396
397
statement(TestVocab .siblingVar, createResource(" http://test.binary-array-ld.net/example/foo/bar/var2" ))
397
398
statement(RDF .type, BALD .Resource )
398
- statement(BALD .references, createPlainLiteral(" var9" ))
399
399
}
400
400
}
401
401
statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/var0" )) {
@@ -420,39 +420,37 @@ class BinaryArrayConvertCliTest {
420
420
outputFile.absolutePath
421
421
)
422
422
423
- fun sortAnon (res : Resource ): String {
424
- return if (res.hasProperty(BALD .target)) {
425
- res.getProperty(BALD .target).`object `.toString()
426
- } else {
427
- res.id.toString()
428
- }
429
- }
430
-
431
423
val model = createDefaultModel().read(outputFile.toURI().toString(), " ttl" )
432
424
ModelVerifier (model).apply {
433
425
resource(" http://test.binary-array-ld.net/example" ) {
434
426
statement(RDF .type, BALD .Container )
435
427
statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/" )) {
436
428
statement(RDF .type, BALD .Container )
437
- statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/elev" ), sortAnon = ::sortAnon ) {
429
+ statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/elev" ), sortAnon = ::sortRefs ) {
438
430
statement(RDF .type, BALD .Array )
439
431
statement(RDFS .label, createPlainLiteral(" height" ))
440
432
statement(BALD .references) {
441
433
statement(RDF .type, BALD .Reference )
434
+ statement(BALD .sourceRefShape) {
435
+ list(15 , 10 )
436
+ }
442
437
statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/lat" ))
443
438
statement(BALD .targetRefShape) {
444
- list(createTypedLiteral( 15 ), createTypedLiteral( 1 ) )
439
+ list(15 , 1 )
445
440
}
446
441
}
447
442
statement(BALD .references) {
448
443
statement(RDF .type, BALD .Reference )
444
+ statement(BALD .sourceRefShape) {
445
+ list(15 , 10 )
446
+ }
449
447
statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/lon" ))
450
448
statement(BALD .targetRefShape) {
451
- list(createTypedLiteral( 1 ), createTypedLiteral( 10 ) )
449
+ list(1 , 10 )
452
450
}
453
451
}
454
452
statement(BALD .shape) {
455
- list(createTypedLiteral( 15 ), createTypedLiteral( 10 ) )
453
+ list(15 , 10 )
456
454
}
457
455
}
458
456
statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/lat" )) {
@@ -461,7 +459,7 @@ class BinaryArrayConvertCliTest {
461
459
statement(BALD .arrayFirstValue, createTypedLiteral(" 6.5" , XSDDatatype .XSDfloat ))
462
460
statement(BALD .arrayLastValue, createTypedLiteral(" -6.5" , XSDDatatype .XSDfloat ))
463
461
statement(BALD .shape) {
464
- list(createTypedLiteral( 15 ) )
462
+ list(15 )
465
463
}
466
464
}
467
465
statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/lon" )) {
@@ -470,11 +468,93 @@ class BinaryArrayConvertCliTest {
470
468
statement(BALD .arrayFirstValue, createTypedLiteral(" 0.5" , XSDDatatype .XSDfloat ))
471
469
statement(BALD .arrayLastValue, createTypedLiteral(" 9.5" , XSDDatatype .XSDfloat ))
472
470
statement(BALD .shape) {
473
- list(createTypedLiteral( 10 ) )
471
+ list(10 )
474
472
}
475
473
}
476
474
}
477
475
}
478
476
}
479
477
}
478
+
479
+ @Test
480
+ fun run_withVariableReferences_outputsVariableReferences () {
481
+ val inputFile = writeToNetCdf(" /netcdf/ref-attr.cdl" )
482
+ val outputFile = createTempFile()
483
+ val aliasFile = ResourceFileConverter .toFile(" /turtle/var-alias.ttl" , " ttl" )
484
+
485
+ run (
486
+ " --uri" , " http://test.binary-array-ld.net/example" ,
487
+ " --alias" , aliasFile.absolutePath,
488
+ inputFile.absolutePath,
489
+ outputFile.absolutePath
490
+ )
491
+
492
+ val model = createDefaultModel().read(outputFile.toURI().toString(), " ttl" )
493
+ ModelVerifier (model).apply {
494
+ resource(" http://test.binary-array-ld.net/example" ) {
495
+ statement(RDF .type, BALD .Container )
496
+ statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/" )) {
497
+ statement(RDF .type, BALD .Container )
498
+ statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/var0" ), sortAnon = ::sortRefs) {
499
+ statement(RDF .type, BALD .Array )
500
+ statement(BALD .references) {
501
+ statement(RDF .type, BALD .Reference )
502
+ statement(BALD .sourceRefShape) {
503
+ list(10 , 90 , 15 , 1 )
504
+ }
505
+ statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/var1" ))
506
+ statement(BALD .targetRefShape) {
507
+ list(1 , 90 , 15 , 60 )
508
+ }
509
+ }
510
+ statement(BALD .references) {
511
+ statement(RDF .type, BALD .Reference )
512
+ statement(BALD .sourceRefShape) {
513
+ list(10 , 90 , 15 )
514
+ }
515
+ statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/var2" ))
516
+ statement(BALD .targetRefShape) {
517
+ list(1 , 1 , 15 )
518
+ }
519
+ }
520
+ statement(BALD .shape) {
521
+ list(10 , 90 , 15 )
522
+ }
523
+ }
524
+ statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/var1" )) {
525
+ statement(TestVocab .references, createResource(" http://test.binary-array-ld.net/example/var2" ))
526
+ statement(RDF .type, BALD .Array )
527
+ statement(BALD .references) {
528
+ statement(RDF .type, BALD .Reference )
529
+ statement(BALD .sourceRefShape) {
530
+ list(90 , 15 , 60 )
531
+ }
532
+ statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/var2" ))
533
+ statement(BALD .targetRefShape) {
534
+ list(1 , 15 , 1 )
535
+ }
536
+ }
537
+ statement(BALD .shape) {
538
+ list(90 , 15 , 60 )
539
+ }
540
+ }
541
+ statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/var2" )) {
542
+ statement(RDF .type, BALD .Array )
543
+ statement(BALD .shape) {
544
+ list(15 )
545
+ }
546
+ }
547
+ statement(BALD .isPrefixedBy, createPlainLiteral(" prefix_list" ))
548
+ }
549
+ }
550
+ }
551
+ }
552
+
553
+ private fun sortRefs (res : Resource ): String {
554
+ return if (res.hasProperty(BALD .target)) {
555
+ res.getProperty(BALD .target).`object `.toString()
556
+ } else {
557
+ res.id.toString()
558
+ }
559
+ }
480
560
}
0 commit comments