You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2013/07/26 13:22:42 UTC
[37/51] [partial] initial commit
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
new file mode 100644
index 0000000..4efbc2b
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.EntityType.EntityTypeA;
+
+public interface JPAEdmMockData {
+ /*
+ * Edm Complex Type Mock Data
+ */
+ public interface ComplexType {
+
+ public interface ComplexTypeA {
+ public static final String name = "ComplexTypeA";
+ public static final Class<ComplexTypeA> clazz = ComplexTypeA.class;
+
+ public interface Property {
+ public static final String PROPERTY_A = "A";
+ public static final String PROPERTY_B = "B";
+ public static final String PROPERTY_C = "C";
+ }
+
+ }
+
+ public interface ComplexTypeB {
+ public static final String name = "ComplexTypeB";
+
+ public interface Property {
+ public static final String PROPERTY_D = "D";
+ public static final String PROPERTY_E = "E";
+ }
+
+ }
+ }
+
+ public interface EntityType
+ {
+ public interface EntityTypeA
+ {
+ public static final String name = "SalesOrderHeader";
+ public static final Class<EntityTypeA> entityClazz = EntityTypeA.class;
+
+ public interface Property
+ {
+ public static final String PROPERTY_A = SimpleType.SimpleTypeA.NAME;
+
+ }
+
+ }
+ }
+
+ public interface SimpleType
+ {
+ public interface SimpleTypeA
+ {
+ public static final String NAME = "SOID";
+ public static final Class<String> clazz = String.class;
+ public static final Class<EntityTypeA> declaringClazz = EntityType.EntityTypeA.class;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
new file mode 100644
index 0000000..fdff58b
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+public class JPAEmbeddableMock<X> implements EmbeddableType<X> {
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
new file mode 100644
index 0000000..4bef724
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+public class JPAEmbeddableTypeMock<X> implements EmbeddableType<X> {
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
new file mode 100644
index 0000000..27fea5c
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.IdentifiableType;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.Type;
+
+public abstract class JPAEntityTypeMock<X> implements EntityType<X> {
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredId(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredVersion(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getId(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getIdClassAttributes() {
+ return null;
+ }
+
+ @Override
+ public Type<?> getIdType() {
+ return null;
+ }
+
+ @Override
+ public IdentifiableType<? super X> getSupertype() {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getVersion(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public boolean hasSingleIdAttribute() {
+ return false;
+ }
+
+ @Override
+ public boolean hasVersionAttribute() {
+ return false;
+ }
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getBindableJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
new file mode 100644
index 0000000..217275c
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+
+import javax.persistence.JoinColumns;
+
+public class JPAJavaMemberMock implements Member, AnnotatedElement, Annotation {
+
+ @Override
+ public Class<?> getDeclaringClass() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public int getModifiers() {
+ return 0;
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ return false;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(
+ final Class<? extends Annotation> annotationClass) {
+ return false;
+ }
+
+ @Override
+ public Annotation[] getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Annotation[] getDeclaredAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return JoinColumns.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
new file mode 100644
index 0000000..520ba8e
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+public class JPAManagedTypeMock<X> implements ManagedType<X> {
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
+ final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0,
+ final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(
+ final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
new file mode 100644
index 0000000..8772efb
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.Metamodel;
+
+public class JPAMetaModelMock implements Metamodel {
+
+ @Override
+ public <X> EmbeddableType<X> embeddable(final Class<X> arg0) {
+ return null;
+ }
+
+ @Override
+ public <X> EntityType<X> entity(final Class<X> arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<EmbeddableType<?>> getEmbeddables() {
+ return null;
+ }
+
+ @Override
+ public Set<EntityType<?>> getEntities() {
+ return null;
+ }
+
+ @Override
+ public Set<ManagedType<?>> getManagedTypes() {
+ return null;
+ }
+
+ @Override
+ public <X> ManagedType<X> managedType(final Class<X> arg0) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
new file mode 100644
index 0000000..75be01a
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.mock.model;
+
+import java.lang.reflect.Member;
+
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.Type;
+
+public class JPASingularAttributeMock<X, T> implements SingularAttribute<X, T> {
+
+ @Override
+ public ManagedType<X> getDeclaringType() {
+ return null;
+ }
+
+ @Override
+ public Member getJavaMember() {
+ return null;
+ }
+
+ @Override
+ public Class<T> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+ return null;
+ }
+
+ @Override
+ public boolean isAssociation() {
+ return false;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public Class<T> getBindableJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
+ return null;
+ }
+
+ @Override
+ public Type<T> getType() {
+ return null;
+ }
+
+ @Override
+ public boolean isId() {
+ return false;
+ }
+
+ @Override
+ public boolean isOptional() {
+ return false;
+ }
+
+ @Override
+ public boolean isVersion() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
new file mode 100644
index 0000000..8930e62
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.persistence.metamodel.Attribute;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
+
+public class JPAEdmAssociationEndTest extends JPAEdmTestModelView {
+
+ private final static int VARIANT1 = 1;
+ private final static int VARIANT2 = 2;
+ private final static int VARIANT3 = 3;
+
+ private static int variant;
+
+ private static final String PUNIT_NAME = "salesorderprocessing";
+ private static JPAEdmAssociationEnd objJPAEdmAssociationEnd = null;
+ private static JPAEdmAssociationEndTest objJPAEdmAssociationEndTest = null;
+
+ @BeforeClass
+ public static void setup() {
+ objJPAEdmAssociationEndTest = new JPAEdmAssociationEndTest();
+ objJPAEdmAssociationEnd = new JPAEdmAssociationEnd(
+ objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
+ try {
+ objJPAEdmAssociationEnd.getBuilder().build();
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetBuilder() {
+ JPAEdmBuilder builder = objJPAEdmAssociationEnd.getBuilder();
+ assertNotNull(builder);
+
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmAssociationEnd.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmAssociationEnd.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetAssociationEnd1() {
+ AssociationEnd associationEnd = objJPAEdmAssociationEnd
+ .getEdmAssociationEnd1();
+ assertEquals(associationEnd.getType().getName(), "SOID");
+ }
+
+ @Test
+ public void testGetAssociationEnd2() {
+ AssociationEnd associationEnd = objJPAEdmAssociationEnd
+ .getEdmAssociationEnd2();
+ assertEquals(associationEnd.getType().getName(), "String");
+ }
+
+ @Test
+ public void testCompare() {
+ assertTrue(objJPAEdmAssociationEnd.compare(
+ getAssociationEnd("SOID", 1), getAssociationEnd("String", 1)));
+ assertFalse(objJPAEdmAssociationEnd.compare(
+ getAssociationEnd("String", 2), getAssociationEnd("SOID", 1)));
+ }
+
+ @Test
+ public void testBuildAssociationEnd()
+ {
+ assertEquals("SOID", objJPAEdmAssociationEnd.getEdmAssociationEnd1().getType().getName());
+ assertEquals(new FullQualifiedName("salesorderprocessing", "SOID"), objJPAEdmAssociationEnd.getEdmAssociationEnd1().getType());
+ assertTrue(objJPAEdmAssociationEnd.isConsistent());
+
+ }
+
+ private AssociationEnd getAssociationEnd(final String typeName, final int variant) {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(getFullQualifiedName(typeName));
+ if (variant == VARIANT1) {
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+ } else if (variant == VARIANT2) {
+ associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+ } else if (variant == VARIANT3) {
+ associationEnd.setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
+ }
+ else {
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);//
+ }
+ return associationEnd;
+ }
+
+ private FullQualifiedName getFullQualifiedName(final String typeName) {
+ FullQualifiedName fullQualifiedName = new FullQualifiedName(PUNIT_NAME,
+ typeName);
+ return fullQualifiedName;
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return PUNIT_NAME;
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ EntityType entityType = new EntityType();
+ entityType.setName(SimpleTypeA.NAME);
+ return entityType;
+ }
+
+ // The inner class which gives us an replica of the jpa attribute
+ @SuppressWarnings("hiding")
+ public class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) SimpleType.SimpleTypeA.clazz;
+ }
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ if (variant == VARIANT1) {
+ return PersistentAttributeType.ONE_TO_MANY;
+ } else if (variant == VARIANT2) {
+ return PersistentAttributeType.ONE_TO_ONE;
+ } else if (variant == VARIANT3) {
+ return PersistentAttributeType.MANY_TO_ONE;
+ } else {
+ return PersistentAttributeType.MANY_TO_MANY;
+ }
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
new file mode 100644
index 0000000..a2ac371
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+
+public class JPAEdmAssociationSetTest extends JPAEdmTestModelView {
+
+ private JPAEdmAssociationSetTest objJPAEdmAssociationSetTest;
+ private JPAEdmAssociationSet objJPAEdmAssociationSet;
+
+ @Before
+ public void setUp() {
+ objJPAEdmAssociationSetTest = new JPAEdmAssociationSetTest();
+ objJPAEdmAssociationSet = new JPAEdmAssociationSet(objJPAEdmAssociationSetTest);
+ try {
+ objJPAEdmAssociationSet.getBuilder().build();
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmAssociationSet.getBuilder());
+ }
+
+ @Test
+ public void testGetConsistentEdmAssociationSetList() {
+ assertNotNull(objJPAEdmAssociationSet.getConsistentEdmAssociationSetList());
+ }
+
+ @Test
+ public void testGetEdmAssociationSet() {
+ assertNotNull(objJPAEdmAssociationSet.getEdmAssociationSet());
+ }
+
+ @Test
+ public void testGetEdmAssociation() {
+ assertNotNull(objJPAEdmAssociationSet.getEdmAssociation());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmAssociationSet.isConsistent());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmAssociationSet.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmAssociationSet.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmAssociationView getJPAEdmAssociationView() {
+ return this;
+ }
+
+ @Override
+ public AssociationSet getEdmAssociationSet() {
+ AssociationSet associationSet = new AssociationSet();
+ associationSet.setEnd1(new AssociationSetEnd());
+ associationSet.setEnd2(new AssociationSetEnd());
+
+ return associationSet;
+ }
+
+ @Override
+ public List<Association> getConsistentEdmAssociationList() {
+ return getEdmAssociationListLocal();
+ }
+
+ @Override
+ public List<AssociationSet> getConsistentEdmAssociationSetList() {
+
+ List<AssociationSet> associationSetList = new ArrayList<AssociationSet>();
+ associationSetList.add(getEdmAssociationSet());
+ associationSetList.add(getEdmAssociationSet());
+
+ return associationSetList;
+ }
+
+ @Override
+ public List<EntitySet> getConsistentEdmEntitySetList() {
+ return getEntitySetListLocal();
+ }
+
+ @Override
+ public boolean isConsistent() {
+ return true;
+ }
+
+ @Override
+ public Schema getEdmSchema() {
+ Schema schema = new Schema();
+ schema.setNamespace("salesordereprocessing");
+ return schema;
+ }
+
+ private List<EntitySet> getEntitySetListLocal() {
+ List<EntitySet> entitySetList = new ArrayList<EntitySet>();
+
+ EntitySet entitySet = new EntitySet();
+ entitySet.setName("SalesOrderHeader");
+ entitySet.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
+
+ EntitySet entitySet2 = new EntitySet();
+ entitySet2.setName("SalesOrderItem");
+ entitySet2.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
+
+ entitySetList.add(entitySet);
+ entitySetList.add(entitySet2);
+ return entitySetList;
+ }
+
+ private List<Association> getEdmAssociationListLocal() {
+ List<Association> associationList = new ArrayList<Association>();
+
+ Association association = new Association();
+ association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+ association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole("SalesOrderHeader"));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem")).setRole("SalesOrderItem"));
+
+ associationList.add(association);
+ return associationList;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
new file mode 100644
index 0000000..857c246
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
@@ -0,0 +1,438 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.metamodel.Attribute;
+
+import org.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
+
+public class JPAEdmAssociationTest extends JPAEdmTestModelView {
+
+ private static JPAEdmAssociation objAssociation = null;
+ private static String ASSOCIATION_NAME = "SalesOrderHeader_String";
+ private static JPAEdmAssociationTest localView = null;
+ private static final String PUNIT_NAME = "salesorderprocessing";
+ private int variant;
+
+ @BeforeClass
+ public static void setup() {
+ localView = new JPAEdmAssociationTest();
+ objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
+ try {
+ objAssociation.getBuilder().build();
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd1() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader"));
+ associationEnd.setRole("SalesOrderHeader");
+ associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+ return associationEnd;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd2() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName("salesorderprocessing",
+ "String"));
+ associationEnd.setRole("String");
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+ return associationEnd;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association.setEnd1(new AssociationEnd().setType(new FullQualifiedName(
+ "salesorderprocessing", "SalesOrderHeader")));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName(
+ "salesorderprocessing", "String")));
+
+ return association;
+ }
+
+ @Override
+ public boolean isExists() {
+ return true;
+ }
+
+ @Override
+ public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
+ JPAEdmReferentialConstraint refConstraintView = new JPAEdmReferentialConstraint(
+ localView, localView, localView);
+ return refConstraintView;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return PUNIT_NAME;
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ EntityType entityType = new EntityType();
+ entityType.setName(SimpleTypeA.NAME);
+ return entityType;
+ }
+
+ // The inner class which gives us an replica of the jpa attribute
+ @SuppressWarnings("hiding")
+ private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) SimpleType.SimpleTypeA.clazz;
+ }
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ if (variant == 1) {
+ return PersistentAttributeType.ONE_TO_MANY;
+ } else if (variant == 2) {
+ return PersistentAttributeType.ONE_TO_ONE;
+ } else if (variant == 2) {
+ return PersistentAttributeType.MANY_TO_ONE;
+ } else {
+ return PersistentAttributeType.MANY_TO_MANY;
+ }
+
+ }
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objAssociation.getBuilder());
+ }
+
+ @Test
+ public void testGetEdmAssociation() {
+ assertNotNull(objAssociation.getEdmAssociation());
+ assertEquals(objAssociation.getEdmAssociation().getName(),
+ ASSOCIATION_NAME);
+ }
+
+ @Test
+ public void testGetConsistentEdmAssociationList() {
+ assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
+ }
+
+ @Override
+ public String getEdmRelationShipName() {
+ return "Association_SalesOrderHeader_String";
+ }
+
+ @Test
+ public void testSearchAssociation1() {
+ class TestAssociationEndView extends JPAEdmTestModelView {
+ @Override
+ public String getEdmRelationShipName() {
+ return "SalesOrderHeader_String1";
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public String getJoinColumnName() {
+ return "SO_ID";
+ }
+
+ @Override
+ public String getJoinColumnReferenceColumnName() {
+ return "DEMO_ID";
+ }
+
+ @Override
+ public String getMappedByName() {
+ return "demo";
+ }
+
+ @Override
+ public String getOwningPropertyName() {
+ return "salesOrder";
+ }
+
+ @Override
+ public int getNumberOfAssociationsWithSimilarEndPoints(
+ final JPAEdmAssociationEndView view) {
+ return 1;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ EntityType entityType = new EntityType();
+ entityType.setName("SalesOrderHeader");
+ return entityType;
+ }
+
+ @SuppressWarnings("hiding")
+ class AttributeMock<Object, String> extends
+ JPAAttributeMock<Object, String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) SimpleType.SimpleTypeA.clazz;
+ }
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+
+ return PersistentAttributeType.ONE_TO_MANY;
+
+ }
+
+ @Override
+ public Member getJavaMember() {
+ return new AnnotatedElementMock();
+ }
+
+ @Override
+ public java.lang.String getName() {
+ // TODO Auto-generated method stub
+ return super.getName();
+ }
+
+ class AnnotatedElementMock implements AnnotatedElement, Member {
+
+ @Override
+ public boolean isAnnotationPresent(
+ final Class<? extends Annotation> annotationClass) {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Annotation getAnnotation(@SuppressWarnings("rawtypes") final Class annotationClass) {
+ if (annotationClass.equals(JoinColumn.class)) {
+ JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+ EasyMock.expect(joinColumn.name()).andStubReturn("SO_ID");
+ EasyMock.expect(joinColumn.referencedColumnName()).andStubReturn("DEMO_ID");
+ EasyMock.replay(joinColumn);
+ return joinColumn;
+ }
+ else {
+ OneToMany oneToMany = EasyMock.createMock(OneToMany.class);
+ EasyMock.expect(oneToMany.mappedBy()).andStubReturn("demo");
+ EasyMock.replay(oneToMany);
+ return oneToMany;
+ }
+ }
+
+ @Override
+ public Annotation[] getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Annotation[] getDeclaredAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Class<?> getDeclaringClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getModifiers() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ }
+
+ }
+ }
+ TestAssociationEndView objJPAEdmAssociationEndTest = new TestAssociationEndView();
+ JPAEdmAssociationEnd objJPAEdmAssociationEnd = new JPAEdmAssociationEnd(
+ objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
+ try {
+ objJPAEdmAssociationEnd.getBuilder().build();
+ Field field = objAssociation.getClass().getDeclaredField("associationEndMap");
+ field.setAccessible(true);
+ Map<String, JPAEdmAssociationEndView> associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
+ associationEndMap.put("SalesOrderHeader_String", objJPAEdmAssociationEnd);
+ field.set(objAssociation, associationEndMap);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertEquals("SalesOrderHeader_String", objAssociation.searchAssociation(objJPAEdmAssociationEnd).getName());
+
+ }
+
+ @Test
+ public void testAddJPAEdmAssociationView() {
+
+ class LocalJPAAssociationView extends JPAEdmTestModelView {
+ @Override
+ public AssociationEnd getEdmAssociationEnd1() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName(
+ "salesorderprocessing", "SalesOrderHeader"));
+ associationEnd.setRole("SalesOrderHeader");
+ associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+ return associationEnd;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd2() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName(
+ "salesorderprocessing", "SalesOrderItem"));
+ associationEnd.setRole("SalesOrderItem");
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+ return associationEnd;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association.setEnd1(new AssociationEnd()
+ .setType(new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader")));
+ association.setEnd2(new AssociationEnd()
+ .setType(new FullQualifiedName("salesorderprocessing",
+ "SalesOrderItem")));
+
+ return association;
+ }
+ }
+ LocalJPAAssociationView assocViewObj = new LocalJPAAssociationView();
+ JPAEdmAssociation objLocalAssociation = new JPAEdmAssociation(
+ assocViewObj, assocViewObj, assocViewObj, 1);
+ try {
+ objLocalAssociation.getBuilder().build();
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ objAssociation.addJPAEdmAssociationView(objLocalAssociation, localView);
+
+ }
+
+ @Test
+ public void testAddJPAEdmRefConstraintView() {
+
+ localView = new JPAEdmAssociationTest();
+ objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
+ try {
+ objAssociation.getBuilder().build();
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ objAssociation.addJPAEdmRefConstraintView(localView);
+ assertTrue(objAssociation.getConsistentEdmAssociationList()
+ .size() > 0);
+ }
+
+ @Test
+ public void testGetJPAEdmReferentialConstraintView() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
new file mode 100644
index 0000000..6e92aa0
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.persistence.metamodel.Metamodel;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+
+public class JPAEdmBaseViewImplTest extends JPAEdmTestModelView {
+
+ private JPAEdmBaseViewImplTest objJPAEdmBaseViewImplTest;
+ private JPAEdmBaseViewImpl objJPAEdmBaseViewImpl;
+
+ @Before
+ public void setUp() {
+ objJPAEdmBaseViewImplTest = new JPAEdmBaseViewImplTest();
+ objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(objJPAEdmBaseViewImplTest) {
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ return null;
+ }
+ };
+
+ objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(getJPAMetaModel(), getpUnitName()) {
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ return null;
+ }
+ };
+
+ }
+
+ @Test
+ public void testGetpUnitName() {
+ assertTrue(objJPAEdmBaseViewImpl.getpUnitName().equals("salesorderprocessing"));
+ }
+
+ @Test
+ public void testGetJPAMetaModel() {
+ assertNotNull(objJPAEdmBaseViewImpl.getJPAMetaModel());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmBaseViewImpl.isConsistent());
+ }
+
+ @Test
+ public void testClean() {
+ objJPAEdmBaseViewImpl.clean();
+ assertFalse(objJPAEdmBaseViewImpl.isConsistent());
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAMetaModelMock();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
new file mode 100644
index 0000000..88f1210
--- /dev/null
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * 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.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+
+public class JPAEdmComplexTypeTest extends JPAEdmTestModelView {
+
+ private static JPAEdmComplexType objComplexType = null;
+ private static JPAEdmComplexTypeTest localView = null;
+
+ @BeforeClass
+ public static void setup() {
+ localView = new JPAEdmComplexTypeTest();
+ objComplexType = new JPAEdmComplexType(localView);
+ try {
+ objComplexType.getBuilder().build();
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public EmbeddableType<?> getJPAEmbeddableType() {
+ @SuppressWarnings("hiding")
+ class JPAComplexAttribute<Long> extends JPAEmbeddableMock<Long>
+ {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<Long> getJavaType() {
+
+ return (Class<Long>) java.lang.Long.class;
+ }
+
+ }
+ return new JPAComplexAttribute();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ @Test
+ public void testGetBuilder() {
+
+ assertNotNull(objComplexType.getBuilder());
+ }
+
+ @Test
+ public void testGetEdmComplexType() {
+ assertEquals(objComplexType.getEdmComplexType().getName(), "String");
+ }
+
+ @Test
+ public void testSearchComplexTypeString() {
+ assertNotNull(objComplexType.searchEdmComplexType("java.lang.String"));
+
+ }
+
+ @Test
+ public void testGetJPAEmbeddableType() {
+ assertTrue(objComplexType.getJPAEmbeddableType().getAttributes().size() > 0);
+
+ }
+
+ @Test
+ public void testGetConsistentEdmComplexTypes() {
+ assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 0);
+ }
+
+ @Test
+ public void testSearchComplexTypeFullQualifiedName() {
+ assertNotNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "String")));
+
+ }
+
+ @Test
+ public void testSearchComplexTypeFullQualifiedNameNegative()
+ {
+ assertNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "lang.String")));
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objComplexType.getBuilder();
+ JPAEdmBuilder builder2 = objComplexType.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testAddCompleTypeView() {
+ localView = new JPAEdmComplexTypeTest();
+ objComplexType = new JPAEdmComplexType(localView);
+ try {
+ objComplexType.getBuilder().build();
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ objComplexType.addJPAEdmCompleTypeView(localView);
+ assertTrue(objComplexType.getConsistentEdmComplexTypes()
+ .size() > 1);
+ }
+
+ @Test
+ public void testExpandEdmComplexType() {
+ ComplexType complexType = new ComplexType();
+ List<Property> properties = new ArrayList<Property>();
+ JPAEdmMapping mapping1 = new JPAEdmMappingImpl();
+ mapping1.setJPAColumnName("LINEITEMID");
+ ((Mapping) mapping1).setInternalName("LineItemKey.LiId");
+ JPAEdmMapping mapping2 = new JPAEdmMappingImpl();
+ mapping2.setJPAColumnName("LINEITEMNAME");
+ ((Mapping) mapping2).setInternalName("LineItemKey.LiName");
+ properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1));
+ properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2));
+ complexType.setProperties(properties);
+ List<Property> expandedList = null;
+ try
+ {
+ objComplexType.expandEdmComplexType(complexType, expandedList, "SalesOrderItemKey");
+ } catch (ClassCastException e)
+ {
+ assertTrue(false);
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testComplexTypeCreation()
+ {
+ try {
+ objComplexType.getBuilder().build();
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals(objComplexType.pUnitName, "salesorderprocessing");
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock
+ {
+ Set<EmbeddableType<?>> embeddableSet;
+
+ public JPAEdmMetaModel() {
+ embeddableSet = new HashSet<EmbeddableType<?>>();
+ }
+
+ @Override
+ public Set<EmbeddableType<?>> getEmbeddables() {
+ embeddableSet.add(new JPAEdmEmbeddable<String>());
+ return embeddableSet;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEmbeddable<String> extends JPAEmbeddableMock<String>
+ {
+
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet()
+ {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String>
+ {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return PersistentAttributeType.BASIC;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return false;
+ }
+
+ }
+}