Skip to content

Commit

Permalink
Add tests #333
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Sep 25, 2024
1 parent 27634d1 commit d84cc94
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ public void shouldLookupInSeparateInternalMap() {
);
}

@Test
public void shouldUseDefaultOptionFromLookupOption() {
assertMap(
"put_map('testMap', Aloha: Alohaeha, 'Moin': 'Moin zäme')",
LOOKUP + " 'testMap', default: 'Tach')"
);
}

@Test
public void shouldLookupInSeparateExternalFileMap() {
assertMap(
Expand Down Expand Up @@ -630,6 +638,52 @@ public void shouldUseDefaultValueIfNotFound() {
);
}

@Test
public void shouldUseDefaultOptionValueIfNotFound() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
"put_map('testMap', Aloha: Alohaeha, 'Moin': 'Moin zäme')",
"lookup('title.*', 'testMap', default: 'Tach')"
),
i -> {
i.startRecord("1");
i.literal("title", "Aloha");
i.literal("title", "Moin");
i.literal("title", "Yo");
i.endRecord();
},
o -> {
o.get().startRecord("1");
o.get().literal("title", "Alohaeha");
o.get().literal("title", "Moin zäme");
o.get().literal("title", "Tach");
o.get().endRecord();
}
);
}

@Test
public void shouldPreferDefaultOptionValueOverDefaultMapValue() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
"put_map('testMap', Aloha: Alohaeha, 'Moin': 'Moin zäme', __default: Tach)",
"lookup('title.*', 'testMap', default: 'Hi')"
),
i -> {
i.startRecord("1");
i.literal("title", "Aloha");
i.literal("title", "Moin");
i.literal("title", "Yo");
i.endRecord();
},
o -> {
o.get().startRecord("1");
o.get().literal("title", "Alohaeha");
o.get().literal("title", "Moin zäme");
o.get().literal("title", "Hi");
o.get().endRecord();
}
);
}

@Test
// See https://github.com/metafacture/metafacture-fix/issues/149
public void shouldDeleteNonFoundLookupOnDemand() {
Expand Down

0 comments on commit d84cc94

Please sign in to comment.