You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/09/24 14:43:04 UTC
[37/51] [partial] Refactored project structure
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/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
deleted file mode 100644
index 915c562..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * 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/57599da6/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
deleted file mode 100644
index 8e528b2..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * 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/57599da6/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
deleted file mode 100644
index a4aa2b5..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * 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 java.util.ArrayList;
-
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.Type;
-
-public class JPAPluralAttributeMock implements PluralAttribute<Object, ArrayList<String>, String> {
-
- @Override
- public String getName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ManagedType<Object> getDeclaringType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Class<ArrayList<String>> getJavaType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Member getJavaMember() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isAssociation() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Class<String> getBindableJavaType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.PluralAttribute.CollectionType getCollectionType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Type<String> getElementType() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/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
deleted file mode 100644
index 41124fe..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * 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/57599da6/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
deleted file mode 100644
index 05db5ab..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * 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.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;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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/57599da6/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
deleted file mode 100644
index 965d3d7..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * 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.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;
-import org.junit.Before;
-import org.junit.Test;
-
-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/57599da6/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
deleted file mode 100644
index f7c8f47..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*******************************************************************************
- * 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.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;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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/57599da6/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
deleted file mode 100644
index bdbf104..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * 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.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.junit.Before;
-import org.junit.Test;
-
-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/57599da6/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
deleted file mode 100644
index 2fabe8c..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * 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.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;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-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;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
deleted file mode 100644
index 4e9355b..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * 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 java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-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.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmEntityContainerTest extends JPAEdmTestModelView {
-
- private JPAEdmEntityContainer objJPAEdmEntityContainer;
- private JPAEdmEntityContainerTest objJPAEdmEntityContainerTest;
-
- @Before
- public void setUp() {
- objJPAEdmEntityContainerTest = new JPAEdmEntityContainerTest();
- objJPAEdmEntityContainer = new JPAEdmEntityContainer(objJPAEdmEntityContainerTest);
- try {
- objJPAEdmEntityContainer.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(objJPAEdmEntityContainer.getBuilder());
- }
-
- @Test
- public void testGetEdmEntityContainer() {
- assertNotNull(objJPAEdmEntityContainer.getEdmEntityContainer());
- assertTrue(objJPAEdmEntityContainer.getEdmEntityContainer().getEntitySets().size() > 0);
- }
-
- @Test
- public void testGetConsistentEdmEntityContainerList() {
- assertNotNull(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList());
- assertTrue(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList().size() > 0);
-
- }
-
- @Test
- public void testGetJPAEdmEntitySetView() {
- assertNotNull(objJPAEdmEntityContainer.getJPAEdmEntitySetView());
- assertEquals("salesorderprocessing", objJPAEdmEntityContainer.getJPAEdmEntitySetView().getpUnitName());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmEntityContainer.isConsistent());
- objJPAEdmEntityContainer.clean();
- assertFalse(objJPAEdmEntityContainer.isConsistent());
- }
-
- @Test
- public void testGetEdmAssociationSetView() {
- assertNotNull(objJPAEdmEntityContainer.getEdmAssociationSetView());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmEntityContainer.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmEntityContainer.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityType<String>();
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- @Override
- public Schema getEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace("salesordereprocessing");
- return schema;
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public JPAEdmAssociationView getJPAEdmAssociationView() {
- return this;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- return new JPAEdmBuilder() {
-
- @Override
- public void build() {
- // Nothing to do?
- }
- };
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityType<String> extends JPAEntityTypeMock<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;
- }
-
- 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 true;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
deleted file mode 100644
index 74c203e..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * 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 java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-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.JPAEdmEntityContainerView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmEntitySetTest extends JPAEdmTestModelView {
-
- private static JPAEdmEntitySet objJPAEdmEntitySet;
- private static JPAEdmEntitySetTest objJPAEdmEntitySetTest;
-
- @Before
- public void setUp() {
- objJPAEdmEntitySetTest = new JPAEdmEntitySetTest();
- objJPAEdmEntitySet = new JPAEdmEntitySet(objJPAEdmEntitySetTest);
- try {
- objJPAEdmEntitySet.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(objJPAEdmEntitySet.getBuilder());
- }
-
- @Test
- public void testGetEdmEntitySet() {
- assertNotNull(objJPAEdmEntitySet.getEdmEntitySet());
- assertNotNull(objJPAEdmEntitySet.getEdmEntitySet().getEntityType());
- }
-
- @Test
- public void testGetConsistentEntitySetList() {
- assertTrue(objJPAEdmEntitySet.getConsistentEdmEntitySetList().size() > 0);
- }
-
- @Test
- public void testGetJPAEdmEntityTypeView() {
- assertNotNull(objJPAEdmEntitySet.getJPAEdmEntityTypeView());
- assertEquals("salesorderprocessing", objJPAEdmEntitySet.getJPAEdmEntityTypeView().getpUnitName());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmEntitySet.isConsistent());
-
- objJPAEdmEntitySet.getJPAEdmEntityTypeView().clean();
- assertFalse(objJPAEdmEntitySet.getJPAEdmEntityTypeView().isConsistent());
-
- objJPAEdmEntitySet.clean();
- assertFalse(objJPAEdmEntitySet.isConsistent());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmEntitySet.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmEntitySet.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityType<String>();
- }
-
- @Override
- public JPAEdmKeyView getJPAEdmKeyView() {
- return this;
- }
-
- @Override
- public Schema getEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace("salesordereprocessing");
- return schema;
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityType<String> extends JPAEntityTypeMock<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 java.lang.String getName() {
- return "SalesOrderHeader";
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- 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 true;
- }
- }
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
deleted file mode 100644
index dfbe879..0000000
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * 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.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-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.JPAEdmEntityContainerView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmEntityTypeTest extends JPAEdmTestModelView {
-
- private static JPAEdmEntityTypeTest objJPAEdmEntityTypeTest;
- private static JPAEdmEntityType objJPAEdmEntityType;
-
- @Before
- public void setUp() {
- objJPAEdmEntityTypeTest = new JPAEdmEntityTypeTest();
- objJPAEdmEntityType = new JPAEdmEntityType(objJPAEdmEntityTypeTest);
- try {
- objJPAEdmEntityType.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(objJPAEdmEntityType.getBuilder());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmEntityType.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmEntityType.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetEdmEntityType() {
- assertNotNull(objJPAEdmEntityType.getEdmEntityType());
- assertNotNull(objJPAEdmEntityType.getEdmEntityType().getKey());
- }
-
- @Test
- public void testGetJPAEntityType() {
- assertNotNull(objJPAEdmEntityType.getJPAEntityType());
-
- }
-
- @Test
- public void testGetConsistentEdmEntityTypes() {
- assertTrue(objJPAEdmEntityType.getConsistentEdmEntityTypes().size() > 0);
- }
-
- @Test
- public void testSearchEdmEntityType() {
- assertNotNull(objJPAEdmEntityType.searchEdmEntityType("SalesOrderHeader"));
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmEntityType.isConsistent());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityTypeLocal<String>();
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityTypeLocal<String> extends JPAEntityTypeMock<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;
- }
-
- 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 true;
- }
- }
- }
-}