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 25
25
import java .net .URL ;
26
26
import java .util .List ;
27
27
28
+ import static org .hamcrest .CoreMatchers .containsString ;
28
29
import static org .hamcrest .CoreMatchers .is ;
30
+ import static org .junit .Assert .assertEquals ;
29
31
import static org .junit .Assert .assertThat ;
30
32
31
33
public class ApiModelUnitTestCase
@@ -106,4 +108,21 @@ public void shouldGenerateXsdSchemaOnRecursiveTypes()
106
108
"</schema>" ));
107
109
108
110
}
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
+ }
109
128
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 15
15
body :
16
16
application/xml :
17
17
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