You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by tb...@apache.org on 2014/01/02 13:47:02 UTC
[15/47] [OLINGO-99] Re-factor Package Names. Following are the changes
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
deleted file mode 100644
index f00cc61..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
+++ /dev/null
@@ -1,191 +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.edm;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-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.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmModel;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ODataJPAEdmProviderNegativeTest {
-
- private static ODataJPAEdmProvider edmProvider;
-
- @BeforeClass
- public static void setup() {
-
- edmProvider = new ODataJPAEdmProvider();
- try {
- Class<? extends ODataJPAEdmProvider> clazz = edmProvider.getClass();
- Field field = clazz.getDeclaredField("schemas");
- field.setAccessible(true);
- List<Schema> schemas = new ArrayList<Schema>();
- schemas.add(new Schema().setNamespace("salesorderprocessing")); // Empty Schema
- field.set(edmProvider, schemas);
- field = clazz.getDeclaredField("oDataJPAContext");
- field.setAccessible(true);
- field.set(edmProvider, ODataJPAContextMock.mockODataJPAContext());
- field = clazz.getDeclaredField("jpaEdmModel");
- field.setAccessible(true);
- field.set(edmProvider, new JPAEdmModel(null, null));
- } 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);
- } catch (NoSuchFieldException 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);
- }
-
- }
-
- @Test
- public void testNullGetEntityContainerInfo() {
- EntityContainerInfo entityContainer = null;
- try {
- entityContainer = edmProvider.getEntityContainerInfo("salesorderprocessingContainer");
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNull(entityContainer);
- }
-
- @Test
- public void testNullGetEntityType() {
- FullQualifiedName entityTypeName = new FullQualifiedName("salesorderprocessing", "SalesOrderHeader");
- try {
- assertNull(edmProvider.getEntityType(entityTypeName));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testNullGetComplexType() {
- FullQualifiedName complexTypeName = new FullQualifiedName("salesorderprocessing", "Address");
- try {
- assertNull(edmProvider.getComplexType(complexTypeName));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetAssociationFullQualifiedName() {
- Association association = null;
- try {
- association =
- edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNull(association);
- }
-
- @Test
- public void testGetEntitySet() {
- try {
- assertNull(edmProvider.getEntitySet("salesorderprocessingContainer", "SalesOrderHeaders"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetAssociationSet() {
- try {
- assertNull(edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName(
- "salesorderprocessing", "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testNullGetFunctionImport() {
-
- try {
- assertNull(edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testNullGetFunctionImport2() {
-
- try {
- ODataJPAEdmProvider provider = new ODataJPAEdmProvider();
- try {
- Class<? extends ODataJPAEdmProvider> clazz = provider.getClass();
- Field field = clazz.getDeclaredField("schemas");
- field.setAccessible(true);
- List<Schema> schemas = new ArrayList<Schema>();
- Schema schema = new Schema().setNamespace("salesorderprocessing");
- EntityContainer container = new EntityContainer().setName("salesorderprocessingContainer");
- List<EntityContainer> containerList = new ArrayList<EntityContainer>();
- containerList.add(container); // Empty Container
- schema.setEntityContainers(containerList);
- schemas.add(schema); // Empty Schema
- field.set(provider, schemas);
- } 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);
- } catch (NoSuchFieldException 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);
- }
-
- assertNull(provider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testGetSchemas() {
- try {
- assertNotNull(edmProvider.getSchemas());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
deleted file mode 100644
index 8dbd9da..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
+++ /dev/null
@@ -1,385 +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.edm;
-
-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.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-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.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.EdmSchemaMock;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmModel;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ODataJPAEdmProviderTest {
-
- private static ODataJPAEdmProvider edmProvider;
-
- @BeforeClass
- public static void setup() {
-
- edmProvider = new ODataJPAEdmProvider();
- try {
- Class<? extends ODataJPAEdmProvider> clazz = edmProvider.getClass();
- Field field = clazz.getDeclaredField("schemas");
- field.setAccessible(true);
- List<Schema> schemas = new ArrayList<Schema>();
- schemas.add(EdmSchemaMock.createMockEdmSchema());
- field.set(edmProvider, schemas);
- field = clazz.getDeclaredField("oDataJPAContext");
- field.setAccessible(true);
- field.set(edmProvider, ODataJPAContextMock.mockODataJPAContext());
- field = clazz.getDeclaredField("jpaEdmModel");
- field.setAccessible(true);
- field.set(edmProvider, new JPAEdmModel(null, null));
- } 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);
- } catch (NoSuchFieldException 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);
- }
-
- }
-
- @Test
- public void testConstructor() {
- try {
- ODataJPAEdmProvider edmProv = new ODataJPAEdmProvider(ODataJPAContextMock.mockODataJPAContext());
- edmProv.getClass();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetODataJPAContext() {
- String pUnitName = edmProvider.getODataJPAContext().getPersistenceUnitName();
- assertEquals("salesorderprocessing", pUnitName);
- }
-
- @Test
- public void testGetEntityContainerInfo() {
- String entityContainerName = null;
- EntityContainerInfo entityContainer = null;
- try {
- entityContainer = edmProvider.getEntityContainerInfo("salesorderprocessingContainer");
- entityContainerName = entityContainer.getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals("salesorderprocessingContainer", entityContainerName);
- assertNotNull(entityContainer);
- }
-
- @Test
- public void testDefaultGetEntityContainerInfo() {
- String entityContainerName = null;
- EntityContainerInfo entityContainer = null;
- try {
- entityContainer = edmProvider.getEntityContainerInfo(null);
- entityContainerName = entityContainer.getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals("salesorderprocessingContainer", entityContainerName);
- assertNotNull(entityContainer);
- }
-
- @Test
- public void testGetEntityType() {
- FullQualifiedName entityTypeName = new FullQualifiedName("salesorderprocessing", "SalesOrderHeader");
- String entityName = null;
- try {
- entityName = edmProvider.getEntityType(entityTypeName).getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("SalesOrderHeader", entityName);
- try {
- edmProvider.getEntityType(new FullQualifiedName("salesorder", "abc"));
- } catch (ODataException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetComplexType() {
- FullQualifiedName complexTypeName = new FullQualifiedName("salesorderprocessing", "Address");
- String nameStr = null;
- try {
- nameStr = edmProvider.getComplexType(complexTypeName).getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("Address", nameStr);
- }
-
- @Test
- public void testGetAssociationFullQualifiedName() {
- Association association = null;
- try {
- association =
- edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(association);
- assertEquals("SalesOrderHeader_SalesOrderItem", association.getName());
- }
-
- @Test
- public void testGetEntitySet() {
- String entitySetName = null;
- try {
- entitySetName = edmProvider.getEntitySet("salesorderprocessingContainer", "SalesOrderHeaders").getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("SalesOrderHeaders", entitySetName);
- try {
- assertNull(edmProvider.getEntitySet("salesorderprocessing", "SalesOrderHeaders"));
- } catch (ODataException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetAssociationSet() {
- AssociationSet associationSet = null;
-
- try {
- associationSet =
- edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader");
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(associationSet);
- assertEquals("SalesOrderHeader_SalesOrderItemSet", associationSet.getName());
- try {
- associationSet =
- edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(associationSet);
- try {
- associationSet =
- edmProvider.getAssociationSet("salesorderproceContainer", new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
- } catch (ODataException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetFunctionImport() {
- String functionImportName = null;
- try {
- functionImportName =
- edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1").getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("SalesOrder_FunctionImport1", functionImportName);
- try {
- functionImportName =
- edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1").getName();
- } catch (ODataException e) {
- assertTrue(true);
- }
- try {
- assertNotNull(edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
- } catch (ODataException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testGetSchemas() {
- try {
- assertNotNull(edmProvider.getSchemas());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testgetComplexTypeWithBuffer() {
- HashMap<String, ComplexType> compTypes = new HashMap<String, ComplexType>();
- ComplexType comp = new ComplexType();
- comp.setName("Address");
- compTypes.put("salesorderprocessing" + "." + "Address", comp);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- Field f;
- try {
- f = claz.getDeclaredField("complexTypes");
- f.setAccessible(true);
- f.set(jpaEdmProv, compTypes);
- } catch (NoSuchFieldException 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 (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);
- }
-
- try {
- assertEquals(comp, jpaEdmProv.getComplexType(new FullQualifiedName("salesorderprocessing", "Address")));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- try {
- jpaEdmProv.getComplexType(new FullQualifiedName("salesorderessing", "abc"));
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetEntityContainerInfoWithBuffer() {
- HashMap<String, EntityContainerInfo> entityContainerInfos = new HashMap<String, EntityContainerInfo>();
- EntityContainerInfo entityContainer = new EntityContainerInfo();
- entityContainer.setName("salesorderprocessingContainer");
- entityContainerInfos.put("salesorderprocessingContainer", entityContainer);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- try {
- Field f = claz.getDeclaredField("entityContainerInfos");
- f.setAccessible(true);
- f.set(jpaEdmProv, entityContainerInfos);
- assertEquals(entityContainer, jpaEdmProv.getEntityContainerInfo("salesorderprocessingContainer"));
- jpaEdmProv.getEntityContainerInfo("abc");
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (NoSuchFieldException 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 (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);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetEntityTypeWithBuffer() {
- HashMap<String, org.apache.olingo.odata2.api.edm.provider.EntityType> entityTypes =
- new HashMap<String, org.apache.olingo.odata2.api.edm.provider.EntityType>();
- org.apache.olingo.odata2.api.edm.provider.EntityType entity =
- new org.apache.olingo.odata2.api.edm.provider.EntityType();
- entity.setName("SalesOrderHeader");
- entityTypes.put("salesorderprocessing" + "." + "SalesorderHeader", entity);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- Field f;
- try {
- f = claz.getDeclaredField("entityTypes");
- f.setAccessible(true);
- f.set(jpaEdmProv, entityTypes);
- assertEquals(entity, jpaEdmProv.getEntityType(new FullQualifiedName("salesorderprocessing", "SalesorderHeader")));
- } catch (NoSuchFieldException 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 (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);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- try {
- jpaEdmProv.getEntityType(new FullQualifiedName("salesoprocessing", "abc"));
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetAssociationWithBuffer() {
- HashMap<String, Association> associations = new HashMap<String, Association>();
- Association association = new Association();
- association.setName("SalesOrderHeader_SalesOrderItem");
- associations.put("salesorderprocessing" + "." + "SalesOrderHeader_SalesOrderItem", association);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- Field f;
- try {
- f = claz.getDeclaredField("associations");
- f.setAccessible(true);
- f.set(jpaEdmProv, associations);
- assertEquals(association, jpaEdmProv.getAssociation(new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem")));
- } catch (NoSuchFieldException 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 (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);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- try {
- jpaEdmProv.getAssociation(new FullQualifiedName("salesorderprocessing", "abc"));
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
deleted file mode 100644
index 7da02d8..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
+++ /dev/null
@@ -1,377 +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.jpql;
-
-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.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.persistence.Cache;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnitUtil;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
-import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAProcessorImplTest;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.factory.ODataJPAFactoryImpl;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext.JPQLSelectContextBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class JPQLBuilderFactoryTest {
-
- @Test
- public void testGetStatementBuilderFactoryforSelect() throws ODataException {
-
- GetEntitySetUriInfo getEntitySetView = getUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLSelectStatementBuilder);
-
- }
-
- @Test
- public void testGetStatementBuilderFactoryforSelectSingle() throws ODataException {
-
- GetEntityUriInfo getEntityView = getEntityUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLSelectSingleStatementBuilder);
-
- }
-
- @Test
- public void testGetStatementBuilderFactoryforJoinSelect() throws ODataException {
-
- GetEntitySetUriInfo getEntitySetView = getUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN, getEntitySetView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLJoinStatementBuilder);
-
- }
-
- @Test
- public void testGetStatementBuilderFactoryforJoinSelectSingle() throws ODataException {
-
- GetEntityUriInfo getEntityView = getEntityUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN_SINGLE, getEntityView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLJoinSelectSingleStatementBuilder);
-
- }
-
- @Test
- public void testGetContextBuilderforDelete() throws ODataException {
-
- // Build JPQL ContextBuilder
- JPQLContextBuilder contextBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.DELETE);
-
- assertNull(contextBuilder);
-
- }
-
- @Test
- public void testGetContextBuilderforSelect() throws ODataException {
-
- // Build JPQL ContextBuilder
- JPQLContextBuilder contextBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT);
-
- assertNotNull(contextBuilder);
- assertTrue(contextBuilder instanceof JPQLSelectContextBuilder);
-
- }
-
- @Test
- public void testGetContextBuilderforSelectSingle() throws ODataException {
-
- // Build JPQL ContextBuilder
- JPQLContextBuilder contextBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT_SINGLE);
-
- assertNotNull(contextBuilder);
- assertTrue(contextBuilder instanceof JPQLSelectSingleContextBuilder);
-
- }
-
- private GetEntitySetUriInfo getUriInfo() throws EdmException {
- GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SOItem");
- EasyMock.replay(edmEntityType);
- OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
- EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(getEntitySetView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
- EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(null);
- EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(null);
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(getEntitySetView.getNavigationSegments()).andStubReturn(navigationSegments);
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- try {
- EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
- EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
-
- EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);
-
- } catch (EdmException e2) {
- fail("this should not happen");
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
- EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- EasyMock.expect(getEntitySetView.getKeyPredicates()).andStubReturn(keyPredicates);
- EasyMock.replay(getEntitySetView);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.replay(edmEntitySet);
- return getEntitySetView;
- }
-
- private GetEntityUriInfo getEntityUriInfo() throws EdmException {
- GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("");
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
- EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(getEntityView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.replay(edmEntityType, edmEntitySet);
- EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(getEntityView.getNavigationSegments()).andStubReturn(navigationSegments);
- EasyMock.replay(getEntityView);
- return getEntityView;
- }
-
- @Test
- public void testJPAAccessFactory() {
- ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
- JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory();
- ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
- Class<?> clazz = oDataJPAContextImpl.getClass();
- try {
- Field field = clazz.getDeclaredField("em");
- field.setAccessible(true);
- field.set(oDataJPAContextImpl, new JPAProcessorImplTest().getLocalEntityManager());
- } 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);
- }
- EntityManagerFactory emf = new EntityManagerFactory() {
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public Map<String, Object> getProperties() {
- return null;
- }
-
- @Override
- public PersistenceUnitUtil getPersistenceUnitUtil() {
- return null;
- }
-
- @Override
- public Metamodel getMetamodel() {
- return null;
- }
-
- @Override
- public CriteriaBuilder getCriteriaBuilder() {
- return null;
- }
-
- @Override
- public Cache getCache() {
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public EntityManager createEntityManager(final Map arg0) {
- return null;
- }
-
- @Override
- public EntityManager createEntityManager() {
- return null;
- }
-
- @Override
- public void close() {}
- };
- oDataJPAContextImpl.setEntityManagerFactory(emf);
- oDataJPAContextImpl.setPersistenceUnitName("pUnit");
-
- assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl));
- assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl));
-
- }
-
- @Test
- public void testOdataJpaAccessFactory() {
-
- ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
- ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory();
- ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
-
- EntityManagerFactory emf = new EntityManagerFactory() {
-
- @Override
- public boolean isOpen() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Map<String, Object> getProperties() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public PersistenceUnitUtil getPersistenceUnitUtil() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Metamodel getMetamodel() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public CriteriaBuilder getCriteriaBuilder() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Cache getCache() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public EntityManager createEntityManager(final Map arg0) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public EntityManager createEntityManager() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void close() {
- // TODO Auto-generated method stub
-
- }
- };
- oDataJPAContextImpl.setEntityManagerFactory(emf);
- oDataJPAContextImpl.setPersistenceUnitName("pUnit");
-
- assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en")));
- assertNotNull(jpaAccessFactory.createODataJPAContext());
- assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl));
- assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
deleted file mode 100644
index 509591f..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.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.jpql;
-
-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.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-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.jpql.JPQLJoinSelectContext.JPQLJoinContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinContextTest {
-
- GetEntitySetUriInfo entitySetUriInfo;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- @Before
- public void setUp() throws Exception {
- entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
- final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
- final List<KeyPredicate> keyPredicates = createKeyPredicates();
- NavigationSegment navigationSegment = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- NavigationSegment navigationSegment1 = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty1;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- navigationSegments.add(navigationSegment);
- navigationSegments.add(navigationSegment1);
- EasyMock.expect(entitySetUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
- EasyMock.expect(entitySetUriInfo.getOrderBy()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getFilter()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getKeyPredicates()).andStubReturn(keyPredicates);
- EasyMock.expect(entitySetUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(entitySetUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.replay(edmEntityType, edmEntitySet, entitySetUriInfo);
-
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testGetJPAOuterJoinClauses() {
- JPQLJoinSelectContext joinContext = new JPQLJoinSelectContext(false);
- JPQLJoinContextBuilder joinContextBuilder = joinContext.new JPQLJoinContextBuilder();
- try {
- joinContextBuilder.entitySetView = entitySetUriInfo;
- joinContextBuilder.build();
- } catch (ODataJPAModelException e) {
- fail("Should not come here");
- } catch (ODataJPARuntimeException e) {
- fail("Should not come here");
- }
- List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
- assertNotNull(joinClauses);
- assertTrue(joinClauses.size() > 0);
- assertEquals("E1", joinClauses.get(0).getEntityAlias());
- assertEquals("SOHeader", joinClauses.get(0).getEntityName());
- assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
- assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
- }
-
- private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
- EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
- EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
- EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
- EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
- EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
- EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
- EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
- return navigationProperty;
- }
-
- private List<KeyPredicate> createKeyPredicates() throws EdmException {
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
-
- EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- return keyPredicates;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
deleted file mode 100644
index b7c9c7d..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
+++ /dev/null
@@ -1,215 +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.jpql;
-
-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.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-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.jpql.JPQLJoinSelectSingleContext.JPQLJoinSelectSingleContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinSelectSingleContextTest {
-
- GetEntityUriInfo entityUriInfo;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- public void setUp(final boolean toThrowException) throws Exception {
- entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
- final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
- final List<KeyPredicate> keyPredicates = createKeyPredicates(toThrowException);
- NavigationSegment navigationSegment = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- NavigationSegment navigationSegment1 = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty1;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- navigationSegments.add(navigationSegment);
- navigationSegments.add(navigationSegment1);
- EasyMock.expect(entityUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
- EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(entityUriInfo.getFilter()).andStubReturn(null);
- EasyMock.expect(entityUriInfo.getKeyPredicates()).andStubReturn(createKeyPredicates(toThrowException));
- EasyMock.expect(entityUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(entityUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.replay(edmEntityType, edmEntitySet, entityUriInfo);
-
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testGetJPAOuterJoinClauses() throws Exception {
- setUp(false);
-
- JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
- JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
- try {
- joinContextBuilder.entityView = entityUriInfo;
- joinContextBuilder.build();
- } catch (ODataJPAModelException e) {
- fail("Should not come here");
- } catch (ODataJPARuntimeException e) {
- fail("Should not come here");
- }
- List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
- assertNotNull(joinClauses);
- assertTrue(joinClauses.size() > 0);
- assertEquals("E1", joinClauses.get(0).getEntityAlias());
- assertEquals("SOHeader", joinClauses.get(0).getEntityName());
- assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
- assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
- }
-
- @Test
- public void testExceptionThrown() throws Exception {
- setUp(true);
- JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
- JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
- try {
- joinContextBuilder.entityView = entityUriInfo;
- joinContextBuilder.build();
- fail("Should not come here");
- } catch (ODataJPAModelException e) {
- fail("Should not come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
- EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
- EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
- EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
- EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
- EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
- EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
- EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
- return navigationProperty;
- }
-
- private List<KeyPredicate> createKeyPredicates(final boolean toThrowException) throws EdmException {
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- if (toThrowException) {
- EasyMock.expect(edmProperty.getType()).andStubThrow(new EdmException(null));
- } else {
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
-
- EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- return keyPredicates;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
deleted file mode 100644
index c7df74b..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
+++ /dev/null
@@ -1,142 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-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.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinSelectSingleStatementBuilderTest {
- JPQLJoinSelectSingleContextView context = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
- context = EasyMock.createMock(JPQLJoinSelectSingleContextView.class);
- EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("gt1");
- EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
- EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
- EasyMock.expect(context.getKeyPredicates()).andStubReturn(createKeyPredicates());
- EasyMock.expect(context.getSelectExpression()).andStubReturn("gt1");
- EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
- EasyMock.replay(context);
- }
-
- private List<JPAJoinClause> getJoinClauseList() {
- List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
- JPAJoinClause jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", null, null, "soh.soId = 1", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- return joinClauseList;
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testBuild() throws Exception {
- setUp(getJoinClauseList());
- JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
- new JPQLJoinSelectSingleStatementBuilder(context);
- try {
- JPQLStatement jpqlStatement = jpqlJoinSelectsingleStatementBuilder.build();
- assertEquals(
- "SELECT gt1 FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.soId = 1 AND " +
- "soi.shId = soh.soId AND mat.id = 'abc'",
- jpqlStatement.toString());
- } catch (ODataJPARuntimeException e) {
- fail("Should not have come here");
- }
-
- }
-
- private List<KeyPredicate> createKeyPredicates() throws EdmException {
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
-
- EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- return keyPredicates;
- }
-
- @Test
- public void testJoinClauseAsNull() throws Exception {
- setUp(null);
- JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
- new JPQLJoinSelectSingleStatementBuilder(context);
- try {
- jpqlJoinSelectsingleStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testJoinClauseListAsEmpty() throws Exception {
- List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
- setUp(joinClauseList);
- JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
- new JPQLJoinSelectSingleStatementBuilder(context);
- try {
- jpqlJoinSelectsingleStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/63b621a8/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
deleted file mode 100644
index dad45e3..0000000
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
+++ /dev/null
@@ -1,124 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinStatementBuilderTest {
- JPQLJoinContextView context = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
- context = EasyMock.createMock(JPQLJoinContextView.class);
- EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("mat");
- EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
- EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
- EasyMock.expect(context.getSelectExpression()).andStubReturn("mat");
- EasyMock.expect(context.getWhereExpression()).andStubReturn("soh.buyerId = 2");
- HashMap<String, String> orderByMap = new HashMap<String, String>();
- orderByMap.put("mat.buyerId", "asc");
- orderByMap.put("mat.city", "desc");
- EasyMock.expect(context.getOrderByCollection()).andStubReturn(orderByMap);
- EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
- EasyMock.replay(context);
- }
-
- private List<JPAJoinClause> getJoinClauseList() {
- List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
- JPAJoinClause jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", null, null, "soh.createdBy = 'Peter'", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- return joinClauseList;
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testBuild() throws Exception {
- setUp(getJoinClauseList());
- JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
- try {
- JPQLStatement jpqlStatement = jpqlJoinStatementBuilder.build();
- assertEquals(
- "SELECT mat FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.buyerId = 2 AND "
- +
- "soh.createdBy = 'Peter' AND soi.shId = soh.soId AND mat.id = 'abc' "
- +
- "ORDER BY mat.buyerId asc , mat.city desc",
- jpqlStatement.toString());
- } catch (ODataJPARuntimeException e) {
- fail("Should not have come here");
- }
-
- }
-
- @Test
- public void testJoinClauseAsNull() throws Exception {
- setUp(null);
- JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
- try {
- jpqlJoinStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testJoinClauseListAsEmpty() throws Exception {
- setUp(new ArrayList<JPAJoinClause>());
- JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
- try {
- jpqlJoinStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
-}