This repository was archived by the owner on Feb 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-121
lines changed
parser/xml-to-raml-type-validations/array-error Expand file tree Collapse file tree 3 files changed +19
-121
lines changed Original file line number Diff line number Diff line change 2525import java .net .URL ;
2626import java .util .List ;
2727
28+ import static org .hamcrest .CoreMatchers .containsString ;
2829import static org .hamcrest .CoreMatchers .is ;
30+ import static org .junit .Assert .assertEquals ;
2931import static org .junit .Assert .assertThat ;
3032
3133public class ApiModelUnitTestCase
@@ -106,4 +108,21 @@ public void shouldGenerateXsdSchemaOnRecursiveTypes()
106108 "</schema>" ));
107109
108110 }
111+
112+ @ Test
113+ public void testXMLValidation ()
114+ {
115+ URL savedRamlLocation = getClass ().getClassLoader ().getResource ("org/raml/v2/unit/xml-validation.raml" );
116+ RamlModelResult ramlModelResult = new RamlModelBuilder ().buildApi (savedRamlLocation .toString ());
117+ TypeDeclaration typeDeclaration = ramlModelResult .getApiV10 ().resources ().get (0 ).methods ().get (0 ).body ().get (0 );
118+ List <ValidationResult > validationResults = typeDeclaration .validate ("<root>\n " +
119+ " <name>robert</name>\n " +
120+ " <my-custom-xml>with-custom-value</my-custom-xml>\n " +
121+ " </root>" );
122+ assertEquals (1 , validationResults .size ());
123+ String message = validationResults .get (0 ).getMessage ();
124+ assertThat (message , containsString ("Error validating XML. Error: cvc-complex-type.2.4.a: Invalid content was found starting with element" ));
125+ assertThat (message , containsString ("my-custom-xml" ));
126+ assertThat (message , containsString ("One of '{\" http://validationnamespace.raml.org\" :friends}' is expected." ));
127+ }
109128}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1515 body :
1616 application/xml :
1717 type : root
18- example : |
19- <root>
20- <name>robert</name>
21- <my-custom-xml>with-custom-value</my-custom-xml>
22- </root>
You can’t perform that action at this time.
0 commit comments