- void verifyXML( Node errorInfoNode );
- void verifyJson( JsonElement errorInfoElement );
- }
-
- static class ComplexErrorInfoVerifier implements ErrorInfoVerifier {
-
- Map<String, String> expErrorInfo;
-
- public ComplexErrorInfoVerifier( Map<String, String> expErrorInfo ) {
- this.expErrorInfo = expErrorInfo;
- }
-
- @Override
- public void verifyXML( Node errorInfoNode ) {
-
- Map<String, String> mutableExpMap = Maps.newHashMap( expErrorInfo );
- NodeList childNodes = errorInfoNode.getChildNodes();
- for( int i = 0; i < childNodes.getLength(); i++ ) {
- Node child = childNodes.item( i );
- if( child instanceof Element ) {
- String expValue = mutableExpMap.remove( child.getNodeName() );
- assertNotNull( "Found unexpected \"error-info\" child node: " +
- child.getNodeName(), expValue );
- assertEquals( "Text content for \"error-info\" child node " +
- child.getNodeName(), expValue, child.getTextContent() );
- }
- }
-
- if( !mutableExpMap.isEmpty() ) {
- fail( "Missing \"error-info\" child nodes: " + mutableExpMap );
- }
- }
-
- @Override
- public void verifyJson( JsonElement errorInfoElement ) {
-
- assertTrue( "\"error-info\" Json element is not an Object",
- errorInfoElement.isJsonObject() );
-
- Map<String, String> actualErrorInfo = Maps.newHashMap();
- for( Entry<String, JsonElement> entry: errorInfoElement.getAsJsonObject().entrySet() ) {
- String leafName = entry.getKey();
- JsonElement leafElement = entry.getValue();
- actualErrorInfo.put( leafName, leafElement.getAsString() );
- }