From 15164da8f1133a571481cd0d9db77c269c8e9fa1 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Tue, 20 Oct 2015 15:51:40 +0200 Subject: [PATCH] [OLINGO-786] Fix alias usage in metadata for annotations --- .../xml/MetadataDocumentXmlSerializer.java | 10 +++++----- .../xml/MetadataDocumentXmlSerializerTest.java | 2 +- .../serializer/xml/MetadataDocumentTest.java | 16 ++-------------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java index 356b90e25..b761374e2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java @@ -244,8 +244,8 @@ public class MetadataDocumentXmlSerializer { for (EdmAnnotation annotation : annotations) { writer.writeStartElement(XML_ANNOTATION); if (annotation.getTerm() != null) { - writer.writeAttribute(XML_TERM_ATT, annotation.getTerm().getFullQualifiedName() - .getFullQualifiedNameAsString()); + writer.writeAttribute(XML_TERM_ATT, getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName(), + false)); } if (annotation.getQualifier() != null) { writer.writeAttribute(XML_QUALIFIER_ATT, annotation.getQualifier()); @@ -315,7 +315,7 @@ public class MetadataDocumentXmlSerializer { break; case Cast: EdmCast asCast = dynExp.asCast(); - writer.writeAttribute(XML_TYPE, asCast.getType().getFullQualifiedName().getFullQualifiedNameAsString()); + writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asCast.getType(), false)); if (asCast.getMaxLength() != null) { writer.writeAttribute(XML_MAX_LENGTH, "" + asCast.getMaxLength()); @@ -345,7 +345,7 @@ public class MetadataDocumentXmlSerializer { break; case IsOf: EdmIsOf asIsOf = dynExp.asIsOf(); - writer.writeAttribute(XML_TYPE, asIsOf.getType().getFullQualifiedName().getFullQualifiedNameAsString()); + writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asIsOf.getType(), false)); if (asIsOf.getMaxLength() != null) { writer.writeAttribute(XML_MAX_LENGTH, "" + asIsOf.getMaxLength()); @@ -388,7 +388,7 @@ public class MetadataDocumentXmlSerializer { break; case Record: EdmRecord asRecord = dynExp.asRecord(); - writer.writeAttribute(XML_TYPE, asRecord.getType().getFullQualifiedName().getFullQualifiedNameAsString()); + writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(asRecord.getType(), false)); for (EdmPropertyValue propValue : asRecord.getPropertyValues()) { writer.writeStartElement(XML_PROPERTY_Value); writer.writeAttribute(XML_PROPERTY, propValue.getProperty()); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java index 7af378012..365da7a68 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java @@ -333,7 +333,7 @@ public class MetadataDocumentXmlSerializerTest { assertTrue(metadata.contains("PathValue")); assertTrue(metadata.contains("PropertyPathValue")); assertTrue(metadata - .contains("value" + .contains("value" + "")); assertTrue(metadata.contains("URLRefValue")); diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java index 8045b6311..b655e49cf 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java @@ -50,6 +50,7 @@ public class MetadataDocumentTest { final String metadata = IOUtils.toString( odata.createSerializer(ContentType.APPLICATION_XML).metadataDocument(serviceMetadata).getContent()); + System.out.println(metadata); assertNotNull(metadata); assertThat(metadata, containsString("" + "" + "")); @@ -76,23 +77,10 @@ public class MetadataDocumentTest { + "" + "")); -// assertThat(metadata, containsString("" -// + "" -// + "" -// + "")); - assertThat(metadata, containsString("" + "" + "" - + "" - + "" - + "" - + "" - + "")); + + ""