@@ -453,6 +453,14 @@ public void shouldLookupInSeparateInternalMap() {
453
453
);
454
454
}
455
455
456
+ @ Test
457
+ public void shouldUseDefaultOptionFromLookupOption () {
458
+ assertMap (
459
+ "put_map('testMap', Aloha: Alohaeha, 'Moin': 'Moin zäme')" ,
460
+ LOOKUP + " 'testMap', default: 'Tach')"
461
+ );
462
+ }
463
+
456
464
@ Test
457
465
public void shouldLookupInSeparateExternalFileMap () {
458
466
assertMap (
@@ -630,6 +638,52 @@ public void shouldUseDefaultValueIfNotFound() {
630
638
);
631
639
}
632
640
641
+ @ Test
642
+ public void shouldUseDefaultOptionValueIfNotFound () {
643
+ MetafixTestHelpers .assertFix (streamReceiver , Arrays .asList (
644
+ "put_map('testMap', Aloha: Alohaeha, 'Moin': 'Moin zäme')" ,
645
+ "lookup('title.*', 'testMap', default: 'Tach')"
646
+ ),
647
+ i -> {
648
+ i .startRecord ("1" );
649
+ i .literal ("title" , "Aloha" );
650
+ i .literal ("title" , "Moin" );
651
+ i .literal ("title" , "Yo" );
652
+ i .endRecord ();
653
+ },
654
+ o -> {
655
+ o .get ().startRecord ("1" );
656
+ o .get ().literal ("title" , "Alohaeha" );
657
+ o .get ().literal ("title" , "Moin zäme" );
658
+ o .get ().literal ("title" , "Tach" );
659
+ o .get ().endRecord ();
660
+ }
661
+ );
662
+ }
663
+
664
+ @ Test
665
+ public void shouldPreferDefaultOptionValueOverDefaultMapValue () {
666
+ MetafixTestHelpers .assertFix (streamReceiver , Arrays .asList (
667
+ "put_map('testMap', Aloha: Alohaeha, 'Moin': 'Moin zäme', __default: Tach)" ,
668
+ "lookup('title.*', 'testMap', default: 'Hi')"
669
+ ),
670
+ i -> {
671
+ i .startRecord ("1" );
672
+ i .literal ("title" , "Aloha" );
673
+ i .literal ("title" , "Moin" );
674
+ i .literal ("title" , "Yo" );
675
+ i .endRecord ();
676
+ },
677
+ o -> {
678
+ o .get ().startRecord ("1" );
679
+ o .get ().literal ("title" , "Alohaeha" );
680
+ o .get ().literal ("title" , "Moin zäme" );
681
+ o .get ().literal ("title" , "Hi" );
682
+ o .get ().endRecord ();
683
+ }
684
+ );
685
+ }
686
+
633
687
@ Test
634
688
// See https://github.com/metafacture/metafacture-fix/issues/149
635
689
public void shouldDeleteNonFoundLookupOnDemand () {
0 commit comments