Skip to content

Commit 726d0fa

Browse files
committed
Add test for to_var #282
1 parent 5561729 commit 726d0fa

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,4 +4084,39 @@ public void shouldTransformStringToBase64() {
40844084
);
40854085
}
40864086

4087+
@Test
4088+
public void shouldCreateVariableFromLiteralValue() {
4089+
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
4090+
"to_var('data.title','testVar')",
4091+
"add_field('testResult','This is a $[testVar]')"
4092+
),
4093+
i -> {
4094+
i.startRecord("1");
4095+
i.startEntity("data");
4096+
i.literal("title", "test");
4097+
i.endEntity();
4098+
i.endRecord();
4099+
i.startRecord("2");
4100+
i.startEntity("data");
4101+
i.literal("title", "second-test");
4102+
i.endEntity();
4103+
i.endRecord();
4104+
},
4105+
o -> {
4106+
o.get().startRecord("1");
4107+
o.get().startEntity("data");
4108+
o.get().literal("title", "test");
4109+
o.get().endEntity();
4110+
o.get().literal("testResult", "This is a test");
4111+
o.get().endRecord();
4112+
o.get().startRecord("2");
4113+
o.get().startEntity("data");
4114+
o.get().literal("title", "second-test");
4115+
o.get().endEntity();
4116+
o.get().literal("testResult", "This is a second-test");
4117+
o.get().endRecord();
4118+
}
4119+
);
4120+
}
4121+
40874122
}

0 commit comments

Comments
 (0)