From fd033d7deccc833a2df2cb42530079bd2a7deea5 Mon Sep 17 00:00:00 2001 From: Michael Bolz Date: Mon, 13 Oct 2014 15:23:22 +0200 Subject: [PATCH] [OLINGO-423] Added convenience and tests --- .../EdmxReferenceIncludeAnnotationImpl.java | 4 +++ .../core/edmx/EdmxReferenceIncludeImpl.java | 4 +++ .../serializer/xml/MetadataDocumentTest.java | 35 ++++++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java index 1a4d7b48a..575c11544 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java @@ -34,6 +34,10 @@ public class EdmxReferenceIncludeAnnotationImpl implements EdmxReferenceIncludeA this.targetNamespace = targetNamespace; } + public EdmxReferenceIncludeAnnotationImpl(String termNamespace) { + this(termNamespace, null, null); + } + @Override public String getTermNamespace() { return termNamespace; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java index 0da95dfdf..0a4ecd3e2 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java @@ -31,6 +31,10 @@ public class EdmxReferenceIncludeImpl implements EdmxReferenceInclude { this.alias = alias; } + public EdmxReferenceIncludeImpl(String namespace) { + this(namespace, null); + } + @Override public String getNamespace() { return namespace; 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 85ac1e88a..2856cc49a 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 @@ -117,11 +117,26 @@ public class MetadataDocumentTest { new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermNs.5", "Q.5", "TargetNS.5")); edmxReferences.add(referenceWithAll); + EdmxReferenceImpl referenceWithAllAndNull = new EdmxReferenceImpl( + URI.create("http://localhost/odata/odata/v4.0/referenceWithAllAndNull")); + referenceWithAllAndNull.addInclude(new EdmxReferenceIncludeImpl("referenceWithAllAndNull.1")); + referenceWithAllAndNull.addInclude(new EdmxReferenceIncludeImpl("referenceWithAllAndNull.2", null)); + referenceWithAllAndNull.addIncludeAnnotation( + new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermNs.4")); + referenceWithAllAndNull.addIncludeAnnotation( + new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermAndNullNs.5", "Q.5", null)); + referenceWithAllAndNull.addIncludeAnnotation( + new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermAndNullNs.6", null, "TargetNS")); + referenceWithAllAndNull.addIncludeAnnotation( + new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermAndNullNs.7", null, null)); + edmxReferences.add(referenceWithAllAndNull); + ServiceMetadata serviceMetadata = new ServiceMetadataImpl(ODataServiceVersion.V40, new TestMetadataProvider(), edmxReferences); InputStream metadata = serializer.metadataDocument(serviceMetadata); assertNotNull(metadata); + String metadataString = IOUtils.toString(metadata); // edmx reference assertTrue(metadataString.contains( @@ -144,13 +159,23 @@ public class MetadataDocumentTest { "")); assertTrue(metadataString.contains( "" + - "" + - "" + - "" + + "" + + "" + - "" + - "")); + "")); + assertTrue(metadataString.contains( + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "")); } @Test