@@ -567,7 +567,7 @@ public void testWrongLocationPatchSourceInPostParse() throws Exception {
567567 XContentType .JSON
568568 )
569569 ) {
570- DocumentParserContext context = new TestDocumentParserContext (MappingLookup . EMPTY , sourceToParse ) {
570+ DocumentParserContext context = new TestDocumentParserContext (mapperService . mappingLookup () , sourceToParse ) {
571571 @ Override
572572 public XContentParser parser () {
573573 return parser ;
@@ -576,7 +576,7 @@ public XContentParser parser() {
576576 var xContentLocation = new XContentLocation (0 , 3 );
577577 context .addSourceFieldPatch (fieldMapper , xContentLocation );
578578 var exc = expectThrows (IllegalArgumentException .class , () -> mapper .postParse (context ));
579- assertThat (exc .getMessage (), containsString ("Cannot find patch" ));
579+ assertThat (exc .getMessage (), containsString ("Registered patch not found " ));
580580 }
581581 }
582582
@@ -594,15 +594,16 @@ public void testRemainingPatchSourceInPostParse() throws Exception {
594594 XContentBuilder builder = JsonXContent .contentBuilder ();
595595 builder .value (Map .of ("another_field" , 45 ));
596596 var sourceToParse = new SourceToParse ("0" , BytesReference .bytes (builder ), builder .contentType ());
597- FieldMapper fieldMapper = (FieldMapper ) mapperService .mappingLookup ().getMapper ("field" );
597+ var fieldMapper = (FieldMapper ) mapperService .mappingLookup ().getMapper ("field" );
598+ var anotherFieldMapper = (FieldMapper ) mapperService .mappingLookup ().getMapper ("another_field" );
598599 try (
599600 var parser = XContentHelper .createParserNotCompressed (
600601 XContentParserConfiguration .EMPTY ,
601602 sourceToParse .source (),
602603 XContentType .JSON
603604 )
604605 ) {
605- DocumentParserContext context = new TestDocumentParserContext (MappingLookup . EMPTY , sourceToParse ) {
606+ DocumentParserContext context = new TestDocumentParserContext (mapperService . mappingLookup () , sourceToParse ) {
606607 @ Override
607608 public XContentParser parser () {
608609 return parser ;
@@ -612,13 +613,13 @@ public XContentParser parser() {
612613 context .addSourceFieldPatch (fieldMapper , xContentLocation1 );
613614 {
614615 var exc = expectThrows (IllegalArgumentException .class , () -> context .addSourceFieldPatch (fieldMapper , xContentLocation1 ));
615- assertThat (exc .getMessage (), containsString (xContentLocation1 . toString () ));
616+ assertThat (exc .getMessage (), containsString ("Field [field] does not support patching the same location " ));
616617 }
617618 var xContentLocation2 = new XContentLocation (2 , 6 );
618- context .addSourceFieldPatch (fieldMapper , xContentLocation2 );
619+ context .addSourceFieldPatch (anotherFieldMapper , xContentLocation2 );
619620
620621 var exc = expectThrows (IllegalArgumentException .class , () -> mapper .postParse (context ));
621- assertThat (exc .getMessage (), allOf ( containsString (xContentLocation2 . toString ()), containsString ( xContentLocation1 . toString ()) ));
622+ assertThat (exc .getMessage (), containsString ("Registered patch not found" ));
622623 }
623624 }
624625}
0 commit comments