[OLINGO-423] Added convenience and tests
This commit is contained in:
parent
e3121831b4
commit
fd033d7dec
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
|||
"</edmx:Reference>"));
|
||||
assertTrue(metadataString.contains(
|
||||
"<edmx:Reference Uri=\"http://localhost/odata/odata/v4.0/referenceWithAll\">" +
|
||||
"<edmx:Include Namespace=\"ReferenceWithAll.1\" Alias=\"Core1\"/>" +
|
||||
"<edmx:Include Namespace=\"ReferenceWithAll.2\" Alias=\"Core2\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\" " +
|
||||
"<edmx:Include Namespace=\"ReferenceWithAll.1\" Alias=\"Core1\"/>" +
|
||||
"<edmx:Include Namespace=\"ReferenceWithAll.2\" Alias=\"Core2\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\" " +
|
||||
"Qualifier=\"Q.4\" TargetNamespace=\"TargetNS.4\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.5\" " +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.5\" " +
|
||||
"Qualifier=\"Q.5\" TargetNamespace=\"TargetNS.5\"/>" +
|
||||
"</edmx:Reference>"));
|
||||
"</edmx:Reference>"));
|
||||
assertTrue(metadataString.contains(
|
||||
"<edmx:Reference Uri=\"http://localhost/odata/odata/v4.0/referenceWithAllAndNull\">" +
|
||||
"<edmx:Include Namespace=\"referenceWithAllAndNull.1\"/>" +
|
||||
"<edmx:Include Namespace=\"referenceWithAllAndNull.2\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermAndNullNs.5\" Qualifier=\"Q.5\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermAndNullNs.6\" " +
|
||||
"TargetNamespace=\"TargetNS\"/>" +
|
||||
"<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermAndNullNs.7\"/>" +
|
||||
"</edmx:Reference>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue