@@ -339,7 +339,7 @@ class BinaryArrayConvertCliTest {
339339 * Requirements class E-1, E-2
340340 */
341341 @Test
342- fun run_withVariableReferenceAttributes_outputsVariableReferences () {
342+ fun run_withVariableValueAttributes_outputsVariableValues () {
343343 val inputFile = writeToNetCdf(" /netcdf/var-ref.cdl" )
344344 val outputFile = createTempFile()
345345 val contextFile = ResourceFileConverter .toFile(" /jsonld/context.json" )
@@ -393,9 +393,9 @@ class BinaryArrayConvertCliTest {
393393 }
394394 }
395395 statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/foo/var1" )) {
396+ statement(TestVocab .references, createPlainLiteral(" var9" ))
396397 statement(TestVocab .siblingVar, createResource(" http://test.binary-array-ld.net/example/foo/bar/var2" ))
397398 statement(RDF .type, BALD .Resource )
398- statement(BALD .references, createPlainLiteral(" var9" ))
399399 }
400400 }
401401 statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/var0" )) {
@@ -420,39 +420,37 @@ class BinaryArrayConvertCliTest {
420420 outputFile.absolutePath
421421 )
422422
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-
431423 val model = createDefaultModel().read(outputFile.toURI().toString(), " ttl" )
432424 ModelVerifier (model).apply {
433425 resource(" http://test.binary-array-ld.net/example" ) {
434426 statement(RDF .type, BALD .Container )
435427 statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/" )) {
436428 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 ) {
438430 statement(RDF .type, BALD .Array )
439431 statement(RDFS .label, createPlainLiteral(" height" ))
440432 statement(BALD .references) {
441433 statement(RDF .type, BALD .Reference )
434+ statement(BALD .sourceRefShape) {
435+ list(15 , 10 )
436+ }
442437 statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/lat" ))
443438 statement(BALD .targetRefShape) {
444- list(createTypedLiteral( 15 ), createTypedLiteral( 1 ) )
439+ list(15 , 1 )
445440 }
446441 }
447442 statement(BALD .references) {
448443 statement(RDF .type, BALD .Reference )
444+ statement(BALD .sourceRefShape) {
445+ list(15 , 10 )
446+ }
449447 statement(BALD .target, createResource(" http://test.binary-array-ld.net/example/lon" ))
450448 statement(BALD .targetRefShape) {
451- list(createTypedLiteral( 1 ), createTypedLiteral( 10 ) )
449+ list(1 , 10 )
452450 }
453451 }
454452 statement(BALD .shape) {
455- list(createTypedLiteral( 15 ), createTypedLiteral( 10 ) )
453+ list(15 , 10 )
456454 }
457455 }
458456 statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/lat" )) {
@@ -461,7 +459,7 @@ class BinaryArrayConvertCliTest {
461459 statement(BALD .arrayFirstValue, createTypedLiteral(" 6.5" , XSDDatatype .XSDfloat ))
462460 statement(BALD .arrayLastValue, createTypedLiteral(" -6.5" , XSDDatatype .XSDfloat ))
463461 statement(BALD .shape) {
464- list(createTypedLiteral( 15 ) )
462+ list(15 )
465463 }
466464 }
467465 statement(BALD .contains, createResource(" http://test.binary-array-ld.net/example/lon" )) {
@@ -470,11 +468,93 @@ class BinaryArrayConvertCliTest {
470468 statement(BALD .arrayFirstValue, createTypedLiteral(" 0.5" , XSDDatatype .XSDfloat ))
471469 statement(BALD .arrayLastValue, createTypedLiteral(" 9.5" , XSDDatatype .XSDfloat ))
472470 statement(BALD .shape) {
473- list(createTypedLiteral( 10 ) )
471+ list(10 )
474472 }
475473 }
476474 }
477475 }
478476 }
479477 }
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+ }
480560}
0 commit comments