You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/10/09 14:43:52 UTC
[1/2] olingo-odata4 git commit: [OLINGO-786] Add EdmTerm tests and
refacotor getAppliesTo
Repository: olingo-odata4
Updated Branches:
refs/heads/olingo786 9c1981c41 -> b69cd6e60
[OLINGO-786] Add EdmTerm tests and refacotor getAppliesTo
AppliesTo delivered a list of classes. This functionallity is not needed
thus I deleted it. Now it is just a list of strings. As a conveniece we
could use a list of enums in the future.
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/3f7df13a
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/3f7df13a
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/3f7df13a
Branch: refs/heads/olingo786
Commit: 3f7df13a630f2ffb8c7be9063de0e945fd814b12
Parents: 9c1981c
Author: Christian Amend <ch...@sap.com>
Authored: Thu Oct 8 17:11:07 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Thu Oct 8 17:11:07 2015 +0200
----------------------------------------------------------------------
.../olingo/fit/base/MetadataTestITCase.java | 4 +-
.../apache/olingo/client/core/MetadataTest.java | 3 +-
.../olingo/commons/api/edm/EdmAnnotations.java | 14 ++
.../commons/api/edm/EdmAnnotationsTarget.java | 11 --
.../apache/olingo/commons/api/edm/EdmTerm.java | 9 +-
.../commons/api/edm/provider/CsdlTerm.java | 22 ---
.../core/edm/AbstractEdmBindingTarget.java | 11 --
.../core/edm/AbstractEdmOperationImport.java | 10 --
.../core/edm/AbstractEdmStructuredType.java | 14 +-
.../commons/core/edm/EdmAnnotationsImpl.java | 5 +
.../core/edm/EdmEntityContainerImpl.java | 10 --
.../commons/core/edm/EdmEnumTypeImpl.java | 12 +-
.../olingo/commons/core/edm/EdmMemberImpl.java | 15 +--
.../core/edm/EdmNavigationPropertyImpl.java | 19 +--
.../commons/core/edm/EdmPropertyImpl.java | 15 +--
.../olingo/commons/core/edm/EdmTermImpl.java | 29 +---
.../commons/core/edm/EdmTypeDefinitionImpl.java | 10 --
.../core/edm/provider/EdmMappingTest.java | 5 +-
.../core/edm/provider/EdmMemberImplTest.java | 2 +-
.../provider/EdmNavigationPropertyImplTest.java | 10 +-
.../core/edm/provider/EdmPropertyImplTest.java | 14 +-
.../core/edm/provider/EdmTermImplTest.java | 133 +++++++++++++++++++
.../xml/ODataXmlDeserializerTest.java | 2 +-
23 files changed, 190 insertions(+), 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/fit/src/test/java/org/apache/olingo/fit/base/MetadataTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/MetadataTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/MetadataTestITCase.java
index 17ac626..e393e20 100644
--- a/fit/src/test/java/org/apache/olingo/fit/base/MetadataTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/base/MetadataTestITCase.java
@@ -115,8 +115,8 @@ public class MetadataTestITCase extends AbstractTestITCase {
final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core.IsLanguageDependent"));
assertNotNull(isLanguageDependent);
- assertTrue(isLanguageDependent.getAppliesTo().contains(EdmProperty.class));
- assertTrue(isLanguageDependent.getAppliesTo().contains(EdmTerm.class));
+ assertTrue(isLanguageDependent.getAppliesTo().contains("Property"));
+ assertTrue(isLanguageDependent.getAppliesTo().contains("Term"));
assertEquals(edm.getTypeDefinition(new FullQualifiedName("Core.Tag")), isLanguageDependent.getType());
assertEquals(EdmBoolean.getInstance(), ((EdmTypeDefinition) isLanguageDependent.getType()).getUnderlyingType());
assertNotNull(isLanguageDependent.getAnnotation(descriptionTerm, null));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
index b31f970..41e885c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
@@ -167,8 +167,7 @@ public class MetadataTest extends AbstractTest {
final EdmAnnotationsTarget annotationsTarget = annotationGroup.getTarget();
assertNotNull(annotationsTarget);
assertTrue(EdmAnnotationsTarget.TargetType.Property == annotationsTarget.getAnnotationsTargetType());
- assertEquals(new FullQualifiedName("ODataDemo.Product"), annotationsTarget.getAnnotationsTargetFQN());
- assertEquals("Name", annotationsTarget.getAnnotationsTargetPath());
+ assertEquals("ODataDemo.Product/Name", annotationGroup.getTargetPath());
final EdmAnnotation annotation = annotationGroup.getAnnotations().get(0);
assertNotNull(annotation);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java
index de00b44..229cce8 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java
@@ -34,8 +34,22 @@ public interface EdmAnnotations {
* @return a string allowing annotation authors a means of conditionally applying an annotation
*/
String getQualifier();
+
+ /**
+ * Will return the full path to the target
+ * e.g. MySchema.MyEntityContainer/MyEntitySet/MySchema.MyEntityType/MyProperty
+ * @return the path to the target
+ */
+ String getTargetPath();
+ /**
+ * @param term
+ * @return the annotation for the given term or null if not present
+ */
EdmAnnotation getAnnotation(EdmTerm term);
+ /**
+ * @return a list of all annotations
+ */
List<EdmAnnotation> getAnnotations();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java
index 24e5910..3994336 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java
@@ -54,17 +54,6 @@ public interface EdmAnnotationsTarget {
}
/**
- * @return {@link FullQualifiedName} of this target, or of the parent element if applicable
- *
- */
- FullQualifiedName getAnnotationsTargetFQN();
-
- /**
- * @return name of child element, not null if not needed
- */
- String getAnnotationsTargetPath();
-
- /**
* @return {@link TargetType} of this target
*/
TargetType getAnnotationsTargetType();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java
index a8d24b3..85a0140 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java
@@ -32,6 +32,9 @@ public interface EdmTerm extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable
*/
EdmType getType();
+ /**
+ * @return the fully qualified name of this term
+ */
FullQualifiedName getFullQualifiedName();
/**
@@ -46,12 +49,12 @@ public interface EdmTerm extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable
* @return list of CSDL element that this term can be applied to; if no value is supplied, the term is not restricted
* in its application.
*/
- List<Class<?>> getAppliesTo();
+ List<String> getAppliesTo();
/**
- * @return true if nullable or null if not specified
+ * @return true if nullable
*/
- Boolean isNullable();
+ boolean isNullable();
/**
* @return the maximum length as an Integer or null if not specified
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlTerm.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlTerm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlTerm.java
index 6d33cb7..517c190 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlTerm.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlTerm.java
@@ -38,8 +38,6 @@ public class CsdlTerm extends CsdlAbstractEdmItem implements CsdlNamed, CsdlAnno
private List<String> appliesTo = new ArrayList<String>();
- private boolean isCollection;
-
// Facets
private String defaultValue;
@@ -132,26 +130,6 @@ public class CsdlTerm extends CsdlAbstractEdmItem implements CsdlNamed, CsdlAnno
}
/**
- * Is collection.
- *
- * @return the boolean
- */
- public boolean isCollection() {
- return isCollection;
- }
-
- /**
- * Sets collection.
- *
- * @param isCollection the is collection
- * @return the collection
- */
- public CsdlTerm setCollection(final boolean isCollection) {
- this.isCollection = isCollection;
- return this;
- }
-
- /**
* Gets default value.
*
* @return the default value
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java
index 858b821..94956e2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java
@@ -29,7 +29,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.CsdlBindingTarget;
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationPropertyBinding;
@@ -79,16 +78,6 @@ public abstract class AbstractEdmBindingTarget extends AbstractEdmNamed implemen
}
@Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return container.getFullQualifiedName();
- }
-
- @Override
- public String getAnnotationsTargetPath() {
- return getName();
- }
-
- @Override
public EdmBindingTarget getRelatedBindingTarget(final String path) {
if (path == null) {
return null;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java
index ef14501..711b8cc 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java
@@ -67,14 +67,4 @@ public abstract class AbstractEdmOperationImport extends AbstractEdmNamed implem
public EdmEntityContainer getEntityContainer() {
return container;
}
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return container.getFullQualifiedName();
- }
-
- @Override
- public String getAnnotationsTargetPath() {
- return getName();
- }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java
index 51194ce..09f31f9 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java
@@ -145,22 +145,12 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E
return true;
}
- @Override
- public String getAnnotationsTargetPath() {
- return null;
- }
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return getFullQualifiedName();
- }
-
public Map<String, EdmProperty> getProperties() {
if (properties == null) {
final Map<String, EdmProperty> localPorperties = new LinkedHashMap<String, EdmProperty>();
final List<CsdlProperty> structureTypeProperties = providerStructuredType.getProperties();
for (CsdlProperty property : structureTypeProperties) {
- localPorperties.put(property.getName(), new EdmPropertyImpl(edm, typeName, property));
+ localPorperties.put(property.getName(), new EdmPropertyImpl(edm, property));
}
properties = Collections.unmodifiableMap(localPorperties);
}
@@ -177,7 +167,7 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E
if (structuredTypeNavigationProperties != null) {
for (CsdlNavigationProperty navigationProperty : structuredTypeNavigationProperties) {
localNavigationProperties.put(navigationProperty.getName(),
- new EdmNavigationPropertyImpl(edm, typeName, navigationProperty));
+ new EdmNavigationPropertyImpl(edm, navigationProperty));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java
index d1f44c7..8c0ad5c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationsImpl.java
@@ -145,4 +145,9 @@ public class EdmAnnotationsImpl implements EdmAnnotations {
return annotations;
}
+ @Override
+ public String getTargetPath() {
+ return annotationGroup.getTarget();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java
index 48f0889..ee2993c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEntityContainerImpl.java
@@ -311,16 +311,6 @@ public class EdmEntityContainerImpl extends AbstractEdmNamed implements EdmEntit
}
@Override
- public String getAnnotationsTargetPath() {
- return null;
- }
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return getFullQualifiedName();
- }
-
- @Override
public TargetType getAnnotationsTargetType() {
return TargetType.EntityContainer;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
index 2cc1d39..21a70a2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmEnumTypeImpl.java
@@ -103,7 +103,7 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
final List<String> memberNamesLocal = new ArrayList<String>();
if (enumType.getMembers() != null) {
for (final CsdlEnumMember member : enumType.getMembers()) {
- membersMapLocal.put(member.getName(), new EdmMemberImpl(edm, getFullQualifiedName(), member));
+ membersMapLocal.put(member.getName(), new EdmMemberImpl(edm, member));
memberNamesLocal.add(member.getName());
}
@@ -255,16 +255,6 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType {
public TargetType getAnnotationsTargetType() {
return TargetType.EnumType;
}
-
- @Override
- public String getAnnotationsTargetPath() {
- return null;
- }
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return getFullQualifiedName();
- }
@Override
public int hashCode() {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java
index a84bafa..adf9507 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java
@@ -20,17 +20,14 @@ package org.apache.olingo.commons.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmMember;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember;
public class EdmMemberImpl extends AbstractEdmNamed implements EdmMember {
- private final FullQualifiedName enumFQN;
private final CsdlEnumMember member;
- public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final CsdlEnumMember member) {
+ public EdmMemberImpl(final Edm edm, final CsdlEnumMember member) {
super(edm, member.getName(), member);
- this.enumFQN = enumFQN;
this.member = member;
}
@@ -40,16 +37,6 @@ public class EdmMemberImpl extends AbstractEdmNamed implements EdmMember {
}
@Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return enumFQN;
- }
-
- @Override
- public String getAnnotationsTargetPath() {
- return getName();
- }
-
- @Override
public String getValue() {
return member.getValue();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java
index 4b387e3..0a37c6e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmNavigationPropertyImpl.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -35,16 +35,13 @@ import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint;
public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmElement, EdmNavigationProperty {
- private final FullQualifiedName structuredTypeName;
private final CsdlNavigationProperty navigationProperty;
private List<EdmReferentialConstraint> referentialConstraints;
private EdmEntityType typeImpl;
private EdmNavigationProperty partnerNavigationProperty;
- public EdmNavigationPropertyImpl(
- final Edm edm, final FullQualifiedName structuredTypeName, final CsdlNavigationProperty navigationProperty) {
+ public EdmNavigationPropertyImpl(final Edm edm, final CsdlNavigationProperty navigationProperty) {
super(edm, navigationProperty.getName(), navigationProperty);
- this.structuredTypeName = structuredTypeName;
this.navigationProperty = navigationProperty;
}
@@ -129,14 +126,4 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmEl
public TargetType getAnnotationsTargetType() {
return TargetType.NavigationProperty;
}
-
- @Override
- public String getAnnotationsTargetPath() {
- return getName();
- }
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return structuredTypeName;
- }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmPropertyImpl.java
index 7a54a10..9ab0ffc 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmPropertyImpl.java
@@ -24,21 +24,18 @@ import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, EdmElement {
- private final FullQualifiedName structuredTypeName;
private final CsdlProperty property;
private final EdmTypeInfo typeInfo;
private EdmType propertyType;
- public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final CsdlProperty property) {
+ public EdmPropertyImpl(final Edm edm, final CsdlProperty property) {
super(edm, property.getName(), property);
- this.structuredTypeName = structuredTypeName;
this.property = property;
typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build();
}
@@ -111,16 +108,6 @@ public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, Ed
}
@Override
- public String getAnnotationsTargetPath() {
- return getName();
- }
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return structuredTypeName;
- }
-
- @Override
public boolean isPrimitive() {
return typeInfo.isPrimitiveType();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTermImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTermImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTermImpl.java
index ec6223a..8945e30 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTermImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTermImpl.java
@@ -21,7 +21,6 @@ package org.apache.olingo.commons.core.edm;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang3.ClassUtils;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmTerm;
@@ -38,7 +37,7 @@ public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
private final EdmTypeInfo typeInfo;
private EdmType termType;
private EdmTerm baseTerm;
- private List<Class<?>> appliesTo;
+ private List<String> appliesTo;
public EdmTermImpl(final Edm edm, final String namespace, final CsdlTerm term) {
super(edm, term.getName(), term);
@@ -82,24 +81,16 @@ public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
}
@Override
- public List<Class<?>> getAppliesTo() {
+ public List<String> getAppliesTo() {
if (appliesTo == null) {
- final List<Class<?>> appliesToLocal = new ArrayList<Class<?>>();
- for (String element : term.getAppliesTo()) {
- try {
- appliesToLocal.add(ClassUtils.getClass(EdmTerm.class.getPackage().getName() + ".Edm" + element));
- } catch (ClassNotFoundException e) {
- throw new EdmException("Could not load Edm class for {} " + element, e);
- }
- }
-
- appliesTo = appliesToLocal;
+ appliesTo = new ArrayList<String>();
+ appliesTo.addAll(term.getAppliesTo());
}
return appliesTo;
}
@Override
- public Boolean isNullable() {
+ public boolean isNullable() {
return term.isNullable();
}
@@ -132,14 +123,4 @@ public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm {
public TargetType getAnnotationsTargetType() {
return TargetType.Term;
}
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return getFullQualifiedName();
- }
-
- @Override
- public String getAnnotationsTargetPath() {
- return null;
- }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeDefinitionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeDefinitionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeDefinitionImpl.java
index 9c777d9..d97c2ca 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeDefinitionImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeDefinitionImpl.java
@@ -149,14 +149,4 @@ public class EdmTypeDefinitionImpl extends AbstractEdmNamed implements EdmTypeDe
public TargetType getAnnotationsTargetType() {
return TargetType.TypeDefinition;
}
-
- @Override
- public FullQualifiedName getAnnotationsTargetFQN() {
- return getFullQualifiedName();
- }
-
- @Override
- public String getAnnotationsTargetPath() {
- return getName();
- }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMappingTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMappingTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMappingTest.java
index c284edf..455dd15 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMappingTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMappingTest.java
@@ -27,7 +27,6 @@ import java.util.Date;
import org.apache.olingo.commons.api.edm.EdmParameter;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.provider.CsdlMapping;
import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
@@ -40,7 +39,7 @@ public class EdmMappingTest {
@Test
public void initialMappingMustBeNull() {
CsdlProperty property = new CsdlProperty().setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName());
- EdmProperty edmProperty = new EdmPropertyImpl(null, new FullQualifiedName("namespace.name"), property);
+ EdmProperty edmProperty = new EdmPropertyImpl(null, property);
assertNull(edmProperty.getMapping());
@@ -56,7 +55,7 @@ public class EdmMappingTest {
CsdlProperty property = new CsdlProperty()
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setMapping(mapping);
- EdmProperty edmProperty = new EdmPropertyImpl(null, new FullQualifiedName("namespace.name"), property);
+ EdmProperty edmProperty = new EdmPropertyImpl(null, property);
assertNotNull(edmProperty.getMapping());
assertEquals(Date.class, edmProperty.getMapping().getMappedJavaClass());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java
index a5e774c..09e3fd9 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java
@@ -31,7 +31,7 @@ public class EdmMemberImplTest {
@Test
public void enumMember() {
final CsdlEnumMember member = new CsdlEnumMember().setName("name").setValue("value");
- final EdmMemberImpl memberImpl = new EdmMemberImpl(mock(EdmProviderImpl.class), null, member);
+ final EdmMemberImpl memberImpl = new EdmMemberImpl(mock(EdmProviderImpl.class), member);
assertEquals("name", memberImpl.getName());
assertEquals("value", memberImpl.getValue());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java
index bfab176..94f6b93 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java
@@ -57,7 +57,7 @@ public class EdmNavigationPropertyImplTest {
CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
- EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider);
+ EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
assertFalse(property.isCollection());
assertFalse(property.isNullable());
EdmType type = property.getType();
@@ -87,7 +87,7 @@ public class EdmNavigationPropertyImplTest {
referentialConstraints.add(new CsdlReferentialConstraint().setProperty("property").setReferencedProperty(
"referencedProperty"));
propertyProvider.setReferentialConstraints(referentialConstraints);
- EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider);
+ EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
assertEquals("property", property.getReferencingPropertyName("referencedProperty"));
assertNull(property.getReferencingPropertyName("wrong"));
}
@@ -108,7 +108,7 @@ public class EdmNavigationPropertyImplTest {
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
propertyProvider.setPartner("partnerName");
- EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider);
+ EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
EdmNavigationProperty partner = property.getPartner();
assertNotNull(partner);
@@ -132,7 +132,7 @@ public class EdmNavigationPropertyImplTest {
propertyProvider.setType(entityTypeName);
propertyProvider.setNullable(false);
propertyProvider.setPartner("wrong");
- EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider);
+ EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
property.getPartner();
}
@@ -140,7 +140,7 @@ public class EdmNavigationPropertyImplTest {
public void navigationPropertyWithNonExistentType() throws Exception {
EdmProviderImpl edm = mock(EdmProviderImpl.class);
CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty();
- EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, null, propertyProvider);
+ EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider);
property.getType();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java
index e9f907f..ff68098 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java
@@ -49,7 +49,7 @@ public class EdmPropertyImplTest {
EdmProviderImpl edm = new EdmProviderImpl(mock(CsdlEdmProvider.class));
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(EdmPrimitiveTypeKind.Binary.getFullQualifiedName());
- final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertTrue(property.isPrimitive());
final EdmType type = property.getType();
assertEquals(EdmTypeKind.PRIMITIVE, type.getKind());
@@ -66,7 +66,7 @@ public class EdmPropertyImplTest {
when(provider.getComplexType(complexTypeName)).thenReturn(complexTypeProvider);
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(complexTypeName);
- final EdmProperty property = new EdmPropertyImpl(edm, complexTypeName, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertFalse(property.isCollection());
assertFalse(property.isPrimitive());
final EdmType type = property.getType();
@@ -84,7 +84,7 @@ public class EdmPropertyImplTest {
when(provider.getEnumType(enumTypeName)).thenReturn(enumTypeProvider);
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(enumTypeName);
- final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertFalse(property.isCollection());
assertFalse(property.isPrimitive());
final EdmType type = property.getType();
@@ -103,7 +103,7 @@ public class EdmPropertyImplTest {
when(provider.getTypeDefinition(typeName)).thenReturn(typeProvider);
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(typeName);
- final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertFalse(property.isPrimitive());
final EdmType type = property.getType();
assertEquals(EdmTypeKind.DEFINITION, type.getKind());
@@ -117,7 +117,7 @@ public class EdmPropertyImplTest {
EdmProviderImpl edm = new EdmProviderImpl(provider);
final CsdlProperty propertyProvider = new CsdlProperty()
.setType(new FullQualifiedName("ns", "wrong"));
- final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
property.getType();
fail();
}
@@ -128,7 +128,7 @@ public class EdmPropertyImplTest {
EdmProviderImpl edm = new EdmProviderImpl(provider);
final CsdlProperty propertyProvider = new CsdlProperty()
.setType(new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, "type"));
- final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
property.getType();
fail();
}
@@ -144,7 +144,7 @@ public class EdmPropertyImplTest {
propertyProvider.setUnicode(true);
propertyProvider.setNullable(false);
propertyProvider.setDefaultValue("x");
- final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider);
+ final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertTrue(property.isPrimitive());
assertNull(property.getMapping());
assertNull(property.getMimeType());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTermImplTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTermImplTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTermImplTest.java
new file mode 100644
index 0000000..7ab7248
--- /dev/null
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTermImplTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edm.provider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget.TargetType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmTerm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
+import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
+import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
+import org.apache.olingo.commons.core.edm.EdmProviderImpl;
+import org.apache.olingo.commons.core.edm.EdmTermImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EdmTermImplTest {
+
+ private EdmTerm initialTerm;
+ private EdmTerm derivedTerm;
+
+ @Before
+ public void setupTypes() throws Exception {
+ CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
+ EdmProviderImpl edm = new EdmProviderImpl(provider);
+
+ CsdlTerm csdlTerm = new CsdlTerm();
+ FullQualifiedName csdlTerm1Name = new FullQualifiedName("namespace", "name1");
+ csdlTerm.setName(csdlTerm1Name.getName());
+ csdlTerm.setType("Edm.String");
+ when(provider.getTerm(csdlTerm1Name)).thenReturn(csdlTerm);
+ initialTerm = new EdmTermImpl(edm, "namespace", csdlTerm);
+
+ CsdlTerm derivedCsdlTerm = new CsdlTerm();
+ FullQualifiedName derivedTermName = new FullQualifiedName("namespace", "name2");
+ derivedCsdlTerm.setName(derivedTermName.getName());
+ derivedCsdlTerm.setType("Edm.String");
+ derivedCsdlTerm.setBaseTerm("namespace.name1");
+ List<String> appliesTo = new ArrayList<String>();
+ appliesTo.add("Property");
+ derivedCsdlTerm.setAppliesTo(appliesTo);
+ List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
+ csdlAnnotations.add(new CsdlAnnotation().setTerm("name1"));
+ derivedCsdlTerm.setAnnotations(csdlAnnotations );
+
+ derivedCsdlTerm.setNullable(false);
+ derivedCsdlTerm.setMaxLength(new Integer(15));
+ derivedCsdlTerm.setDefaultValue("abc");
+ derivedCsdlTerm.setPrecision(new Integer(14));
+ derivedCsdlTerm.setScale(new Integer(13));
+
+ when(provider.getTerm(derivedTermName)).thenReturn(derivedCsdlTerm);
+ derivedTerm = new EdmTermImpl(edm, "namespace", derivedCsdlTerm);
+
+ }
+
+ @Test
+ public void termBasics() throws Exception {
+ assertEquals("name1", initialTerm.getName());
+ assertEquals(new FullQualifiedName("namespace", "name1"), initialTerm.getFullQualifiedName());
+
+ assertTrue(initialTerm.getAnnotations().isEmpty());
+ assertTrue(initialTerm.getAppliesTo().isEmpty());
+ assertNull(initialTerm.getBaseTerm());
+
+ EdmPrimitiveType type = (EdmPrimitiveType) initialTerm.getType();
+ assertEquals(type.getName(), "String");
+
+ assertEquals(TargetType.Term, initialTerm.getAnnotationsTargetType());
+
+ //initial facets
+ assertTrue(initialTerm.isNullable());
+ assertNull(initialTerm.getDefaultValue());
+ assertNull(initialTerm.getMaxLength());
+ assertNull(initialTerm.getPrecision());
+ assertNull(initialTerm.getScale());
+ assertNull(initialTerm.getSrid());
+ }
+
+ @Test
+ public void derivedTermTest() {
+ assertEquals("name2", derivedTerm.getName());
+ assertEquals(new FullQualifiedName("namespace", "name2"), derivedTerm.getFullQualifiedName());
+
+ assertNotNull(derivedTerm.getBaseTerm());
+ assertEquals("name1", derivedTerm.getBaseTerm().getName());
+ assertFalse(derivedTerm.getAnnotations().isEmpty());
+ assertEquals(1, derivedTerm.getAnnotations().size());
+ assertFalse(derivedTerm.getAppliesTo().isEmpty());
+ assertEquals("Property", derivedTerm.getAppliesTo().get(0));
+
+ EdmPrimitiveType type = (EdmPrimitiveType) derivedTerm.getType();
+ assertEquals(type.getName(), "String");
+
+ assertEquals(TargetType.Term, derivedTerm.getAnnotationsTargetType());
+
+ //set facets
+ assertFalse(derivedTerm.isNullable());
+ assertEquals("abc", derivedTerm.getDefaultValue());
+ assertEquals(new Integer(15), derivedTerm.getMaxLength());
+ assertEquals(new Integer(14), derivedTerm.getPrecision());
+ assertEquals(new Integer(13), derivedTerm.getScale());
+ assertNull(derivedTerm.getSrid());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3f7df13a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
index 71f4d35..3d0e2fc 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
@@ -487,7 +487,7 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
CsdlProperty prop = new CsdlProperty();
prop.setName("ShipTo");
prop.setType(new FullQualifiedName("Model.Address"));
- EdmPropertyImpl edmProperty = new EdmPropertyImpl(edm, null, prop);
+ EdmPropertyImpl edmProperty = new EdmPropertyImpl(edm, prop);
String payload = "<data:ShipTo xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" " +
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
[2/2] olingo-odata4 git commit: [OLINGO-786] Add edm annotations tests
Posted by ch...@apache.org.
[OLINGO-786] Add edm annotations tests
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/b69cd6e6
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/b69cd6e6
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/b69cd6e6
Branch: refs/heads/olingo786
Commit: b69cd6e60549ac1b4eba185e8aaf073746067449
Parents: 3f7df13
Author: Christian Amend <ch...@sap.com>
Authored: Fri Oct 9 14:42:38 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Oct 9 14:42:38 2015 +0200
----------------------------------------------------------------------
.../api/edm/provider/CsdlEntityContainer.java | 7 +-
.../provider/AbstractEdmAnnotatableTest.java | 97 ++++++++++++++++++++
2 files changed, 103 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b69cd6e6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlEntityContainer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlEntityContainer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlEntityContainer.java
index 5cb13c8..5358f6e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlEntityContainer.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/CsdlEntityContainer.java
@@ -42,7 +42,7 @@ public class CsdlEntityContainer extends CsdlAbstractEdmItem implements CsdlName
private List<CsdlSingleton> singletons = new ArrayList<CsdlSingleton>();
- private final List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>();
+ private List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>();
// Annotations
@Override
@@ -237,5 +237,10 @@ public class CsdlEntityContainer extends CsdlAbstractEdmItem implements CsdlName
public List<CsdlAnnotation> getAnnotations() {
return annotations;
}
+
+ public CsdlEntityContainer setAnnotations(List<CsdlAnnotation> annotations) {
+ this.annotations = annotations;
+ return this;
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b69cd6e6/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmAnnotatableTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmAnnotatableTest.java b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmAnnotatableTest.java
new file mode 100644
index 0000000..2ecf0c7
--- /dev/null
+++ b/lib/commons-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmAnnotatableTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edm.provider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmAnnotatable;
+import org.apache.olingo.commons.api.edm.EdmTerm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAnnotatable;
+import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.core.edm.AbstractEdmAnnotatable;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class AbstractEdmAnnotatableTest {
+
+ Edm edm;
+ private EdmTerm term;
+
+ @Before
+ public void setupEdm(){
+ edm = mock(Edm.class);
+ term = mock(EdmTerm.class);
+ FullQualifiedName fullQualifiedName = new FullQualifiedName("namespace", "name");
+ when(term.getFullQualifiedName()).thenReturn(fullQualifiedName);
+ when(edm.getTerm(fullQualifiedName)).thenReturn(term);
+ }
+
+ @Test
+ public void noAnnotations() {
+ EdmAnnotatable anno = new EdmAnnotatableTester(null, new CsdlEntityContainer());
+
+ assertNotNull(anno.getAnnotations());
+ assertEquals(0, anno.getAnnotations().size());
+
+ assertNull(anno.getAnnotation(null, null));
+
+
+ assertNull(anno.getAnnotation(term, null));
+ assertNull(anno.getAnnotation(term, "qualifier"));
+ assertNull(anno.getAnnotation(null, "qualifier"));
+ }
+
+ @Ignore
+ @Test
+ public void singleAnnotation() {
+ CsdlEntityContainer annotatable = new CsdlEntityContainer();
+ CsdlAnnotation annotation = new CsdlAnnotation();
+ annotation.setTerm("namespace.name");
+ List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>();
+ annotations.add(annotation);
+ annotatable.setAnnotations(annotations);
+ EdmAnnotatable anno = new EdmAnnotatableTester(edm, annotatable);
+
+ assertNotNull(anno.getAnnotations());
+ assertEquals(1, anno.getAnnotations().size());
+
+ assertNotNull(anno.getAnnotation(term, null));
+ assertNull(anno.getAnnotation(term, "qualifier"));
+ assertNull(anno.getAnnotation(null, null));
+ assertNull(anno.getAnnotation(null, "qualifier"));
+ }
+
+ private class EdmAnnotatableTester extends AbstractEdmAnnotatable {
+ public EdmAnnotatableTester(final Edm edm, final CsdlAnnotatable annotatable) {
+ super(edm, annotatable);
+ }
+ }
+
+}