File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
main/java/org/metafacture/metamorph/functions
test/java/org/metafacture/metamorph/functions Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ public final class Regexp extends AbstractFunction {
3939 public void receive (final String name , final String value ,
4040 final NamedValueSource source , final int recordCount ,
4141 final int entityCount ) {
42+ if (null == value ) {
43+ return ;
44+ }
4245 matcher .reset (value );
4346 if (null == format ) {
4447 while (matcher .find ()) {
Original file line number Diff line number Diff line change @@ -95,4 +95,27 @@ public void shouldIgnoreEmptyMatchGroups() {
9595 ordered .verify (receiver ).endRecord ();
9696 ordered .verifyNoMoreInteractions ();
9797 }
98+
99+ @ Test
100+ public void shouldIgnoreNullValues () {
101+ metamorph = InlineMorph .in (this )
102+ .with ("<rules>" )
103+ .with (" <data source='s'>" )
104+ .with (" <regexp match='a.*' />" )
105+ .with (" </data>" )
106+ .with ("</rules>" )
107+ .createConnectedTo (receiver );
108+
109+ metamorph .startRecord ("1" );
110+ metamorph .literal ("s" , "aaccdd" );
111+ metamorph .literal ("s" , null );
112+ metamorph .endRecord ();
113+
114+ final InOrder ordered = inOrder (receiver );
115+ ordered .verify (receiver ).startRecord ("1" );
116+ ordered .verify (receiver ).literal ("s" , "aaccdd" );
117+ ordered .verify (receiver ).endRecord ();
118+ ordered .verifyNoMoreInteractions ();
119+ }
120+
98121}
You can’t perform that action at this time.
0 commit comments