@@ -4097,51 +4097,24 @@ public void shouldCreateVariableFromLiteralValue() {
4097
4097
i .endEntity ();
4098
4098
i .endRecord ();
4099
4099
i .startRecord ("2" );
4100
- i .startEntity ("data" );
4101
- i .literal ("title" , "test1" );
4102
- i .literal ("title" , "test2" );
4103
- i .endEntity ();
4104
4100
i .endRecord ();
4105
4101
i .startRecord ("3" );
4106
4102
i .startEntity ("data" );
4107
- i .startEntity ("title" );
4108
- i .literal ("key" , "value" );
4109
- i .endEntity ();
4110
- i .endEntity ();
4111
- i .endRecord ();
4112
- i .startRecord ("4" );
4113
- i .endRecord ();
4114
- i .startRecord ("5" );
4115
- i .startEntity ("data" );
4116
4103
i .literal ("title" , "final-test" );
4117
4104
i .endEntity ();
4118
4105
i .endRecord ();
4119
4106
},
4120
- ( o , f ) -> {
4107
+ o -> {
4121
4108
o .get ().startRecord ("1" );
4122
4109
o .get ().startEntity ("data" );
4123
4110
o .get ().literal ("title" , "test" );
4124
4111
o .get ().endEntity ();
4125
4112
o .get ().literal ("testResult" , "This is a test" );
4126
4113
o .get ().endRecord ();
4127
4114
o .get ().startRecord ("2" );
4128
- o .get ().startEntity ("data" );
4129
- o .get ().literal ("title" , "test1" );
4130
- o .get ().literal ("title" , "test2" );
4131
- o .get ().endEntity ();
4132
- o .get ().literal ("testResult" , "This is a [test1, test2]" );
4133
- o .get ().endRecord ();
4134
- o .get ().startRecord ("3" );
4135
- o .get ().startEntity ("data" );
4136
- o .get ().startEntity ("title" );
4137
- o .get ().literal ("key" , "value" );
4138
- f .apply (2 ).endEntity ();
4139
- o .get ().literal ("testResult" , "This is a {key=value}" );
4140
- o .get ().endRecord ();
4141
- o .get ().startRecord ("4" );
4142
4115
o .get ().literal ("testResult" , "This is a " );
4143
4116
o .get ().endRecord ();
4144
- o .get ().startRecord ("5 " );
4117
+ o .get ().startRecord ("3 " );
4145
4118
o .get ().startEntity ("data" );
4146
4119
o .get ().literal ("title" , "final-test" );
4147
4120
o .get ().endEntity ();
@@ -4180,4 +4153,45 @@ public void shouldCreateVariableFromLiteralValueWithDefault() {
4180
4153
);
4181
4154
}
4182
4155
4156
+ @ Test
4157
+ public void shouldNotCreateVariableFromArrayValue () {
4158
+ MetafixTestHelpers .assertExecutionException (IllegalStateException .class , "Expected String, got Array" , () ->
4159
+ MetafixTestHelpers .assertFix (streamReceiver , Arrays .asList (
4160
+ "to_var('data.title', 'testVar')"
4161
+ ),
4162
+ i -> {
4163
+ i .startRecord ("1" );
4164
+ i .startEntity ("data" );
4165
+ i .literal ("title" , "test1" );
4166
+ i .literal ("title" , "test2" );
4167
+ i .endEntity ();
4168
+ i .endRecord ();
4169
+ },
4170
+ o -> {
4171
+ }
4172
+ )
4173
+ );
4174
+ }
4175
+
4176
+ @ Test
4177
+ public void shouldNotCreateVariableFromHashValue () {
4178
+ MetafixTestHelpers .assertExecutionException (IllegalStateException .class , "Expected String, got Hash" , () ->
4179
+ MetafixTestHelpers .assertFix (streamReceiver , Arrays .asList (
4180
+ "to_var('data.title', 'testVar')"
4181
+ ),
4182
+ i -> {
4183
+ i .startRecord ("1" );
4184
+ i .startEntity ("data" );
4185
+ i .startEntity ("title" );
4186
+ i .literal ("key" , "value" );
4187
+ i .endEntity ();
4188
+ i .endEntity ();
4189
+ i .endRecord ();
4190
+ },
4191
+ o -> {
4192
+ }
4193
+ )
4194
+ );
4195
+ }
4196
+
4183
4197
}
0 commit comments