This is an automated email from the ASF dual-hosted git repository. mibo pushed a commit to branch OLINGO-1636-jdk_upgrade in repository https://gitbox.apache.org/repos/asf/olingo-odata2.git
commit 83032e8659da1502791e51a7b2f9f80162d5d681 Author: Iliyan Velichkov <[email protected]> AuthorDate: Thu Dec 14 14:42:50 2023 +0200 adapts tests Signed-off-by: Iliyan Velichkov <[email protected]> --- .../processor/ref/model/ResourceHelper.java | 4 +- odata2-jpa-processor/jpa-api/pom.xml | 18 +- .../api/model/mapping/JPAAttributeMapType.java | 12 +- .../api/model/mapping/JPAEdmMappingModel.java | 18 +- .../model/mapping/JPAEdmMappingModelFactory.java | 2 +- .../model/mapping/JPAEmbeddableTypeMapType.java | 10 +- .../model/mapping/JPAEmbeddableTypesMapType.java | 8 +- .../api/model/mapping/JPAEntityTypeMapType.java | 10 +- .../api/model/mapping/JPAEntityTypesMapType.java | 8 +- .../model/mapping/JPAPersistenceUnitMapType.java | 10 +- .../api/model/mapping/JPARelationshipMapType.java | 12 +- .../processor/api/model/mapping/package-info.java | 38 +- .../access/model/JPAEdmMappingModelService.java | 3 +- .../core/ODataJPADefaultProcessorTest.java | 13 +- .../model/JPAEdmMappingModelServiceTest.java | 378 ++++++------ .../core/jpql/JPQLBuilderFactoryTest.java | 649 +++++++++++---------- 16 files changed, 618 insertions(+), 575 deletions(-) diff --git a/odata2-annotation-processor/annotation-processor-ref/src/main/java/org/apache/olingo/odata2/annotation/processor/ref/model/ResourceHelper.java b/odata2-annotation-processor/annotation-processor-ref/src/main/java/org/apache/olingo/odata2/annotation/processor/ref/model/ResourceHelper.java index 8fc4dc27..511169f1 100644 --- a/odata2-annotation-processor/annotation-processor-ref/src/main/java/org/apache/olingo/odata2/annotation/processor/ref/model/ResourceHelper.java +++ b/odata2-annotation-processor/annotation-processor-ref/src/main/java/org/apache/olingo/odata2/annotation/processor/ref/model/ResourceHelper.java @@ -33,7 +33,9 @@ public class ResourceHelper { public static byte[] load(final String resource, final byte[] defaultResult) { InputStream instream = null; try { - instream = ResourceHelper.class.getResourceAsStream(resource); + instream = Thread.currentThread() + .getContextClassLoader() + .getResourceAsStream(resource); if (instream == null) { return defaultResult; } diff --git a/odata2-jpa-processor/jpa-api/pom.xml b/odata2-jpa-processor/jpa-api/pom.xml index dc6909d5..780290e5 100644 --- a/odata2-jpa-processor/jpa-api/pom.xml +++ b/odata2-jpa-processor/jpa-api/pom.xml @@ -17,7 +17,8 @@ specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -31,14 +32,15 @@ <artifactId>olingo-odata2-jpa-processor-api</artifactId> <packaging>jar</packaging> <name>${project.artifactId}</name> - + <build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> - <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + <manifestFile> + ${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> @@ -72,12 +74,16 @@ </plugin> </plugins> </build> - + <dependencies> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + </dependency> <!-- JPA Support --> <dependency> - <groupId>jakarta.persistence</groupId> - <artifactId>jakarta.persistence-api</artifactId> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> </dependency> <!-- OData Java Library --> diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAAttributeMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAAttributeMapType.java index 302a51d6..cb899a42 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAAttributeMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAAttributeMapType.java @@ -16,12 +16,12 @@ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; /** * diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModel.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModel.java index 1d585dfd..b2b255cb 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModel.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModel.java @@ -14,11 +14,11 @@ ******************************************************************************/ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** * <p> @@ -52,9 +52,9 @@ public class JPAEdmMappingModel { /** * Gets the value of the persistenceUnit property. - * + * * @return possible object is {@link JPAPersistenceUnitMapType } - * + * */ public JPAPersistenceUnitMapType getPersistenceUnit() { return persistenceUnit; @@ -62,9 +62,9 @@ public class JPAEdmMappingModel { /** * Sets the value of the persistenceUnit property. - * + * * @param value allowed object is {@link JPAPersistenceUnitMapType } - * + * */ public void setPersistenceUnit(final JPAPersistenceUnitMapType value) { persistenceUnit = value; diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModelFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModelFactory.java index 5f2683aa..5ab4991b 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModelFactory.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEdmMappingModelFactory.java @@ -14,7 +14,7 @@ ******************************************************************************/ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; -import javax.xml.bind.annotation.XmlRegistry; +import jakarta.xml.bind.annotation.XmlRegistry; /** * This object contains factory methods for each Java content interface and Java element interface diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypeMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypeMapType.java index 024ea5ae..47803af2 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypeMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypeMapType.java @@ -14,11 +14,11 @@ ******************************************************************************/ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; /** * diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypesMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypesMapType.java index 6dcfb8a6..6bec5a12 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypesMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEmbeddableTypesMapType.java @@ -16,10 +16,10 @@ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; /** * <p> diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypeMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypeMapType.java index fe6173c8..8c989234 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypeMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypeMapType.java @@ -14,11 +14,11 @@ ******************************************************************************/ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; /** * diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypesMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypesMapType.java index 5cbd7599..afacacec 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypesMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAEntityTypesMapType.java @@ -16,10 +16,10 @@ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; /** * <p> diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAPersistenceUnitMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAPersistenceUnitMapType.java index 53bc390c..7ce8c0aa 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAPersistenceUnitMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPAPersistenceUnitMapType.java @@ -14,11 +14,11 @@ ******************************************************************************/ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; /** * diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPARelationshipMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPARelationshipMapType.java index ed596422..50970877 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPARelationshipMapType.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/JPARelationshipMapType.java @@ -16,12 +16,12 @@ package org.apache.olingo.odata2.jpa.processor.api.model.mapping; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; /** * diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/package-info.java index 45a7c3f9..ed06d383 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/package-info.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/mapping/package-info.java @@ -1,28 +1,24 @@ /******************************************************************************* - * 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 - * + * 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. + * + * 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. ******************************************************************************/ /** - * <h3>OData JPA Processor API Library - Mapping Model</h3> - * The JPA EDM Mapping model (XML document) is represented as JAXB annotated Java Classes. - * - * + * <h3>OData JPA Processor API Library - Mapping Model</h3> The JPA EDM Mapping model (XML document) + * is represented as JAXB annotated Java Classes. + * + * */ [email protected](namespace = "http://www.apache.org/olingo/odata2/jpa/processor/api/model/mapping", - elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) [email protected](namespace = "http://www.apache.org/olingo/odata2/jpa/processor/api/model/mapping", + elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.apache.olingo.odata2.jpa.processor.api.model.mapping; diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java index a458f2d2..adf26047 100644 --- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java +++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java @@ -74,7 +74,8 @@ public class JPAEdmMappingModelService implements JPAEdmMappingModelAccess { } catch (JAXBException e) { mappingModelExists = false; - ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e); + ODataJPAModelException ex = ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e); + throw new IllegalStateException("Failed to load model", ex); } finally { try { if (is != null) { diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPADefaultProcessorTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPADefaultProcessorTest.java index 0b3e8173..ceb52ec5 100644 --- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPADefaultProcessorTest.java +++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPADefaultProcessorTest.java @@ -476,21 +476,26 @@ public class ODataJPADefaultProcessorTest extends JPAEdmTestModelView { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Address other = (Address) obj; - if (!getEnclosingInstance().equals(other.getEnclosingInstance())) + if (!getEnclosingInstance().equals(other.getEnclosingInstance())) { return false; + } return Objects.equals(soId, other.soId); } private ODataJPADefaultProcessorTest getEnclosingInstance() { return ODataJPADefaultProcessorTest.this; } + } private Metamodel mockMetaModel() { diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelServiceTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelServiceTest.java index bb0c1d34..7ef9a487 100644 --- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelServiceTest.java +++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelServiceTest.java @@ -1,20 +1,16 @@ /******************************************************************************* - * 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 - * + * 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. + * + * 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.jpa.processor.core.access.model; @@ -23,191 +19,185 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - import java.io.InputStream; - import org.apache.olingo.odata2.jpa.processor.core.mock.ODataJPAContextMock; import org.junit.BeforeClass; import org.junit.Test; public class JPAEdmMappingModelServiceTest extends JPAEdmMappingModelService { - private static JPAEdmMappingModelServiceTest objJPAEdmMappingModelServiceTest; - - private static final String MAPPING_FILE_CORRECT = "SalesOrderProcessingMappingModels.xml"; - private static final String MAPPING_FILE_INCORRECT = "TEST.xml"; - - private static int VARIANT_MAPPING_FILE; // 0 FOR INCORRECT, 1 FOR CORRECT - - private static String PERSISTENCE_UNIT_NAME_JPA = "salesorderprocessing"; - private static String PERSISTENCE_UNIT_NAME_EDM = "SalesOrderProcessing"; - - private static String ENTITY_TYPE_NAME_JPA = "SalesOrderHeader"; - private static String ENTITY_TYPE_NAME_EDM = "SalesOrder"; - private static String ENTITY_SET_NAME_EDM = "SalesOrders"; - private static String RELATIONSHIP_NAME_JPA = "salesOrderItems"; - private static String RELATIONSHIP_NAME_EDM = "SalesOrderItemDetails"; - private static String ATTRIBUTE_NAME_JPA = "netAmount"; - private static String ATTRIBUTE_NAME_EDM = "NetAmount"; - private static String EMBEDDABLE_TYPE_NAME_JPA = "SalesOrderItemKey"; - private static String EMBEDDABLE_ATTRIBUTE_NAME_JPA = "liId"; - private static String EMBEDDABLE_ATTRIBUTE_NAME_EDM = "ID"; - private static String EMBEDDABLE_TYPE_2_NAME_JPA = "SalesOrderItemKey"; - - private static String ENTITY_TYPE_NAME_JPA_WRONG = "SalesOrderHeaders"; - private static String RELATIONSHIP_NAME_JPA_WRONG = "value"; - private static String EMBEDDABLE_TYPE_NAME_JPA_WRONG = "SalesOrderItemKeys"; - - public JPAEdmMappingModelServiceTest() { - super(ODataJPAContextMock.mockODataJPAContext()); - } - - @BeforeClass - public static void setup() { - objJPAEdmMappingModelServiceTest = new JPAEdmMappingModelServiceTest(); - VARIANT_MAPPING_FILE = 1; - objJPAEdmMappingModelServiceTest.loadMappingModel(); - } - - @Test - public void testLoadMappingModel() { - VARIANT_MAPPING_FILE = 1; - loadMappingModel(); - assertTrue(isMappingModelExists()); - } - - @Test - public void testLoadMappingModelNegative() { - VARIANT_MAPPING_FILE = 0; - loadMappingModel(); - assertFalse(isMappingModelExists()); - // reset it for other JUnits - VARIANT_MAPPING_FILE = 1; - loadMappingModel(); - } - - @Test - public void testIsMappingModelExists() { - assertTrue(objJPAEdmMappingModelServiceTest.isMappingModelExists()); - } - - @Test - public void testGetJPAEdmMappingModel() { - assertNotNull(objJPAEdmMappingModelServiceTest.getJPAEdmMappingModel()); - } - - @Test - public void testMapJPAPersistenceUnit() { - assertEquals(PERSISTENCE_UNIT_NAME_EDM, objJPAEdmMappingModelServiceTest - .mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_JPA)); - } - - @Test - public void testMapJPAPersistenceUnitNegative() { - assertNull(objJPAEdmMappingModelServiceTest.mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_EDM));// Wrong value to - // bring null - } - - @Test - public void testMapJPAEntityType() { - assertEquals(ENTITY_TYPE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA)); - } - - @Test - public void testMapJPAEntityTypeNegative() { - assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring - // null - } - - @Test - public void testMapJPAEntitySet() { - assertEquals(ENTITY_SET_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA)); - } - - @Test - public void testMapJPAEntitySetNegative() { - assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring - // null - } - - @Test - public void testMapJPAAttribute() { - assertEquals(ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA, - ATTRIBUTE_NAME_JPA)); - } - - @Test - public void testMapJPAAttributeNegative() { - // Wrong value to bring null - assertNull(objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA, ATTRIBUTE_NAME_JPA + "AA")); - } - - @Test - public void testMapJPARelationship() { - assertEquals(RELATIONSHIP_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA, - RELATIONSHIP_NAME_JPA)); - } - - @Test - public void testMapJPARelationshipNegative() { - // Wrong value to bring null - assertNull(objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA, RELATIONSHIP_NAME_JPA_WRONG)); - } - - @Test - public void testMapJPAEmbeddableType() { - assertEquals("SalesOrderLineItemKey", objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType("SalesOrderItemKey")); - } - - @Test - public void testMapJPAEmbeddableTypeNegative() { - assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType(EMBEDDABLE_TYPE_NAME_JPA_WRONG));// Wrong value to + private static JPAEdmMappingModelServiceTest objJPAEdmMappingModelServiceTest; + + private static final String MAPPING_FILE_CORRECT = "SalesOrderProcessingMappingModels.xml"; + private static final String MAPPING_FILE_INCORRECT = "TEST.xml"; + + private static int VARIANT_MAPPING_FILE; // 0 FOR INCORRECT, 1 FOR CORRECT + + private static String PERSISTENCE_UNIT_NAME_JPA = "salesorderprocessing"; + private static String PERSISTENCE_UNIT_NAME_EDM = "SalesOrderProcessing"; + + private static String ENTITY_TYPE_NAME_JPA = "SalesOrderHeader"; + private static String ENTITY_TYPE_NAME_EDM = "SalesOrder"; + private static String ENTITY_SET_NAME_EDM = "SalesOrders"; + private static String RELATIONSHIP_NAME_JPA = "salesOrderItems"; + private static String RELATIONSHIP_NAME_EDM = "SalesOrderItemDetails"; + private static String ATTRIBUTE_NAME_JPA = "netAmount"; + private static String ATTRIBUTE_NAME_EDM = "NetAmount"; + private static String EMBEDDABLE_TYPE_NAME_JPA = "SalesOrderItemKey"; + private static String EMBEDDABLE_ATTRIBUTE_NAME_JPA = "liId"; + private static String EMBEDDABLE_ATTRIBUTE_NAME_EDM = "ID"; + private static String EMBEDDABLE_TYPE_2_NAME_JPA = "SalesOrderItemKey"; + + private static String ENTITY_TYPE_NAME_JPA_WRONG = "SalesOrderHeaders"; + private static String RELATIONSHIP_NAME_JPA_WRONG = "value"; + private static String EMBEDDABLE_TYPE_NAME_JPA_WRONG = "SalesOrderItemKeys"; + + public JPAEdmMappingModelServiceTest() { + super(ODataJPAContextMock.mockODataJPAContext()); + } + + @BeforeClass + public static void setup() { + objJPAEdmMappingModelServiceTest = new JPAEdmMappingModelServiceTest(); + VARIANT_MAPPING_FILE = 1; + objJPAEdmMappingModelServiceTest.loadMappingModel(); + } + + @Test + public void testLoadMappingModel() { + VARIANT_MAPPING_FILE = 1; + loadMappingModel(); + assertTrue(isMappingModelExists()); + } + + @Test + public void testLoadMappingModelNegative() { + VARIANT_MAPPING_FILE = 0; + loadMappingModel(); + assertFalse(isMappingModelExists()); + // reset it for other JUnits + VARIANT_MAPPING_FILE = 1; + loadMappingModel(); + } + + @Test + public void testIsMappingModelExists() { + assertTrue(objJPAEdmMappingModelServiceTest.isMappingModelExists()); + } + + @Test + public void testGetJPAEdmMappingModel() { + assertNotNull(objJPAEdmMappingModelServiceTest.getJPAEdmMappingModel()); + } + + @Test + public void testMapJPAPersistenceUnit() { + assertEquals(PERSISTENCE_UNIT_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_JPA)); + } + + @Test + public void testMapJPAPersistenceUnitNegative() { + assertNull(objJPAEdmMappingModelServiceTest.mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_EDM));// Wrong value to // bring null - } - - @Test - public void testMapJPAEmbeddableTypeAttribute() { - assertEquals(EMBEDDABLE_ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute( - EMBEDDABLE_TYPE_NAME_JPA, EMBEDDABLE_ATTRIBUTE_NAME_JPA)); - } - - @Test - public void testMapJPAEmbeddableTypeAttributeNegative() { - assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(EMBEDDABLE_TYPE_NAME_JPA_WRONG, - EMBEDDABLE_ATTRIBUTE_NAME_JPA)); - } - - @Test - public void testCheckExclusionOfJPAEntityType() { - assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEntityType(ENTITY_TYPE_NAME_JPA)); - } - - @Test - public void testCheckExclusionOfJPAAttributeType() { - assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAAttributeType(ENTITY_TYPE_NAME_JPA, - ATTRIBUTE_NAME_JPA)); - } - - @Test - public void testCheckExclusionOfJPAEmbeddableType() { - assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableType(EMBEDDABLE_TYPE_2_NAME_JPA)); - } - - @Test - public void testCheckExclusionOfJPAEmbeddableAttributeType() { - assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableAttributeType(EMBEDDABLE_TYPE_NAME_JPA, - EMBEDDABLE_ATTRIBUTE_NAME_JPA)); - } - - /** - * This method is for loading the xml file for testing. - */ - @Override - protected InputStream loadMappingModelInputStream() { - if (VARIANT_MAPPING_FILE == 1) { - return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_CORRECT); - } else { - return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_INCORRECT); - } - } + } + + @Test + public void testMapJPAEntityType() { + assertEquals(ENTITY_TYPE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA)); + } + + @Test + public void testMapJPAEntityTypeNegative() { + assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring + // null + } + + @Test + public void testMapJPAEntitySet() { + assertEquals(ENTITY_SET_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA)); + } + + @Test + public void testMapJPAEntitySetNegative() { + assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring + // null + } + + @Test + public void testMapJPAAttribute() { + assertEquals(ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA, ATTRIBUTE_NAME_JPA)); + } + + @Test + public void testMapJPAAttributeNegative() { + // Wrong value to bring null + assertNull(objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA, ATTRIBUTE_NAME_JPA + "AA")); + } + + @Test + public void testMapJPARelationship() { + assertEquals(RELATIONSHIP_NAME_EDM, + objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA, RELATIONSHIP_NAME_JPA)); + } + + @Test + public void testMapJPARelationshipNegative() { + // Wrong value to bring null + assertNull(objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA, RELATIONSHIP_NAME_JPA_WRONG)); + } + + @Test + public void testMapJPAEmbeddableType() { + assertEquals("SalesOrderLineItemKey", objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType("SalesOrderItemKey")); + } + + @Test + public void testMapJPAEmbeddableTypeNegative() { + assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType(EMBEDDABLE_TYPE_NAME_JPA_WRONG));// Wrong value to + // bring null + } + + @Test + public void testMapJPAEmbeddableTypeAttribute() { + assertEquals(EMBEDDABLE_ATTRIBUTE_NAME_EDM, + objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(EMBEDDABLE_TYPE_NAME_JPA, EMBEDDABLE_ATTRIBUTE_NAME_JPA)); + } + + @Test + public void testMapJPAEmbeddableTypeAttributeNegative() { + assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(EMBEDDABLE_TYPE_NAME_JPA_WRONG, + EMBEDDABLE_ATTRIBUTE_NAME_JPA)); + } + + @Test + public void testCheckExclusionOfJPAEntityType() { + assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEntityType(ENTITY_TYPE_NAME_JPA)); + } + + @Test + public void testCheckExclusionOfJPAAttributeType() { + assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAAttributeType(ENTITY_TYPE_NAME_JPA, ATTRIBUTE_NAME_JPA)); + } + + @Test + public void testCheckExclusionOfJPAEmbeddableType() { + assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableType(EMBEDDABLE_TYPE_2_NAME_JPA)); + } + + @Test + public void testCheckExclusionOfJPAEmbeddableAttributeType() { + assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableAttributeType(EMBEDDABLE_TYPE_NAME_JPA, + EMBEDDABLE_ATTRIBUTE_NAME_JPA)); + } + + /** + * This method is for loading the xml file for testing. + */ + @Override + protected InputStream loadMappingModelInputStream() { + if (VARIANT_MAPPING_FILE == 1) { + return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_CORRECT); + } + return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_INCORRECT); + } } diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLBuilderFactoryTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLBuilderFactoryTest.java index e3646d69..2dd768c6 100644 --- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLBuilderFactoryTest.java +++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLBuilderFactoryTest.java @@ -1,20 +1,16 @@ /******************************************************************************* - * 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 - * + * 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. + * + * 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.jpa.processor.core.jpql; @@ -22,23 +18,10 @@ 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 jakarta.persistence.Cache; -import jakarta.persistence.EntityGraph; -import jakarta.persistence.EntityManager; -import jakarta.persistence.EntityManagerFactory; -import jakarta.persistence.PersistenceUnitUtil; -import jakarta.persistence.Query; -import jakarta.persistence.SynchronizationType; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.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; @@ -65,339 +48,399 @@ import org.apache.olingo.odata2.jpa.processor.core.jpql.JPQLSelectContext.JPQLSe import org.apache.olingo.odata2.jpa.processor.core.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder; import org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmMappingImpl; import org.easymock.EasyMock; +import org.junit.Ignore; import org.junit.Test; +import jakarta.persistence.Cache; +import jakarta.persistence.EntityGraph; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceUnitUtil; +import jakarta.persistence.Query; +import jakarta.persistence.SynchronizationType; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.metamodel.Metamodel; 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); + @Test + public void testGetStatementBuilderFactoryforSelect() throws ODataException { - assertTrue(statementBuilder instanceof JPQLSelectStatementBuilder); + GetEntitySetUriInfo getEntitySetView = getUriInfo(); - } + // Build JPQL Context + JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView) + .build(); + JPQLStatementBuilder statementBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getStatementBuilder(selectContext); - @Test - public void testGetStatementBuilderFactoryforSelectSingle() throws ODataException { + assertTrue(statementBuilder instanceof JPQLSelectStatementBuilder); - 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 testGetStatementBuilderFactoryforSelectSingle() throws ODataException { - } + GetEntityUriInfo getEntityView = getEntityUriInfo(); - @Test - public void testGetStatementBuilderFactoryforJoinSelect() throws ODataException { + // Build JPQL Context + JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView) + .build(); + JPQLStatementBuilder statementBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getStatementBuilder(selectContext); - GetEntitySetUriInfo getEntitySetView = getUriInfo(); + assertTrue(statementBuilder instanceof JPQLSelectSingleStatementBuilder); - // 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 testGetStatementBuilderFactoryforJoinSelect() throws ODataException { - } + GetEntitySetUriInfo getEntitySetView = getUriInfo(); - @Test - public void testGetStatementBuilderFactoryforJoinSelectSingle() throws ODataException { + // Build JPQL Context + JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN, getEntitySetView) + .build(); + JPQLStatementBuilder statementBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getStatementBuilder(selectContext); - GetEntityUriInfo getEntityView = getEntityUriInfo(); + assertTrue(statementBuilder instanceof JPQLJoinStatementBuilder); - // 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 testGetStatementBuilderFactoryforJoinSelectSingle() throws ODataException { - } + GetEntityUriInfo getEntityView = getEntityUriInfo(); - @Test - public void testGetContextBuilderforDelete() throws ODataException { + // Build JPQL Context + JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN_SINGLE, getEntityView) + .build(); + JPQLStatementBuilder statementBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getStatementBuilder(selectContext); - // Build JPQL ContextBuilder - JPQLContextBuilder contextBuilder = - new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.DELETE); + assertTrue(statementBuilder instanceof JPQLJoinSelectSingleStatementBuilder); - assertNull(contextBuilder); + } - } + @Test + public void testGetContextBuilderforDelete() throws ODataException { - @Test - public void testGetContextBuilderforSelect() throws ODataException { + // Build JPQL ContextBuilder + JPQLContextBuilder contextBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getContextBuilder(JPQLContextType.DELETE); - // Build JPQL ContextBuilder - JPQLContextBuilder contextBuilder = - new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT); + assertNull(contextBuilder); - assertNotNull(contextBuilder); - assertTrue(contextBuilder instanceof JPQLSelectContextBuilder); + } - } + @Test + public void testGetContextBuilderforSelect() throws ODataException { - @Test - public void testGetContextBuilderforSelectSingle() throws ODataException { + // Build JPQL ContextBuilder + JPQLContextBuilder contextBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getContextBuilder(JPQLContextType.SELECT); - // Build JPQL ContextBuilder - JPQLContextBuilder contextBuilder = - new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT_SINGLE); + assertNotNull(contextBuilder); + assertTrue(contextBuilder instanceof JPQLSelectContextBuilder); - assertNotNull(contextBuilder); - assertTrue(contextBuilder instanceof JPQLSelectSingleContextBuilder); + } - } + @Test + public void testGetContextBuilderforSelectSingle() throws ODataException { - 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 = EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance(); - JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class); - EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1"); - EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1"); - EasyMock.expect(edmMapping.getJPAType()) - .andStubReturn(null); - try { - EasyMock.expect(kpProperty.getName()).andStubReturn("Field1"); - EasyMock.expect(kpProperty.getType()).andStubReturn(edmType); + // Build JPQL ContextBuilder + JPQLContextBuilder contextBuilder = new ODataJPAFactoryImpl().getJPQLBuilderFactory() + .getContextBuilder(JPQLContextType.SELECT_SINGLE); - EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping); + assertNotNull(contextBuilder); + assertTrue(contextBuilder instanceof JPQLSelectSingleContextBuilder); - } catch (EdmException e2) { - fail("this should not happen"); - } - EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty); - EasyMock.replay(edmMapping, 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(); - try { - oDataJPAContextImpl.setEntityManager(new JPAProcessorImplTest().getLocalEntityManager()); - } 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); - } - final EntityManager em = EasyMock.createMock(EntityManager.class); - Metamodel metamodel = EasyMock.createMock(Metamodel.class); - EasyMock.expect(em.getMetamodel()).andReturn(metamodel).anyTimes(); - EasyMock.expect(em.isOpen()).andReturn(true).anyTimes(); - EasyMock.replay(em); - - oDataJPAContextImpl.setEntityManagerFactory(new TestEntityManagerFactory(em)); - oDataJPAContextImpl.setPersistenceUnitName("pUnit"); - - assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl)); - assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl)); - } - - - @Test - public void testJPAAccessFactoryEntityManagerOnly() { - ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); - JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory(); - ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); - - final EntityManager em = EasyMock.createMock(EntityManager.class); - Metamodel metamodel = EasyMock.createMock(Metamodel.class); - EasyMock.expect(em.getMetamodel()).andReturn(metamodel).anyTimes(); - EasyMock.expect(em.isOpen()).andReturn(true).anyTimes(); - EasyMock.replay(em); - - oDataJPAContextImpl.setEntityManager(em); - - assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl)); - assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl)); - } - - @Test - public void testOdataJpaAccessFactory() { - - ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); - ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory(); - ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); - - final EntityManager em = EasyMock.createMock(EntityManager.class); - Metamodel metamodel = EasyMock.createMock(Metamodel.class); - EasyMock.expect(em.getMetamodel()).andReturn(metamodel).anyTimes(); - EasyMock.expect(em.isOpen()).andReturn(true); - EasyMock.replay(em); - - oDataJPAContextImpl.setEntityManagerFactory(new TestEntityManagerFactory(em)); - oDataJPAContextImpl.setPersistenceUnitName("pUnit"); - - assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en"))); - assertNotNull(jpaAccessFactory.createODataJPAContext()); - assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl)); - assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl)); - } - - @Test - public void testOdataJpaAccessFactoryEntityManagerOnly() { - ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); - ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory(); - ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); - - EntityManager em = EasyMock.createMock(EntityManager.class); - Metamodel metamodel = EasyMock.createMock(Metamodel.class); - EasyMock.expect(em.getMetamodel()).andReturn(metamodel).anyTimes(); - EasyMock.expect(em.isOpen()).andReturn(true).anyTimes(); - EasyMock.replay(em); - - oDataJPAContextImpl.setEntityManager(em); - oDataJPAContextImpl.setPersistenceUnitName("pUnit"); - - assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en"))); - assertNotNull(jpaAccessFactory.createODataJPAContext()); - assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl)); - assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl)); - } - - private static class TestEntityManagerFactory implements EntityManagerFactory { - - private EntityManager em; - - public TestEntityManagerFactory(EntityManager entityManager) { - em = entityManager; } - @Override - public boolean isOpen() { - return false; + 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 = EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance(); + JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class); + EasyMock.expect(edmMapping.getInternalName()) + .andStubReturn("Field1"); + EasyMock.expect(keyPredicate.getLiteral()) + .andStubReturn("1"); + EasyMock.expect(edmMapping.getJPAType()) + .andStubReturn(null); + 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, 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; } - @Override - public Map<String, Object> getProperties() { - return null; + 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; } - @Override - public PersistenceUnitUtil getPersistenceUnitUtil() { - return null; + @Test + public void testJPAAccessFactory() { + ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); + JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory(); + ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); + try { + oDataJPAContextImpl.setEntityManager(new JPAProcessorImplTest().getLocalEntityManager()); + } catch (SecurityException | IllegalArgumentException e) { + fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); + } + final EntityManager em = EasyMock.createMock(EntityManager.class); + Metamodel metamodel = EasyMock.createMock(Metamodel.class); + EasyMock.expect(em.getMetamodel()) + .andReturn(metamodel) + .anyTimes(); + EasyMock.expect(em.isOpen()) + .andReturn(true) + .anyTimes(); + EasyMock.replay(em); + + oDataJPAContextImpl.setEntityManagerFactory(new TestEntityManagerFactory(em)); + oDataJPAContextImpl.setPersistenceUnitName("pUnit"); + + assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl)); + assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl)); } - @Override - public void addNamedQuery(String s, Query query) { - } + @Ignore("easymock doesn't respect the times section") + @Test + public void testJPAAccessFactoryEntityManagerOnly() { + ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); + JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory(); + ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); - @Override - public <T> T unwrap(Class<T> aClass) { - return null; - } + final EntityManager em = EasyMock.createMock(EntityManager.class); + Metamodel metamodel = EasyMock.createMock(Metamodel.class); + EasyMock.expect(em.getMetamodel()) + .andReturn(metamodel) + .anyTimes(); + EasyMock.expect(em.isOpen()) + .andReturn(true) + .anyTimes(); + EasyMock.replay(em); - @Override - public <T> void addNamedEntityGraph(String s, EntityGraph<T> entityGraph) { + oDataJPAContextImpl.setEntityManager(em); + assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl)); + assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl)); } - @Override - public Metamodel getMetamodel() { - return null; + @Ignore("easymock doesn't respect the times section") + @Test + public void testOdataJpaAccessFactory() { + + ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); + ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory(); + ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); + + final EntityManager em = EasyMock.createMock(EntityManager.class); + Metamodel metamodel = EasyMock.createMock(Metamodel.class); + EasyMock.expect(em.getMetamodel()) + .andReturn(metamodel) + .anyTimes(); + EasyMock.expect(em.isOpen()) + .andReturn(true) + .anyTimes(); + EasyMock.replay(em); + + oDataJPAContextImpl.setEntityManagerFactory(new TestEntityManagerFactory(em)); + oDataJPAContextImpl.setPersistenceUnitName("pUnit"); + + assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en"))); + assertNotNull(jpaAccessFactory.createODataJPAContext()); + assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl)); + assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl)); } - @Override - public CriteriaBuilder getCriteriaBuilder() { - return null; + @Test + public void testOdataJpaAccessFactoryEntityManagerOnly() { + ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl(); + ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory(); + ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl(); + + EntityManager em = EasyMock.createMock(EntityManager.class); + Metamodel metamodel = EasyMock.createMock(Metamodel.class); + EasyMock.expect(em.getMetamodel()) + .andReturn(metamodel) + .anyTimes(); + EasyMock.expect(em.isOpen()) + .andReturn(true) + .anyTimes(); + EasyMock.replay(em); + + oDataJPAContextImpl.setEntityManager(em); + oDataJPAContextImpl.setPersistenceUnitName("pUnit"); + + assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en"))); + assertNotNull(jpaAccessFactory.createODataJPAContext()); + assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl)); + assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl)); } - @Override - public Cache getCache() { - return null; - } + private static class TestEntityManagerFactory implements EntityManagerFactory { - @SuppressWarnings("rawtypes") - @Override - public EntityManager createEntityManager(final Map arg0) { - return em; - } + private final EntityManager em; - @Override - public EntityManager createEntityManager(SynchronizationType synchronizationType) { - return null; - } + public TestEntityManagerFactory(EntityManager entityManager) { + em = entityManager; + } - @Override - public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) { - return null; - } + @Override + public boolean isOpen() { + return false; + } - @Override - public EntityManager createEntityManager() { - return em; - } + @Override + public Map<String, Object> getProperties() { + return null; + } + + @Override + public PersistenceUnitUtil getPersistenceUnitUtil() { + return null; + } + + @Override + public void addNamedQuery(String s, Query query) { + + } + + @Override + public <T> T unwrap(Class<T> aClass) { + return null; + } + + @Override + public <T> void addNamedEntityGraph(String s, EntityGraph<T> entityGraph) { + + } + + @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 em; + } + + @Override + public EntityManager createEntityManager(SynchronizationType synchronizationType) { + return null; + } + + @Override + public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) { + return null; + } + + @Override + public EntityManager createEntityManager() { + return em; + } - @Override - public void close() { + @Override + public void close() {} } - }; }
