You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2025/03/01 13:18:13 UTC
(olingo-odata2) branch OLINGO-1636-jdk_upgrade updated (8bb4c432 -> 04159846)
This is an automated email from the ASF dual-hosted git repository.
mibo pushed a change to branch OLINGO-1636-jdk_upgrade
in repository https://gitbox.apache.org/repos/asf/olingo-odata2.git
discard 8bb4c432 [OLINGO-1636] Upgrade Olingo ODataV2 to support JDK 17
new 04159846 [OLINGO-1636] Upgrade Olingo ODataV2 to support JDK 17
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (8bb4c432)
\
N -- N -- N refs/heads/OLINGO-1636-jdk_upgrade (04159846)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
odata2-annotation-processor/annotation-processor-api/pom.xml | 2 +-
odata2-annotation-processor/annotation-processor-core/pom.xml | 2 +-
odata2-annotation-processor/annotation-processor-ref/pom.xml | 2 +-
odata2-annotation-processor/annotation-processor-web/pom.xml | 2 +-
odata2-annotation-processor/pom.xml | 2 +-
odata2-dist/janos/pom.xml | 2 +-
odata2-dist/javadoc/pom.xml | 2 +-
odata2-dist/jpa/pom.xml | 2 +-
odata2-dist/lib/pom.xml | 2 +-
odata2-dist/pom.xml | 2 +-
odata2-dist/ref/pom.xml | 2 +-
odata2-jpa-processor/jpa-api/pom.xml | 2 +-
odata2-jpa-processor/jpa-core/pom.xml | 2 +-
odata2-jpa-processor/jpa-ref/pom.xml | 2 +-
odata2-jpa-processor/jpa-web/pom.xml | 2 +-
odata2-jpa-processor/pom.xml | 2 +-
odata2-lib/odata-annotation/pom.xml | 2 +-
odata2-lib/odata-api/pom.xml | 2 +-
odata2-lib/odata-client-api/pom.xml | 2 +-
odata2-lib/odata-client-core/pom.xml | 2 +-
odata2-lib/odata-core/pom.xml | 2 +-
odata2-lib/odata-fit/pom.xml | 2 +-
odata2-lib/odata-ref/pom.xml | 2 +-
odata2-lib/odata-testutil/pom.xml | 2 +-
odata2-lib/odata-web/pom.xml | 2 +-
odata2-lib/pom.xml | 2 +-
odata2-sample/cars-annotation-archetype/pom.xml | 4 ++--
odata2-sample/cars-jpa-archetype/pom.xml | 2 +-
odata2-sample/cars-service-archetype/pom.xml | 4 ++--
odata2-sample/pom.xml | 2 +-
odata2-spring/pom.xml | 2 +-
pom.xml | 2 +-
32 files changed, 34 insertions(+), 34 deletions(-)
(olingo-odata2) 01/01: [OLINGO-1636] Upgrade Olingo ODataV2 to support JDK 17
Posted by mi...@apache.org.
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 04159846504958ffdb96f4046901bafdc51c0115
Author: Iliyan Velichkov <ve...@gmail.com>
AuthorDate: Wed Dec 13 09:54:19 2023 +0200
[OLINGO-1636] Upgrade Olingo ODataV2 to support JDK 17
add build.yml
add workflows
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
change java from 1.6 to 1.8
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
build with java 8
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
skip tests in workflows
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
fix compilation
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
set version 3.0.0-SNAPSHOT
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
enable tests execution
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
add release workflow
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
update release.yml
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
version set to 3.0.1 for release
version set to 3.0.2-SNAPSHOT for development
deploy jars
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
add distributionManagement
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
change job name
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
version set to 3.0.2 for release
version set to 3.0.3-SNAPSHOT for development
make olingo compatible with Spring Boot 3
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
use java 8
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
use java 11
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
use java 17
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
javax.ws.rs -> jakarta.ws.rs
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
adapt tests
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
more test adaptations
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
adapt test
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
fix docs
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
adapt tests
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
more adaptations
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
[OLINGO-1636] adapts tests
Signed-off-by: Iliyan Velichkov <ve...@gmail.com>
---
.github/workflows/build.yml | 28 +
.github/workflows/maven.yml | 4 +-
.github/workflows/pull-request.yml | 33 +
.github/workflows/release.yml | 106 +
.gitignore | 1 +
.../annotation-processor-api/pom.xml | 2 +-
.../annotation-processor-core/pom.xml | 2 +-
.../annotation-processor-ref/pom.xml | 4 +-
.../processor/ref/model/ResourceHelper.java | 136 +-
.../processor/ref/AbstractRefXmlTest.java | 118 +-
.../annotation-processor-web/pom.xml | 14 +-
.../src/main/resources/META-INF/LICENSE | 4 +-
.../src/main/webapp/WEB-INF/web.xml | 2 +-
odata2-annotation-processor/pom.xml | 2 +-
odata2-dist/janos/pom.xml | 2 +-
odata2-dist/janos/src/main/resources/LICENSE | 4 +-
odata2-dist/javadoc/pom.xml | 2 +-
odata2-dist/jpa/pom.xml | 8 +-
odata2-dist/jpa/src/main/assembly/jpa-assembly.xml | 2 +-
odata2-dist/jpa/src/main/resources/LICENSE | 6 +-
odata2-dist/lib/pom.xml | 2 +-
odata2-dist/lib/src/main/resources/LICENSE | 4 +-
odata2-dist/pom.xml | 2 +-
odata2-dist/ref/pom.xml | 3 +-
odata2-dist/ref/src/main/resources/LICENSE | 6 +-
odata2-jpa-processor/jpa-api/pom.xml | 21 +-
.../odata2/jpa/processor/api/ODataJPAContext.java | 8 +-
.../jpa/processor/api/ODataJPAProcessor.java | 2 +-
.../api/ODataJPAQueryExtensionEntityListener.java | 28 +-
.../jpa/processor/api/ODataJPAServiceFactory.java | 4 +-
.../api/ODataJPATombstoneEntityListener.java | 12 +-
.../jpa/processor/api/model/JPAEdmBaseView.java | 4 +-
.../processor/api/model/JPAEdmComplexTypeView.java | 4 +-
.../processor/api/model/JPAEdmEntityTypeView.java | 101 +-
.../processor/api/model/JPAEdmPropertyView.java | 8 +-
.../api/model/mapping/JPAAttributeMapType.java | 285 ++-
.../api/model/mapping/JPAEdmMappingModel.java | 90 +-
.../model/mapping/JPAEdmMappingModelFactory.java | 132 +-
.../model/mapping/JPAEmbeddableTypeMapType.java | 234 ++-
.../model/mapping/JPAEmbeddableTypesMapType.java | 105 +-
.../api/model/mapping/JPAEntityTypeMapType.java | 345 ++--
.../api/model/mapping/JPAEntityTypesMapType.java | 105 +-
.../model/mapping/JPAPersistenceUnitMapType.java | 224 +--
.../api/model/mapping/JPARelationshipMapType.java | 235 ++-
.../processor/api/model/mapping/package-info.java | 38 +-
odata2-jpa-processor/jpa-core/pom.xml | 22 +-
.../jpa/processor/core/ODataJPAContextImpl.java | 4 +-
.../core/ODataJPATransactionLocalDefault.java | 4 +-
.../jpa/processor/core/access/data/JPAEntity.java | 930 +++++----
.../jpa/processor/core/access/data/JPALink.java | 2 +-
.../jpa/processor/core/access/data/JPAPage.java | 2 +-
.../core/access/data/JPAProcessorImpl.java | 6 +-
.../core/access/data/JPAQueryBuilder.java | 10 +-
.../access/model/JPAEdmMappingModelService.java | 413 ++--
.../core/access/model/JPAEdmNameBuilder.java | 8 +-
.../core/access/model/JPATypeConverter.java | 12 +-
.../processor/core/model/JPAEdmAssociationEnd.java | 10 +-
.../processor/core/model/JPAEdmBaseViewImpl.java | 2 +-
.../processor/core/model/JPAEdmComplexType.java | 4 +-
.../jpa/processor/core/model/JPAEdmEntityType.java | 24 +-
.../jpa/processor/core/model/JPAEdmFacets.java | 4 +-
.../jpa/processor/core/model/JPAEdmModel.java | 2 +-
.../jpa/processor/core/model/JPAEdmProperty.java | 22 +-
.../model/JPAEdmReferentialConstraintRole.java | 2 +-
.../processor/core/ODataJPAContextImplTest.java | 4 +-
.../core/ODataJPADefaultProcessorTest.java | 1146 ++++++-----
.../core/ODataJPAResponseBuilderTest.java | 1397 ++++++-------
.../data/JPAEntityParserForStaticMethodTest.java | 578 +++---
.../core/access/data/JPAEntityParserTest.java | 1268 ++++++------
.../core/access/data/JPAPageBuilderTest.java | 10 +-
.../core/access/data/JPAProcessorImplTest.java | 18 +-
.../core/access/data/JPAQueryBuilderTest.java | 4 +-
.../model/JPAEdmMappingModelServiceTest.java | 378 ++--
.../core/access/model/JPATypeConverterTest.java | 8 +-
.../core/jpql/JPQLBuilderFactoryTest.java | 649 +++---
.../processor/core/mock/ODataJPAContextMock.java | 191 +-
.../core/mock/ODataJPAServiceFactoryMock.java | 60 +-
.../processor/core/mock/OnJPAWriteContentMock.java | 65 +-
.../mock/data/EntityWithXmlAdapterOnProperty.java | 2 +-
.../jpa/processor/core/mock/data/JPATypeMock.java | 2 +-
.../jpa/processor/core/mock/data/XmlAdapter.java | 47 +-
.../core/mock/model/JPAAttributeMock.java | 6 +-
.../core/mock/model/JPAEmbeddableMock.java | 18 +-
.../core/mock/model/JPAEmbeddableTypeMock.java | 18 +-
.../core/mock/model/JPAEntityTypeMock.java | 24 +-
.../core/mock/model/JPAJavaMemberMock.java | 2 +-
.../core/mock/model/JPAManagedTypeMock.java | 18 +-
.../core/mock/model/JPAMetaModelMock.java | 8 +-
.../core/mock/model/JPAPluralAttributeMock.java | 12 +-
.../core/mock/model/JPASingularAttributeMock.java | 10 +-
.../core/model/JPAEdmAssociationEndTest.java | 2 +-
.../core/model/JPAEdmAssociationTest.java | 6 +-
.../core/model/JPAEdmBaseViewImplTest.java | 2 +-
.../core/model/JPAEdmComplexTypeTest.java | 6 +-
.../core/model/JPAEdmEntityContainerTest.java | 6 +-
.../processor/core/model/JPAEdmEntitySetTest.java | 6 +-
.../processor/core/model/JPAEdmEntityTypeTest.java | 6 +-
.../jpa/processor/core/model/JPAEdmKeyTest.java | 2 +-
.../jpa/processor/core/model/JPAEdmModelTest.java | 6 +-
.../core/model/JPAEdmNavigationPropertyTest.java | 8 +-
.../processor/core/model/JPAEdmPropertyTest.java | 22 +-
.../model/JPAEdmReferentialConstraintRoleTest.java | 6 +-
.../model/JPAEdmReferentialConstraintTest.java | 6 +-
.../jpa/processor/core/model/JPAEdmSchemaTest.java | 2 +-
.../processor/core/model/JPAEdmTestModelView.java | 8 +-
odata2-jpa-processor/jpa-ref/pom.xml | 8 +-
.../ref/converter/BlobToByteConverter.java | 4 +-
.../ref/converter/ClobToStringConverter.java | 4 +-
.../jpa/processor/ref/converter/UUIDConverter.java | 4 +-
.../ref/factory/JPAEntityManagerFactory.java | 4 +-
.../ref/listeners/CustomerQueryExtension.java | 4 +-
.../listeners/SalesOrderItemTombstoneListener.java | 4 +-
.../ref/listeners/SalesOrderTombstoneListener.java | 6 +-
.../odata2/jpa/processor/ref/model/Address.java | 4 +-
.../odata2/jpa/processor/ref/model/Category.java | 12 +-
.../odata2/jpa/processor/ref/model/Customer.java | 24 +-
.../jpa/processor/ref/model/CustomerBase.java | 6 +-
.../odata2/jpa/processor/ref/model/Material.java | 20 +-
.../odata2/jpa/processor/ref/model/Note.java | 22 +-
.../jpa/processor/ref/model/SalesOrderHeader.java | 24 +-
.../jpa/processor/ref/model/SalesOrderItem.java | 16 +-
.../jpa/processor/ref/model/SalesOrderItemKey.java | 4 +-
.../odata2/jpa/processor/ref/model/SampleGuid.java | 12 +-
.../odata2/jpa/processor/ref/model/Store.java | 12 +-
.../src/main/resources/META-INF/persistence.xml | 8 +-
odata2-jpa-processor/jpa-web/pom.xml | 18 +-
.../processor/ref/extension/OnDBWriteContent.java | 63 +-
.../ref/extension/SalesOrderHeaderProcessor.java | 6 +-
.../jpa/processor/ref/util/DataGenerator.java | 4 +-
.../jpa-web/src/main/resources/META-INF/LICENSE | 6 +-
.../jpa-web/src/main/webapp/WEB-INF/web.xml | 2 +-
.../jpa-web/src/main/webapp/index.jsp | 8 +-
odata2-jpa-processor/pom.xml | 2 +-
odata2-lib/odata-annotation/pom.xml | 2 +-
odata2-lib/odata-api/pom.xml | 2 +-
.../org/apache/olingo/odata2/api/package-info.java | 4 +-
odata2-lib/odata-client-api/pom.xml | 3 +-
odata2-lib/odata-client-core/pom.xml | 4 +-
.../core/ep/deserializer/XmlEntryDeserializer.java | 1045 +++++-----
.../ep/deserializer/XmlPropertyDeserializer.java | 310 ++-
.../client/core/ep/JSON_XMLErrorConsumerTest.java | 92 +-
.../JsonErrorDocumentDeserializerTest.java | 403 ++--
.../core/ep/deserializer/XmlErrorDocumentTest.java | 434 ++--
odata2-lib/odata-core/pom.xml | 115 +-
.../olingo/odata2/core/debug/DebugInfoServer.java | 2 +-
.../core/debug/ODataDebugResponseWrapper.java | 2 +-
.../ep/consumer/AtomServiceDocumentConsumer.java | 483 +++--
.../org/apache/olingo/odata2/core/rest/MERGE.java | 2 +-
.../odata2/core/rest/ODataExceptionMapperImpl.java | 24 +-
.../odata2/core/rest/ODataExceptionWrapper.java | 10 +-
.../odata2/core/rest/ODataRedirectLocator.java | 14 +-
.../olingo/odata2/core/rest/ODataRootLocator.java | 24 +-
.../olingo/odata2/core/rest/ODataSubLocator.java | 345 ++--
.../org/apache/olingo/odata2/core/rest/PATCH.java | 2 +-
.../apache/olingo/odata2/core/rest/RestUtil.java | 28 +-
.../odata2/core/rest/SubLocatorParameter.java | 22 +-
.../odata2/core/rest/app/ODataApplication.java | 14 +-
.../odata2/core/servlet/ODataExceptionWrapper.java | 2 +-
.../olingo/odata2/core/servlet/ODataServlet.java | 748 +++----
.../olingo/odata2/core/servlet/RestUtil.java | 2 +-
.../core/uri/expression/FilterParserImpl.java | 1840 +++++++++--------
.../apache/olingo/odata2/core/DispatcherTest.java | 808 ++++----
.../odata2/core/ODataExceptionWrapperTest.java | 6 +-
.../core/ODataRequestHandlerValidationTest.java | 1376 +++++++------
.../olingo/odata2/core/batch/BatchHandlerTest.java | 404 ++--
.../odata2/core/batch/BatchRequestParserTest.java | 2070 ++++++++------------
.../odata2/core/batch/BatchResponseParserTest.java | 794 +++-----
.../odata2/core/batch/BatchResponseTest.java | 456 ++---
.../odata2/core/commons/ContentTypeTest.java | 2 +-
.../olingo/odata2/core/commons/XmlHelperTest.java | 338 ++--
.../core/debug/ODataDebugResponseWrapperTest.java | 2 +-
.../odata2/core/ep/ProviderFacadeImplTest.java | 796 ++++----
.../consumer/AtomServiceDocumentConsumerTest.java | 519 ++---
.../ep/consumer/JsonErrorDocumentConsumerTest.java | 402 ++--
.../consumer/JsonServiceDocumentConsumerTest.java | 110 +-
.../ep/consumer/ServiceDocumentConsumerTest.java | 169 +-
.../ep/consumer/XmlErrorDocumentConsumerTest.java | 433 ++--
.../core/rest/ODataExceptionMapperImplTest.java | 16 +-
.../odata2/core/servlet/ODataServletTest.java | 658 ++++---
.../olingo/odata2/core/servlet/RestUtilTest.java | 2 +-
.../core/uri/expression/TestAbapCompatibility.java | 1140 ++++++-----
odata2-lib/odata-fit/pom.xml | 65 +-
.../olingo/odata2/fit/basic/AbstractBasicTest.java | 2 +-
.../odata2/fit/basic/AcceptHeaderTypeTest.java | 2 +-
.../olingo/odata2/fit/basic/BasicHttpTest.java | 545 +++---
.../basic/ContentNegotiationDollarFormatTest.java | 4 +-
.../olingo/odata2/fit/basic/ContextTest.java | 6 +-
.../olingo/odata2/fit/basic/DebugDisabledTest.java | 2 +-
.../olingo/odata2/fit/basic/ErrorResponseTest.java | 2 +-
.../olingo/odata2/fit/basic/FitLoadTest.java | 4 +-
.../fit/basic/HttpExceptionResponseTest.java | 196 +-
.../odata2/fit/basic/LanguageNegotiationTest.java | 157 +-
.../olingo/odata2/fit/basic/MetadataTest.java | 2 +-
.../odata2/fit/basic/ServiceResolutionTest.java | 560 +++---
.../olingo/odata2/fit/basic/UrlRewriteTest.java | 286 +--
.../misc/CxfCacheUriInfoIssueService1Factory.java | 2 +-
.../misc/CxfCacheUriInfoIssueService2Factory.java | 2 +-
.../odata2/fit/misc/CxfCacheUriInfoIssueTest.java | 2 +-
.../odata2/fit/misc/ODataApplicationTest.java | 2 +-
odata2-lib/odata-ref/pom.xml | 15 +-
.../apache/olingo/odata2/ref/model/Employee.java | 336 ++--
.../org/apache/olingo/odata2/ref/model/Photo.java | 261 ++-
odata2-lib/odata-testutil/pom.xml | 25 +-
.../odata2/testutil/helper/LocaleAsserter.java | 16 +
.../SampleClassForInvalidMessageReferences.java | 56 +-
.../olingo/odata2/testutil/server/TestServer.java | 274 ++-
odata2-lib/odata-web/pom.xml | 10 +-
.../odata-web/src/main/resources/META-INF/LICENSE | 4 +-
.../odata-web/src/main/webapp/WEB-INF/web.xml | 2 +-
odata2-lib/pom.xml | 2 +-
odata2-sample/cars-annotation-archetype/pom.xml | 4 +-
.../src/main/resources/archetype-resources/pom.xml | 17 +-
.../src/main/webapp/WEB-INF/web.xml | 2 +-
odata2-sample/cars-jpa-archetype/pom.xml | 2 +-
.../src/main/resources/archetype-resources/pom.xml | 7 -
.../src/main/java/model/Address.java | 4 +-
.../src/main/java/model/Car.java | 16 +-
.../src/main/java/model/Driver.java | 14 +-
.../src/main/java/model/Key.java | 4 +-
.../src/main/java/model/Manufacturer.java | 16 +-
.../java/service/ODataJPACarServiceFactory.java | 12 +-
.../src/main/resources/META-INF/persistence.xml | 8 +-
.../src/main/webapp/WEB-INF/web.xml | 2 +-
odata2-sample/cars-service-archetype/pom.xml | 4 +-
.../src/main/resources/archetype-resources/pom.xml | 13 +-
.../src/main/webapp/WEB-INF/web.xml | 2 +-
odata2-sample/pom.xml | 2 +-
odata2-spring/pom.xml | 11 +-
.../olingo/odata2/spring/OlingoRootLocator.java | 2 +-
pom.xml | 244 ++-
src/checkstyle/config.xml | 4 +-
231 files changed, 14960 insertions(+), 15064 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 00000000..72b632a8
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,28 @@
+name: Build
+on:
+ push:
+ branches:
+ - main
+ - master
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Cache local Maven repository
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-maven-
+ - name: Set up JDK Corretto
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'corretto'
+ java-version: '17'
+ architecture: x64
+ - name: Maven Build
+ run: mvn clean install
+
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 64e1e103..25eca780 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- - name: Set up JDK 8 (Corretto)
+ - name: Set up JDK (Corretto)
uses: actions/setup-java@v3
with:
- java-version: '8'
+ java-version: '17'
distribution: 'corretto'
cache: maven
- name: Build with Maven
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
new file mode 100644
index 00000000..162c8d2f
--- /dev/null
+++ b/.github/workflows/pull-request.yml
@@ -0,0 +1,33 @@
+name: Pull Request
+
+on:
+ pull_request:
+ branches:
+ - main
+ - master
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}-latest
+ strategy:
+ matrix:
+ os: [ubuntu, windows]
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Cache local Maven repository
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-maven-
+ - name: Set up JDK Corretto
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'corretto'
+ java-version: 17
+ - name: Maven Build
+ run: mvn clean install
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..c579644c
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,106 @@
+name: Release
+
+on:
+ workflow_dispatch:
+ inputs:
+ releaseVersion:
+ description: Release Version
+ required: true
+ default: 3.0.0
+ snapshotVersion:
+ description: Snapshot Version
+ required: true
+ default: 3.0.1-SNAPSHOT
+
+run-name: 'version set to ${{ github.event.inputs.releaseVersion }} for release'
+
+jobs:
+ release-project:
+ runs-on: ubuntu-latest
+ steps:
+
+ - uses: actions/checkout@v3
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ fetch-depth: 0
+
+ - name: Cache local Maven repository
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-maven-
+
+ - name: Set up JDK Corretto
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'corretto'
+ java-version: '17'
+ architecture: x64
+
+ - name: "Configure Git"
+ run: |
+ git fetch
+ git checkout ${{ github.event.inputs.branch }}
+ git config user.name "$GITHUB_ACTOR"
+ git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
+
+ - name: "Maven: Set Release Version"
+ run: mvn versions:set -DnewVersion=${{ github.event.inputs.releaseVersion }}
+
+ - name: Setup Maven settings.xml
+ uses: whelk-io/maven-settings-xml-action@v11
+ with:
+ servers:
+ '[
+ {
+ "id": "github",
+ "username": "${env.GITHUB_USERNAME}",
+ "password": "${env.GITHUB_TOKEN}"
+ }
+ ]'
+
+ - name: Build Project
+ run: mvn clean install
+
+ - name: Publish to GitHub Packages Apache Maven
+ run: mvn deploy
+ env:
+ GITHUB_USERNAME: x-access-token
+ GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
+ BUILD_ENV: 'github-actions'
+
+ - name: "Git: Commit Release Version"
+ run: |
+ git add '**pom.xml'
+ git commit -m "version set to ${{ github.event.inputs.releaseVersion }} for release"
+
+ - name: "Maven: Set Snapshot Version"
+ run: mvn versions:set -DnewVersion=${{ github.event.inputs.snapshotVersion }}
+
+ - name: "Git: Commit Snapshot Version"
+ run: |
+ git add '**pom.xml'
+ git commit -m "version set to ${{ github.event.inputs.snapshotVersion }} for development"
+
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
+ with:
+ tag_name: ${{ github.event.inputs.releaseVersion }}
+ release_name: Release ${{ github.event.inputs.releaseVersion }}
+ body: |
+ Changes in this Release:
+ - First Change
+ - Second Change
+ draft: false
+ prerelease: false
+
+ - name: "Git: Push Changes"
+ run: |
+ git checkout -B ${{ github.event.inputs.releaseVersion }}
+ git push --set-upstream origin ${{ github.event.inputs.releaseVersion }}
+ git checkout -B master
+ git push --set-upstream origin master
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index e000e0dc..b30725e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ classes
.DS_Store
nb-configuration.xml
context.xml
+*.versionsBackup
\ No newline at end of file
diff --git a/odata2-annotation-processor/annotation-processor-api/pom.xml b/odata2-annotation-processor/annotation-processor-api/pom.xml
index 120163da..d5cf999f 100644
--- a/odata2-annotation-processor/annotation-processor-api/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-api/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-annotation-processor/annotation-processor-core/pom.xml b/odata2-annotation-processor/annotation-processor-core/pom.xml
index b57a282f..85d46807 100644
--- a/odata2-annotation-processor/annotation-processor-core/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-core/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-annotation-processor/annotation-processor-ref/pom.xml b/odata2-annotation-processor/annotation-processor-ref/pom.xml
index 3f62b39a..143638eb 100644
--- a/odata2-annotation-processor/annotation-processor-ref/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-ref/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
@@ -90,7 +90,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
@@ -102,7 +101,6 @@
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
- <version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
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 7d64bc41..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
@@ -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.annotation.processor.ref.model;
@@ -23,7 +19,6 @@ import java.awt.image.WritableRaster;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-
import javax.imageio.ImageIO;
/**
@@ -31,66 +26,69 @@ import javax.imageio.ImageIO;
*/
public class ResourceHelper {
- public static byte[] loadAsByte(final String resource) {
- return load(resource, new byte[0]);
- }
-
- public static byte[] load(final String resource, final byte[] defaultResult) {
- InputStream instream = null;
- try {
- instream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
- if (instream == null) {
- return defaultResult;
- }
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- int b = 0;
- while ((b = instream.read()) != -1) {
- stream.write(b);
- }
+ public static byte[] loadAsByte(final String resource) {
+ return load(resource, new byte[0]);
+ }
- return stream.toByteArray();
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- if (instream != null) {
+ public static byte[] load(final String resource, final byte[] defaultResult) {
+ InputStream instream = null;
try {
- instream.close();
- } catch (IOException ex) {}
- }
+ instream = Thread.currentThread()
+ .getContextClassLoader()
+ .getResourceAsStream(resource);
+ if (instream == null) {
+ return defaultResult;
+ }
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ int b = 0;
+ while ((b = instream.read()) != -1) {
+ stream.write(b);
+ }
+
+ return stream.toByteArray();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (instream != null) {
+ try {
+ instream.close();
+ } catch (IOException ex) {
+ }
+ }
+ }
+ }
+
+ public enum Format {
+ BMP, JPEG, PNG, GIF
}
- }
- public enum Format {
- BMP, JPEG, PNG, GIF
- };
+ public static byte[] generateImage() {
+ return generateImage(Format.PNG);
+ }
- public static byte[] generateImage() {
- return generateImage(Format.PNG);
- }
+ public static byte[] generateImage(final Format format) {
+ try {
+ int width = 320;
+ int height = 320;
+ BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
+ WritableRaster raster = image.getRaster();
- public static byte[] generateImage(final Format format) {
- try {
- int width = 320;
- int height = 320;
- BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
- WritableRaster raster = image.getRaster();
+ int mod = format.ordinal() + 2;
+ for (int h = 0; h < height; h++) {
+ for (int w = 0; w < width; w++) {
+ if (((h / 32) + (w / 32)) % mod == 0) {
+ raster.setSample(w, h, 0, 0);
+ } else {
+ raster.setSample(w, h, 0, 1);
+ }
+ }
+ }
- int mod = format.ordinal() + 2;
- for (int h = 0; h < height; h++) {
- for (int w = 0; w < width; w++) {
- if (((h / 32) + (w / 32)) % mod == 0) {
- raster.setSample(w, h, 0, 0);
- } else {
- raster.setSample(w, h, 0, 1);
- }
+ ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
+ ImageIO.write(image, format.name(), out);
+ return out.toByteArray();
+ } catch (IOException ex) {
+ return new byte[0];
}
- }
-
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
- ImageIO.write(image, format.name(), out);
- return out.toByteArray();
- } catch (IOException ex) {
- return new byte[0];
}
- }
}
diff --git a/odata2-annotation-processor/annotation-processor-ref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/AbstractRefXmlTest.java b/odata2-annotation-processor/annotation-processor-ref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/AbstractRefXmlTest.java
index 635e605b..13867b9c 100644
--- a/odata2-annotation-processor/annotation-processor-ref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/AbstractRefXmlTest.java
+++ b/odata2-annotation-processor/annotation-processor-ref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/AbstractRefXmlTest.java
@@ -1,30 +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.
******************************************************************************/
package org.apache.olingo.odata2.annotation.processor.ref;
import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
-
import org.apache.http.HttpResponse;
import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
import org.apache.olingo.odata2.api.edm.Edm;
@@ -38,59 +32,59 @@ import org.xml.sax.SAXException;
/**
* Abstract base class for tests employing the reference scenario reading or writing XML.
- *
+ *
*/
@Ignore("no test methods")
public class AbstractRefXmlTest extends AbstractRefTest {
- public AbstractRefXmlTest(final ServletType servletType) {
- super(servletType);
- }
-
- @Before
- public void setXmlNamespacePrefixes() {
- Map<String, String> prefixMap = new HashMap<String, String>();
- prefixMap.put(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005);
- prefixMap.put(Edm.PREFIX_APP, Edm.NAMESPACE_APP_2007);
- prefixMap.put(Edm.PREFIX_D, Edm.NAMESPACE_D_2007_08);
- prefixMap.put(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08);
- prefixMap.put(Edm.PREFIX_EDM, Edm.NAMESPACE_EDM_2008_09);
- prefixMap.put(Edm.PREFIX_EDMX, Edm.NAMESPACE_EDMX_2007_06);
- prefixMap.put(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998);
- XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
- }
-
- @Override
- protected void badRequest(final String uri) throws Exception {
- final HttpResponse response = callUri(uri, HttpStatusCodes.BAD_REQUEST);
- validateXmlError(getBody(response));
- }
+ public AbstractRefXmlTest(final ServletType servletType) {
+ super(servletType);
+ }
- @Override
- protected void notFound(final String uri) throws Exception {
- final HttpResponse response = callUri(uri, HttpStatusCodes.NOT_FOUND);
- validateXmlError(getBody(response));
- }
+ @Before
+ public void setXmlNamespacePrefixes() {
+ Map<String, String> prefixMap = new HashMap<String, String>();
+ prefixMap.put(Edm.PREFIX_ATOM, Edm.NAMESPACE_ATOM_2005);
+ prefixMap.put(Edm.PREFIX_APP, Edm.NAMESPACE_APP_2007);
+ prefixMap.put(Edm.PREFIX_D, Edm.NAMESPACE_D_2007_08);
+ prefixMap.put(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08);
+ prefixMap.put(Edm.PREFIX_EDM, Edm.NAMESPACE_EDM_2008_09);
+ prefixMap.put(Edm.PREFIX_EDMX, Edm.NAMESPACE_EDMX_2007_06);
+ prefixMap.put(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998);
+ XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
+ }
- protected void validateXmlError(final String xml) throws XpathException, IOException, SAXException {
- assertXpathExists("/m:error", xml);
- assertXpathExists("/m:error/m:code", xml);
- assertXpathExists("/m:error/m:message[@xml:lang=\"en\"]", xml);
- }
+ @Override
+ protected void badRequest(final String uri) throws Exception {
+ final HttpResponse response = callUri(uri, HttpStatusCodes.BAD_REQUEST);
+ validateXmlError(getBody(response));
+ }
- protected String readFile(final String filename) throws IOException {
- InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
- if (in == null) {
- throw new IOException("Requested file '" + filename + "' was not found.");
+ @Override
+ protected void notFound(final String uri) throws Exception {
+ final HttpResponse response = callUri(uri, HttpStatusCodes.NOT_FOUND);
+ validateXmlError(getBody(response));
}
- byte[] tmp = new byte[8192];
- int count = in.read(tmp);
- StringBuffer b = new StringBuffer();
- while (count >= 0) {
- b.append(new String(tmp, 0, count));
- count = in.read(tmp);
+ protected void validateXmlError(final String xml) throws XpathException, IOException, SAXException {
+ assertXpathExists("/m:error", xml);
+ assertXpathExists("/m:error/m:code", xml);
+ assertXpathExists("/m:error/m:message[@xml:lang=\"en\"]", xml);
}
- return b.toString();
- }
+ protected String readFile(final String filename) throws IOException {
+ InputStream in = AbstractRefXmlTest.class.getResourceAsStream(filename);
+ if (in == null) {
+ throw new IOException("Requested file '" + filename + "' was not found.");
+ }
+
+ byte[] tmp = new byte[8192];
+ int count = in.read(tmp);
+ StringBuffer b = new StringBuffer();
+ while (count >= 0) {
+ b.append(new String(tmp, 0, count));
+ count = in.read(tmp);
+ }
+
+ return b.toString();
+ }
}
diff --git a/odata2-annotation-processor/annotation-processor-web/pom.xml b/odata2-annotation-processor/annotation-processor-web/pom.xml
index 797d8dac..5f00dff2 100644
--- a/odata2-annotation-processor/annotation-processor-web/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-web/pom.xml
@@ -20,14 +20,10 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
- <properties>
- <version.slf4j>1.7.1</version.slf4j>
- </properties>
-
<build>
<resources>
<resource>
@@ -61,13 +57,6 @@
</build>
<dependencies>
- <dependency>
- <!-- required because of auto detection of web facet 2.5 -->
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
@@ -86,7 +75,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>${version.slf4j}</version>
</dependency>
</dependencies>
diff --git a/odata2-annotation-processor/annotation-processor-web/src/main/resources/META-INF/LICENSE b/odata2-annotation-processor/annotation-processor-web/src/main/resources/META-INF/LICENSE
index 6547e963..28751de4 100644
--- a/odata2-annotation-processor/annotation-processor-web/src/main/resources/META-INF/LICENSE
+++ b/odata2-annotation-processor/annotation-processor-web/src/main/resources/META-INF/LICENSE
@@ -497,8 +497,8 @@
=====================================================================
- - javax.ws.rs-api (http://jax-rs-spec.java.net)
- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
+ - jakarta.ws.rs-api (http://jax-rs-spec.java.net)
+ jakarta.ws.rs:jakarta.ws.rs-api:jar:2.0-m10
- JAXB Reference Implementation (http://jaxb.java.net/)
com.sun.xml.bind:jaxb-impl:jar:2.2.6
License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
diff --git a/odata2-annotation-processor/annotation-processor-web/src/main/webapp/WEB-INF/web.xml b/odata2-annotation-processor/annotation-processor-web/src/main/webapp/WEB-INF/web.xml
index 2e4635ec..15eca607 100644
--- a/odata2-annotation-processor/annotation-processor-web/src/main/webapp/WEB-INF/web.xml
+++ b/odata2-annotation-processor/annotation-processor-web/src/main/webapp/WEB-INF/web.xml
@@ -30,7 +30,7 @@
<servlet-name>ReferenceScenarioServlet</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
<init-param>
- <param-name>javax.ws.rs.Application</param-name>
+ <param-name>jakarta.ws.rs.Application</param-name>
<param-value>org.apache.olingo.odata2.core.rest.app.ODataApplication</param-value>
</init-param>
<init-param>
diff --git a/odata2-annotation-processor/pom.xml b/odata2-annotation-processor/pom.xml
index d830a1c5..3f3f19c7 100644
--- a/odata2-annotation-processor/pom.xml
+++ b/odata2-annotation-processor/pom.xml
@@ -18,7 +18,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-parent</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-dist/janos/pom.xml b/odata2-dist/janos/pom.xml
index f4b3926e..37704a27 100644
--- a/odata2-dist/janos/pom.xml
+++ b/odata2-dist/janos/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-dist</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-dist/janos/src/main/resources/LICENSE b/odata2-dist/janos/src/main/resources/LICENSE
index 932a86ec..d832967e 100644
--- a/odata2-dist/janos/src/main/resources/LICENSE
+++ b/odata2-dist/janos/src/main/resources/LICENSE
@@ -205,8 +205,8 @@
=====================================================================
- - javax.ws.rs-api (http://jax-rs-spec.java.net)
- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
+ - jakarta.ws.rs-api (http://jax-rs-spec.java.net)
+ jakarta.ws.rs:jakarta.ws.rs-api:jar:2.0-m10
License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
=====================================================================
diff --git a/odata2-dist/javadoc/pom.xml b/odata2-dist/javadoc/pom.xml
index 841a18b8..59b4cd35 100644
--- a/odata2-dist/javadoc/pom.xml
+++ b/odata2-dist/javadoc/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-dist</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-dist/jpa/pom.xml b/odata2-dist/jpa/pom.xml
index 6264163f..32cae72c 100644
--- a/odata2-dist/jpa/pom.xml
+++ b/odata2-dist/jpa/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-dist</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
@@ -99,11 +99,5 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>${version.javax.persistence}</version>
- <scope>compile</scope>
- </dependency>
</dependencies>
</project>
diff --git a/odata2-dist/jpa/src/main/assembly/jpa-assembly.xml b/odata2-dist/jpa/src/main/assembly/jpa-assembly.xml
index 9c0c7b8d..4b89c473 100644
--- a/odata2-dist/jpa/src/main/assembly/jpa-assembly.xml
+++ b/odata2-dist/jpa/src/main/assembly/jpa-assembly.xml
@@ -28,7 +28,7 @@
<include>org.apache.olingo:olingo-odata2-api-annotation</include>
<include>org.apache.olingo:olingo-odata2-jpa-processor-api</include>
<include>org.apache.olingo:olingo-odata2-jpa-processor-core</include>
- <include>org.eclipse.persistence:javax.persistence</include>
+ <include>jakarta.persistence:jakarta.persistence-api</include>
</includes>
</dependencySet>
</dependencySets>
diff --git a/odata2-dist/jpa/src/main/resources/LICENSE b/odata2-dist/jpa/src/main/resources/LICENSE
index e2f9f31a..765b0c15 100644
--- a/odata2-dist/jpa/src/main/resources/LICENSE
+++ b/odata2-dist/jpa/src/main/resources/LICENSE
@@ -204,8 +204,8 @@
=====================================================================
- - javax.ws.rs-api (http://jax-rs-spec.java.net)
- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
+ - jakarta.ws.rs-api (http://jax-rs-spec.java.net)
+ jakarta.ws.rs:jakarta.ws.rs-api:jar:2.0-m10
License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
=====================================================================
@@ -587,7 +587,7 @@
=====================================================================
- Javax Persistence (http://www.eclipse.org/eclipselink)
- org.eclipse.persistence:javax.persistence:jar:2.0.5
+ jakarta.persistence:jakarta.persistence-api:jar:2.0.5
License: Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html)
License: Eclipse Distribution License v. 1.0
(http://www.eclipse.org/org/documents/edl-v10.php)
diff --git a/odata2-dist/lib/pom.xml b/odata2-dist/lib/pom.xml
index 012687cd..e8e23da8 100644
--- a/odata2-dist/lib/pom.xml
+++ b/odata2-dist/lib/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-dist</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-dist/lib/src/main/resources/LICENSE b/odata2-dist/lib/src/main/resources/LICENSE
index 932a86ec..d832967e 100644
--- a/odata2-dist/lib/src/main/resources/LICENSE
+++ b/odata2-dist/lib/src/main/resources/LICENSE
@@ -205,8 +205,8 @@
=====================================================================
- - javax.ws.rs-api (http://jax-rs-spec.java.net)
- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
+ - jakarta.ws.rs-api (http://jax-rs-spec.java.net)
+ jakarta.ws.rs:jakarta.ws.rs-api:jar:2.0-m10
License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
=====================================================================
diff --git a/odata2-dist/pom.xml b/odata2-dist/pom.xml
index 3aa08424..d0ab591b 100644
--- a/odata2-dist/pom.xml
+++ b/odata2-dist/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-parent</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/odata2-dist/ref/pom.xml b/odata2-dist/ref/pom.xml
index 199f6e89..5e2c5473 100644
--- a/odata2-dist/ref/pom.xml
+++ b/odata2-dist/ref/pom.xml
@@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-dist</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
@@ -117,7 +117,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.7.1</version>
</dependency>
</dependencies>
</project>
diff --git a/odata2-dist/ref/src/main/resources/LICENSE b/odata2-dist/ref/src/main/resources/LICENSE
index 00b68b50..c99a4b6d 100644
--- a/odata2-dist/ref/src/main/resources/LICENSE
+++ b/odata2-dist/ref/src/main/resources/LICENSE
@@ -497,8 +497,8 @@
=====================================================================
- - javax.ws.rs-api (http://jax-rs-spec.java.net)
- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
+ - jakarta.ws.rs-api (http://jax-rs-spec.java.net)
+ jakarta.ws.rs:jakarta.ws.rs-api:jar:2.0-m10
- JAXB Reference Implementation (http://jaxb.java.net/)
com.sun.xml.bind:jaxb-impl:jar:2.2.6
License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
@@ -917,7 +917,7 @@
- EclipseLink (non-OSGi) (http://www.eclipse.org/eclipselink)
org.eclipse.persistence:eclipselink:jar:2.5.0
- Javax Persistence (http://www.eclipse.org/eclipselink)
- org.eclipse.persistence:javax.persistence:jar:2.0.5
+ jakarta.persistence:jakarta.persistence-api:jar:2.0.5
License: Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html)
License: Eclipse Distribution License v. 1.0
(http://www.eclipse.org/org/documents/edl-v10.php)
diff --git a/odata2-jpa-processor/jpa-api/pom.xml b/odata2-jpa-processor/jpa-api/pom.xml
index 872f2ae9..5db331ae 100644
--- a/odata2-jpa-processor/jpa-api/pom.xml
+++ b/odata2-jpa-processor/jpa-api/pom.xml
@@ -17,28 +17,30 @@
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>
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<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,13 +74,16 @@
</plugin>
</plugins>
</build>
-
+
<dependencies>
+ <dependency>
+ <groupId>jakarta.xml.bind</groupId>
+ <artifactId>jakarta.xml.bind-api</artifactId>
+ </dependency>
<!-- JPA Support -->
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>${version.javax.persistence}</version>
+ <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/ODataJPAContext.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAContext.java
index 7cb54d9f..1c98759f 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAContext.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAContext.java
@@ -18,8 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata2.jpa.processor.api;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
import org.apache.olingo.odata2.api.processor.ODataContext;
@@ -111,7 +111,7 @@ public interface ODataJPAContext {
* context.
*
* @param emf
- * is of type {@link javax.persistence.EntityManagerFactory}
+ * is of type {@link jakarta.persistence.EntityManagerFactory}
*
*/
public void setEntityManagerFactory(EntityManagerFactory emf);
@@ -159,7 +159,7 @@ public interface ODataJPAContext {
* Hence all entities that are accessed within JPA processor are managed by
* single entity manager.
*
- * @return an instance of type {@link javax.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.EntityManager}
*/
public EntityManager getEntityManager();
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAProcessor.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAProcessor.java
index 0c355f56..7a669025 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAProcessor.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAProcessor.java
@@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata2.jpa.processor.api;
-import javax.persistence.EntityManager;
+import jakarta.persistence.EntityManager;
import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAProcessor;
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAQueryExtensionEntityListener.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAQueryExtensionEntityListener.java
index e2c09d5b..892267de 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAQueryExtensionEntityListener.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAQueryExtensionEntityListener.java
@@ -21,8 +21,8 @@ package org.apache.olingo.odata2.jpa.processor.api;
import java.util.List;
import java.util.Locale;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.Query;
import org.apache.olingo.odata2.api.exception.ODataApplicationException;
import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
@@ -41,8 +41,8 @@ public abstract class ODataJPAQueryExtensionEntityListener extends ODataJPATombs
/**
* Override this method to build JPA Query for OData request - GetEntitySet; SELECT *
* @param uriInfo is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public Query getQuery(GetEntitySetUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
return null;
@@ -52,8 +52,8 @@ public abstract class ODataJPAQueryExtensionEntityListener extends ODataJPATombs
* Override this method to build JPA Query for OData request - GetEntity; SELECT SINGLE with key in WHERE
* clause
* @param uriInfo is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public Query getQuery(GetEntityUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
return null;
@@ -63,8 +63,8 @@ public abstract class ODataJPAQueryExtensionEntityListener extends ODataJPATombs
* Override this method to build JPA Query for OData request - GetEntity Count; SELECT SINGLE with key in WHERE
* clause
* @param uriInfo is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public Query getQuery(GetEntityCountUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
return null;
@@ -73,8 +73,8 @@ public abstract class ODataJPAQueryExtensionEntityListener extends ODataJPATombs
/**
* Override this method to build JPA Query for OData request - GetEntitySet Count; SELECT COUNT(*)
* @param uriInfo is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public Query getQuery(GetEntitySetCountUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
return null;
@@ -84,8 +84,8 @@ public abstract class ODataJPAQueryExtensionEntityListener extends ODataJPATombs
* Override this method to build JPA Query for OData request - Update; SELECT SINGLE with key in WHERE
* clause
* @param uriInfo is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public Query getQuery(PutMergePatchUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
return null;
@@ -95,8 +95,8 @@ public abstract class ODataJPAQueryExtensionEntityListener extends ODataJPATombs
* Override this method to build JPA Query for OData request - Delete; SELECT SINGLE with key in WHERE
* clause
* @param uriInfo is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public Query getQuery(DeleteUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
return null;
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAServiceFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAServiceFactory.java
index 6089be08..9a56135f 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAServiceFactory.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPAServiceFactory.java
@@ -59,7 +59,7 @@ import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
* <servlet-name>ReferenceScenarioServlet</servlet-name>
* <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
* <init-param>
- * <param-name>javax.ws.rs.Application</param-name>
+ * <param-name>jakarta.ws.rs.Application</param-name>
* <param-value>org.apache.olingo.odata2.core.rest.ODataApplication</param-value>
* </init-param>
* <init-param>
@@ -85,7 +85,7 @@ public abstract class ODataJPAServiceFactory extends ODataServiceFactory {
/**
* Implement this method and initialize OData JPA Context. It is mandatory
- * to set an instance of type {@link javax.persistence.EntityManagerFactory} into the context. An exception of type
+ * to set an instance of type {@link jakarta.persistence.EntityManagerFactory} into the context. An exception of type
* {@link org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException} is thrown if
* EntityManagerFactory is not initialized. <br>
* <br>
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPATombstoneEntityListener.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPATombstoneEntityListener.java
index 0dfc9356..a19804a1 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPATombstoneEntityListener.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/ODataJPATombstoneEntityListener.java
@@ -20,8 +20,8 @@ package org.apache.olingo.odata2.jpa.processor.api;
import java.util.List;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.Query;
import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
@@ -40,20 +40,20 @@ public abstract class ODataJPATombstoneEntityListener {
}
/**
- * Implement this method to create a {@link javax.persistence.Query} object. The Query object can be created from
+ * Implement this method to create a {@link jakarta.persistence.Query} object. The Query object can be created from
* OData requests. The query instance thus created can be used for handling delta JPA entities. The delta token passed
* from OData request can
* be accessed from {@link com.sap.core.odata.processor.api.jpa.ODataJPATombstoneContext}.
* @param resultsView is a reference to OData request
- * @param em is a reference to {@link javax.persistence.EntityManager}
- * @return an instance of type {@link javax.persistence.Query}
+ * @param em is a reference to {@link jakarta.persistence.EntityManager}
+ * @return an instance of type {@link jakarta.persistence.Query}
*/
public abstract Query getQuery(GetEntitySetUriInfo resultsView, EntityManager em) throws ODataJPARuntimeException;
/**
* Implement this method to create a delta token.
* @param deltas is list of delta JPA Entities
- * @param query is an instance of type {@link javax.persistence.Query} that was used for handling delta entites
+ * @param query is an instance of type {@link jakarta.persistence.Query} that was used for handling delta entites
* @return a delta token of type String
*/
public abstract String generateDeltaToken(List<Object> deltas, Query query);
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmBaseView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmBaseView.java
index 56aa8b30..82fa48c8 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmBaseView.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmBaseView.java
@@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata2.jpa.processor.api.model;
-import javax.persistence.metamodel.Metamodel;
+import jakarta.persistence.metamodel.Metamodel;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmBuilder;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmMappingModelAccess;
@@ -46,7 +46,7 @@ public interface JPAEdmBaseView {
/**
* The method returns the Java Persistence MetaModel
*
- * @return a meta model of type {@link javax.persistence.metamodel.Metamodel}
+ * @return a meta model of type {@link jakarta.persistence.metamodel.Metamodel}
*/
public Metamodel getJPAMetaModel();
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmComplexTypeView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmComplexTypeView.java
index 3b5a8840..6f53d063 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmComplexTypeView.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmComplexTypeView.java
@@ -58,9 +58,9 @@ public interface JPAEdmComplexTypeView extends JPAEdmBaseView {
* The method returns an JPA embeddable type that is currently being
* processed.
*
- * @return an instance of type {@link javax.persistence.metamodel.EmbeddableType}
+ * @return an instance of type {@link jakarta.persistence.metamodel.EmbeddableType}
*/
- public javax.persistence.metamodel.EmbeddableType<?> getJPAEmbeddableType();
+ public jakarta.persistence.metamodel.EmbeddableType<?> getJPAEmbeddableType();
/**
* The method returns a consistent list of EDM complex types.
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmEntityTypeView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmEntityTypeView.java
index 80de0848..17a2563e 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmEntityTypeView.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmEntityTypeView.java
@@ -1,76 +1,69 @@
/*******************************************************************************
- * 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.api.model;
import java.util.List;
-
import org.apache.olingo.odata2.api.edm.provider.EntityType;
/**
- * A view on Java Persistence entity types and EDM entity types. Java
- * persistence entity types are converted into EDM entity types.
+ * A view on Java Persistence entity types and EDM entity types. Java persistence entity types are
+ * converted into EDM entity types.
* <p>
- * The implementation of the view provides access to EDM entity types for the
- * given JPA EDM model. The view acts as a container for consistent list of EDM
- * entity types. An EDM entity type is said to be consistent only if it has at
- * least one consistent EDM property and at least one consistent EDM key.
- *
- *
+ * The implementation of the view provides access to EDM entity types for the given JPA EDM model.
+ * The view acts as a container for consistent list of EDM entity types. An EDM entity type is said
+ * to be consistent only if it has at least one consistent EDM property and at least one consistent
+ * EDM key.
+ *
+ *
* <p>
+ *
* @org.apache.olingo.odata2.DoNotImplement
* @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmPropertyView
* @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmKeyView
* @see org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmNavigationPropertyView
- *
+ *
*/
public interface JPAEdmEntityTypeView extends JPAEdmBaseView {
- /**
- * The method returns an EDM entity currently being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
- */
- public EntityType getEdmEntityType();
+ /**
+ * The method returns an EDM entity currently being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
+ */
+ EntityType getEdmEntityType();
- /**
- * The method returns java persistence Entity type currently being
- * processed.
- *
- * @return an instance of type {@link javax.persistence.metamodel.EntityType}
- */
- public javax.persistence.metamodel.EntityType<?> getJPAEntityType();
+ /**
+ * The method returns java persistence Entity type currently being processed.
+ *
+ * @return an instance of type {@link javax.persistence.metamodel.EntityType}
+ */
+ jakarta.persistence.metamodel.EntityType<?> getJPAEntityType();
- /**
- * The method returns a consistent list of EDM entity types for a given java
- * persistence meta model.
- *
- * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
- */
- public List<EntityType> getConsistentEdmEntityTypes();
+ /**
+ * The method returns a consistent list of EDM entity types for a given java persistence meta model.
+ *
+ * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
+ */
+ List<EntityType> getConsistentEdmEntityTypes();
- /**
- * The method searches in the consistent list of EDM entity types for the
- * given EDM entity type's name.
- *
- * @param jpaEntityTypeName
- * is the name of EDM entity type
- * @return a reference to EDM entity type if found else null
- */
- public EntityType searchEdmEntityType(String jpaEntityTypeName);
+ /**
+ * The method searches in the consistent list of EDM entity types for the given EDM entity type's
+ * name.
+ *
+ * @param jpaEntityTypeName is the name of EDM entity type
+ * @return a reference to EDM entity type if found else null
+ */
+ EntityType searchEdmEntityType(String jpaEntityTypeName);
}
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmPropertyView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmPropertyView.java
index 3ce66d64..1eca444e 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmPropertyView.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmPropertyView.java
@@ -20,7 +20,7 @@ package org.apache.olingo.odata2.jpa.processor.api.model;
import java.util.List;
-import javax.persistence.metamodel.Attribute;
+import jakarta.persistence.metamodel.Attribute;
import org.apache.olingo.odata2.api.edm.provider.Property;
import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
@@ -74,16 +74,16 @@ public interface JPAEdmPropertyView extends JPAEdmBaseView {
/**
* The method returns a JPA Attribute for the given JPA entity type.
*
- * @return an instance of type {@link javax.persistence.metamodel.Attribute
+ * @return an instance of type {@link jakarta.persistence.metamodel.Attribute
* <?, ?>}
*/
Attribute<?, ?> getJPAAttribute();
/**
- * The method returns a JPA Attribute referenced by a JPA Attribute in the {@link javax.persistence.JoinColumn}
+ * The method returns a JPA Attribute referenced by a JPA Attribute in the {@link jakarta.persistence.JoinColumn}
* annotation for the given JPA entity type .
*
- * @return an instance of type {@link javax.persistence.metamodel.Attribute
+ * @return an instance of type {@link jakarta.persistence.metamodel.Attribute
* <?, ?>}
*/
Attribute<?, ?> getJPAReferencedAttribute();
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 e7bcbe97..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
@@ -1,45 +1,40 @@
/*******************************************************************************
- * 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.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;
/**
- *
- * The default name for EDM
- * property is derived from JPA attribute name. This can be overriden
- * using
+ *
+ * The default name for EDM property is derived from JPA attribute name. This can be overriden using
* JPAAttributeMapType.
- *
- *
- * <p>Java class for JPAAttributeMapType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
+ *
+ *
+ * <p>
+ * Java class for JPAAttributeMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPAAttributeMapType">
* <complexContent>
@@ -60,143 +55,139 @@ import javax.xml.bind.annotation.XmlValue;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAAttributeMapType", propOrder = { "jpaAttribute" })
+@XmlType(name = "JPAAttributeMapType", propOrder = {"jpaAttribute"})
public class JPAAttributeMapType {
- @XmlElement(name = "JPAAttribute")
- protected List<JPAAttributeMapType.JPAAttribute> jpaAttribute;
-
- /**
- * Gets the value of the jpaAttribute property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the jpaAttribute property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getJPAAttribute().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPAAttributeMapType.JPAAttribute }
- *
- *
- */
- public List<JPAAttributeMapType.JPAAttribute> getJPAAttribute() {
- if (jpaAttribute == null) {
- jpaAttribute = new ArrayList<JPAAttributeMapType.JPAAttribute>();
- }
- return jpaAttribute;
- }
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>string">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = { "value" })
- public static class JPAAttribute {
-
- @XmlValue
- protected String value;
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "exclude")
- protected Boolean exclude;
+ @XmlElement(name = "JPAAttribute")
+ protected List<JPAAttributeMapType.JPAAttribute> jpaAttribute;
/**
- * Gets the value of the value property.
+ * Gets the value of the jpaAttribute property.
*
- * @return
- * possible object is {@link String }
+ * <p>
+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a <CODE>set</CODE> method for the jpaAttribute property.
*
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getJPAAttribute().add(newItem);
+ * </pre>
*
- * @param value
- * allowed object is {@link String }
*
- */
- public void setValue(final String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the name property.
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JPAAttributeMapType.JPAAttribute }
*
- * @return
- * possible object is {@link String }
*
*/
- public String getName() {
- return name;
+ public List<JPAAttributeMapType.JPAAttribute> getJPAAttribute() {
+ if (jpaAttribute == null) {
+ jpaAttribute = new ArrayList<JPAAttributeMapType.JPAAttribute>();
+ }
+ return jpaAttribute;
}
/**
- * Sets the value of the name property.
+ * <p>
+ * Java class for anonymous complex type.
*
- * @param value
- * allowed object is {@link String }
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
*
- */
- public void setName(final String value) {
- name = value;
- }
-
- /**
- * Gets the value of the exclude property.
+ * <pre>
+ * <complexType>
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
*
- * @return
- * possible object is {@link Boolean }
*
*/
- public boolean isExclude() {
- if (exclude == null) {
- return false;
- } else {
- return exclude;
- }
- }
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"value"})
+ public static class JPAAttribute {
- /**
- * Sets the value of the exclude property.
- *
- * @param value
- * allowed object is {@link Boolean }
- *
- */
- public void setExclude(final Boolean value) {
- exclude = value;
- }
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "exclude")
+ protected Boolean exclude;
- }
+ /**
+ * Gets the value of the value property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ /**
+ * Gets the value of the exclude property.
+ *
+ * @return possible object is {@link Boolean }
+ *
+ */
+ public boolean isExclude() {
+ if (exclude == null) {
+ return false;
+ }
+ return exclude;
+ }
+
+ /**
+ * Sets the value of the exclude property.
+ *
+ * @param value allowed object is {@link Boolean }
+ *
+ */
+ public void setExclude(final Boolean value) {
+ exclude = value;
+ }
+
+ }
}
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 a4175d48..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
@@ -1,37 +1,32 @@
/*******************************************************************************
- * 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.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>
* Java class for anonymous complex type.
- *
+ *
* <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType>
* <complexContent>
@@ -44,36 +39,35 @@ import javax.xml.bind.annotation.XmlType;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = { "persistenceUnit" })
+@XmlType(name = "", propOrder = {"persistenceUnit"})
@XmlRootElement(name = "JPAEDMMappingModel")
public class JPAEdmMappingModel {
- @XmlElement(name = "PersistenceUnit", required = true)
- protected JPAPersistenceUnitMapType persistenceUnit;
+ @XmlElement(name = "PersistenceUnit", required = true)
+ protected JPAPersistenceUnitMapType persistenceUnit;
- /**
- * Gets the value of the persistenceUnit property.
- *
- * @return possible object is {@link JPAPersistenceUnitMapType }
- *
- */
- public JPAPersistenceUnitMapType getPersistenceUnit() {
- return persistenceUnit;
- }
+ /**
+ * Gets the value of the persistenceUnit property.
+ *
+ * @return possible object is {@link JPAPersistenceUnitMapType }
+ *
+ */
+ public JPAPersistenceUnitMapType getPersistenceUnit() {
+ return persistenceUnit;
+ }
- /**
- * Sets the value of the persistenceUnit property.
- *
- * @param value
- * allowed object is {@link JPAPersistenceUnitMapType }
- *
- */
- public void setPersistenceUnit(final JPAPersistenceUnitMapType value) {
- persistenceUnit = value;
- }
+ /**
+ * 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 84f8b282..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
@@ -1,85 +1,83 @@
/*******************************************************************************
- * 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.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 generated in the
- * org.apache.olingo.odata2.processor.api.jpa.model.mapping package.
+ * This object contains factory methods for each Java content interface and Java element interface
+ * generated in the org.apache.olingo.odata2.processor.api.jpa.model.mapping package.
* <p>
- * An ObjectFactory allows you to programatically construct new instances of the
- * Java representation for XML content. The Java representation of XML content
- * can consist of schema derived interfaces and classes representing the binding
- * of schema type definitions, element declarations and model groups. Factory
- * methods for each of these are provided in this class.
- *
+ * An ObjectFactory allows you to programatically construct new instances of the Java representation
+ * for XML content. The Java representation of XML content can consist of schema derived interfaces
+ * and classes representing the binding of schema type definitions, element declarations and model
+ * groups. Factory methods for each of these are provided in this class.
+ *
*/
@XmlRegistry
public class JPAEdmMappingModelFactory {
- /**
- * Create a new ObjectFactory that can be used to create new instances of
- * schema derived classes for package:
- * org.apache.olingo.odata2.processor.api.jpa.model.mapping
- *
- */
- public JPAEdmMappingModelFactory() {}
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for
+ * package: org.apache.olingo.odata2.processor.api.jpa.model.mapping
+ *
+ */
+ public JPAEdmMappingModelFactory() {}
- /**
- * Create an instance of {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPARelationshipMapType }
- *
- */
- public JPARelationshipMapType createJPARelationshipMapType() {
- return new JPARelationshipMapType();
- }
+ /**
+ * Create an instance of
+ * {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPARelationshipMapType }
+ *
+ */
+ public JPARelationshipMapType createJPARelationshipMapType() {
+ return new JPARelationshipMapType();
+ }
- /**
- * Create an instance of {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAAttributeMapType }
- *
- */
- public JPAAttributeMapType createJPAAttributeMapType() {
- return new JPAAttributeMapType();
- }
+ /**
+ * Create an instance of
+ * {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAAttributeMapType }
+ *
+ */
+ public JPAAttributeMapType createJPAAttributeMapType() {
+ return new JPAAttributeMapType();
+ }
- /**
- * Create an instance of {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEdmMappingModel }
- *
- */
- public JPAEdmMappingModel createJPAEDMMappingModel() {
- return new JPAEdmMappingModel();
- }
+ /**
+ * Create an instance of
+ * {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEdmMappingModel }
+ *
+ */
+ public JPAEdmMappingModel createJPAEDMMappingModel() {
+ return new JPAEdmMappingModel();
+ }
- /**
- * Create an instance of {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAPersistenceUnitMapType }
- *
- */
- public JPAPersistenceUnitMapType createJPAPersistenceUnitMapType() {
- return new JPAPersistenceUnitMapType();
- }
+ /**
+ * Create an instance of
+ * {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAPersistenceUnitMapType }
+ *
+ */
+ public JPAPersistenceUnitMapType createJPAPersistenceUnitMapType() {
+ return new JPAPersistenceUnitMapType();
+ }
- /**
- * Create an instance of {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEmbeddableTypeMapType }
- *
- */
- public JPAEmbeddableTypeMapType createJPAEmbeddableTypeMapType() {
- return new JPAEmbeddableTypeMapType();
- }
+ /**
+ * Create an instance of
+ * {@link org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEmbeddableTypeMapType }
+ *
+ */
+ public JPAEmbeddableTypeMapType createJPAEmbeddableTypeMapType() {
+ return new JPAEmbeddableTypeMapType();
+ }
}
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 e6406738..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
@@ -1,40 +1,37 @@
/*******************************************************************************
- * 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.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;
/**
- *
- * The default name for EDM
- * complex type is derived from JPA Embeddable type name. This can be
+ *
+ * The default name for EDM complex type is derived from JPA Embeddable type name. This can be
* overriden using JPAEmbeddableTypeMapType.
- *
- *
- * <p>Java class for JPAEmbeddableTypeMapType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
+ *
+ *
+ * <p>
+ * Java class for JPAEmbeddableTypeMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPAEmbeddableTypeMapType">
* <complexContent>
@@ -50,112 +47,103 @@ import javax.xml.bind.annotation.XmlType;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEmbeddableTypeMapType", propOrder = { "edmComplexType", "jpaAttributes" })
+@XmlType(name = "JPAEmbeddableTypeMapType", propOrder = {"edmComplexType", "jpaAttributes"})
public class JPAEmbeddableTypeMapType {
- @XmlElement(name = "EDMComplexType")
- protected String edmComplexType;
- @XmlElement(name = "JPAAttributes", required = true)
- protected JPAAttributeMapType jpaAttributes;
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "exclude")
- protected Boolean exclude;
+ @XmlElement(name = "EDMComplexType")
+ protected String edmComplexType;
+ @XmlElement(name = "JPAAttributes", required = true)
+ protected JPAAttributeMapType jpaAttributes;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "exclude")
+ protected Boolean exclude;
- /**
- * Gets the value of the edmComplexType property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getEDMComplexType() {
- return edmComplexType;
- }
+ /**
+ * Gets the value of the edmComplexType property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getEDMComplexType() {
+ return edmComplexType;
+ }
- /**
- * Sets the value of the edmComplexType property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMComplexType(final String value) {
- edmComplexType = value;
- }
+ /**
+ * Sets the value of the edmComplexType property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setEDMComplexType(final String value) {
+ edmComplexType = value;
+ }
- /**
- * Gets the value of the jpaAttributes property.
- *
- * @return
- * possible object is {@link JPAAttributeMapType }
- *
- */
- public JPAAttributeMapType getJPAAttributes() {
- return jpaAttributes;
- }
+ /**
+ * Gets the value of the jpaAttributes property.
+ *
+ * @return possible object is {@link JPAAttributeMapType }
+ *
+ */
+ public JPAAttributeMapType getJPAAttributes() {
+ return jpaAttributes;
+ }
- /**
- * Sets the value of the jpaAttributes property.
- *
- * @param value
- * allowed object is {@link JPAAttributeMapType }
- *
- */
- public void setJPAAttributes(final JPAAttributeMapType value) {
- jpaAttributes = value;
- }
+ /**
+ * Sets the value of the jpaAttributes property.
+ *
+ * @param value allowed object is {@link JPAAttributeMapType }
+ *
+ */
+ public void setJPAAttributes(final JPAAttributeMapType value) {
+ jpaAttributes = value;
+ }
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
- /**
- * Gets the value of the exclude property.
- *
- * @return
- * possible object is {@link Boolean }
- *
- */
- public boolean isExclude() {
- if (exclude == null) {
- return false;
- } else {
- return exclude;
+ /**
+ * Gets the value of the exclude property.
+ *
+ * @return possible object is {@link Boolean }
+ *
+ */
+ public boolean isExclude() {
+ if (exclude == null) {
+ return false;
+ }
+ return exclude;
}
- }
- /**
- * Sets the value of the exclude property.
- *
- * @param value
- * allowed object is {@link Boolean }
- *
- */
- public void setExclude(final Boolean value) {
- exclude = value;
- }
+ /**
+ * Sets the value of the exclude property.
+ *
+ * @param value allowed object is {@link Boolean }
+ *
+ */
+ public void setExclude(final Boolean value) {
+ exclude = value;
+ }
}
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 62931244..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
@@ -1,39 +1,33 @@
/*******************************************************************************
- * 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.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>
* Java class for JPAEmbeddableTypesMapType complex type.
- *
+ *
* <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPAEmbeddableTypesMapType">
* <complexContent>
@@ -47,43 +41,42 @@ import javax.xml.bind.annotation.XmlType;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEmbeddableTypesMapType", propOrder = { "jpaEmbeddableType" })
+@XmlType(name = "JPAEmbeddableTypesMapType", propOrder = {"jpaEmbeddableType"})
public class JPAEmbeddableTypesMapType {
- @XmlElement(name = "JPAEmbeddableType")
- protected List<JPAEmbeddableTypeMapType> jpaEmbeddableType;
+ @XmlElement(name = "JPAEmbeddableType")
+ protected List<JPAEmbeddableTypeMapType> jpaEmbeddableType;
- /**
- * Gets the value of the jpaEmbeddableType property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a
- * snapshot. Therefore any modification you make to the returned list will
- * be present inside the JAXB object. This is why there is not a
- * <CODE>set</CODE> method for the jpaEmbeddableType property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getJPAEmbeddableType().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPAEmbeddableTypeMapType }
- *
- *
- */
- public List<JPAEmbeddableTypeMapType> getJPAEmbeddableType() {
- if (jpaEmbeddableType == null) {
- jpaEmbeddableType = new ArrayList<JPAEmbeddableTypeMapType>();
+ /**
+ * Gets the value of the jpaEmbeddableType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a <CODE>set</CODE> method for the jpaEmbeddableType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getJPAEmbeddableType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list {@link JPAEmbeddableTypeMapType }
+ *
+ *
+ */
+ public List<JPAEmbeddableTypeMapType> getJPAEmbeddableType() {
+ if (jpaEmbeddableType == null) {
+ jpaEmbeddableType = new ArrayList<JPAEmbeddableTypeMapType>();
+ }
+ return jpaEmbeddableType;
}
- return jpaEmbeddableType;
- }
}
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 22e18192..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
@@ -1,40 +1,37 @@
/*******************************************************************************
- * 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.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;
/**
- *
- * The default name for EDM
- * entity type is derived from JPA entity type name. This can be
- * overriden using JPAEntityTypeMapType.
- *
- *
- * <p>Java class for JPAEntityTypeMapType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
+ *
+ * The default name for EDM entity type is derived from JPA entity type name. This can be overriden
+ * using JPAEntityTypeMapType.
+ *
+ *
+ * <p>
+ * Java class for JPAEntityTypeMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPAEntityTypeMapType">
* <complexContent>
@@ -53,161 +50,147 @@ import javax.xml.bind.annotation.XmlType;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEntityTypeMapType", propOrder = { "edmEntityType", "edmEntitySet", "jpaAttributes",
- "jpaRelationships" })
+@XmlType(name = "JPAEntityTypeMapType", propOrder = {"edmEntityType", "edmEntitySet", "jpaAttributes", "jpaRelationships"})
public class JPAEntityTypeMapType {
- @XmlElement(name = "EDMEntityType")
- protected String edmEntityType;
- @XmlElement(name = "EDMEntitySet")
- protected String edmEntitySet;
- @XmlElement(name = "JPAAttributes", required = true)
- protected JPAAttributeMapType jpaAttributes;
- @XmlElement(name = "JPARelationships", required = true)
- protected JPARelationshipMapType jpaRelationships;
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "exclude")
- protected Boolean exclude;
-
- /**
- * Gets the value of the edmEntityType property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getEDMEntityType() {
- return edmEntityType;
- }
-
- /**
- * Sets the value of the edmEntityType property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMEntityType(final String value) {
- edmEntityType = value;
- }
-
- /**
- * Gets the value of the edmEntitySet property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getEDMEntitySet() {
- return edmEntitySet;
- }
-
- /**
- * Sets the value of the edmEntitySet property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMEntitySet(final String value) {
- edmEntitySet = value;
- }
-
- /**
- * Gets the value of the jpaAttributes property.
- *
- * @return
- * possible object is {@link JPAAttributeMapType }
- *
- */
- public JPAAttributeMapType getJPAAttributes() {
- return jpaAttributes;
- }
-
- /**
- * Sets the value of the jpaAttributes property.
- *
- * @param value
- * allowed object is {@link JPAAttributeMapType }
- *
- */
- public void setJPAAttributes(final JPAAttributeMapType value) {
- jpaAttributes = value;
- }
-
- /**
- * Gets the value of the jpaRelationships property.
- *
- * @return
- * possible object is {@link JPARelationshipMapType }
- *
- */
- public JPARelationshipMapType getJPARelationships() {
- return jpaRelationships;
- }
-
- /**
- * Sets the value of the jpaRelationships property.
- *
- * @param value
- * allowed object is {@link JPARelationshipMapType }
- *
- */
- public void setJPARelationships(final JPARelationshipMapType value) {
- jpaRelationships = value;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
-
- /**
- * Gets the value of the exclude property.
- *
- * @return
- * possible object is {@link Boolean }
- *
- */
- public boolean isExclude() {
- if (exclude == null) {
- return false;
- } else {
- return exclude;
+ @XmlElement(name = "EDMEntityType")
+ protected String edmEntityType;
+ @XmlElement(name = "EDMEntitySet")
+ protected String edmEntitySet;
+ @XmlElement(name = "JPAAttributes", required = true)
+ protected JPAAttributeMapType jpaAttributes;
+ @XmlElement(name = "JPARelationships", required = true)
+ protected JPARelationshipMapType jpaRelationships;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "exclude")
+ protected Boolean exclude;
+
+ /**
+ * Gets the value of the edmEntityType property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getEDMEntityType() {
+ return edmEntityType;
+ }
+
+ /**
+ * Sets the value of the edmEntityType property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setEDMEntityType(final String value) {
+ edmEntityType = value;
+ }
+
+ /**
+ * Gets the value of the edmEntitySet property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getEDMEntitySet() {
+ return edmEntitySet;
+ }
+
+ /**
+ * Sets the value of the edmEntitySet property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setEDMEntitySet(final String value) {
+ edmEntitySet = value;
+ }
+
+ /**
+ * Gets the value of the jpaAttributes property.
+ *
+ * @return possible object is {@link JPAAttributeMapType }
+ *
+ */
+ public JPAAttributeMapType getJPAAttributes() {
+ return jpaAttributes;
+ }
+
+ /**
+ * Sets the value of the jpaAttributes property.
+ *
+ * @param value allowed object is {@link JPAAttributeMapType }
+ *
+ */
+ public void setJPAAttributes(final JPAAttributeMapType value) {
+ jpaAttributes = value;
+ }
+
+ /**
+ * Gets the value of the jpaRelationships property.
+ *
+ * @return possible object is {@link JPARelationshipMapType }
+ *
+ */
+ public JPARelationshipMapType getJPARelationships() {
+ return jpaRelationships;
+ }
+
+ /**
+ * Sets the value of the jpaRelationships property.
+ *
+ * @param value allowed object is {@link JPARelationshipMapType }
+ *
+ */
+ public void setJPARelationships(final JPARelationshipMapType value) {
+ jpaRelationships = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ /**
+ * Gets the value of the exclude property.
+ *
+ * @return possible object is {@link Boolean }
+ *
+ */
+ public boolean isExclude() {
+ if (exclude == null) {
+ return false;
+ }
+ return exclude;
+ }
+
+ /**
+ * Sets the value of the exclude property.
+ *
+ * @param value allowed object is {@link Boolean }
+ *
+ */
+ public void setExclude(final Boolean value) {
+ exclude = value;
}
- }
-
- /**
- * Sets the value of the exclude property.
- *
- * @param value
- * allowed object is {@link Boolean }
- *
- */
- public void setExclude(final Boolean value) {
- exclude = value;
- }
}
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 7a72e084..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
@@ -1,39 +1,33 @@
/*******************************************************************************
- * 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.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>
* Java class for JPAEntityTypesMapType complex type.
- *
+ *
* <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPAEntityTypesMapType">
* <complexContent>
@@ -47,43 +41,42 @@ import javax.xml.bind.annotation.XmlType;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEntityTypesMapType", propOrder = { "jpaEntityType" })
+@XmlType(name = "JPAEntityTypesMapType", propOrder = {"jpaEntityType"})
public class JPAEntityTypesMapType {
- @XmlElement(name = "JPAEntityType")
- protected List<JPAEntityTypeMapType> jpaEntityType;
+ @XmlElement(name = "JPAEntityType")
+ protected List<JPAEntityTypeMapType> jpaEntityType;
- /**
- * Gets the value of the jpaEntityType property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a
- * snapshot. Therefore any modification you make to the returned list will
- * be present inside the JAXB object. This is why there is not a
- * <CODE>set</CODE> method for the jpaEntityType property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getJPAEntityType().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPAEntityTypeMapType }
- *
- *
- */
- public List<JPAEntityTypeMapType> getJPAEntityType() {
- if (jpaEntityType == null) {
- jpaEntityType = new ArrayList<JPAEntityTypeMapType>();
+ /**
+ * Gets the value of the jpaEntityType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a <CODE>set</CODE> method for the jpaEntityType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getJPAEntityType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list {@link JPAEntityTypeMapType }
+ *
+ *
+ */
+ public List<JPAEntityTypeMapType> getJPAEntityType() {
+ if (jpaEntityType == null) {
+ jpaEntityType = new ArrayList<JPAEntityTypeMapType>();
+ }
+ return jpaEntityType;
}
- return jpaEntityType;
- }
}
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 22260eac..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
@@ -1,42 +1,37 @@
/*******************************************************************************
- * 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.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;
/**
- *
- * By default Java Persistence Unit name is taken as EDM schema name. This can
- * be overriden using JPAPersistenceUnitMapType.
- *
- *
+ *
+ * By default Java Persistence Unit name is taken as EDM schema name. This can be overriden using
+ * JPAPersistenceUnitMapType.
+ *
+ *
* <p>
* Java class for JPAPersistenceUnitMapType complex type.
- *
+ *
* <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPAPersistenceUnitMapType">
* <complexContent>
@@ -53,105 +48,100 @@ import javax.xml.bind.annotation.XmlType;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAPersistenceUnitMapType",
- propOrder = { "edmSchemaNamespace", "jpaEntityTypes", "jpaEmbeddableTypes" })
+@XmlType(name = "JPAPersistenceUnitMapType", propOrder = {"edmSchemaNamespace", "jpaEntityTypes", "jpaEmbeddableTypes"})
public class JPAPersistenceUnitMapType {
- @XmlElement(name = "EDMSchemaNamespace")
- protected String edmSchemaNamespace;
- @XmlElement(name = "JPAEntityTypes", required = true)
- protected JPAEntityTypesMapType jpaEntityTypes;
- @XmlElement(name = "JPAEmbeddableTypes", required = true)
- protected JPAEmbeddableTypesMapType jpaEmbeddableTypes;
- @XmlAttribute(name = "name", required = true)
- protected String name;
+ @XmlElement(name = "EDMSchemaNamespace")
+ protected String edmSchemaNamespace;
+ @XmlElement(name = "JPAEntityTypes", required = true)
+ protected JPAEntityTypesMapType jpaEntityTypes;
+ @XmlElement(name = "JPAEmbeddableTypes", required = true)
+ protected JPAEmbeddableTypesMapType jpaEmbeddableTypes;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
- /**
- * Gets the value of the edmSchemaNamespace property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getEDMSchemaNamespace() {
- return edmSchemaNamespace;
- }
+ /**
+ * Gets the value of the edmSchemaNamespace property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getEDMSchemaNamespace() {
+ return edmSchemaNamespace;
+ }
- /**
- * Sets the value of the edmSchemaNamespace property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMSchemaNamespace(final String value) {
- edmSchemaNamespace = value;
- }
+ /**
+ * Sets the value of the edmSchemaNamespace property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setEDMSchemaNamespace(final String value) {
+ edmSchemaNamespace = value;
+ }
- /**
- * Gets the value of the jpaEntityTypes property.
- *
- * @return possible object is {@link JPAEntityTypesMapType }
- *
- */
- public JPAEntityTypesMapType getJPAEntityTypes() {
- return jpaEntityTypes;
- }
+ /**
+ * Gets the value of the jpaEntityTypes property.
+ *
+ * @return possible object is {@link JPAEntityTypesMapType }
+ *
+ */
+ public JPAEntityTypesMapType getJPAEntityTypes() {
+ return jpaEntityTypes;
+ }
- /**
- * Sets the value of the jpaEntityTypes property.
- *
- * @param value
- * allowed object is {@link JPAEntityTypesMapType }
- *
- */
- public void setJPAEntityTypes(final JPAEntityTypesMapType value) {
- jpaEntityTypes = value;
- }
+ /**
+ * Sets the value of the jpaEntityTypes property.
+ *
+ * @param value allowed object is {@link JPAEntityTypesMapType }
+ *
+ */
+ public void setJPAEntityTypes(final JPAEntityTypesMapType value) {
+ jpaEntityTypes = value;
+ }
- /**
- * Gets the value of the jpaEmbeddableTypes property.
- *
- * @return possible object is {@link JPAEmbeddableTypesMapType }
- *
- */
- public JPAEmbeddableTypesMapType getJPAEmbeddableTypes() {
- return jpaEmbeddableTypes;
- }
+ /**
+ * Gets the value of the jpaEmbeddableTypes property.
+ *
+ * @return possible object is {@link JPAEmbeddableTypesMapType }
+ *
+ */
+ public JPAEmbeddableTypesMapType getJPAEmbeddableTypes() {
+ return jpaEmbeddableTypes;
+ }
- /**
- * Sets the value of the jpaEmbeddableTypes property.
- *
- * @param value
- * allowed object is {@link JPAEmbeddableTypesMapType }
- *
- */
- public void setJPAEmbeddableTypes(final JPAEmbeddableTypesMapType value) {
- jpaEmbeddableTypes = value;
- }
+ /**
+ * Sets the value of the jpaEmbeddableTypes property.
+ *
+ * @param value allowed object is {@link JPAEmbeddableTypesMapType }
+ *
+ */
+ public void setJPAEmbeddableTypes(final JPAEmbeddableTypesMapType value) {
+ jpaEmbeddableTypes = value;
+ }
- /**
- * Gets the value of the name property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
}
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 25a2f956..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
@@ -1,46 +1,40 @@
/*******************************************************************************
- * 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.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;
/**
- *
- * The default name for EDM navigation property is derived from JPA relationship
- * name. This can be overriden using JPARelationshipMapType.
- *
- *
+ *
+ * The default name for EDM navigation property is derived from JPA relationship name. This can be
+ * overriden using JPARelationshipMapType.
+ *
+ *
* <p>
* Java class for JPARelationshipMapType complex type.
- *
+ *
* <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
+ * The following schema fragment specifies the expected content contained within this class.
+ *
* <pre>
* <complexType name="JPARelationshipMapType">
* <complexContent>
@@ -60,116 +54,113 @@ import javax.xml.bind.annotation.XmlValue;
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPARelationshipMapType", propOrder = { "jpaRelationship" })
+@XmlType(name = "JPARelationshipMapType", propOrder = {"jpaRelationship"})
public class JPARelationshipMapType {
- @XmlElement(name = "JPARelationship")
- protected List<JPARelationshipMapType.JPARelationship> jpaRelationship;
-
- /**
- * Gets the value of the jpaRelationship property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a
- * snapshot. Therefore any modification you make to the returned list will
- * be present inside the JAXB object. This is why there is not a
- * <CODE>set</CODE> method for the jpaRelationship property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getJPARelationship().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPARelationshipMapType.JPARelationship }
- *
- *
- */
- public List<JPARelationshipMapType.JPARelationship> getJPARelationship() {
- if (jpaRelationship == null) {
- jpaRelationship = new ArrayList<JPARelationshipMapType.JPARelationship>();
- }
- return jpaRelationship;
- }
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained
- * within this class.
- *
- * <pre>
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>string">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = { "value" })
- public static class JPARelationship {
-
- @XmlValue
- protected String value;
- @XmlAttribute(name = "name", required = true)
- protected String name;
+ @XmlElement(name = "JPARelationship")
+ protected List<JPARelationshipMapType.JPARelationship> jpaRelationship;
/**
- * Gets the value of the value property.
+ * Gets the value of the jpaRelationship property.
*
- * @return possible object is {@link String }
+ * <p>
+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a <CODE>set</CODE> method for the jpaRelationship property.
*
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
+ * <p>
+ * For example, to add a new item, do as follows:
*
- * @param value
- * allowed object is {@link String }
+ * <pre>
+ * getJPARelationship().add(newItem);
+ * </pre>
*
- */
- public void setValue(final String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the name property.
*
- * @return possible object is {@link String }
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JPARelationshipMapType.JPARelationship }
+ *
*
*/
- public String getName() {
- return name;
+ public List<JPARelationshipMapType.JPARelationship> getJPARelationship() {
+ if (jpaRelationship == null) {
+ jpaRelationship = new ArrayList<JPARelationshipMapType.JPARelationship>();
+ }
+ return jpaRelationship;
}
/**
- * Sets the value of the name property.
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
*
- * @param value
- * allowed object is {@link String }
*
*/
- public void setName(final String value) {
- name = value;
- }
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"value"})
+ public static class JPARelationship {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
- }
+ /**
+ * Gets the value of the value property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ }
}
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.
+ *
+ *
*/
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.apache.org/olingo/odata2/jpa/processor/api/model/mapping",
- elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+@jakarta.xml.bind.annotation.XmlSchema(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/pom.xml b/odata2-jpa-processor/jpa-core/pom.xml
index c8eb662a..2c09c1fa 100644
--- a/odata2-jpa-processor/jpa-core/pom.xml
+++ b/odata2-jpa-processor/jpa-core/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
@@ -68,10 +68,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>17</source>
+ <target>17</target>
</configuration>
</plugin>
</plugins>
@@ -88,9 +87,8 @@
<!-- Java Persistence API -->
<!-- ########################## -->
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>${version.javax.persistence}</version>
+ <groupId>jakarta.persistence</groupId>
+ <artifactId>jakarta.persistence-api</artifactId>
</dependency>
<!-- ########################## -->
@@ -122,14 +120,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.1</version>
- <scope>test</scope>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>5.2.0</version>
+ <scope>test</scope>
</dependency>
<!-- ########################## -->
@@ -138,7 +135,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
index 075d0a1c..2d40bccd 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
@@ -18,8 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata2.jpa.processor.core;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
import org.apache.olingo.odata2.api.processor.ODataContext;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionLocalDefault.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionLocalDefault.java
index 532764c6..fc032e10 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionLocalDefault.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionLocalDefault.java
@@ -20,8 +20,8 @@ package org.apache.olingo.odata2.jpa.processor.core;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPATransaction;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityTransaction;
public class ODataJPATransactionLocalDefault implements ODataJPATransaction {
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntity.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntity.java
index a3f5495c..3db5ab5b 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntity.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntity.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.data;
@@ -32,10 +28,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
import org.apache.olingo.odata2.api.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.edm.EdmEntityType;
import org.apache.olingo.odata2.api.edm.EdmException;
@@ -43,9 +35,9 @@ 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.edm.EdmStructuralType;
+import org.apache.olingo.odata2.api.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmTypeKind;
import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.edm.EdmType;
import org.apache.olingo.odata2.api.ep.entry.EntryMetadata;
import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
@@ -55,511 +47,487 @@ import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelExcepti
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
import org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmMapping;
import org.apache.olingo.odata2.jpa.processor.core.model.JPAEdmMappingImpl;
+import jakarta.xml.bind.annotation.adapters.XmlAdapter;
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
public class JPAEntity {
- private Object jpaEntity = null;
- private JPAEntity parentJPAEntity = null;
- private EdmEntityType oDataEntityType = null;
- private EdmEntitySet oDataEntitySet = null;
- private Class<?> jpaType = null;
- private HashMap<String, Method> accessModifiersWrite = null;
- private JPAEntityParser jpaEntityParser = null;
- private ODataJPAContext oDataJPAContext;
- private OnJPAWriteContent onJPAWriteContent = null;
- private List<String> relatedJPAEntityLink = new ArrayList<String>();
- private HashMap<String, List<Object>> relatedJPAEntityMap = null;
- private EdmNavigationProperty viaNavigationProperty;
-
- public JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet,
- final ODataJPAContext context) {
- this.oDataEntityType = oDataEntityType;
- this.oDataEntitySet = oDataEntitySet;
- oDataJPAContext = context;
- try {
- JPAEdmMapping mapping = (JPAEdmMapping) oDataEntityType.getMapping();
- jpaType = mapping.getJPAType();
- } catch (EdmException e) {
- return;
+ private Object jpaEntity = null;
+ private JPAEntity parentJPAEntity = null;
+ private EdmEntityType oDataEntityType = null;
+ private EdmEntitySet oDataEntitySet = null;
+ private Class<?> jpaType = null;
+ private HashMap<String, Method> accessModifiersWrite = null;
+ private JPAEntityParser jpaEntityParser = null;
+ private ODataJPAContext oDataJPAContext;
+ private OnJPAWriteContent onJPAWriteContent = null;
+ private final List<String> relatedJPAEntityLink = new ArrayList<String>();
+ private HashMap<String, List<Object>> relatedJPAEntityMap = null;
+ private EdmNavigationProperty viaNavigationProperty;
+
+ public JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet, final ODataJPAContext context) {
+ this.oDataEntityType = oDataEntityType;
+ this.oDataEntitySet = oDataEntitySet;
+ oDataJPAContext = context;
+ try {
+ JPAEdmMapping mapping = (JPAEdmMapping) oDataEntityType.getMapping();
+ jpaType = mapping.getJPAType();
+ } catch (EdmException e) {
+ return;
+ }
+ jpaEntityParser = new JPAEntityParser();
+ onJPAWriteContent = oDataJPAContext.getODataContext()
+ .getServiceFactory()
+ .getCallback(OnJPAWriteContent.class);
+ }
+
+ public void setAccessModifersWrite(final HashMap<String, Method> accessModifiersWrite) {
+ this.accessModifiersWrite = accessModifiersWrite;
}
- jpaEntityParser = new JPAEntityParser();
- onJPAWriteContent = oDataJPAContext.getODataContext().getServiceFactory().getCallback(OnJPAWriteContent.class);
- }
- public void setAccessModifersWrite(final HashMap<String, Method> accessModifiersWrite) {
- this.accessModifiersWrite = accessModifiersWrite;
- }
+ public void setParentJPAEntity(final JPAEntity jpaEntity) {
+ parentJPAEntity = jpaEntity;
+ }
- public void setParentJPAEntity(final JPAEntity jpaEntity) {
- parentJPAEntity = jpaEntity;
- }
+ public JPAEntity getParentJPAEntity() {
+ return parentJPAEntity;
+ }
- public JPAEntity getParentJPAEntity() {
- return parentJPAEntity;
- }
+ public Object getJPAEntity() {
+ return jpaEntity;
+ }
- public Object getJPAEntity() {
- return jpaEntity;
- }
+ public void setViaNavigationProperty(EdmNavigationProperty viaNavigationProperty) {
+ this.viaNavigationProperty = viaNavigationProperty;
+ }
- public void setViaNavigationProperty(EdmNavigationProperty viaNavigationProperty) {
- this.viaNavigationProperty = viaNavigationProperty;
- }
+ public EdmNavigationProperty getViaNavigationProperty() {
+ return viaNavigationProperty;
+ }
- public EdmNavigationProperty getViaNavigationProperty() {
- return viaNavigationProperty;
- }
+ public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
- public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
+ if (oDataEntry == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null);
+ }
+ try {
+ EntryMetadata entryMetadata = oDataEntry.getMetadata();
+ Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
+ if (oDataEntry.containsInlineEntry()) {
+ normalizeInlineEntries(oDataEntryProperties);
+ }
- if (oDataEntry == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL, null);
+ if (oDataEntry.getProperties()
+ .size() > 0) {
+
+ write(oDataEntryProperties, true);
+
+ for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
+ EdmNavigationProperty navProperty = (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName);
+ if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) {
+ oDataEntry.getProperties()
+ .get(navigationPropertyName);
+ JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity, navProperty);
+ continue;
+ }
+ // The second condition is required to ensure that there is an explicit request to link
+ // two entities. Else the third condition will always be true for cases where two navigations
+ // point to same entity types.
+ if (parentJPAEntity != null && navProperty.getRelationship()
+ .equals(getViaNavigationProperty().getRelationship())) {
+ List<Object> targetJPAEntities = new ArrayList<Object>();
+ targetJPAEntities.add(parentJPAEntity.getJPAEntity());
+ JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty);
+ } else if (!entryMetadata.getAssociationUris(navigationPropertyName)
+ .isEmpty()) {
+ if (!relatedJPAEntityLink.contains(navigationPropertyName)) {
+ relatedJPAEntityLink.add(navigationPropertyName);
+ }
+ }
+ }
+ }
+ if (!relatedJPAEntityLink.isEmpty()) {
+ JPALink link = new JPALink(oDataJPAContext);
+ link.setSourceJPAEntity(jpaEntity);
+ link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink);
+ }
+ } catch (EdmException | ODataJPAModelException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
}
- try {
- EntryMetadata entryMetadata = oDataEntry.getMetadata();
- Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
- if (oDataEntry.containsInlineEntry()) {
- normalizeInlineEntries(oDataEntryProperties);
- }
- if (oDataEntry.getProperties().size() > 0) {
+ public EdmEntitySet getEdmEntitySet() {
+ return oDataEntitySet;
+ }
+ public void create(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
+ normalizeInlineEntries(oDataEntryProperties);
write(oDataEntryProperties, true);
+ }
- for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
- EdmNavigationProperty navProperty =
- (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName);
- if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) {
- oDataEntry.getProperties().get(navigationPropertyName);
- JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity,
- navProperty);
- continue;
- }
- // The second condition is required to ensure that there is an explicit request to link
- // two entities. Else the third condition will always be true for cases where two navigations
- // point to same entity types.
- if (parentJPAEntity != null
- && navProperty.getRelationship().equals(getViaNavigationProperty().getRelationship())) {
- List<Object> targetJPAEntities = new ArrayList<Object>();
- targetJPAEntities.add(parentJPAEntity.getJPAEntity());
- JPALink.linkJPAEntities(targetJPAEntities, jpaEntity, navProperty);
- } else if (!entryMetadata.getAssociationUris(navigationPropertyName).isEmpty()) {
- if (!relatedJPAEntityLink.contains(navigationPropertyName)) {
- relatedJPAEntityLink.add(navigationPropertyName);
- }
- }
+ public void update(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
+ if (oDataEntry == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null);
}
- }
- if (!relatedJPAEntityLink.isEmpty()) {
+ Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
+ if (oDataEntry.containsInlineEntry()) {
+ normalizeInlineEntries(oDataEntryProperties);
+ }
+ write(oDataEntryProperties, false);
JPALink link = new JPALink(oDataJPAContext);
link.setSourceJPAEntity(jpaEntity);
- link.create(oDataEntitySet, oDataEntry, relatedJPAEntityLink);
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- } catch (ODataJPAModelException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ try {
+ link.create(oDataEntitySet, oDataEntry, oDataEntityType.getNavigationPropertyNames());
+ } catch (EdmException | ODataJPAModelException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
}
- }
- public EdmEntitySet getEdmEntitySet() {
- return oDataEntitySet;
- }
-
- public void create(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
- normalizeInlineEntries(oDataEntryProperties);
- write(oDataEntryProperties, true);
- }
-
- public void update(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
- if (oDataEntry == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL, null);
- }
- Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
- if (oDataEntry.containsInlineEntry()) {
- normalizeInlineEntries(oDataEntryProperties);
+ public void update(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
+ normalizeInlineEntries(oDataEntryProperties);
+ write(oDataEntryProperties, false);
}
- write(oDataEntryProperties, false);
- JPALink link = new JPALink(oDataJPAContext);
- link.setSourceJPAEntity(jpaEntity);
- try {
- link.create(oDataEntitySet, oDataEntry, oDataEntityType.getNavigationPropertyNames());
- } catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- } catch (ODataJPAModelException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+
+ public void setJPAEntity(final Object jpaEntity) {
+ this.jpaEntity = jpaEntity;
}
- }
-
- public void update(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
- normalizeInlineEntries(oDataEntryProperties);
- write(oDataEntryProperties, false);
- }
-
- public void setJPAEntity(final Object jpaEntity) {
- this.jpaEntity = jpaEntity;
- }
-
- protected void setComplexProperty(Method accessModifier, final Object jpaEntity,
- final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue)
- throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- InstantiationException, ODataJPARuntimeException, NoSuchMethodException, SecurityException, SQLException {
-
- setComplexProperty(accessModifier, jpaEntity, edmComplexType, propertyValue, null);
- }
-
- protected void setProperty(final Method method, final Object entity, final Object entityPropertyValue,
- final EdmSimpleType type, boolean isNullable) throws
- IllegalAccessException, IllegalArgumentException, InvocationTargetException, ODataJPARuntimeException,
- EdmException {
-
- setProperty(method, entity, entityPropertyValue, type, null, isNullable);
- }
-
- protected void setEmbeddableKeyProperty(final HashMap<String, String> embeddableKeys,
- final List<EdmProperty> oDataEntryKeyProperties,
- final Map<String, Object> oDataEntryProperties, final Object entity)
- throws ODataJPARuntimeException, EdmException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, InstantiationException {
-
- HashMap<String, Object> embeddableObjMap = new HashMap<String, Object>();
- List<EdmProperty> leftODataEntryKeyProperties = new ArrayList<EdmProperty>();
- HashMap<String, String> leftEmbeddableKeys = new HashMap<String, String>();
-
- for (EdmProperty edmProperty : oDataEntryKeyProperties) {
- if (oDataEntryProperties.containsKey(edmProperty.getName()) == false) {
- continue;
- }
-
- String edmPropertyName = edmProperty.getName();
- String embeddableKeyNameComposite = embeddableKeys.get(edmPropertyName);
- if (embeddableKeyNameComposite == null) {
- continue;
- }
- String embeddableKeyNameSplit[] = embeddableKeyNameComposite.split("\\.");
- String methodPartName = null;
- Method method = null;
- Object embeddableObj = null;
-
- if (embeddableObjMap.containsKey(embeddableKeyNameSplit[0]) == false) {
- methodPartName = embeddableKeyNameSplit[0];
- method = jpaEntityParser.getAccessModifierSet(entity, methodPartName);
- embeddableObj = method.getParameterTypes()[0].newInstance();
- method.invoke(entity, embeddableObj);
- embeddableObjMap.put(embeddableKeyNameSplit[0], embeddableObj);
- } else {
- embeddableObj = embeddableObjMap.get(embeddableKeyNameSplit[0]);
- }
-
- if (embeddableKeyNameSplit.length == 2) {
- methodPartName = embeddableKeyNameSplit[1];
- method = jpaEntityParser.getAccessModifierSet(embeddableObj, methodPartName);
- Object simpleObj = oDataEntryProperties.get(edmProperty.getName());
- method.invoke(embeddableObj, simpleObj);
- } else if (embeddableKeyNameSplit.length > 2) { // Deeply nested
- leftODataEntryKeyProperties.add(edmProperty);
- leftEmbeddableKeys
- .put(edmPropertyName, embeddableKeyNameComposite.split(embeddableKeyNameSplit[0] + ".", 2)[1]);
- }
+
+ protected void setComplexProperty(Method accessModifier, final Object jpaEntity, final EdmStructuralType edmComplexType,
+ final HashMap<String, Object> propertyValue)
+ throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException,
+ ODataJPARuntimeException, NoSuchMethodException, SecurityException, SQLException {
+
+ setComplexProperty(accessModifier, jpaEntity, edmComplexType, propertyValue, null);
}
- }
- protected Object instantiateJPAEntity() throws InstantiationException, IllegalAccessException {
- if (jpaType == null) {
- throw new InstantiationException();
+ protected void setProperty(final Method method, final Object entity, final Object entityPropertyValue, final EdmSimpleType type,
+ boolean isNullable)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, ODataJPARuntimeException, EdmException {
+
+ setProperty(method, entity, entityPropertyValue, type, null, isNullable);
}
- return jpaType.newInstance();
- }
-
- private void normalizeInlineEntries(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
- List<ODataEntry> entries = null;
- try {
- for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
- Object inline = oDataEntryProperties.get(navigationPropertyName);
- if (inline instanceof ODataFeed) {
- entries = ((ODataFeed) inline).getEntries();
- } else if (inline instanceof ODataEntry) {
- entries = new ArrayList<ODataEntry>();
- entries.add((ODataEntry) inline);
- }
- if (entries != null) {
- oDataEntryProperties.put(navigationPropertyName, entries);
- entries = null;
+ protected void setEmbeddableKeyProperty(final HashMap<String, String> embeddableKeys, final List<EdmProperty> oDataEntryKeyProperties,
+ final Map<String, Object> oDataEntryProperties, final Object entity) throws ODataJPARuntimeException, EdmException,
+ IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
+
+ HashMap<String, Object> embeddableObjMap = new HashMap<String, Object>();
+ List<EdmProperty> leftODataEntryKeyProperties = new ArrayList<EdmProperty>();
+ HashMap<String, String> leftEmbeddableKeys = new HashMap<String, String>();
+
+ for (EdmProperty edmProperty : oDataEntryKeyProperties) {
+ if (!oDataEntryProperties.containsKey(edmProperty.getName())) {
+ continue;
+ }
+
+ String edmPropertyName = edmProperty.getName();
+ String embeddableKeyNameComposite = embeddableKeys.get(edmPropertyName);
+ if (embeddableKeyNameComposite == null) {
+ continue;
+ }
+ String embeddableKeyNameSplit[] = embeddableKeyNameComposite.split("\\.");
+ String methodPartName = null;
+ Method method = null;
+ Object embeddableObj = null;
+
+ if (!embeddableObjMap.containsKey(embeddableKeyNameSplit[0])) {
+ methodPartName = embeddableKeyNameSplit[0];
+ method = jpaEntityParser.getAccessModifierSet(entity, methodPartName);
+ embeddableObj = method.getParameterTypes()[0].newInstance();
+ method.invoke(entity, embeddableObj);
+ embeddableObjMap.put(embeddableKeyNameSplit[0], embeddableObj);
+ } else {
+ embeddableObj = embeddableObjMap.get(embeddableKeyNameSplit[0]);
+ }
+
+ if (embeddableKeyNameSplit.length == 2) {
+ methodPartName = embeddableKeyNameSplit[1];
+ method = jpaEntityParser.getAccessModifierSet(embeddableObj, methodPartName);
+ Object simpleObj = oDataEntryProperties.get(edmProperty.getName());
+ method.invoke(embeddableObj, simpleObj);
+ } else if (embeddableKeyNameSplit.length > 2) { // Deeply nested
+ leftODataEntryKeyProperties.add(edmProperty);
+ leftEmbeddableKeys.put(edmPropertyName, embeddableKeyNameComposite.split(embeddableKeyNameSplit[0] + ".", 2)[1]);
+ }
}
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
}
- }
-
- @SuppressWarnings("unchecked")
- private void write(final Map<String, Object> oDataEntryProperties,
- final boolean isCreate)
- throws ODataJPARuntimeException {
- try {
-
- EdmStructuralType structuralType = null;
- final List<String> keyNames = oDataEntityType.getKeyPropertyNames();
-
- if (isCreate) {
- jpaEntity = instantiateJPAEntity();
- } else if (jpaEntity == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.RESOURCE_NOT_FOUND, null);
- }
-
- if (accessModifiersWrite == null) {
- accessModifiersWrite =
- jpaEntityParser.getAccessModifiers(jpaEntity, oDataEntityType, JPAEntityParser.ACCESS_MODIFIER_SET);
- }
-
- if (oDataEntityType == null || oDataEntryProperties == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL, null);
- }
-
- final HashMap<String, String> embeddableKeys =
- jpaEntityParser.getJPAEmbeddableKeyMap(jpaEntity.getClass().getName());
- Set<String> propertyNames = null;
- if (embeddableKeys != null) {
- setEmbeddableKeyProperty(embeddableKeys, oDataEntityType.getKeyProperties(), oDataEntryProperties,
- jpaEntity);
-
- propertyNames = new HashSet<String>();
- propertyNames.addAll(oDataEntryProperties.keySet());
- for (String key : embeddableKeys.keySet()) {
- propertyNames.remove(key);
+
+ protected Object instantiateJPAEntity() throws InstantiationException, IllegalAccessException {
+ if (jpaType == null) {
+ throw new InstantiationException();
}
- } else {
- propertyNames = oDataEntryProperties.keySet();
- }
-
- boolean isVirtual = false;
- for (String propertyName : propertyNames) {
- EdmTyped edmTyped = (EdmTyped) oDataEntityType.getProperty(propertyName);
- if (edmTyped instanceof EdmProperty) {
- isVirtual = ((JPAEdmMappingImpl)((EdmProperty) edmTyped).getMapping()).isVirtualAccess();
- } else {
- isVirtual = false;
+
+ return jpaType.newInstance();
+ }
+
+ private void normalizeInlineEntries(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
+ List<ODataEntry> entries = null;
+ try {
+ for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
+ Object inline = oDataEntryProperties.get(navigationPropertyName);
+ if (inline instanceof ODataFeed) {
+ entries = ((ODataFeed) inline).getEntries();
+ } else if (inline instanceof ODataEntry) {
+ entries = new ArrayList<ODataEntry>();
+ entries.add((ODataEntry) inline);
+ }
+ if (entries != null) {
+ oDataEntryProperties.put(navigationPropertyName, entries);
+ entries = null;
+ }
+ }
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
- Method accessModifier = null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void write(final Map<String, Object> oDataEntryProperties, final boolean isCreate) throws ODataJPARuntimeException {
+ try {
- switch (edmTyped.getType().getKind()) {
- case SIMPLE:
- if (isCreate == false) {
- if (keyNames.contains(edmTyped.getName())) {
- continue;
+ EdmStructuralType structuralType = null;
+ final List<String> keyNames = oDataEntityType.getKeyPropertyNames();
+
+ if (isCreate) {
+ jpaEntity = instantiateJPAEntity();
+ } else if (jpaEntity == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RESOURCE_NOT_FOUND, null);
}
- }
- accessModifier = accessModifiersWrite.get(propertyName);
- EdmProperty edmProperty = (EdmProperty)oDataEntityType.getProperty(propertyName);
- boolean isNullable = edmProperty.getFacets() == null ? (keyNames.contains(propertyName)? false : true)
- : edmProperty.getFacets().isNullable() == null ? true : edmProperty.getFacets().isNullable();
- if (isVirtual) {
- setProperty(accessModifier, jpaEntity, oDataEntryProperties.get(propertyName), (EdmSimpleType) edmTyped
- .getType(), isNullable);
- } else {
- setProperty(accessModifier, jpaEntity, oDataEntryProperties.get(propertyName), (EdmSimpleType) edmTyped
- .getType(), isNullable);
- }
- break;
- case COMPLEX:
- structuralType = (EdmStructuralType) edmTyped.getType();
- accessModifier = accessModifiersWrite.get(propertyName);
- if (isVirtual) {
- setComplexProperty(accessModifier, jpaEntity,
- structuralType,
- (HashMap<String, Object>) oDataEntryProperties.get(propertyName), propertyName);
- } else {
- setComplexProperty(accessModifier, jpaEntity,
- structuralType,
- (HashMap<String, Object>) oDataEntryProperties.get(propertyName));
- }
- break;
- case NAVIGATION:
- case ENTITY:
- if (isCreate) {
- structuralType = (EdmStructuralType) edmTyped.getType();
- EdmNavigationProperty navProperty = (EdmNavigationProperty) edmTyped;
- EdmEntitySet edmRelatedEntitySet = oDataEntitySet.getRelatedEntitySet(navProperty);
- List<ODataEntry> relatedEntries = (List<ODataEntry>) oDataEntryProperties.get(propertyName);
- if (relatedJPAEntityMap == null) {
- relatedJPAEntityMap = new HashMap<String, List<Object>>();
+
+ if (accessModifiersWrite == null) {
+ accessModifiersWrite = jpaEntityParser.getAccessModifiers(jpaEntity, oDataEntityType, JPAEntityParser.ACCESS_MODIFIER_SET);
+ }
+
+ if (oDataEntityType == null || oDataEntryProperties == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null);
+ }
+
+ final HashMap<String, String> embeddableKeys = jpaEntityParser.getJPAEmbeddableKeyMap(jpaEntity.getClass()
+ .getName());
+ Set<String> propertyNames = null;
+ if (embeddableKeys != null) {
+ setEmbeddableKeyProperty(embeddableKeys, oDataEntityType.getKeyProperties(), oDataEntryProperties, jpaEntity);
+
+ propertyNames = new HashSet<String>();
+ propertyNames.addAll(oDataEntryProperties.keySet());
+ for (String key : embeddableKeys.keySet()) {
+ propertyNames.remove(key);
+ }
+ } else {
+ propertyNames = oDataEntryProperties.keySet();
}
- List<Object> relatedJPAEntities = new ArrayList<Object>();
- for (ODataEntry oDataEntry : relatedEntries) {
- JPAEntity relatedEntity =
- new JPAEntity((EdmEntityType) structuralType, edmRelatedEntitySet, oDataJPAContext);
- relatedEntity.setParentJPAEntity(this);
- relatedEntity.setViaNavigationProperty(navProperty);
- relatedEntity.create(oDataEntry);
- if (oDataEntry.getProperties().size() == 0) {
- if (!oDataEntry.getMetadata().getUri().isEmpty()
- && !relatedJPAEntityLink.contains(navProperty.getName())) {
- relatedJPAEntityLink.add(navProperty.getName());
+
+ boolean isVirtual = false;
+ for (String propertyName : propertyNames) {
+ EdmTyped edmTyped = oDataEntityType.getProperty(propertyName);
+ if (edmTyped instanceof EdmProperty) {
+ isVirtual = ((JPAEdmMappingImpl) ((EdmProperty) edmTyped).getMapping()).isVirtualAccess();
+ } else {
+ isVirtual = false;
+ }
+ Method accessModifier = null;
+
+ switch (edmTyped.getType()
+ .getKind()) {
+ case SIMPLE:
+ if (!isCreate) {
+ if (keyNames.contains(edmTyped.getName())) {
+ continue;
+ }
+ }
+ accessModifier = accessModifiersWrite.get(propertyName);
+ EdmProperty edmProperty = (EdmProperty) oDataEntityType.getProperty(propertyName);
+ boolean isNullable = edmProperty.getFacets() == null ? (keyNames.contains(propertyName) ? false : true)
+ : edmProperty.getFacets()
+ .isNullable() == null ? true
+ : edmProperty.getFacets()
+ .isNullable();
+ if (isVirtual) {
+ setProperty(accessModifier, jpaEntity, oDataEntryProperties.get(propertyName),
+ (EdmSimpleType) edmTyped.getType(), isNullable);
+ } else {
+ setProperty(accessModifier, jpaEntity, oDataEntryProperties.get(propertyName),
+ (EdmSimpleType) edmTyped.getType(), isNullable);
+ }
+ break;
+ case COMPLEX:
+ structuralType = (EdmStructuralType) edmTyped.getType();
+ accessModifier = accessModifiersWrite.get(propertyName);
+ if (isVirtual) {
+ setComplexProperty(accessModifier, jpaEntity, structuralType,
+ (HashMap<String, Object>) oDataEntryProperties.get(propertyName), propertyName);
+ } else {
+ setComplexProperty(accessModifier, jpaEntity, structuralType,
+ (HashMap<String, Object>) oDataEntryProperties.get(propertyName));
+ }
+ break;
+ case NAVIGATION:
+ case ENTITY:
+ if (isCreate) {
+ structuralType = (EdmStructuralType) edmTyped.getType();
+ EdmNavigationProperty navProperty = (EdmNavigationProperty) edmTyped;
+ EdmEntitySet edmRelatedEntitySet = oDataEntitySet.getRelatedEntitySet(navProperty);
+ List<ODataEntry> relatedEntries = (List<ODataEntry>) oDataEntryProperties.get(propertyName);
+ if (relatedJPAEntityMap == null) {
+ relatedJPAEntityMap = new HashMap<String, List<Object>>();
+ }
+ List<Object> relatedJPAEntities = new ArrayList<Object>();
+ for (ODataEntry oDataEntry : relatedEntries) {
+ JPAEntity relatedEntity =
+ new JPAEntity((EdmEntityType) structuralType, edmRelatedEntitySet, oDataJPAContext);
+ relatedEntity.setParentJPAEntity(this);
+ relatedEntity.setViaNavigationProperty(navProperty);
+ relatedEntity.create(oDataEntry);
+ if (oDataEntry.getProperties()
+ .size() == 0) {
+ if (!oDataEntry.getMetadata()
+ .getUri()
+ .isEmpty()
+ && !relatedJPAEntityLink.contains(navProperty.getName())) {
+ relatedJPAEntityLink.add(navProperty.getName());
+ }
+ } else {
+ relatedJPAEntities.add(relatedEntity.getJPAEntity());
+ }
+ }
+ if (!relatedJPAEntities.isEmpty()) {
+ relatedJPAEntityMap.put(navProperty.getName(), relatedJPAEntities);
+ }
+ }
+ default:
}
- } else {
- relatedJPAEntities.add(relatedEntity.getJPAEntity());
- }
}
- if (!relatedJPAEntities.isEmpty()) {
- relatedJPAEntityMap.put(navProperty.getName(), relatedJPAEntities);
+ } catch (Exception e) {
+ if (e instanceof ODataJPARuntimeException) {
+ throw (ODataJPARuntimeException) e;
}
- }
- default:
- continue;
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
- }
- } catch (Exception e) {
- if (e instanceof ODataJPARuntimeException) {
- throw (ODataJPARuntimeException) e;
- }
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected void setComplexProperty(Method accessModifier, final Object jpaEntity,
- final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue, String propertyName)
- throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- InstantiationException, ODataJPARuntimeException, NoSuchMethodException, SecurityException, SQLException {
-
- JPAEdmMapping mapping = (JPAEdmMapping) edmComplexType.getMapping();
- Object embeddableObject = mapping.getJPAType().newInstance();
- if (propertyName != null) {
- accessModifier.invoke(jpaEntity, propertyName, embeddableObject);
- } else {
- accessModifier.invoke(jpaEntity, embeddableObject);
}
- HashMap<String, Method> accessModifiers =
- jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType,
- JPAEntityParser.ACCESS_MODIFIER_SET);
-
- for (String edmPropertyName : edmComplexType.getPropertyNames()) {
- if (propertyValue != null) {
- EdmTyped edmTyped = edmComplexType.getProperty(edmPropertyName);
- accessModifier = accessModifiers.get(edmPropertyName);
- EdmType type = edmTyped.getType();
- if (type.getKind().toString().equals(EdmTypeKind.COMPLEX.toString())) {
- setComplexProperty(accessModifier, embeddableObject, (EdmStructuralType) type,
- (HashMap<String, Object>) propertyValue.get(edmPropertyName), propertyName);
+ @SuppressWarnings("unchecked")
+ protected void setComplexProperty(Method accessModifier, final Object jpaEntity, final EdmStructuralType edmComplexType,
+ final HashMap<String, Object> propertyValue, String propertyName)
+ throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException,
+ ODataJPARuntimeException, NoSuchMethodException, SecurityException, SQLException {
+
+ JPAEdmMapping mapping = (JPAEdmMapping) edmComplexType.getMapping();
+ Object embeddableObject = mapping.getJPAType()
+ .newInstance();
+ if (propertyName != null) {
+ accessModifier.invoke(jpaEntity, propertyName, embeddableObject);
} else {
- EdmSimpleType simpleType = (EdmSimpleType) type;
- EdmProperty edmProperty = (EdmProperty)edmComplexType.getProperty(edmPropertyName);
- boolean isNullable = edmProperty.getFacets() == null ? true
- : edmProperty.getFacets().isNullable() == null ? true : edmProperty.getFacets().isNullable();
- if (propertyName != null) {
- setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName),
- simpleType, isNullable);
- } else {
- setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName),
- simpleType, isNullable);
- }
+ accessModifier.invoke(jpaEntity, embeddableObject);
}
- }
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- protected void setProperty(final Method method, final Object entity, final Object entityPropertyValue,
- final EdmSimpleType type, String propertyName, boolean isNullable) throws
- IllegalAccessException, IllegalArgumentException, InvocationTargetException, ODataJPARuntimeException,
- EdmException {
- if (entityPropertyValue != null || isNullable) {
- if (propertyName != null) {
- method.invoke(entity, propertyName, entityPropertyValue);
- return;
- }
- Class<?> parameterType = method.getParameterTypes()[0];
- if (type != null && type.getDefaultType().equals(String.class)) {
- if (parameterType.equals(String.class)) {
- method.invoke(entity, entityPropertyValue);
- } else if (parameterType.equals(char[].class)) {
- char[] characters = entityPropertyValue != null ? ((String) entityPropertyValue).toCharArray() : null;
- method.invoke(entity, characters);
- } else if (parameterType.equals(char.class)) {
- char c = entityPropertyValue != null ? ((String) entityPropertyValue).charAt(0) : '\u0000';
- method.invoke(entity, c);
- } else if (parameterType.equals(Character[].class)) {
- Character[] characters = entityPropertyValue != null ?
- JPAEntityParser.toCharacterArray((String) entityPropertyValue) : null;
- method.invoke(entity, (Object) characters);
- } else if (parameterType.equals(Character.class)) {
- Character c = entityPropertyValue != null ?
- Character.valueOf(((String) entityPropertyValue).charAt(0)) : null;
- method.invoke(entity, c);
- } else if (parameterType.isEnum()) {
- Enum e = entityPropertyValue != null ?
- Enum.valueOf((Class<Enum>) parameterType, (String) entityPropertyValue) : null;
- method.invoke(entity, e);
- } else {
- String setterName = method.getName();
- String getterName = setterName.replace("set", "get");
- try {
- Method getMethod = entity.getClass().getDeclaredMethod(getterName);
- if(getMethod.isAnnotationPresent(XmlJavaTypeAdapter.class)) {
- XmlAdapter xmlAdapter = getMethod.getAnnotation(XmlJavaTypeAdapter.class)
- .value().newInstance();
- method.invoke(entity, xmlAdapter.unmarshal(entityPropertyValue));
+
+ HashMap<String, Method> accessModifiers =
+ jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType, JPAEntityParser.ACCESS_MODIFIER_SET);
+
+ for (String edmPropertyName : edmComplexType.getPropertyNames()) {
+ if (propertyValue != null) {
+ EdmTyped edmTyped = edmComplexType.getProperty(edmPropertyName);
+ accessModifier = accessModifiers.get(edmPropertyName);
+ EdmType type = edmTyped.getType();
+ if (type.getKind()
+ .toString()
+ .equals(EdmTypeKind.COMPLEX.toString())) {
+ setComplexProperty(accessModifier, embeddableObject, (EdmStructuralType) type,
+ (HashMap<String, Object>) propertyValue.get(edmPropertyName), propertyName);
+ } else {
+ EdmSimpleType simpleType = (EdmSimpleType) type;
+ EdmProperty edmProperty = (EdmProperty) edmComplexType.getProperty(edmPropertyName);
+ boolean isNullable = edmProperty.getFacets() == null ? true
+ : edmProperty.getFacets()
+ .isNullable() == null ? true
+ : edmProperty.getFacets()
+ .isNullable();
+ if (propertyName != null) {
+ setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName), simpleType, isNullable);
+ } else {
+ setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName), simpleType, isNullable);
+ }
+ }
}
- } catch (Exception e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
- }
}
- } else if (parameterType.equals(Blob.class)) {
- if (onJPAWriteContent == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.ERROR_JPA_BLOB_NULL, null);
- } else {
- method.invoke(entity, entityPropertyValue != null ?
- onJPAWriteContent.getJPABlob((byte[]) entityPropertyValue) : null);
- }
- } else if (parameterType.equals(Clob.class)) {
- if (onJPAWriteContent == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.ERROR_JPA_CLOB_NULL, null);
- } else {
- method.invoke(entity, entityPropertyValue != null ?
- onJPAWriteContent.getJPAClob(((String) entityPropertyValue).toCharArray()) : null);
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ protected void setProperty(final Method method, final Object entity, final Object entityPropertyValue, final EdmSimpleType type,
+ String propertyName, boolean isNullable)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, ODataJPARuntimeException, EdmException {
+ if (entityPropertyValue != null || isNullable) {
+ if (propertyName != null) {
+ method.invoke(entity, propertyName, entityPropertyValue);
+ return;
+ }
+ Class<?> parameterType = method.getParameterTypes()[0];
+ if (type != null && type.getDefaultType()
+ .equals(String.class)) {
+ if (parameterType.equals(String.class)) {
+ method.invoke(entity, entityPropertyValue);
+ } else if (parameterType.equals(char[].class)) {
+ char[] characters = entityPropertyValue != null ? ((String) entityPropertyValue).toCharArray() : null;
+ method.invoke(entity, characters);
+ } else if (parameterType.equals(char.class)) {
+ char c = entityPropertyValue != null ? ((String) entityPropertyValue).charAt(0) : '\u0000';
+ method.invoke(entity, c);
+ } else if (parameterType.equals(Character[].class)) {
+ Character[] characters =
+ entityPropertyValue != null ? JPAEntityParser.toCharacterArray((String) entityPropertyValue) : null;
+ method.invoke(entity, (Object) characters);
+ } else if (parameterType.equals(Character.class)) {
+ Character c = entityPropertyValue != null ? Character.valueOf(((String) entityPropertyValue).charAt(0)) : null;
+ method.invoke(entity, c);
+ } else if (parameterType.isEnum()) {
+ Enum e = entityPropertyValue != null ? Enum.valueOf((Class<Enum>) parameterType, (String) entityPropertyValue) : null;
+ method.invoke(entity, e);
+ } else {
+ String setterName = method.getName();
+ String getterName = setterName.replace("set", "get");
+ try {
+ Method getMethod = entity.getClass()
+ .getDeclaredMethod(getterName);
+ if (getMethod.isAnnotationPresent(XmlJavaTypeAdapter.class)) {
+ XmlAdapter xmlAdapter = getMethod.getAnnotation(XmlJavaTypeAdapter.class)
+ .value()
+ .newInstance();
+ method.invoke(entity, xmlAdapter.unmarshal(entityPropertyValue));
+ }
+ } catch (Exception e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
+ }
+ }
+ } else if (parameterType.equals(Blob.class)) {
+ if (onJPAWriteContent == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPA_BLOB_NULL, null);
+ }
+ method.invoke(entity, entityPropertyValue != null ? onJPAWriteContent.getJPABlob((byte[]) entityPropertyValue) : null);
+ } else if (parameterType.equals(Clob.class)) {
+ if (onJPAWriteContent == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPA_CLOB_NULL, null);
+ }
+ method.invoke(entity,
+ entityPropertyValue != null ? onJPAWriteContent.getJPAClob(((String) entityPropertyValue).toCharArray()) : null);
+ } else if (parameterType.equals(Timestamp.class)) {
+ Timestamp ts = entityPropertyValue != null ? new Timestamp(((Calendar) entityPropertyValue).getTimeInMillis()) : null;
+ method.invoke(entity, ts);
+ } else if (parameterType.equals(java.util.Date.class)) {
+ Date d = entityPropertyValue != null ? ((Calendar) entityPropertyValue).getTime() : null;
+ method.invoke(entity, d);
+ } else if (parameterType.equals(java.sql.Date.class)) {
+ java.sql.Date d =
+ entityPropertyValue != null ? new java.sql.Date(((Calendar) entityPropertyValue).getTimeInMillis()) : null;
+ method.invoke(entity, d);
+ } else if (parameterType.equals(java.sql.Time.class)) {
+ java.sql.Time t =
+ entityPropertyValue != null ? new java.sql.Time(((Calendar) entityPropertyValue).getTimeInMillis()) : null;
+ method.invoke(entity, t);
+ } else if (parameterType.equals(byte.class)) {
+ byte b = entityPropertyValue != null ? Byte.parseByte(entityPropertyValue.toString()) : 0;
+ method.invoke(entity, b);
+ } else {
+ method.invoke(entity, entityPropertyValue);
+ }
}
- } else if (parameterType.equals(Timestamp.class)) {
- Timestamp ts = entityPropertyValue != null ?
- new Timestamp(((Calendar) entityPropertyValue).getTimeInMillis()) : null;
- method.invoke(entity, ts);
- } else if (parameterType.equals(java.util.Date.class)) {
- Date d = entityPropertyValue != null ? ((Calendar) entityPropertyValue).getTime(): null;
- method.invoke(entity, d);
- } else if (parameterType.equals(java.sql.Date.class)) {
- java.sql.Date d = entityPropertyValue != null ?
- new java.sql.Date(((Calendar) entityPropertyValue).getTimeInMillis()) : null;
- method.invoke(entity, d);
- } else if (parameterType.equals(java.sql.Time.class)) {
- java.sql.Time t = entityPropertyValue != null ?
- new java.sql.Time(((Calendar) entityPropertyValue).getTimeInMillis()) : null;
- method.invoke(entity, t);
- } else if (parameterType.equals(byte.class)) {
- byte b = entityPropertyValue != null ?
- Byte.parseByte(entityPropertyValue.toString()) : 0;
- method.invoke(entity, b);
- } else {
- method.invoke(entity, entityPropertyValue);
- }
}
- }
-}
\ No newline at end of file
+}
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPALink.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPALink.java
index c8a43943..a657b9eb 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPALink.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPALink.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
-import javax.persistence.EntityManager;
+import jakarta.persistence.EntityManager;
import org.apache.olingo.odata2.api.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.edm.EdmException;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
index 4f95e51e..16ff82d3 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
@@ -21,7 +21,7 @@ package org.apache.olingo.odata2.jpa.processor.core.access.data;
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Query;
+import jakarta.persistence.Query;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAPaging;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAProcessorImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAProcessorImpl.java
index 2aaef0d6..d498ed08 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAProcessorImpl.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAProcessorImpl.java
@@ -25,9 +25,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceException;
-import javax.persistence.Query;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.PersistenceException;
+import jakarta.persistence.Query;
import org.apache.olingo.odata2.api.commons.InlineCount;
import org.apache.olingo.odata2.api.edm.EdmEntitySet;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
index 24290bf8..9dd2f6bc 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
@@ -29,11 +29,11 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import javax.persistence.TemporalType;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.Query;
+import jakarta.persistence.TemporalType;
+import jakarta.persistence.metamodel.Attribute;
+import jakarta.persistence.metamodel.EntityType;
import org.apache.olingo.odata2.api.edm.EdmException;
import org.apache.olingo.odata2.api.uri.UriInfo;
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 69153ec1..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
@@ -1,31 +1,22 @@
/*******************************************************************************
- * 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;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmMappingModelAccess;
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelException;
@@ -36,235 +27,251 @@ import org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEmbeddableTyp
import org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAEntityTypeMapType;
import org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPAPersistenceUnitMapType;
import org.apache.olingo.odata2.jpa.processor.api.model.mapping.JPARelationshipMapType.JPARelationship;
+import jakarta.xml.bind.JAXBContext;
+import jakarta.xml.bind.JAXBException;
+import jakarta.xml.bind.Unmarshaller;
public class JPAEdmMappingModelService implements JPAEdmMappingModelAccess {
- boolean mappingModelExists = true;
- private JPAEdmMappingModel mappingModel;
- private InputStream mappingModelStream = null;
- private String mappingModelName;
-
- public JPAEdmMappingModelService(final ODataJPAContext ctx) {
- JPAEdmExtension ext = null;
- mappingModelName = ctx.getJPAEdmMappingModel();
- if (mappingModelName == null) {
- ext = ctx.getJPAEdmExtension();
- if (ext != null) {
- mappingModelStream = ext.getJPAEdmMappingModelStream();
- }
- }
-
- mappingModelExists = mappingModelName != null || mappingModelStream != null;
- }
-
- @Override
- public void loadMappingModel() {
- InputStream is = null;
- if (mappingModelExists) {
- JAXBContext context;
- try {
- context = JAXBContext.newInstance(JPAEdmMappingModel.class);
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- is = loadMappingModelInputStream();
- if (is == null) {
- mappingModelExists = false;
- return;
+ boolean mappingModelExists = true;
+ private JPAEdmMappingModel mappingModel;
+ private InputStream mappingModelStream = null;
+ private final String mappingModelName;
+
+ public JPAEdmMappingModelService(final ODataJPAContext ctx) {
+ JPAEdmExtension ext = null;
+ mappingModelName = ctx.getJPAEdmMappingModel();
+ if (mappingModelName == null) {
+ ext = ctx.getJPAEdmExtension();
+ if (ext != null) {
+ mappingModelStream = ext.getJPAEdmMappingModelStream();
+ }
}
- mappingModel = (JPAEdmMappingModel) unmarshaller.unmarshal(is);
+ mappingModelExists = mappingModelName != null || mappingModelStream != null;
+ }
- if (mappingModel != null) {
- mappingModelExists = true;
+ @Override
+ public void loadMappingModel() {
+ InputStream is = null;
+ if (mappingModelExists) {
+ JAXBContext context;
+ try {
+ context = JAXBContext.newInstance(JPAEdmMappingModel.class);
+
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ is = loadMappingModelInputStream();
+ if (is == null) {
+ mappingModelExists = false;
+ return;
+ }
+
+ mappingModel = (JPAEdmMappingModel) unmarshaller.unmarshal(is);
+
+ if (mappingModel != null) {
+ mappingModelExists = true;
+ }
+
+ } catch (JAXBException e) {
+ mappingModelExists = false;
+ ODataJPAModelException ex = ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e);
+ throw new IllegalStateException("Failed to load model", ex);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
}
+ }
- } catch (JAXBException e) {
- mappingModelExists = false;
- ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e);
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- // do nothing
- }
- }
+ @Override
+ public boolean isMappingModelExists() {
+ return mappingModelExists;
}
- }
- @Override
- public boolean isMappingModelExists() {
- return mappingModelExists;
- }
+ @Override
+ public JPAEdmMappingModel getJPAEdmMappingModel() {
+ return mappingModel;
+ }
- @Override
- public JPAEdmMappingModel getJPAEdmMappingModel() {
- return mappingModel;
- }
+ @Override
+ public String mapJPAPersistenceUnit(final String persistenceUnitName) {
- @Override
- public String mapJPAPersistenceUnit(final String persistenceUnitName) {
+ JPAPersistenceUnitMapType persistenceUnit = mappingModel.getPersistenceUnit();
+ if (persistenceUnit.getName()
+ .equals(persistenceUnitName)) {
+ return persistenceUnit.getEDMSchemaNamespace();
+ }
- JPAPersistenceUnitMapType persistenceUnit = mappingModel.getPersistenceUnit();
- if (persistenceUnit.getName().equals(persistenceUnitName)) {
- return persistenceUnit.getEDMSchemaNamespace();
+ return null;
}
- return null;
- }
+ @Override
+ public String mapJPAEntityType(final String jpaEntityTypeName) {
- @Override
- public String mapJPAEntityType(final String jpaEntityTypeName) {
-
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null) {
- return jpaEntityTypeMap.getEDMEntityType();
- } else {
- return null;
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null) {
+ return jpaEntityTypeMap.getEDMEntityType();
+ }
+ return null;
}
- }
- @Override
- public String mapJPAEntitySet(final String jpaEntityTypeName) {
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null) {
- return jpaEntityTypeMap.getEDMEntitySet();
- } else {
- return null;
+ @Override
+ public String mapJPAEntitySet(final String jpaEntityTypeName) {
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null) {
+ return jpaEntityTypeMap.getEDMEntitySet();
+ }
+ return null;
}
- }
- @Override
- public String mapJPAAttribute(final String jpaEntityTypeName, final String jpaAttributeName) {
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPAAttributes() != null) {
- // fixing attributes
- // removal issue
- // from mapping
- for (JPAAttribute jpaAttribute : jpaEntityTypeMap.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.getValue();
+ @Override
+ public String mapJPAAttribute(final String jpaEntityTypeName, final String jpaAttributeName) {
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPAAttributes() != null) {
+ // fixing attributes
+ // removal issue
+ // from mapping
+ for (JPAAttribute jpaAttribute : jpaEntityTypeMap.getJPAAttributes()
+ .getJPAAttribute()) {
+ if (jpaAttribute.getName()
+ .equals(jpaAttributeName)) {
+ return jpaAttribute.getValue();
+ }
+ }
}
- }
- }
- return null;
- }
+ return null;
+ }
- @Override
- public String mapJPARelationship(final String jpaEntityTypeName, final String jpaRelationshipName) {
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPARelationships() != null) {
- for (JPARelationship jpaRealtionship : jpaEntityTypeMap.getJPARelationships().getJPARelationship()) {
- if (jpaRealtionship.getName().equals(jpaRelationshipName)) {
- return jpaRealtionship.getValue();
+ @Override
+ public String mapJPARelationship(final String jpaEntityTypeName, final String jpaRelationshipName) {
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPARelationships() != null) {
+ for (JPARelationship jpaRealtionship : jpaEntityTypeMap.getJPARelationships()
+ .getJPARelationship()) {
+ if (jpaRealtionship.getName()
+ .equals(jpaRelationshipName)) {
+ return jpaRealtionship.getValue();
+ }
+ }
}
- }
- }
- return null;
- }
+ return null;
+ }
- @Override
- public String mapJPAEmbeddableType(final String jpaEmbeddableTypeName) {
- JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (jpaEmbeddableType != null) {
- return jpaEmbeddableType.getEDMComplexType();
- } else {
- return null;
+ @Override
+ public String mapJPAEmbeddableType(final String jpaEmbeddableTypeName) {
+ JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (jpaEmbeddableType != null) {
+ return jpaEmbeddableType.getEDMComplexType();
+ }
+ return null;
}
- }
- @Override
- public String mapJPAEmbeddableTypeAttribute(final String jpaEmbeddableTypeName, final String jpaAttributeName) {
- JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (jpaEmbeddableType != null && jpaEmbeddableType.getJPAAttributes() != null) {
- for (JPAAttribute jpaAttribute : jpaEmbeddableType.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.getValue();
+ @Override
+ public String mapJPAEmbeddableTypeAttribute(final String jpaEmbeddableTypeName, final String jpaAttributeName) {
+ JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (jpaEmbeddableType != null && jpaEmbeddableType.getJPAAttributes() != null) {
+ for (JPAAttribute jpaAttribute : jpaEmbeddableType.getJPAAttributes()
+ .getJPAAttribute()) {
+ if (jpaAttribute.getName()
+ .equals(jpaAttributeName)) {
+ return jpaAttribute.getValue();
+ }
+ }
}
- }
+ return null;
}
- return null;
- }
- private JPAEntityTypeMapType searchJPAEntityTypeMapType(final String jpaEntityTypeName) {
- if (mappingModel != null) {
- List<JPAEntityTypeMapType> types = mappingModel.getPersistenceUnit().getJPAEntityTypes().getJPAEntityType();
- for (JPAEntityTypeMapType jpaEntityType : types) {
- if (jpaEntityType.getName().equals(jpaEntityTypeName)) {
- return jpaEntityType;
+ private JPAEntityTypeMapType searchJPAEntityTypeMapType(final String jpaEntityTypeName) {
+ if (mappingModel != null) {
+ List<JPAEntityTypeMapType> types = mappingModel.getPersistenceUnit()
+ .getJPAEntityTypes()
+ .getJPAEntityType();
+ for (JPAEntityTypeMapType jpaEntityType : types) {
+ if (jpaEntityType.getName()
+ .equals(jpaEntityTypeName)) {
+ return jpaEntityType;
+ }
+ }
}
- }
+ return null;
}
- return null;
- }
- private JPAEmbeddableTypeMapType searchJPAEmbeddableTypeMapType(final String jpaEmbeddableTypeName) {
- if (null != mappingModel.getPersistenceUnit() &&
- null != mappingModel.getPersistenceUnit().getJPAEmbeddableTypes()) {
- for (JPAEmbeddableTypeMapType jpaEmbeddableType : mappingModel.getPersistenceUnit().getJPAEmbeddableTypes()
- .getJPAEmbeddableType()) {
- if (jpaEmbeddableType.getName().equals(jpaEmbeddableTypeName)) {
- return jpaEmbeddableType;
+ private JPAEmbeddableTypeMapType searchJPAEmbeddableTypeMapType(final String jpaEmbeddableTypeName) {
+ if (null != mappingModel.getPersistenceUnit() && null != mappingModel.getPersistenceUnit()
+ .getJPAEmbeddableTypes()) {
+ for (JPAEmbeddableTypeMapType jpaEmbeddableType : mappingModel.getPersistenceUnit()
+ .getJPAEmbeddableTypes()
+ .getJPAEmbeddableType()) {
+ if (jpaEmbeddableType.getName()
+ .equals(jpaEmbeddableTypeName)) {
+ return jpaEmbeddableType;
+ }
+ }
}
- }
+ return null;
}
- return null;
- }
- protected InputStream loadMappingModelInputStream() {
- if (mappingModelStream != null) {
- return mappingModelStream;
+ protected InputStream loadMappingModelInputStream() {
+ if (mappingModelStream != null) {
+ return mappingModelStream;
+ }
+ ClassLoader classLoader = JPAEdmMappingModelService.class.getClassLoader();
+ InputStream modelStream = classLoader.getResourceAsStream("../../" + mappingModelName);
+ return (modelStream != null) ? modelStream : classLoader.getResourceAsStream(mappingModelName);
}
- ClassLoader classLoader = JPAEdmMappingModelService.class.getClassLoader();
- InputStream modelStream = classLoader.getResourceAsStream("../../" + mappingModelName);
- return (modelStream != null) ? modelStream : classLoader.getResourceAsStream(mappingModelName);
- }
- @Override
- public boolean checkExclusionOfJPAEntityType(final String jpaEntityTypeName) {
- JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (type != null) {
- return type.isExclude();
+ @Override
+ public boolean checkExclusionOfJPAEntityType(final String jpaEntityTypeName) {
+ JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (type != null) {
+ return type.isExclude();
+ }
+ return false;
}
- return false;
- }
- @Override
- public boolean checkExclusionOfJPAAttributeType(final String jpaEntityTypeName, final String jpaAttributeName) {
- JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (type != null && type.getJPAAttributes() != null) {
- for (JPAAttribute jpaAttribute : type.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.isExclude();
+ @Override
+ public boolean checkExclusionOfJPAAttributeType(final String jpaEntityTypeName, final String jpaAttributeName) {
+ JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (type != null && type.getJPAAttributes() != null) {
+ for (JPAAttribute jpaAttribute : type.getJPAAttributes()
+ .getJPAAttribute()) {
+ if (jpaAttribute.getName()
+ .equals(jpaAttributeName)) {
+ return jpaAttribute.isExclude();
+ }
+ }
}
- }
+ return false;
}
- return false;
- }
- @Override
- public boolean checkExclusionOfJPAEmbeddableType(final String jpaEmbeddableTypeName) {
- JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (type != null) {
- return type.isExclude();
+ @Override
+ public boolean checkExclusionOfJPAEmbeddableType(final String jpaEmbeddableTypeName) {
+ JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (type != null) {
+ return type.isExclude();
+ }
+ return false;
}
- return false;
- }
- @Override
- public boolean checkExclusionOfJPAEmbeddableAttributeType(final String jpaEmbeddableTypeName,
- final String jpaAttributeName) {
- JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (type != null && type.getJPAAttributes() != null) {
- for (JPAAttribute jpaAttribute : type.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.isExclude();
+ @Override
+ public boolean checkExclusionOfJPAEmbeddableAttributeType(final String jpaEmbeddableTypeName, final String jpaAttributeName) {
+ JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (type != null && type.getJPAAttributes() != null) {
+ for (JPAAttribute jpaAttribute : type.getJPAAttributes()
+ .getJPAAttribute()) {
+ if (jpaAttribute.getName()
+ .equals(jpaAttributeName)) {
+ return jpaAttribute.isExclude();
+ }
+ }
}
- }
+ return false;
}
- return false;
- }
}
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
index 675cfc0a..0be8adb3 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
@@ -21,10 +21,10 @@ package org.apache.olingo.odata2.jpa.processor.core.access.model;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
-import javax.persistence.Column;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.PluralAttribute;
+import jakarta.persistence.Column;
+import jakarta.persistence.metamodel.Attribute;
+import jakarta.persistence.metamodel.ManagedType;
+import jakarta.persistence.metamodel.PluralAttribute;
import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
import org.apache.olingo.odata2.api.edm.FullQualifiedName;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPATypeConverter.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPATypeConverter.java
index ec3b4939..579a1f59 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPATypeConverter.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPATypeConverter.java
@@ -29,12 +29,12 @@ import java.sql.Timestamp;
import java.util.Calendar;
import java.util.UUID;
-import javax.persistence.Lob;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.metamodel.Attribute;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import jakarta.persistence.Lob;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
+import jakarta.persistence.metamodel.Attribute;
+import jakarta.xml.bind.annotation.adapters.XmlAdapter;
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelException;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmAssociationEnd.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmAssociationEnd.java
index c2cbd114..a3ff8892 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmAssociationEnd.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmAssociationEnd.java
@@ -28,11 +28,11 @@ import org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmEntityTypeView;
import org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmPropertyView;
import org.apache.olingo.odata2.jpa.processor.core.access.model.JPAEdmNameBuilder;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+import jakarta.persistence.ManyToMany;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.OneToOne;
+import jakarta.persistence.metamodel.Attribute.PersistentAttributeType;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array;
import java.util.List;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmBaseViewImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmBaseViewImpl.java
index 80d9d75a..3af7b37f 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmBaseViewImpl.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmBaseViewImpl.java
@@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata2.jpa.processor.core.model;
-import javax.persistence.metamodel.Metamodel;
+import jakarta.persistence.metamodel.Metamodel;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmBuilder;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmComplexType.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmComplexType.java
index c033494e..940adb5f 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmComplexType.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmComplexType.java
@@ -24,8 +24,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EmbeddableType;
+import jakarta.persistence.metamodel.Attribute;
+import jakarta.persistence.metamodel.EmbeddableType;
import org.apache.olingo.odata2.api.edm.FullQualifiedName;
import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmEntityType.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmEntityType.java
index 0e98cd6a..6b84d1ae 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmEntityType.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmEntityType.java
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Set;
-import javax.persistence.EntityListeners;
+import jakarta.persistence.EntityListeners;
import org.apache.olingo.odata2.api.edm.provider.EntityType;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPATombstoneEntityListener;
@@ -46,7 +46,7 @@ public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntity
private JPAEdmSchemaView schemaView = null;
private EntityType currentEdmEntityType = null;
- private javax.persistence.metamodel.EntityType<?> currentJPAEntityType = null;
+ private jakarta.persistence.metamodel.EntityType<?> currentJPAEntityType = null;
private EntityTypeList<EntityType> consistentEntityTypes = null;
private HashMap<String, EntityType> consistentEntityTypeMap;
@@ -72,7 +72,7 @@ public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntity
}
@Override
- public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
+ public jakarta.persistence.metamodel.EntityType<?> getJPAEntityType() {
return currentJPAEntityType;
}
@@ -92,7 +92,7 @@ public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntity
@Override
public void build() throws ODataJPAModelException, ODataJPARuntimeException {
- Collection<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities();
+ Collection<jakarta.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities();
if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true) {
return;
@@ -102,7 +102,7 @@ public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntity
}
jpaEntityTypes = sortJPAEntityTypes(jpaEntityTypes);
- for (javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
+ for (jakarta.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
currentEdmEntityType = new EntityType();
currentJPAEntityType = jpaEntityType;
@@ -144,15 +144,15 @@ public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntity
}
- private List<javax.persistence.metamodel.EntityType<?>> sortJPAEntityTypes(
- final Collection<javax.persistence.metamodel.EntityType<?>> entities) {
+ private List<jakarta.persistence.metamodel.EntityType<?>> sortJPAEntityTypes(
+ final Collection<jakarta.persistence.metamodel.EntityType<?>> entities) {
- List<javax.persistence.metamodel.EntityType<?>> entityTypeList =
- new ArrayList<javax.persistence.metamodel.EntityType<?>>(entities.size());
+ List<jakarta.persistence.metamodel.EntityType<?>> entityTypeList =
+ new ArrayList<jakarta.persistence.metamodel.EntityType<?>>(entities.size());
- Iterator<javax.persistence.metamodel.EntityType<?>> itr;
- javax.persistence.metamodel.EntityType<?> smallestJpaEntity;
- javax.persistence.metamodel.EntityType<?> currentJpaEntity;
+ Iterator<jakarta.persistence.metamodel.EntityType<?>> itr;
+ jakarta.persistence.metamodel.EntityType<?> smallestJpaEntity;
+ jakarta.persistence.metamodel.EntityType<?> currentJpaEntity;
while (!entities.isEmpty()) {
itr = entities.iterator();
smallestJpaEntity = itr.next();
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmFacets.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmFacets.java
index 04c795ea..abf1ed09 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmFacets.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmFacets.java
@@ -20,8 +20,8 @@ package org.apache.olingo.odata2.jpa.processor.core.model;
import java.lang.reflect.AnnotatedElement;
-import javax.persistence.Column;
-import javax.persistence.metamodel.Attribute;
+import jakarta.persistence.Column;
+import jakarta.persistence.metamodel.Attribute;
import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
import org.apache.olingo.odata2.api.edm.provider.Facets;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmModel.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmModel.java
index 966bdd0b..568c5208 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmModel.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmModel.java
@@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata2.jpa.processor.core.model;
-import javax.persistence.metamodel.Metamodel;
+import jakarta.persistence.metamodel.Metamodel;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmBuilder;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmProperty.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmProperty.java
index 2e2c2be4..e1cdd3ec 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmProperty.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmProperty.java
@@ -26,17 +26,17 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
-import javax.persistence.Column;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.Attribute.PersistentAttributeType;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.SingularAttribute;
+import jakarta.persistence.AttributeOverride;
+import jakarta.persistence.AttributeOverrides;
+import jakarta.persistence.Column;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinColumns;
+import jakarta.persistence.metamodel.Attribute;
+import jakarta.persistence.metamodel.Attribute.PersistentAttributeType;
+import jakarta.persistence.metamodel.EmbeddableType;
+import jakarta.persistence.metamodel.EntityType;
+import jakarta.persistence.metamodel.PluralAttribute;
+import jakarta.persistence.metamodel.SingularAttribute;
import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
import org.apache.olingo.odata2.api.edm.FullQualifiedName;
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmReferentialConstraintRole.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmReferentialConstraintRole.java
index 9c3c89ea..c66290e2 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmReferentialConstraintRole.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/model/JPAEdmReferentialConstraintRole.java
@@ -23,7 +23,7 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.metamodel.Attribute;
+import jakarta.persistence.metamodel.Attribute;
import org.apache.olingo.odata2.api.edm.provider.Association;
import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImplTest.java
index 83952d0d..46bd5a1d 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImplTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImplTest.java
@@ -24,8 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
import org.apache.olingo.odata2.api.processor.ODataContext;
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 f607151c..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
@@ -1,26 +1,21 @@
/*******************************************************************************
- * 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;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
@@ -29,15 +24,8 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Query;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.InlineCount;
import org.apache.olingo.odata2.api.edm.EdmConcurrencyMode;
@@ -69,7 +57,6 @@ import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPADefaultProcessor;
import org.apache.olingo.odata2.jpa.processor.api.ODataJPATransaction;
-import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelException;
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
import org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmMapping;
import org.apache.olingo.odata2.jpa.processor.core.common.ODataJPATestConstants;
@@ -82,508 +69,617 @@ import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityTransaction;
+import jakarta.persistence.Query;
+import jakarta.persistence.metamodel.EntityType;
+import jakarta.persistence.metamodel.Metamodel;
public class ODataJPADefaultProcessorTest extends JPAEdmTestModelView {
- private ODataJPADefaultProcessor objODataJPAProcessorDefault;
-
- private static final String STR_LOCAL_URI = "http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/";
- private static final String SALESORDERPROCESSING_CONTAINER = "salesorderprocessingContainer";
- private static final String SO_ID = "SoId";
- private static final String SALES_ORDER = "SalesOrder";
- private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
- private static final String STR_CONTENT_TYPE = "Content-Type";
-
- @Before
- public void setUp() {
- objODataJPAProcessorDefault = new ODataJPADefaultProcessor(getLocalmockODataJPAContext()) { };
- }
-
- @Test
- public void testReadEntitySetGetEntitySetUriInfoString() {
- try {
- GetEntityUriInfo getEntityView = getEntityUriInfo();
- Assert.assertNotNull(objODataJPAProcessorDefault.readEntity(getEntityView, HttpContentType.APPLICATION_XML));
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPARuntimeException e1) {// Expected
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testcountEntitySet() {
- try {
- ODataResponse countEntitySet =
- objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML);
- Assert.assertNotNull(countEntitySet);
- Object entity = countEntitySet.getEntity();
- Assert.assertNotNull(entity);
-
- byte[] b = new byte[2];
- ((ByteArrayInputStream) entity).read(b);
- Assert.assertEquals("11", new String(b, Charset.forName("utf-8")));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (Exception e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testExistsEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.existsEntity(getEntityCountUriInfo(),
- HttpContentType.APPLICATION_XML));
- Assert.assertNull("ContentType MUST NOT set by entity provider", objODataJPAProcessorDefault.existsEntity(
- getEntityCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (Exception e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testDeleteEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.deleteEntity(getDeletetUriInfo(),
- HttpContentType.APPLICATION_XML));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testCreateEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.createEntity(getPostUriInfo(), getMockedInputStreamContent(),
- HttpContentType.APPLICATION_XML, HttpContentType.APPLICATION_XML));
- } catch (ODataException e) {
- Assert.assertTrue(true); // Expected TODO - need to revisit
- }
- }
-
- @Test
- public void testUpdateEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.updateEntity(getPutUriInfo(), getMockedInputStreamContent(),
- HttpContentType.APPLICATION_XML, false, HttpContentType.APPLICATION_XML));
- } catch (ODataException e) {
- Assert.assertTrue(true); // Expected TODO - need to revisit
- }
- }
-
- private PutMergePatchUriInfo getPutUriInfo() {
- return (PutMergePatchUriInfo) getDeletetUriInfo();
- }
-
- private PostUriInfo getPostUriInfo() {
- return (PostUriInfo) getDeletetUriInfo();
- }
-
- private InputStream getMockedInputStreamContent() {
- return new ByteArrayInputStream(getEntityBody().getBytes());
- }
-
- private String getEntityBody() {
- return "<entry xmlns=\"http://www.w3.org/2005/Atom\" " +
- "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" " +
- "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" " +
- "xml:base=\"http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/\">"
- + "<content type=\"application/xml\">"
- + "<m:properties>"
- + "<d:ID>2</d:ID>"
- + "<d:CreationDate>2013-01-02T00:00:00</d:CreationDate>"
- + "<d:CurrencyCode>Code_555</d:CurrencyCode>"
- + "<d:BuyerAddressInfo m:type=\"SalesOrderProcessing.AddressInfo\">"
- + "<d:Street>Test_Street_Name_055</d:Street>"
- + "<d:Number>2</d:Number>"
- + "<d:Country>Test_Country_2</d:Country>"
- + "<d:City>Test_City_2</d:City>"
- + "</d:BuyerAddressInfo>"
- + "<d:GrossAmount>0.0</d:GrossAmount>"
- + "<d:BuyerId>2</d:BuyerId>"
- + "<d:DeliveryStatus>true</d:DeliveryStatus>"
- + "<d:BuyerName>buyerName_2</d:BuyerName>"
- + "<d:NetAmount>0.0</d:NetAmount>" + "</m:properties>" + "</content>" + "</entry>";
- }
-
- private GetEntitySetCountUriInfo getEntitySetCountUriInfo() {
- return getLocalUriInfo();
- }
-
- private GetEntityCountUriInfo getEntityCountUriInfo() {
- return getLocalUriInfo();
- }
-
- private DeleteUriInfo getDeletetUriInfo() {
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(objUriInfo.getNavigationSegments()).andReturn(navSegments).anyTimes();
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates());
- EasyMock.expect(objUriInfo.isLinks()).andStubReturn(false);
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- private List<KeyPredicate> getKeyPredicates() {
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- return keyPredicates;
- }
-
- /**
- * @return
- */
- private UriInfo getLocalUriInfo() {
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(objUriInfo.getNavigationSegments()).andReturn(navSegments).anyTimes();
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- /**
- * @return
- * @throws EdmException
- */
- private EdmEntitySet getLocalEdmEntitySet() {
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
- EasyMock.replay(edmEntitySet);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return edmEntitySet;
- }
-
- /**
- * @return
- * @throws EdmException
- */
- private EdmEntityType getLocalEdmEntityType() {
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
- EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SALES_ORDER));
- EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn((EdmMapping) getEdmMappingMockedObj(SALES_ORDER));
- EasyMock.replay(edmEntityType);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return edmEntityType;
- }
-
- private InlineCount getInlineCount() {
- return InlineCount.NONE;
- }
-
- private FilterExpression getFilter() {
- return null;
- }
-
- private Integer getSkip() {
- return null;
- }
-
- private Integer getTop() {
- return null;
- }
-
- private OrderByExpression getOrderByExpression() {
- return null;
- }
-
- private ODataJPAContext getLocalmockODataJPAContext() {
- ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
- EasyMock.expect(odataJPAContext.getPageSize()).andReturn(0).anyTimes();
- EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn("salesorderprocessing");
- EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory());
- EasyMock.expect(odataJPAContext.getODataJPATransaction()).andStubReturn(getLocalJpaTransaction());
- EasyMock.expect(odataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
- odataJPAContext.setODataContext((ODataContext) EasyMock.anyObject());
- EasyMock.expectLastCall().anyTimes();
- EasyMock.expect(odataJPAContext.getEntityManager()).andStubReturn(getLocalEntityManager());
- EasyMock.expect(odataJPAContext.isContainerManaged()).andReturn(false);
- EasyMock.expectLastCall().anyTimes();
- EasyMock.replay(odataJPAContext);
- return odataJPAContext;
- }
-
- private ODataJPATransaction getLocalJpaTransaction() {
- ODataJPATransaction tx = EasyMock.createMock(ODataJPATransaction.class);
- tx.begin(); // testing void method
- tx.commit();// testing void method
- tx.rollback();// testing void method
- EasyMock.expect(tx.isActive()).andReturn(false);
- EasyMock.expect(tx.isActive()).andReturn(false);
- EasyMock.replay(tx);
- return tx;
- }
-
- private EntityManagerFactory mockEntityManagerFactory() {
- EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
- EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
- EasyMock.expect(emf.createEntityManager()).andStubReturn(getLocalEntityManager());
- EasyMock.replay(emf);
- return emf;
- }
-
- private EntityManagerFactory mockEntityManagerFactory2() {// For create, to avoid stackoverflow
- EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
- EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
- EasyMock.replay(emf);
- return emf;
- }
-
- private EntityManager getLocalEntityManager() {
- EntityManager em = EasyMock.createMock(EntityManager.class);
- EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
- EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(
- getQueryForSelectCount());
- EasyMock.expect(em.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory2());// For create
- EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction()); // For Delete
- EasyMock.expect(em.isOpen()).andReturn(true).anyTimes();
- Address obj = new Address();
- em.remove(obj);// testing void method
- em.flush();
- em.close();
- EasyMock.expectLastCall().anyTimes();
- EasyMock.replay(em);
- return em;
- }
-
- private EntityTransaction getLocalTransaction() {
- EntityTransaction entityTransaction = EasyMock.createMock(EntityTransaction.class);
- entityTransaction.begin(); // testing void method
- entityTransaction.commit();// testing void method
- entityTransaction.rollback();// testing void method
- EasyMock.expect(entityTransaction.isActive()).andReturn(false);
- EasyMock.replay(entityTransaction);
- return entityTransaction;
- }
-
- private Query getQuery() {
- Query query = EasyMock.createMock(Query.class);
- EasyMock.expect(query.getResultList()).andStubReturn(getResultList());
- EasyMock.replay(query);
- return query;
- }
-
- private Query getQueryForSelectCount() {
- Query query = EasyMock.createMock(Query.class);
- EasyMock.expect(query.getResultList()).andStubReturn(getResultListForSelectCount());
- EasyMock.replay(query);
- return query;
- }
-
- private List<?> getResultList() {
- List<Object> list = new ArrayList<Object>();
- list.add(new Address());
- return list;
- }
-
- private List<?> getResultListForSelectCount() {
- List<Object> list = new ArrayList<Object>();
- list.add(new Long(11));
- return list;
- }
-
- class Address {
- private String soId = "12";
-
- public String getSoId() {
- return soId;
- }
-
- @Override
- public boolean equals(final Object obj) {
- boolean isEqual = false;
- if (obj instanceof Address) {
- isEqual = getSoId().equalsIgnoreCase(((Address) obj).getSoId());//
- }
- return isEqual;
- }
- }
-
- private Metamodel mockMetaModel() {
- Metamodel metaModel = EasyMock.createMock(Metamodel.class);
- EasyMock.expect(metaModel.getEntities()).andStubReturn(getLocalEntities());
- EasyMock.replay(metaModel);
- return metaModel;
- }
-
- private Set<EntityType<?>> getLocalEntities() {
- Set<EntityType<?>> entityTypeSet = new HashSet<EntityType<?>>();
- entityTypeSet.add(getLocalJPAEntityType());
- return entityTypeSet;
- }
-
- @SuppressWarnings("rawtypes")
- private EntityType<EntityType> getLocalJPAEntityType() {
- @SuppressWarnings("unchecked")
- EntityType<EntityType> entityType = EasyMock.createMock(EntityType.class);
- EasyMock.expect(entityType.getJavaType()).andStubReturn(EntityType.class);
- EasyMock.replay(entityType);
- return entityType;
- }
-
- private GetEntityUriInfo getEntityUriInfo() {
- GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(getEntityView.getExpand()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
-
- EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
- EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
- EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SO_ID));
-
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn((EdmMapping) getEdmMappingMockedObj(SALES_ORDER));
-
- EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
-
- EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
-
- EasyMock.replay(edmEntityType, edmEntitySet);
- EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(getEntityView.getNavigationSegments()).andReturn(navigationSegments);
- EasyMock.expect(getEntityView.getStartEntitySet()).andReturn(edmEntitySet);
-
- EasyMock.replay(getEntityView);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return getEntityView;
- }
-
- private EdmEntityContainer getLocalEdmEntityContainer() {
- EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
- EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
- try {
- EasyMock.expect(edmEntityContainer.getName()).andStubReturn(SALESORDERPROCESSING_CONTAINER);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(edmEntityContainer);
- return edmEntityContainer;
- }
-
- private EdmTyped getEdmTypedMockedObj(final String propertyName) {
- EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
- try {
- EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn((EdmMapping) getEdmMappingMockedObj(propertyName));
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType);
- EasyMock.expect(mockedEdmProperty.getName()).andStubReturn("identifier");
- EasyMock.expect(mockedEdmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(mockedEdmProperty.getFacets()).andStubReturn(getEdmFacetsMockedObj());
-
- EasyMock.replay(mockedEdmProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return mockedEdmProperty;
- }
-
- private EdmFacets getEdmFacetsMockedObj() {
- EdmFacets facets = EasyMock.createMock(EdmFacets.class);
- EasyMock.expect(facets.getConcurrencyMode()).andStubReturn(EdmConcurrencyMode.Fixed);
-
- EasyMock.replay(facets);
- return facets;
- }
-
- private JPAEdmMapping getEdmMappingMockedObj(final String propertyName) {
- JPAEdmMappingImpl mockedEdmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- if (propertyName.equalsIgnoreCase(SALES_ORDER)) {
- EasyMock.expect(((EdmMapping) mockedEdmMapping).getInternalName()).andStubReturn(SALES_ORDER_HEADERS);
- } else {
- EasyMock.expect(((EdmMapping) mockedEdmMapping).getInternalName()).andStubReturn(propertyName);
- }
- EasyMock.expect(mockedEdmMapping.getODataJPATombstoneEntityListener()).andReturn(null);
- EasyMock.<Class<?>> expect(mockedEdmMapping.getJPAType()).andReturn(SalesOrderHeader.class);
- EasyMock.replay(mockedEdmMapping);
- return mockedEdmMapping;
- }
-
- private List<String> getLocalPropertyNames() {
- List<String> list = new ArrayList<String>();
- list.add(SO_ID);
- return list;
- }
-
- private ODataContext getLocalODataContext() {
- ODataContext objODataContext = null;
- try {
- ODataContextMock contextMock = new ODataContextMock();
- contextMock.setODataService(new ODataServiceMock().mock());
- contextMock.setPathInfo(getLocalPathInfo());
- objODataContext = contextMock.mock();
-
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return objODataContext;
- }
-
- private PathInfo getLocalPathInfo() {
- PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
- EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
- EasyMock.replay(pathInfo);
- return pathInfo;
- }
-
- private URI getLocalURI() {
- URI uri = null;
- try {
- uri = new URI(STR_LOCAL_URI);
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return uri;
- }
+ private ODataJPADefaultProcessor objODataJPAProcessorDefault;
+
+ private static final String STR_LOCAL_URI = "http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/";
+ private static final String SALESORDERPROCESSING_CONTAINER = "salesorderprocessingContainer";
+ private static final String SO_ID = "SoId";
+ private static final String SALES_ORDER = "SalesOrder";
+ private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
+ private static final String STR_CONTENT_TYPE = "Content-Type";
+
+ @Before
+ public void setUp() {
+ objODataJPAProcessorDefault = new ODataJPADefaultProcessor(getLocalmockODataJPAContext()) {};
+ }
+
+ @Test
+ public void testReadEntitySetGetEntitySetUriInfoString() {
+ try {
+ GetEntityUriInfo getEntityView = getEntityUriInfo();
+ Assert.assertNotNull(objODataJPAProcessorDefault.readEntity(getEntityView, HttpContentType.APPLICATION_XML));
+ } catch (ODataJPARuntimeException e1) {// Expected
+ assertTrue(true);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testcountEntitySet() {
+ try {
+ ODataResponse countEntitySet =
+ objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML);
+ Assert.assertNotNull(countEntitySet);
+ Object entity = countEntitySet.getEntity();
+ Assert.assertNotNull(entity);
+
+ byte[] b = new byte[2];
+ ((ByteArrayInputStream) entity).read(b);
+ Assert.assertEquals("11", new String(b, Charset.forName("utf-8")));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testExistsEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.existsEntity(getEntityCountUriInfo(), HttpContentType.APPLICATION_XML));
+ Assert.assertNull("ContentType MUST NOT set by entity provider",
+ objODataJPAProcessorDefault.existsEntity(getEntityCountUriInfo(), HttpContentType.APPLICATION_XML)
+ .getHeader(STR_CONTENT_TYPE));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testDeleteEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.deleteEntity(getDeletetUriInfo(), HttpContentType.APPLICATION_XML));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testCreateEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.createEntity(getPostUriInfo(), getMockedInputStreamContent(),
+ HttpContentType.APPLICATION_XML, HttpContentType.APPLICATION_XML));
+ } catch (ODataException e) {
+ Assert.assertTrue(true); // Expected TODO - need to revisit
+ }
+ }
+
+ @Test
+ public void testUpdateEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.updateEntity(getPutUriInfo(), getMockedInputStreamContent(),
+ HttpContentType.APPLICATION_XML, false, HttpContentType.APPLICATION_XML));
+ } catch (ODataException e) {
+ Assert.assertTrue(true); // Expected TODO - need to revisit
+ }
+ }
+
+ private PutMergePatchUriInfo getPutUriInfo() {
+ return (PutMergePatchUriInfo) getDeletetUriInfo();
+ }
+
+ private PostUriInfo getPostUriInfo() {
+ return (PostUriInfo) getDeletetUriInfo();
+ }
+
+ private InputStream getMockedInputStreamContent() {
+ return new ByteArrayInputStream(getEntityBody().getBytes());
+ }
+
+ private String getEntityBody() {
+ return "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
+ + "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" "
+ + "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" "
+ + "xml:base=\"http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/\">"
+ + "<content type=\"application/xml\">" + "<m:properties>" + "<d:ID>2</d:ID>"
+ + "<d:CreationDate>2013-01-02T00:00:00</d:CreationDate>" + "<d:CurrencyCode>Code_555</d:CurrencyCode>"
+ + "<d:BuyerAddressInfo m:type=\"SalesOrderProcessing.AddressInfo\">" + "<d:Street>Test_Street_Name_055</d:Street>"
+ + "<d:Number>2</d:Number>" + "<d:Country>Test_Country_2</d:Country>" + "<d:City>Test_City_2</d:City>"
+ + "</d:BuyerAddressInfo>" + "<d:GrossAmount>0.0</d:GrossAmount>" + "<d:BuyerId>2</d:BuyerId>"
+ + "<d:DeliveryStatus>true</d:DeliveryStatus>" + "<d:BuyerName>buyerName_2</d:BuyerName>" + "<d:NetAmount>0.0</d:NetAmount>"
+ + "</m:properties>" + "</content>" + "</entry>";
+ }
+
+ private GetEntitySetCountUriInfo getEntitySetCountUriInfo() {
+ return getLocalUriInfo();
+ }
+
+ private GetEntityCountUriInfo getEntityCountUriInfo() {
+ return getLocalUriInfo();
+ }
+
+ private DeleteUriInfo getDeletetUriInfo() {
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet())
+ .andStubReturn(getLocalEdmEntitySet());
+ List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>();
+ EasyMock.expect(objUriInfo.getNavigationSegments())
+ .andReturn(navSegments)
+ .anyTimes();
+ EasyMock.expect(objUriInfo.getTargetEntitySet())
+ .andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect())
+ .andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy())
+ .andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop())
+ .andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip())
+ .andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount())
+ .andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter())
+ .andStubReturn(getFilter());
+ EasyMock.expect(objUriInfo.getKeyPredicates())
+ .andStubReturn(getKeyPredicates());
+ EasyMock.expect(objUriInfo.isLinks())
+ .andStubReturn(false);
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ private List<KeyPredicate> getKeyPredicates() {
+ return new ArrayList<KeyPredicate>();
+ }
+
+ /**
+ * @return
+ */
+ private UriInfo getLocalUriInfo() {
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet())
+ .andStubReturn(getLocalEdmEntitySet());
+ List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>();
+ EasyMock.expect(objUriInfo.getNavigationSegments())
+ .andReturn(navSegments)
+ .anyTimes();
+ EasyMock.expect(objUriInfo.getTargetEntitySet())
+ .andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect())
+ .andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy())
+ .andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop())
+ .andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip())
+ .andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount())
+ .andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter())
+ .andStubReturn(getFilter());
+ EasyMock.expect(objUriInfo.getFunctionImport())
+ .andStubReturn(null);
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ /**
+ * @return
+ * @throws EdmException
+ */
+ private EdmEntitySet getLocalEdmEntitySet() {
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(edmEntitySet.getName())
+ .andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntitySet.getEntityContainer())
+ .andStubReturn(getLocalEdmEntityContainer());
+ EasyMock.expect(edmEntitySet.getEntityType())
+ .andStubReturn(getLocalEdmEntityType());
+ EasyMock.replay(edmEntitySet);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return edmEntitySet;
+ }
+
+ /**
+ * @return
+ * @throws EdmException
+ */
+ private EdmEntityType getLocalEdmEntityType() {
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(edmEntityType.getKeyProperties())
+ .andStubReturn(new ArrayList<EdmProperty>());
+ EasyMock.expect(edmEntityType.getPropertyNames())
+ .andStubReturn(getLocalPropertyNames());
+ EasyMock.expect(edmEntityType.getProperty(SO_ID))
+ .andStubReturn(getEdmTypedMockedObj(SALES_ORDER));
+ EasyMock.expect(edmEntityType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmEntityType.getNamespace())
+ .andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.getName())
+ .andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.hasStream())
+ .andStubReturn(false);
+ EasyMock.expect(edmEntityType.getNavigationPropertyNames())
+ .andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getKeyPropertyNames())
+ .andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getMapping())
+ .andStubReturn((EdmMapping) getEdmMappingMockedObj(SALES_ORDER));
+ EasyMock.replay(edmEntityType);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return edmEntityType;
+ }
+
+ private InlineCount getInlineCount() {
+ return InlineCount.NONE;
+ }
+
+ private FilterExpression getFilter() {
+ return null;
+ }
+
+ private Integer getSkip() {
+ return null;
+ }
+
+ private Integer getTop() {
+ return null;
+ }
+
+ private OrderByExpression getOrderByExpression() {
+ return null;
+ }
+
+ private ODataJPAContext getLocalmockODataJPAContext() {
+ ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+ EasyMock.expect(odataJPAContext.getPageSize())
+ .andReturn(0)
+ .anyTimes();
+ EasyMock.expect(odataJPAContext.getPersistenceUnitName())
+ .andStubReturn("salesorderprocessing");
+ EasyMock.expect(odataJPAContext.getEntityManagerFactory())
+ .andStubReturn(mockEntityManagerFactory());
+ EasyMock.expect(odataJPAContext.getODataJPATransaction())
+ .andStubReturn(getLocalJpaTransaction());
+ EasyMock.expect(odataJPAContext.getODataContext())
+ .andStubReturn(getLocalODataContext());
+ odataJPAContext.setODataContext((ODataContext) EasyMock.anyObject());
+ EasyMock.expectLastCall()
+ .anyTimes();
+ EasyMock.expect(odataJPAContext.getEntityManager())
+ .andStubReturn(getLocalEntityManager());
+ EasyMock.expect(odataJPAContext.isContainerManaged())
+ .andReturn(false);
+ EasyMock.expectLastCall()
+ .anyTimes();
+ EasyMock.replay(odataJPAContext);
+ return odataJPAContext;
+ }
+
+ private ODataJPATransaction getLocalJpaTransaction() {
+ ODataJPATransaction tx = EasyMock.createMock(ODataJPATransaction.class);
+ tx.begin(); // testing void method
+ tx.commit();// testing void method
+ tx.rollback();// testing void method
+ EasyMock.expect(tx.isActive())
+ .andReturn(false);
+ EasyMock.expect(tx.isActive())
+ .andReturn(false);
+ EasyMock.replay(tx);
+ return tx;
+ }
+
+ private EntityManagerFactory mockEntityManagerFactory() {
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.expect(emf.getMetamodel())
+ .andStubReturn(mockMetaModel());
+ EasyMock.expect(emf.createEntityManager())
+ .andStubReturn(getLocalEntityManager());
+ EasyMock.replay(emf);
+ return emf;
+ }
+
+ private EntityManagerFactory mockEntityManagerFactory2() {// For create, to avoid stackoverflow
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.expect(emf.getMetamodel())
+ .andStubReturn(mockMetaModel());
+ EasyMock.replay(emf);
+ return emf;
+ }
+
+ private EntityManager getLocalEntityManager() {
+ EntityManager em = EasyMock.createMock(EntityManager.class);
+ EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1"))
+ .andStubReturn(getQuery());
+ EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1"))
+ .andStubReturn(getQueryForSelectCount());
+ EasyMock.expect(em.getEntityManagerFactory())
+ .andStubReturn(mockEntityManagerFactory2());// For create
+ EasyMock.expect(em.getTransaction())
+ .andStubReturn(getLocalTransaction()); // For Delete
+ EasyMock.expect(em.isOpen())
+ .andReturn(true)
+ .anyTimes();
+ Address obj = new Address();
+ em.remove(obj);// testing void method
+ em.flush();
+ em.close();
+ EasyMock.expectLastCall()
+ .anyTimes();
+ EasyMock.replay(em);
+ return em;
+ }
+
+ private EntityTransaction getLocalTransaction() {
+ EntityTransaction entityTransaction = EasyMock.createMock(EntityTransaction.class);
+ entityTransaction.begin(); // testing void method
+ entityTransaction.commit();// testing void method
+ entityTransaction.rollback();// testing void method
+ EasyMock.expect(entityTransaction.isActive())
+ .andReturn(false);
+ EasyMock.replay(entityTransaction);
+ return entityTransaction;
+ }
+
+ private Query getQuery() {
+ Query query = EasyMock.createMock(Query.class);
+ EasyMock.expect(query.getResultList())
+ .andStubReturn(getResultList());
+ EasyMock.replay(query);
+ return query;
+ }
+
+ private Query getQueryForSelectCount() {
+ Query query = EasyMock.createMock(Query.class);
+ EasyMock.expect(query.getResultList())
+ .andStubReturn(getResultListForSelectCount());
+ EasyMock.replay(query);
+ return query;
+ }
+
+ private List<?> getResultList() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Address());
+ return list;
+ }
+
+ private List<?> getResultListForSelectCount() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Long(11));
+ return list;
+ }
+
+ class Address {
+ private final String soId = "12";
+
+ public String getSoId() {
+ return soId;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getEnclosingInstance().hashCode();
+ return prime * result + Objects.hash(soId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Address other = (Address) obj;
+ if (!getEnclosingInstance().equals(other.getEnclosingInstance())) {
+ return false;
+ }
+ return Objects.equals(soId, other.soId);
+ }
+
+ private ODataJPADefaultProcessorTest getEnclosingInstance() {
+ return ODataJPADefaultProcessorTest.this;
+ }
+
+ }
+
+ private Metamodel mockMetaModel() {
+ Metamodel metaModel = EasyMock.createMock(Metamodel.class);
+ EasyMock.expect(metaModel.getEntities())
+ .andStubReturn(getLocalEntities());
+ EasyMock.replay(metaModel);
+ return metaModel;
+ }
+
+ private Set<EntityType<?>> getLocalEntities() {
+ Set<EntityType<?>> entityTypeSet = new HashSet<EntityType<?>>();
+ entityTypeSet.add(getLocalJPAEntityType());
+ return entityTypeSet;
+ }
+
+ @SuppressWarnings("rawtypes")
+ private EntityType<EntityType> getLocalJPAEntityType() {
+ @SuppressWarnings("unchecked")
+ EntityType<EntityType> entityType = EasyMock.createMock(EntityType.class);
+ EasyMock.expect(entityType.getJavaType())
+ .andStubReturn(EntityType.class);
+ EasyMock.replay(entityType);
+ return entityType;
+ }
+
+ private GetEntityUriInfo getEntityUriInfo() {
+ GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(getEntityView.getExpand())
+ .andStubReturn(null);
+ EasyMock.expect(edmEntityType.getKeyProperties())
+ .andStubReturn(new ArrayList<EdmProperty>());
+ EasyMock.expect(edmEntitySet.getEntityType())
+ .andStubReturn(edmEntityType);
+ EasyMock.expect(edmEntitySet.getName())
+ .andStubReturn(SALES_ORDER_HEADERS);
+
+ EasyMock.expect(getEntityView.getSelect())
+ .andStubReturn(null);
+ EasyMock.expect(getEntityView.getTargetEntitySet())
+ .andStubReturn(edmEntitySet);
+ EasyMock.expect(edmEntityType.getPropertyNames())
+ .andStubReturn(getLocalPropertyNames());
+ EasyMock.expect(edmEntityType.getProperty(SO_ID))
+ .andStubReturn(getEdmTypedMockedObj(SO_ID));
+
+ EasyMock.expect(edmEntityType.getMapping())
+ .andStubReturn((EdmMapping) getEdmMappingMockedObj(SALES_ORDER));
+
+ EasyMock.expect(edmEntityType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmEntityType.getNamespace())
+ .andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.getName())
+ .andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.hasStream())
+ .andStubReturn(false);
+ EasyMock.expect(edmEntityType.getNavigationPropertyNames())
+ .andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getKeyPropertyNames())
+ .andStubReturn(new ArrayList<String>());
+
+ EasyMock.expect(edmEntitySet.getEntityContainer())
+ .andStubReturn(getLocalEdmEntityContainer());
+
+ EasyMock.replay(edmEntityType, edmEntitySet);
+ EasyMock.expect(getEntityView.getKeyPredicates())
+ .andStubReturn(new ArrayList<KeyPredicate>());
+ List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+ EasyMock.expect(getEntityView.getNavigationSegments())
+ .andReturn(navigationSegments);
+ EasyMock.expect(getEntityView.getStartEntitySet())
+ .andReturn(edmEntitySet);
+
+ EasyMock.replay(getEntityView);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return getEntityView;
+ }
+
+ private EdmEntityContainer getLocalEdmEntityContainer() {
+ EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
+ EasyMock.expect(edmEntityContainer.isDefaultEntityContainer())
+ .andStubReturn(true);
+ try {
+ EasyMock.expect(edmEntityContainer.getName())
+ .andStubReturn(SALESORDERPROCESSING_CONTAINER);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(edmEntityContainer);
+ return edmEntityContainer;
+ }
+
+ private EdmTyped getEdmTypedMockedObj(final String propertyName) {
+ EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
+ try {
+ EasyMock.expect(mockedEdmProperty.getMapping())
+ .andStubReturn((EdmMapping) getEdmMappingMockedObj(propertyName));
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType);
+ EasyMock.expect(mockedEdmProperty.getName())
+ .andStubReturn("identifier");
+ EasyMock.expect(mockedEdmProperty.getType())
+ .andStubReturn(edmType);
+ EasyMock.expect(mockedEdmProperty.getFacets())
+ .andStubReturn(getEdmFacetsMockedObj());
+
+ EasyMock.replay(mockedEdmProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return mockedEdmProperty;
+ }
+
+ private EdmFacets getEdmFacetsMockedObj() {
+ EdmFacets facets = EasyMock.createMock(EdmFacets.class);
+ EasyMock.expect(facets.getConcurrencyMode())
+ .andStubReturn(EdmConcurrencyMode.Fixed);
+
+ EasyMock.replay(facets);
+ return facets;
+ }
+
+ private JPAEdmMapping getEdmMappingMockedObj(final String propertyName) {
+ JPAEdmMappingImpl mockedEdmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ if (propertyName.equalsIgnoreCase(SALES_ORDER)) {
+ EasyMock.expect(((EdmMapping) mockedEdmMapping).getInternalName())
+ .andStubReturn(SALES_ORDER_HEADERS);
+ } else {
+ EasyMock.expect(((EdmMapping) mockedEdmMapping).getInternalName())
+ .andStubReturn(propertyName);
+ }
+ EasyMock.expect(mockedEdmMapping.getODataJPATombstoneEntityListener())
+ .andReturn(null);
+ EasyMock.<Class<?>>expect(mockedEdmMapping.getJPAType())
+ .andReturn(SalesOrderHeader.class);
+ EasyMock.replay(mockedEdmMapping);
+ return mockedEdmMapping;
+ }
+
+ private List<String> getLocalPropertyNames() {
+ List<String> list = new ArrayList<String>();
+ list.add(SO_ID);
+ return list;
+ }
+
+ private ODataContext getLocalODataContext() {
+ ODataContext objODataContext = null;
+ try {
+ ODataContextMock contextMock = new ODataContextMock();
+ contextMock.setODataService(new ODataServiceMock().mock());
+ contextMock.setPathInfo(getLocalPathInfo());
+ objODataContext = contextMock.mock();
+
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return objODataContext;
+ }
+
+ private PathInfo getLocalPathInfo() {
+ PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
+ EasyMock.expect(pathInfo.getServiceRoot())
+ .andStubReturn(getLocalURI());
+ EasyMock.replay(pathInfo);
+ return pathInfo;
+ }
+
+ private URI getLocalURI() {
+ URI uri = null;
+ try {
+ uri = new URI(STR_LOCAL_URI);
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return uri;
+ }
}
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAResponseBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAResponseBuilderTest.java
index 7105c3db..d94f8829 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAResponseBuilderTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAResponseBuilderTest.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;
@@ -22,7 +18,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
@@ -32,7 +27,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.apache.olingo.odata2.api.commons.InlineCount;
import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
import org.apache.olingo.odata2.api.edm.EdmEntitySet;
@@ -76,658 +70,719 @@ import org.junit.Test;
public class ODataJPAResponseBuilderTest extends JPAEdmTestModelView {
- private ODataJPAResponseBuilder responseBuilder;
-
- @Before
- public void init() {
- responseBuilder = new ODataJPAResponseBuilderDefault(getODataJPAContext());
- }
-
- /*
- * This Unit is supposed to test the building of Entity Provider Properties for query with $expand
- */
- @Test
- public void testGetEntityProviderPropertiesQuery() {
- GetEntitySetUriInfo getEntitySetUriInfo = mockEntitySetUriInfoForExpand();
- ODataJPAContext oDataJPAContext = getODataJPAContext();
- // Building the edm entity
- List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
- Map<String, Object> edmEntity = new HashMap<String, Object>();
- edmEntity.put("ID", 1);
- edmEntityList.add(edmEntity);
- // Invoking the private static method using reflection
- Class<?> clazz = ODataJPAResponseBuilderDefault.class;
- Object[] actualParameters = { oDataJPAContext, getEntitySetUriInfo, edmEntityList };
- Class<?>[] formalParameters = { ODataJPAContext.class, GetEntitySetUriInfo.class, List.class };
- EntityProviderWriteProperties providerProperties = null;
- try {
- Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
- method.setAccessible(true);
- providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
- assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- /*
- * This Unit is supposed to test the building of Entity Provider Properties for read with $expand
- */
- @Test
- public void testGetEntityProviderPropertiesRead() {
-
- // Getting the EntityUriInfo
- GetEntityUriInfo getEntityUriInfo = mockEntityUriInfoForExpand();
- ODataJPAContext oDataJPAContext = getODataJPAContext();
- Class<?> clazz = ODataJPAResponseBuilderDefault.class;
- Object[] actualParameters = { oDataJPAContext, getEntityUriInfo };
- Class<?>[] formalParameters = { ODataJPAContext.class, GetEntityUriInfo.class };
- EntityProviderWriteProperties providerProperties = null;
- try {
- Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
- method.setAccessible(true);
- providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
- assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testConstructListofNavProperty() {
- List<ArrayList<NavigationPropertySegment>> expand = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navPropList1 = new ArrayList<NavigationPropertySegment>();
- navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties11"));
- navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties12"));
- expand.add(navPropList1);
- ArrayList<NavigationPropertySegment> navPropList2 = new ArrayList<NavigationPropertySegment>();
- navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties21"));
- navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties22"));
- expand.add(navPropList2);
- Class<?> clazz = ODataJPAResponseBuilderDefault.class;
- Object[] actualParameters = { expand };
- Class<?>[] formalParameters = { List.class };
- List<EdmNavigationProperty> navigationProperties = null;
- try {
- Method method = clazz.getDeclaredMethod("constructListofNavProperty", formalParameters);
- method.setAccessible(true);
- navigationProperties = (List<EdmNavigationProperty>) method.invoke(responseBuilder, actualParameters);
- assertEquals("DemoNavigationProperties21", navigationProperties.get(1).getName());
- assertEquals("DemoNavigationProperties11", navigationProperties.get(0).getName());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testBuildListOfTGetEntitySetUriInfoStringODataJPAContext() {
- try {
- assertNotNull(responseBuilder.build(getResultsView(), getJPAEntities(), "application/xml"));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testBuildNegatives() {// Bad content type
- try {
- EntityType entity = new EntityType();
- entity.setName("SalesOrderHeader");
- try {
- assertNotNull(responseBuilder.build(getLocalGetURIInfo(), getEntity(), "xml"));
- } catch (ODataNotFoundException e) {
- assertTrue(true);
- }
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);// Nothing to do, Expected.
- }
- try {// Bad content type
- assertNotNull(responseBuilder.build(getResultsView(), getJPAEntities(), "xml"));
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);// Nothing to do, Expected.
- }
-
- }
-
- @Test
- public void testBuildObjectGetEntityUriInfoStringODataJPAContext() throws ODataNotFoundException {
- try {
- assertNotNull(responseBuilder.build(getLocalGetURIInfo(), (Object) new SalesOrderHeader(2, 10),
- "application/xml"));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testBuildNullSelects() {// Bad content type
- try {
- responseBuilder.build(getResultsViewWithNullSelects(), getJPAEntities(), "xml");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);// Nothing to do, Expected.
- } catch (Exception e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testBuildGetCount() {
- ODataResponse objODataResponse = null;
- try {
- objODataResponse = responseBuilder.build(1);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(objODataResponse);
- }
-
- private ODataJPAContext getODataJPAContext() {
- ODataJPAContext objODataJPAContext = EasyMock.createMock(ODataJPAContext.class);
- EasyMock.expect(objODataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
- EasyMock.expect(objODataJPAContext.getPageSize()).andReturn(10);
- EasyMock.expect(objODataJPAContext.getPaging()).andReturn(mockJPAPaging()).anyTimes();
- EasyMock.replay(objODataJPAContext);
- return objODataJPAContext;
- }
-
- private ODataContext getLocalODataContext() {
- ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
- try {
- EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(objODataContext);
- return objODataContext;
- }
-
- private JPAPaging mockJPAPaging() {
- JPAPaging paging = new JPAPaging() {
-
- @Override
- public int getStartPage() {
- return 0;
- }
-
- @Override
- public List<Object> getPagedEntities() {
- return null;
- }
-
- @Override
- public int getPageSize() {
- return 10;
- }
-
- @Override
- public int getNextPage() {
- return 10;
- }
- };
-
- return paging;
- }
-
- private PathInfo getLocalPathInfo() {
- PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
- EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
- EasyMock.expect(pathInfo.getRequestUri()).andStubReturn(getRequestURI());
- EasyMock.replay(pathInfo);
- return pathInfo;
- }
-
- private URI getRequestURI() {
- URI uri = null;
- try {
- uri = new URI("SalesOrders");
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return uri;
- }
-
- private URI getLocalURI() {
- URI uri = null;
- try {
- uri = new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/");
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return uri;
- }
-
- private GetEntitySetUriInfo getResultsView() {
- GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
- EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(getSelectItemList());
- EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(getExpandList());
- EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
- EasyMock.replay(objGetEntitySetUriInfo);
- return objGetEntitySetUriInfo;
- }
-
- private List<ArrayList<NavigationPropertySegment>> getExpandList() {
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- return expandList;
- }
-
- private GetEntitySetUriInfo getResultsViewWithNullSelects() {
- GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
- EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(null);
- EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
-
- EasyMock.replay(objGetEntitySetUriInfo);
- return objGetEntitySetUriInfo;
- }
-
- private GetEntityUriInfo getLocalGetURIInfo() {
- GetEntityUriInfo objGetEntityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
- EasyMock.expect(objGetEntityUriInfo.getSelect()).andStubReturn(getSelectItemList());
- EasyMock.expect(objGetEntityUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(objGetEntityUriInfo.getExpand()).andStubReturn(getExpandList());
- EasyMock.replay(objGetEntityUriInfo);
- return objGetEntityUriInfo;
- }
-
- private List<SelectItem> getSelectItemList() {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- selectItems.add(getSelectItem());
- return selectItems;
- }
-
- private SelectItem getSelectItem() {
- SelectItem selectItem = EasyMock.createMock(SelectItem.class);
- EasyMock.expect(selectItem.getProperty()).andStubReturn(getEdmPropertyForSelect());
- List<NavigationPropertySegment> navigationSegmentList = new ArrayList<NavigationPropertySegment>();
- EasyMock.expect(selectItem.getNavigationPropertySegments()).andStubReturn(navigationSegmentList);
- EasyMock.expect(selectItem.isStar()).andReturn(false).anyTimes();
- EasyMock.replay(selectItem);
- return selectItem;
- }
-
- private EdmProperty getEdmPropertyForSelect() {
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- Facets facets = new Facets().setNullable(false);
- try {
- EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.URI, facets)).andStubReturn("2");
- EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.DEFAULT, facets)).andStubReturn("2");
- } catch (EdmSimpleTypeException e1) {
- fail("There is an exception in mocking EdmType object " + e1.getMessage());
- }
- EasyMock.replay(edmType);
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
- EasyMock.expect(edmMapping.getMediaResourceMimeTypeKey()).andReturn(null);
- EasyMock.expect(((JPAEdmMappingImpl) edmMapping).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(edmMapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmProperty.getFacets()).andStubReturn(facets);
- EasyMock.expect(edmProperty.getCustomizableFeedMappings()).andStubReturn(null);
- EasyMock.expect(edmProperty.getMimeType()).andStubReturn(null);
- EasyMock.replay(edmProperty);
-
- } catch (EdmException e) {
- fail("There is an exception in mocking some object " + e.getMessage());
- }
-
- return edmProperty;
-
- }
-
- private EdmEntitySet getLocalTargetEntitySet() {
- EdmEntitySet objEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(objEdmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
- EasyMock.expect(objEdmEntitySet.getName()).andStubReturn("SalesOderHeaders");
- EasyMock.expect(objEdmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(objEdmEntitySet);
- return objEdmEntitySet;
- }
-
- private EdmEntityContainer getLocalEdmEntityContainer() {
- EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
- EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
- try {
- EasyMock.expect(edmEntityContainer.getName()).andStubReturn("salesorderprocessingContainer");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(edmEntityContainer);
- return edmEntityContainer;
- }
-
- private EdmEntityType getLocalEdmEntityType() {
- EdmEntityType objEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(objEdmEntityType.getName()).andStubReturn("SalesOderHeaders");
- EasyMock.expect(objEdmEntityType.getNamespace()).andStubReturn("SalesOderHeaders");
- EasyMock.expect(objEdmEntityType.getKind()).andStubReturn(EdmTypeKind.ENTITY);
- EasyMock.expect(objEdmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(objEdmEntityType.hasStream()).andStubReturn(false);
- ArrayList<String> propertyNames = new ArrayList<String>();
- propertyNames.add("ID");
- EasyMock.expect(objEdmEntityType.getProperty("ID")).andStubReturn(getEdmPropertyForSelect());
- EasyMock.expect(objEdmEntityType.getPropertyNames()).andStubReturn(propertyNames);
- EasyMock.expect(objEdmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(objEdmEntityType.getKeyPropertyNames()).andStubReturn(propertyNames);
- EasyMock.expect(objEdmEntityType.getKeyProperties()).andStubReturn(getKeyProperties());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(objEdmEntityType);
- return objEdmEntityType;
- }
-
- private List<EdmProperty> getKeyProperties() {
- List<EdmProperty> edmProperties = new ArrayList<EdmProperty>();
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType);
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
- EasyMock.replay(edmMapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(edmProperty);
- } catch (EdmException e) {
- fail("There is an exception is mocking some object " + e.getMessage());
- }
-
- edmProperties.add(edmProperty);
- return edmProperties;
- }
-
- private InlineCount getLocalInlineCount() {
- return InlineCount.NONE;
- }
-
- class SalesOrderHeader {
- private int soId;
- private int Field1;
-
- public SalesOrderHeader(final int soId, final int field) {
- this.soId = soId;
- Field1 = field;
- }
-
- public int getField1() {
- return Field1;
- }
-
- public void setField1(final int field1) {
- Field1 = field1;
- }
-
- public int getSoId() {
- return soId;
- }
-
- public void setSoId(final int soId) {
- this.soId = soId;
- }
-
- }
-
- private List<Object> getJPAEntities() {
- List<Object> listJPAEntities = new ArrayList<Object>();
- SalesOrderHeader entity;
- entity = new SalesOrderHeader(2, 10);
- listJPAEntities.add(entity);
- return listJPAEntities;
- }
-
- private Object getEntity() {
- SalesOrderHeader sHeader = new SalesOrderHeader(10, 34);
- return sHeader;
- }
-
- private GetEntityUriInfo mockEntityUriInfoForExpand() {
-
- List<SelectItem> selectItemList = new ArrayList<SelectItem>();
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
- // Mocking the navigation property
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- // Mocking the navigation property segments and adding to expand list
- NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
- EasyMock.replay(navigationPropertySegment);
- navigationPropertyList.add(navigationPropertySegment);
- expandList.add(navigationPropertyList);
- // Mocking EntityUriInfo
- GetEntityUriInfo entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
- EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(selectItemList);
- EasyMock.expect(entityUriInfo.getExpand()).andStubReturn(expandList);
- EasyMock.replay(entityUriInfo);
- return entityUriInfo;
- }
-
- private GetEntitySetUriInfo mockEntitySetUriInfoForExpand() {
-
- List<SelectItem> selectItemList = new ArrayList<SelectItem>();
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
- // Mocking the navigation property
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- // Mocking the navigation property segments and adding to expand list
- NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
- EasyMock.replay(navigationPropertySegment);
- navigationPropertyList.add(navigationPropertySegment);
- expandList.add(navigationPropertyList);
- // Mocking EntityUriInfo
- UriInfoImpl entitySetUriInfo = EasyMock.createMock(UriInfoImpl.class);
- EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(selectItemList);
- EasyMock.expect(entitySetUriInfo.getExpand()).andStubReturn(expandList);
- EasyMock.expect(entitySetUriInfo.getInlineCount()).andStubReturn(InlineCount.ALLPAGES);
- EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
- EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(new Integer(2));
- Map<String, String> customQuery = new HashMap<String, String>();
- customQuery.put("count", "5");
- entitySetUriInfo.setCustomQueryOptions(null);
- EasyMock.expectLastCall().times(1);
- EasyMock.expect(entitySetUriInfo.getCustomQueryOptions()).andStubReturn(customQuery );
- EasyMock.replay(entitySetUriInfo);
- return entitySetUriInfo;
- }
-
- private EdmEntitySet getTargetEntitySetForExpand() {
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(entitySet.getName()).andStubReturn("SalesOrderHeaders");
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(null);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entitySet);
- return entitySet;
- }
-
- private NavigationPropertySegment getNavigationPropertySegment(final String navPropertyName) {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn(navPropertyName);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- NavigationPropertySegment navPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.replay(navPropertySegment);
- return navPropertySegment;
- }
-
- private GetFunctionImportUriInfo mockFunctionImportUriInfo() {
-
- List<SelectItem> selectItemList = new ArrayList<SelectItem>();
- List<ArrayList<NavigationPropertySegment>> expandList = new
- ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
- // Mocking the navigation property
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() +
- ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
-
- // Mocking the navigation property segments and adding to expand list
- NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.expect(navigationPropertySegment.getTargetEntitySet())
- .andStubReturn(getTargetEntitySetForExpand());
- EasyMock.replay(navigationPropertySegment);
- navigationPropertyList.add(navigationPropertySegment);
- expandList.add(navigationPropertyList);
- // Mocking EntityUriInfo
- UriInfoImpl functionImportUriInfo = EasyMock.createMock(UriInfoImpl.class);
- EasyMock.expect(functionImportUriInfo.getSelect()).andStubReturn(selectItemList);
- EasyMock.expect(functionImportUriInfo.getExpand()).andStubReturn(expandList);
- EasyMock.expect(functionImportUriInfo.getInlineCount()).andStubReturn(InlineCount.ALLPAGES);
- EasyMock.expect(functionImportUriInfo.getFunctionImport()).andStubReturn(mockEdmFunctionImport());
- EasyMock.expect(functionImportUriInfo.getCustomQueryOptions()).andStubReturn(null);
- EasyMock.replay(functionImportUriInfo);
- return functionImportUriInfo;
- }
-
- private EdmFunctionImport mockEdmFunctionImport() {
- EdmFunctionImport funcImport = EasyMock.createMock(EdmFunctionImport.class);
- try {
- EasyMock.expect(funcImport.getName()).andStubReturn("FindAllSalesOrders");
- EasyMock.expect(funcImport.getEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(funcImport.getParameterNames()).andStubReturn(
- Arrays.asList("DeliveryStatusCode"));
- EdmTyped typed = EasyMock.createMock(EdmTyped.class);
- EasyMock.expect(typed.getName()).andStubReturn("SalesOrder");
- EasyMock.expect(typed.getMultiplicity()).andStubReturn(EdmMultiplicity.MANY);
- EasyMock.expect(typed.getType()).andStubReturn(getLocalEdmEntityType());
- EasyMock.replay(typed);
- EasyMock.expect(funcImport.getReturnType()).andStubReturn(typed);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 +
- e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(funcImport);
- return funcImport;
- }
- /*
- * This Unit is supposed to test the building of Entity Provider Properties for function import
- */
- @Test
- public void testFunctionImportProviderProperties() {
-
- // Getting the EntityUriInfo
- GetFunctionImportUriInfo getfuncImportUriInfo = mockFunctionImportUriInfo();
- ODataJPAContext oDataJPAContext = getODataJPAContext();
- Class<?> clazz = ODataJPAResponseBuilderDefault.class;
- // Building the edm entity
- List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
- Map<String, Object> edmEntity = new HashMap<String, Object>();
- edmEntity.put("ID", 1);
- edmEntityList.add(edmEntity);
- Object[] actualParameters = { oDataJPAContext, getfuncImportUriInfo, edmEntityList };
- Class<?>[] formalParameters = { ODataJPAContext.class, GetFunctionImportUriInfo.class, List.class };
- EntityProviderWriteProperties providerProperties = null;
- try {
- Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
- method.setAccessible(true);
- providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
- assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
- assertEquals(InlineCount.ALLPAGES, providerProperties.getInlineCountType());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testBuildListOfGetFunctionimportUriInfo() throws Exception {
- try {
- assertNotNull(responseBuilder.build(getFIResultsView(), getJPAEntities(), "application/xml"));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- private GetFunctionImportUriInfo getFIResultsView() {
- GetFunctionImportUriInfo objGetFunctionImportUriInfo = EasyMock.createMock(GetFunctionImportUriInfo.class);
- EasyMock.expect(objGetFunctionImportUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
- EasyMock.expect(objGetFunctionImportUriInfo.getFunctionImport()).andStubReturn(mockEdmFunctionImport());
- EasyMock.expect(objGetFunctionImportUriInfo.getSelect()).andStubReturn(getSelectItemList());
- EasyMock.expect(objGetFunctionImportUriInfo.getExpand()).andStubReturn(getExpandList());
- EasyMock.replay(objGetFunctionImportUriInfo);
- return objGetFunctionImportUriInfo;
- }
+ private ODataJPAResponseBuilder responseBuilder;
+
+ @Before
+ public void init() {
+ responseBuilder = new ODataJPAResponseBuilderDefault(getODataJPAContext());
+ }
+
+ /*
+ * This Unit is supposed to test the building of Entity Provider Properties for query with $expand
+ */
+ @Test
+ public void testGetEntityProviderPropertiesQuery() {
+ GetEntitySetUriInfo getEntitySetUriInfo = mockEntitySetUriInfoForExpand();
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ // Building the edm entity
+ List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
+ Map<String, Object> edmEntity = new HashMap<String, Object>();
+ edmEntity.put("ID", 1);
+ edmEntityList.add(edmEntity);
+ // Invoking the private static method using reflection
+ Class<?> clazz = ODataJPAResponseBuilderDefault.class;
+ Object[] actualParameters = {oDataJPAContext, getEntitySetUriInfo, edmEntityList};
+ Class<?>[] formalParameters = {ODataJPAContext.class, GetEntitySetUriInfo.class, List.class};
+ EntityProviderWriteProperties providerProperties = null;
+ try {
+ Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
+ method.setAccessible(true);
+ providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
+ assertEquals(1, providerProperties.getExpandSelectTree()
+ .getLinks()
+ .size());
+ } catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException
+ | InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ /*
+ * This Unit is supposed to test the building of Entity Provider Properties for read with $expand
+ */
+ @Test
+ public void testGetEntityProviderPropertiesRead() {
+
+ // Getting the EntityUriInfo
+ GetEntityUriInfo getEntityUriInfo = mockEntityUriInfoForExpand();
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ Class<?> clazz = ODataJPAResponseBuilderDefault.class;
+ Object[] actualParameters = {oDataJPAContext, getEntityUriInfo};
+ Class<?>[] formalParameters = {ODataJPAContext.class, GetEntityUriInfo.class};
+ EntityProviderWriteProperties providerProperties = null;
+ try {
+ Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
+ method.setAccessible(true);
+ providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
+ assertEquals(1, providerProperties.getExpandSelectTree()
+ .getLinks()
+ .size());
+ } catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException
+ | InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testConstructListofNavProperty() {
+ List<ArrayList<NavigationPropertySegment>> expand = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navPropList1 = new ArrayList<NavigationPropertySegment>();
+ navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties11"));
+ navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties12"));
+ expand.add(navPropList1);
+ ArrayList<NavigationPropertySegment> navPropList2 = new ArrayList<NavigationPropertySegment>();
+ navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties21"));
+ navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties22"));
+ expand.add(navPropList2);
+ Class<?> clazz = ODataJPAResponseBuilderDefault.class;
+ Object[] actualParameters = {expand};
+ Class<?>[] formalParameters = {List.class};
+ List<EdmNavigationProperty> navigationProperties = null;
+ try {
+ Method method = clazz.getDeclaredMethod("constructListofNavProperty", formalParameters);
+ method.setAccessible(true);
+ navigationProperties = (List<EdmNavigationProperty>) method.invoke(responseBuilder, actualParameters);
+ assertEquals("DemoNavigationProperties21", navigationProperties.get(1)
+ .getName());
+ assertEquals("DemoNavigationProperties11", navigationProperties.get(0)
+ .getName());
+ } catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException
+ | EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testBuildListOfTGetEntitySetUriInfoStringODataJPAContext() {
+ try {
+ assertNotNull(responseBuilder.build(getResultsView(), getJPAEntities(), "application/xml"));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testBuildNegatives() {// Bad content type
+ try {
+ EntityType entity = new EntityType();
+ entity.setName("SalesOrderHeader");
+ try {
+ assertNotNull(responseBuilder.build(getLocalGetURIInfo(), getEntity(), "xml"));
+ } catch (ODataNotFoundException e) {
+ assertTrue(true);
+ }
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);// Nothing to do, Expected.
+ }
+ try {// Bad content type
+ assertNotNull(responseBuilder.build(getResultsView(), getJPAEntities(), "xml"));
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);// Nothing to do, Expected.
+ }
+
+ }
+
+ @Test
+ public void testBuildObjectGetEntityUriInfoStringODataJPAContext() throws ODataNotFoundException {
+ try {
+ assertNotNull(responseBuilder.build(getLocalGetURIInfo(), new SalesOrderHeader(2, 10), "application/xml"));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testBuildNullSelects() {// Bad content type
+ try {
+ responseBuilder.build(getResultsViewWithNullSelects(), getJPAEntities(), "xml");
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testBuildGetCount() {
+ ODataResponse objODataResponse = null;
+ try {
+ objODataResponse = responseBuilder.build(1);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNotNull(objODataResponse);
+ }
+
+ private ODataJPAContext getODataJPAContext() {
+ ODataJPAContext objODataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+ EasyMock.expect(objODataJPAContext.getODataContext())
+ .andStubReturn(getLocalODataContext());
+ EasyMock.expect(objODataJPAContext.getPageSize())
+ .andReturn(10);
+ EasyMock.expect(objODataJPAContext.getPaging())
+ .andReturn(mockJPAPaging())
+ .anyTimes();
+ EasyMock.replay(objODataJPAContext);
+ return objODataJPAContext;
+ }
+
+ private ODataContext getLocalODataContext() {
+ ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
+ try {
+ EasyMock.expect(objODataContext.getPathInfo())
+ .andStubReturn(getLocalPathInfo());
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(objODataContext);
+ return objODataContext;
+ }
+
+ private JPAPaging mockJPAPaging() {
+ return new JPAPaging() {
+
+ @Override
+ public int getStartPage() {
+ return 0;
+ }
+
+ @Override
+ public List<Object> getPagedEntities() {
+ return null;
+ }
+
+ @Override
+ public int getPageSize() {
+ return 10;
+ }
+
+ @Override
+ public int getNextPage() {
+ return 10;
+ }
+ };
+ }
+
+ private PathInfo getLocalPathInfo() {
+ PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
+ EasyMock.expect(pathInfo.getServiceRoot())
+ .andStubReturn(getLocalURI());
+ EasyMock.expect(pathInfo.getRequestUri())
+ .andStubReturn(getRequestURI());
+ EasyMock.replay(pathInfo);
+ return pathInfo;
+ }
+
+ private URI getRequestURI() {
+ URI uri = null;
+ try {
+ uri = new URI("SalesOrders");
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return uri;
+ }
+
+ private URI getLocalURI() {
+ URI uri = null;
+ try {
+ uri = new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/");
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return uri;
+ }
+
+ private GetEntitySetUriInfo getResultsView() {
+ GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EasyMock.expect(objGetEntitySetUriInfo.getInlineCount())
+ .andStubReturn(getLocalInlineCount());
+ EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet())
+ .andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(objGetEntitySetUriInfo.getSelect())
+ .andStubReturn(getSelectItemList());
+ EasyMock.expect(objGetEntitySetUriInfo.getExpand())
+ .andStubReturn(getExpandList());
+ EasyMock.expect(objGetEntitySetUriInfo.getSkip())
+ .andStubReturn(new Integer(1));
+ EasyMock.replay(objGetEntitySetUriInfo);
+ return objGetEntitySetUriInfo;
+ }
+
+ private List<ArrayList<NavigationPropertySegment>> getExpandList() {
+ return new ArrayList<ArrayList<NavigationPropertySegment>>();
+ }
+
+ private GetEntitySetUriInfo getResultsViewWithNullSelects() {
+ GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EasyMock.expect(objGetEntitySetUriInfo.getInlineCount())
+ .andStubReturn(getLocalInlineCount());
+ EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet())
+ .andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(objGetEntitySetUriInfo.getSelect())
+ .andStubReturn(null);
+ EasyMock.expect(objGetEntitySetUriInfo.getExpand())
+ .andStubReturn(null);
+ EasyMock.expect(objGetEntitySetUriInfo.getSkip())
+ .andStubReturn(new Integer(1));
+
+ EasyMock.replay(objGetEntitySetUriInfo);
+ return objGetEntitySetUriInfo;
+ }
+
+ private GetEntityUriInfo getLocalGetURIInfo() {
+ GetEntityUriInfo objGetEntityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
+ EasyMock.expect(objGetEntityUriInfo.getSelect())
+ .andStubReturn(getSelectItemList());
+ EasyMock.expect(objGetEntityUriInfo.getTargetEntitySet())
+ .andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(objGetEntityUriInfo.getExpand())
+ .andStubReturn(getExpandList());
+ EasyMock.replay(objGetEntityUriInfo);
+ return objGetEntityUriInfo;
+ }
+
+ private List<SelectItem> getSelectItemList() {
+ List<SelectItem> selectItems = new ArrayList<SelectItem>();
+ selectItems.add(getSelectItem());
+ return selectItems;
+ }
+
+ private SelectItem getSelectItem() {
+ SelectItem selectItem = EasyMock.createMock(SelectItem.class);
+ EasyMock.expect(selectItem.getProperty())
+ .andStubReturn(getEdmPropertyForSelect());
+ List<NavigationPropertySegment> navigationSegmentList = new ArrayList<NavigationPropertySegment>();
+ EasyMock.expect(selectItem.getNavigationPropertySegments())
+ .andStubReturn(navigationSegmentList);
+ EasyMock.expect(selectItem.isStar())
+ .andReturn(false)
+ .anyTimes();
+ EasyMock.replay(selectItem);
+ return selectItem;
+ }
+
+ private EdmProperty getEdmPropertyForSelect() {
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ Facets facets = new Facets().setNullable(false);
+ try {
+ EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.URI, facets))
+ .andStubReturn("2");
+ EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.DEFAULT, facets))
+ .andStubReturn("2");
+ } catch (EdmSimpleTypeException e1) {
+ fail("There is an exception in mocking EdmType object " + e1.getMessage());
+ }
+ EasyMock.replay(edmType);
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("soId");
+ EasyMock.expect(edmMapping.getMediaResourceMimeTypeKey())
+ .andReturn(null);
+ EasyMock.expect(edmMapping.isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping);
+ try {
+ EasyMock.expect(edmProperty.getName())
+ .andStubReturn("ID");
+ EasyMock.expect(edmProperty.getType())
+ .andStubReturn(edmType);
+ EasyMock.expect(edmProperty.getMapping())
+ .andStubReturn(edmMapping);
+ EasyMock.expect(edmProperty.getFacets())
+ .andStubReturn(facets);
+ EasyMock.expect(edmProperty.getCustomizableFeedMappings())
+ .andStubReturn(null);
+ EasyMock.expect(edmProperty.getMimeType())
+ .andStubReturn(null);
+ EasyMock.replay(edmProperty);
+
+ } catch (EdmException e) {
+ fail("There is an exception in mocking some object " + e.getMessage());
+ }
+
+ return edmProperty;
+
+ }
+
+ private EdmEntitySet getLocalTargetEntitySet() {
+ EdmEntitySet objEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(objEdmEntitySet.getEntityType())
+ .andStubReturn(getLocalEdmEntityType());
+ EasyMock.expect(objEdmEntitySet.getName())
+ .andStubReturn("SalesOderHeaders");
+ EasyMock.expect(objEdmEntitySet.getEntityContainer())
+ .andStubReturn(getLocalEdmEntityContainer());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(objEdmEntitySet);
+ return objEdmEntitySet;
+ }
+
+ private EdmEntityContainer getLocalEdmEntityContainer() {
+ EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
+ EasyMock.expect(edmEntityContainer.isDefaultEntityContainer())
+ .andStubReturn(true);
+ try {
+ EasyMock.expect(edmEntityContainer.getName())
+ .andStubReturn("salesorderprocessingContainer");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(edmEntityContainer);
+ return edmEntityContainer;
+ }
+
+ private EdmEntityType getLocalEdmEntityType() {
+ EdmEntityType objEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(objEdmEntityType.getName())
+ .andStubReturn("SalesOderHeaders");
+ EasyMock.expect(objEdmEntityType.getNamespace())
+ .andStubReturn("SalesOderHeaders");
+ EasyMock.expect(objEdmEntityType.getKind())
+ .andStubReturn(EdmTypeKind.ENTITY);
+ EasyMock.expect(objEdmEntityType.hasStream())
+ .andStubReturn(false);
+ EasyMock.expect(objEdmEntityType.hasStream())
+ .andStubReturn(false);
+ ArrayList<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("ID");
+ EasyMock.expect(objEdmEntityType.getProperty("ID"))
+ .andStubReturn(getEdmPropertyForSelect());
+ EasyMock.expect(objEdmEntityType.getPropertyNames())
+ .andStubReturn(propertyNames);
+ EasyMock.expect(objEdmEntityType.getNavigationPropertyNames())
+ .andStubReturn(new ArrayList<String>());
+ EasyMock.expect(objEdmEntityType.getKeyPropertyNames())
+ .andStubReturn(propertyNames);
+ EasyMock.expect(objEdmEntityType.getKeyProperties())
+ .andStubReturn(getKeyProperties());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(objEdmEntityType);
+ return objEdmEntityType;
+ }
+
+ private List<EdmProperty> getKeyProperties() {
+ List<EdmProperty> edmProperties = new ArrayList<EdmProperty>();
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType);
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("soId");
+ EasyMock.replay(edmMapping);
+ try {
+ EasyMock.expect(edmProperty.getName())
+ .andStubReturn("ID");
+ EasyMock.expect(edmProperty.getType())
+ .andStubReturn(edmType);
+ EasyMock.expect(edmProperty.getMapping())
+ .andStubReturn(edmMapping);
+ EasyMock.replay(edmProperty);
+ } catch (EdmException e) {
+ fail("There is an exception is mocking some object " + e.getMessage());
+ }
+
+ edmProperties.add(edmProperty);
+ return edmProperties;
+ }
+
+ private InlineCount getLocalInlineCount() {
+ return InlineCount.NONE;
+ }
+
+ class SalesOrderHeader {
+ private int soId;
+ private int Field1;
+
+ public SalesOrderHeader(final int soId, final int field) {
+ this.soId = soId;
+ Field1 = field;
+ }
+
+ public int getField1() {
+ return Field1;
+ }
+
+ public void setField1(final int field1) {
+ Field1 = field1;
+ }
+
+ public int getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final int soId) {
+ this.soId = soId;
+ }
+
+ }
+
+ private List<Object> getJPAEntities() {
+ List<Object> listJPAEntities = new ArrayList<Object>();
+ SalesOrderHeader entity;
+ entity = new SalesOrderHeader(2, 10);
+ listJPAEntities.add(entity);
+ return listJPAEntities;
+ }
+
+ private Object getEntity() {
+ return new SalesOrderHeader(10, 34);
+ }
+
+ private GetEntityUriInfo mockEntityUriInfoForExpand() {
+
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>();
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
+ // Mocking the navigation property
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName())
+ .andStubReturn("SalesOrderItemDetails");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ // Mocking the navigation property segments and adding to expand list
+ NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropertySegment.getNavigationProperty())
+ .andStubReturn(navigationProperty);
+ EasyMock.expect(navigationPropertySegment.getTargetEntitySet())
+ .andStubReturn(getTargetEntitySetForExpand());
+ EasyMock.replay(navigationPropertySegment);
+ navigationPropertyList.add(navigationPropertySegment);
+ expandList.add(navigationPropertyList);
+ // Mocking EntityUriInfo
+ GetEntityUriInfo entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
+ EasyMock.expect(entityUriInfo.getSelect())
+ .andStubReturn(selectItemList);
+ EasyMock.expect(entityUriInfo.getExpand())
+ .andStubReturn(expandList);
+ EasyMock.replay(entityUriInfo);
+ return entityUriInfo;
+ }
+
+ private GetEntitySetUriInfo mockEntitySetUriInfoForExpand() {
+
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>();
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
+ // Mocking the navigation property
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName())
+ .andStubReturn("SalesOrderItemDetails");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ // Mocking the navigation property segments and adding to expand list
+ NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropertySegment.getNavigationProperty())
+ .andStubReturn(navigationProperty);
+ EasyMock.expect(navigationPropertySegment.getTargetEntitySet())
+ .andStubReturn(getTargetEntitySetForExpand());
+ EasyMock.replay(navigationPropertySegment);
+ navigationPropertyList.add(navigationPropertySegment);
+ expandList.add(navigationPropertyList);
+ // Mocking EntityUriInfo
+ UriInfoImpl entitySetUriInfo = EasyMock.createMock(UriInfoImpl.class);
+ EasyMock.expect(entitySetUriInfo.getSelect())
+ .andStubReturn(selectItemList);
+ EasyMock.expect(entitySetUriInfo.getExpand())
+ .andStubReturn(expandList);
+ EasyMock.expect(entitySetUriInfo.getInlineCount())
+ .andStubReturn(InlineCount.ALLPAGES);
+ EasyMock.expect(entitySetUriInfo.getSkip())
+ .andStubReturn(new Integer(1));
+ EasyMock.expect(entitySetUriInfo.getTop())
+ .andStubReturn(new Integer(2));
+ Map<String, String> customQuery = new HashMap<String, String>();
+ customQuery.put("count", "5");
+ entitySetUriInfo.setCustomQueryOptions(null);
+ EasyMock.expectLastCall()
+ .times(1);
+ EasyMock.expect(entitySetUriInfo.getCustomQueryOptions())
+ .andStubReturn(customQuery);
+ EasyMock.replay(entitySetUriInfo);
+ return entitySetUriInfo;
+ }
+
+ private EdmEntitySet getTargetEntitySetForExpand() {
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(entitySet.getName())
+ .andStubReturn("SalesOrderHeaders");
+ EasyMock.expect(entitySet.getEntityType())
+ .andStubReturn(null);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entitySet);
+ return entitySet;
+ }
+
+ private NavigationPropertySegment getNavigationPropertySegment(final String navPropertyName) {
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName())
+ .andStubReturn(navPropertyName);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ NavigationPropertySegment navPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navPropertySegment.getNavigationProperty())
+ .andStubReturn(navigationProperty);
+ EasyMock.replay(navPropertySegment);
+ return navPropertySegment;
+ }
+
+ private GetFunctionImportUriInfo mockFunctionImportUriInfo() {
+
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>();
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
+ // Mocking the navigation property
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName())
+ .andStubReturn("SalesOrderItemDetails");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+
+ // Mocking the navigation property segments and adding to expand list
+ NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropertySegment.getNavigationProperty())
+ .andStubReturn(navigationProperty);
+ EasyMock.expect(navigationPropertySegment.getTargetEntitySet())
+ .andStubReturn(getTargetEntitySetForExpand());
+ EasyMock.replay(navigationPropertySegment);
+ navigationPropertyList.add(navigationPropertySegment);
+ expandList.add(navigationPropertyList);
+ // Mocking EntityUriInfo
+ UriInfoImpl functionImportUriInfo = EasyMock.createMock(UriInfoImpl.class);
+ EasyMock.expect(functionImportUriInfo.getSelect())
+ .andStubReturn(selectItemList);
+ EasyMock.expect(functionImportUriInfo.getExpand())
+ .andStubReturn(expandList);
+ EasyMock.expect(functionImportUriInfo.getInlineCount())
+ .andStubReturn(InlineCount.ALLPAGES);
+ EasyMock.expect(functionImportUriInfo.getFunctionImport())
+ .andStubReturn(mockEdmFunctionImport());
+ EasyMock.expect(functionImportUriInfo.getCustomQueryOptions())
+ .andStubReturn(null);
+ EasyMock.replay(functionImportUriInfo);
+ return functionImportUriInfo;
+ }
+
+ private EdmFunctionImport mockEdmFunctionImport() {
+ EdmFunctionImport funcImport = EasyMock.createMock(EdmFunctionImport.class);
+ try {
+ EasyMock.expect(funcImport.getName())
+ .andStubReturn("FindAllSalesOrders");
+ EasyMock.expect(funcImport.getEntitySet())
+ .andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(funcImport.getParameterNames())
+ .andStubReturn(Arrays.asList("DeliveryStatusCode"));
+ EdmTyped typed = EasyMock.createMock(EdmTyped.class);
+ EasyMock.expect(typed.getName())
+ .andStubReturn("SalesOrder");
+ EasyMock.expect(typed.getMultiplicity())
+ .andStubReturn(EdmMultiplicity.MANY);
+ EasyMock.expect(typed.getType())
+ .andStubReturn(getLocalEdmEntityType());
+ EasyMock.replay(typed);
+ EasyMock.expect(funcImport.getReturnType())
+ .andStubReturn(typed);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(funcImport);
+ return funcImport;
+ }
+
+ /*
+ * This Unit is supposed to test the building of Entity Provider Properties for function import
+ */
+ @Test
+ public void testFunctionImportProviderProperties() {
+
+ // Getting the EntityUriInfo
+ GetFunctionImportUriInfo getfuncImportUriInfo = mockFunctionImportUriInfo();
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ Class<?> clazz = ODataJPAResponseBuilderDefault.class;
+ // Building the edm entity
+ List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
+ Map<String, Object> edmEntity = new HashMap<String, Object>();
+ edmEntity.put("ID", 1);
+ edmEntityList.add(edmEntity);
+ Object[] actualParameters = {oDataJPAContext, getfuncImportUriInfo, edmEntityList};
+ Class<?>[] formalParameters = {ODataJPAContext.class, GetFunctionImportUriInfo.class, List.class};
+ EntityProviderWriteProperties providerProperties = null;
+ try {
+ Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
+ method.setAccessible(true);
+ providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
+ assertEquals(1, providerProperties.getExpandSelectTree()
+ .getLinks()
+ .size());
+ assertEquals(InlineCount.ALLPAGES, providerProperties.getInlineCountType());
+ } catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException
+ | InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testBuildListOfGetFunctionimportUriInfo() throws Exception {
+ try {
+ assertNotNull(responseBuilder.build(getFIResultsView(), getJPAEntities(), "application/xml"));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ private GetFunctionImportUriInfo getFIResultsView() {
+ GetFunctionImportUriInfo objGetFunctionImportUriInfo = EasyMock.createMock(GetFunctionImportUriInfo.class);
+ EasyMock.expect(objGetFunctionImportUriInfo.getInlineCount())
+ .andStubReturn(getLocalInlineCount());
+ EasyMock.expect(objGetFunctionImportUriInfo.getFunctionImport())
+ .andStubReturn(mockEdmFunctionImport());
+ EasyMock.expect(objGetFunctionImportUriInfo.getSelect())
+ .andStubReturn(getSelectItemList());
+ EasyMock.expect(objGetFunctionImportUriInfo.getExpand())
+ .andStubReturn(getExpandList());
+ EasyMock.replay(objGetFunctionImportUriInfo);
+ return objGetFunctionImportUriInfo;
+ }
}
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserForStaticMethodTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserForStaticMethodTest.java
index 7a277fca..cbbbe785 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserForStaticMethodTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserForStaticMethodTest.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.data;
@@ -22,351 +18,293 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.SQLException;
-
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialException;
-
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
import org.apache.olingo.odata2.jpa.processor.core.common.ODataJPATestConstants;
import org.junit.Test;
public class JPAEntityParserForStaticMethodTest {
- @Test
- public void testToStringDefault() {
-
- Character[] input = new Character[] { 'A', 'B' };
- assertEquals("AB", JPAEntityParser.toString(input));
-
- }
-
- @Test
- public void testToStringNull() {
- Character[] input = null;
- assertNull(JPAEntityParser.toString(input));
- }
-
- @Test
- public void testToStringPartialNull() {
- Character[] input = new Character[] { 'A', null };
- assertEquals("A", JPAEntityParser.toString(input));
- }
-
- @Test
- public void testToCharacterArrayDefault() {
- String input = new String("AB");
- Character[] ch = JPAEntityParser.toCharacterArray(input);
-
- assertEquals(2, ch.length);
- assertTrue(ch[0].equals('A'));
- assertTrue(ch[1].equals('B'));
- }
-
- @Test
- public void testToCharacterArrayNull() {
- String input = null;
- Character[] ch = JPAEntityParser.toCharacterArray(input);
-
- assertNull(ch);
- }
-
- @Test
- public void testGetPropertyCharacter() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacter", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertEquals("A", output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ @Test
+ public void testToStringDefault() {
+
+ Character[] input = {'A', 'B'};
+ assertEquals("AB", JPAEntityParser.toString(input));
+
+ }
+
+ @Test
+ public void testToStringNull() {
+ Character[] input = null;
+ assertNull(JPAEntityParser.toString(input));
+ }
+
+ @Test
+ public void testToStringPartialNull() {
+ Character[] input = {'A', null};
+ assertEquals("A", JPAEntityParser.toString(input));
}
- }
-
- @Test
- public void testGetPropertyCharacterNull() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacterNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertNull(output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testToCharacterArrayDefault() {
+ String input = new String("AB");
+ Character[] ch = JPAEntityParser.toCharacterArray(input);
+
+ assertEquals(2, ch.length);
+ assertTrue(ch[0].equals('A'));
+ assertTrue(ch[1].equals('B'));
}
- }
-
- @Test
- public void testGetPropertyCharacterArray() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacterArray", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertEquals("AB", output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testToCharacterArrayNull() {
+ String input = null;
+ Character[] ch = JPAEntityParser.toCharacterArray(input);
+
+ assertNull(ch);
}
- }
-
- @Test
- public void testGetPropertyCharacterArrayNull() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacterArrayNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertNull(output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyCharacter() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacter", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertEquals("A", output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetPropertyChar() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getChar", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertEquals("A", output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyCharacterNull() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacterNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertNull(output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharacterArray() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacterArray", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertEquals("AB", output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharacterArrayNull() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharacterArrayNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertNull(output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetPropertyChar() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getChar", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertEquals("A", output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharNull() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertNull(output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetPropertyCharNull() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertNull(output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyCharArray() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharArray", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertEquals("AB", output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetPropertyCharArray() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharArray", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertEquals("AB", output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyCharArrayNull() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharArrayNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertNull(output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetPropertyCharArrayNull() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharArrayNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertNull(output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyCharArrayValueNull() {
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharArrayValueNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
+ assertEquals("A\u0000", output);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetPropertyCharArrayValueNull() {
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getCharArrayValueNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getPropertyValue(method, this, "");
- assertEquals("A\u0000", output);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyObject() {
+
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getObject", (Class<?>[]) null);
+ Object output = JPAEntityParser.getPropertyValue(method, this, "");
+ assertTrue(output != null);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetPropertyObject() {
-
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getObject", (Class<?>[]) null);
- Object output = (Object) JPAEntityParser.getPropertyValue(method, this, "");
- assertTrue(output != null);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
-@Test
- public void testGetPropertyObjectWithParameters() {
-
- try {
- Method method = JPAEntityParserForStaticMethodTest.class.
- getMethod("getObjectWithParameters", getParameterTypeForMethod("getObjectWithParameters"));
- Object output = (Object) JPAEntityParser.getPropertyValue(method, this, "obj1");
- assertTrue(output != null);
-
- } catch (NoSuchMethodException 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 (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetPropertyObjectWithParameters() {
+
+ try {
+ Method method = JPAEntityParserForStaticMethodTest.class.getMethod("getObjectWithParameters",
+ getParameterTypeForMethod("getObjectWithParameters"));
+ Object output = JPAEntityParser.getPropertyValue(method, this, "obj1");
+ assertTrue(output != null);
+
+ } catch (NoSuchMethodException | SecurityException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
-@Test
- public void testGetString() {
- char[] expectedChar = new char[] { 'a', 'b', 'c' };
- try {
- Clob clob = new SerialClob(expectedChar);
- String actualString = JPAEntityParser.getString(clob);
-
- assertEquals(new String(expectedChar), actualString);
-
- } catch (SerialException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SQLException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetString() {
+ char[] expectedChar = {'a', 'b', 'c'};
+ try {
+ Clob clob = new SerialClob(expectedChar);
+ String actualString = JPAEntityParser.getString(clob);
+
+ assertEquals(new String(expectedChar), actualString);
+
+ } catch (SQLException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
-
- @Test
- public void testGetBytes() {
- final String fileName = "SalesOrderProcessingMappingModels.xml";
-
- try {
- InputStream fis = JPAEntityParserForStaticMethodTest.class.getClassLoader().getResourceAsStream(fileName);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int content = fis.read();
- while (content != -1) {
- baos.write(content);
- content = fis.read();
- }
- Blob blob = new SerialBlob(baos.toByteArray());
- byte[] actualBytes = (byte[]) JPAEntityParser.getBytes(blob);
- byte[] expectedBytes = baos.toByteArray();
-
- assertEquals(expectedBytes.length, actualBytes.length);
- int size = actualBytes.length;
- int index = 0;
- while (index < size) {
- assertEquals(expectedBytes[index], actualBytes[index]);
- index++;
- }
-
- } catch (FileNotFoundException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SerialException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SQLException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IOException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ @Test
+ public void testGetBytes() {
+ final String fileName = "SalesOrderProcessingMappingModels.xml";
+
+ try {
+ InputStream fis = JPAEntityParserForStaticMethodTest.class.getClassLoader()
+ .getResourceAsStream(fileName);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ int content = fis.read();
+ while (content != -1) {
+ baos.write(content);
+ content = fis.read();
+ }
+ Blob blob = new SerialBlob(baos.toByteArray());
+ byte[] actualBytes = JPAEntityParser.getBytes(blob);
+ byte[] expectedBytes = baos.toByteArray();
+
+ assertEquals(expectedBytes.length, actualBytes.length);
+ int size = actualBytes.length;
+ int index = 0;
+ while (index < size) {
+ assertEquals(expectedBytes[index], actualBytes[index]);
+ index++;
+ }
+
+ } catch (SQLException | IOException | ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
}
- }
- public Character getCharacter() {
- return new Character('A');
- }
+ public Character getCharacter() {
+ return new Character('A');
+ }
- public Character getCharacterNull() {
- return null;
- }
+ public Character getCharacterNull() {
+ return null;
+ }
- public Character[] getCharacterArray() {
- return new Character[] { 'A', 'B' };
- }
+ public Character[] getCharacterArray() {
+ return new Character[] {'A', 'B'};
+ }
- public Character[] getCharacterArrayNull() {
- return null;
- }
+ public Character[] getCharacterArrayNull() {
+ return null;
+ }
- public char getChar() {
- return 'A';
- }
+ public char getChar() {
+ return 'A';
+ }
- public char getCharNull() {
- return '\u0000';
- }
+ public char getCharNull() {
+ return '\u0000';
+ }
- public char[] getCharArray() {
- return new char[] { 'A', 'B' };
- }
+ public char[] getCharArray() {
+ return new char[] {'A', 'B'};
+ }
- public char[] getCharArrayNull() {
- return null;
- }
+ public char[] getCharArrayNull() {
+ return null;
+ }
- public char[] getCharArrayValueNull() {
- return new char[] { 'A', '\u0000' };
- }
+ public char[] getCharArrayValueNull() {
+ return new char[] {'A', '\u0000'};
+ }
- public Object getObject() {
- return new Object();
- }
+ public Object getObject() {
+ return new Object();
+ }
- public Object getObjectWithParameters(Object ob1) {
- return new Object();
- }
+ public Object getObjectWithParameters(Object ob1) {
+ return new Object();
+ }
- private Class<?>[] getParameterTypeForMethod(String methodName) {
+ private Class<?>[] getParameterTypeForMethod(String methodName) {
- Method[] methods = JPAEntityParserForStaticMethodTest.class.getMethods();
- for (Method method: methods) {
- if (method.getName().equals(methodName)) {
- return method.getParameterTypes();
+ Method[] methods = JPAEntityParserForStaticMethodTest.class.getMethods();
+ for (Method method : methods) {
+ if (method.getName()
+ .equals(methodName)) {
+ return method.getParameterTypes();
+ }
}
- }
- return null;
- }
+ return null;
+ }
}
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserTest.java
index c0b3cf6e..1813557d 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityParserTest.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.data;
@@ -22,14 +18,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.apache.olingo.odata2.api.edm.EdmException;
import org.apache.olingo.odata2.api.edm.EdmMapping;
import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
@@ -45,619 +39,661 @@ import org.easymock.EasyMock;
import org.junit.Test;
public class JPAEntityParserTest {
- /*
- * TestCase - JPAResultParser is a singleton class Check if the same
- * instance is returned when create method is called
- */
- @Test
- public void testCreate() {
- JPAEntityParser resultParser1 = new JPAEntityParser();
- JPAEntityParser resultParser2 = new JPAEntityParser();
-
- if (resultParser1.equals(resultParser2)) {
- fail();
- }
- }
-
- @Test
- public void testparse2EdmPropertyValueMap() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new demoItem("abc", 10);
- EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
- EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
- EdmType edmType01 = EasyMock.createMock(EdmType.class);
- EdmMapping edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- EdmMapping edmMapping01 = EasyMock.createMock(JPAEdmMappingImpl.class);
-
- try {
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmTyped.getName()).andStubReturn("identifier");
- EasyMock.replay(edmType);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
- EasyMock.expect(((JPAEdmMappingImpl) edmMapping).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(edmMapping);
- EasyMock.expect(edmTyped.getType()).andStubReturn(edmType);
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(edmTyped);
- EasyMock.expect(structuralType.getProperty("identifier")).andStubReturn(edmTyped);
-
- EasyMock.expect(edmType01.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmTyped01.getName()).andStubReturn("Value");
- EasyMock.replay(edmType01);
- EasyMock.expect(edmMapping01.getInternalName()).andStubReturn("value");
- EasyMock.expect(((JPAEdmMappingImpl) edmMapping01).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(edmMapping01);
- EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
- EasyMock.expect(edmTyped01.getMapping()).andStubReturn(edmMapping01);
- EasyMock.replay(edmTyped01);
- EasyMock.expect(structuralType.getProperty("value")).andStubReturn(edmTyped01);
-
- List<String> propNames = new ArrayList<String>();
- propNames.add("identifier");
- propNames.add("value");
- EasyMock.expect(structuralType.getPropertyNames()).andReturn(propNames);
- EasyMock.replay(structuralType);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
+ /*
+ * TestCase - JPAResultParser is a singleton class Check if the same instance is returned when
+ * create method is called
+ */
+ @Test
+ public void testCreate() {
+ JPAEntityParser resultParser1 = new JPAEntityParser();
+ JPAEntityParser resultParser2 = new JPAEntityParser();
+
+ if (resultParser1.equals(resultParser2)) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testparse2EdmPropertyValueMap() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new demoItem("abc", 10);
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType01 = EasyMock.createMock(EdmType.class);
+ EdmMapping edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ EdmMapping edmMapping01 = EasyMock.createMock(JPAEdmMappingImpl.class);
+
+ try {
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmTyped.getName())
+ .andStubReturn("identifier");
+ EasyMock.replay(edmType);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("id");
+ EasyMock.expect(((JPAEdmMappingImpl) edmMapping).isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(edmTyped.getType())
+ .andStubReturn(edmType);
+ EasyMock.expect(edmTyped.getMapping())
+ .andStubReturn(edmMapping);
+ EasyMock.replay(edmTyped);
+ EasyMock.expect(structuralType.getProperty("identifier"))
+ .andStubReturn(edmTyped);
+
+ EasyMock.expect(edmType01.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmTyped01.getName())
+ .andStubReturn("Value");
+ EasyMock.replay(edmType01);
+ EasyMock.expect(edmMapping01.getInternalName())
+ .andStubReturn("value");
+ EasyMock.expect(((JPAEdmMappingImpl) edmMapping01).isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping01);
+ EasyMock.expect(edmTyped01.getType())
+ .andStubReturn(edmType01);
+ EasyMock.expect(edmTyped01.getMapping())
+ .andStubReturn(edmMapping01);
+ EasyMock.replay(edmTyped01);
+ EasyMock.expect(structuralType.getProperty("value"))
+ .andStubReturn(edmTyped01);
+
+ List<String> propNames = new ArrayList<String>();
+ propNames.add("identifier");
+ propNames.add("value");
+ EasyMock.expect(structuralType.getPropertyNames())
+ .andReturn(propNames);
+ EasyMock.replay(structuralType);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ try {
+ Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
+ assertEquals(2, result.size());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testparse2EdmPropertyValueMapEdmExcep() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new demoItem("abc", 10);
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType01 = EasyMock.createMock(EdmType.class);
+ EdmMapping edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ EdmMapping edmMapping01 = EasyMock.createMock(JPAEdmMappingImpl.class);
+
+ try {
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmType.getName())
+ .andReturn("identifier");
+ EasyMock.replay(edmType);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("id");
+ EasyMock.expect(((JPAEdmMappingImpl) edmMapping).isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(edmTyped.getType())
+ .andStubThrow(new EdmException(null));
+ EasyMock.expect(edmTyped.getMapping())
+ .andStubReturn(edmMapping);
+ EasyMock.expect(edmTyped.getName())
+ .andReturn("identifier")
+ .anyTimes();
+ EasyMock.replay(edmTyped);
+ EasyMock.expect(structuralType.getProperty("identifier"))
+ .andStubReturn(edmTyped);
+
+ EasyMock.expect(edmType01.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmType01.getName())
+ .andStubReturn("value");
+ EasyMock.replay(edmType01);
+ EasyMock.expect(edmMapping01.getInternalName())
+ .andStubReturn("value");
+ EasyMock.expect(((JPAEdmMappingImpl) edmMapping01).isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping01);
+ EasyMock.expect(edmTyped01.getName())
+ .andReturn("value")
+ .anyTimes();
+ EasyMock.expect(edmTyped01.getType())
+ .andStubReturn(edmType01);
+ EasyMock.expect(edmTyped01.getMapping())
+ .andStubReturn(edmMapping01);
+ EasyMock.replay(edmTyped01);
+ EasyMock.expect(structuralType.getProperty("value"))
+ .andStubReturn(edmTyped01);
+
+ List<String> propNames = new ArrayList<String>();
+ propNames.add("identifier");
+ propNames.add("value");
+ EasyMock.expect(structuralType.getPropertyNames())
+ .andReturn(propNames);
+ EasyMock.replay(structuralType);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); // assertTrue(false);
+ }
+
+ try {
+ resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testparse2EdmPropertyListMap() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Map<String, Object> edmEntity = new HashMap<String, Object>();
+ edmEntity.put("SoId", 1);
+ DemoRelatedEntity relatedEntity = new DemoRelatedEntity("NewOrder");
+ demoItem jpaEntity = new demoItem("laptop", 1);
+ jpaEntity.setRelatedEntity(relatedEntity);
+ List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
+ // Mocking a navigation property and its mapping object
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ try {
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("relatedEntity");
+ EasyMock.expect(edmMapping.isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(navigationProperty.getName())
+ .andStubReturn("RelatedEntities");
+ EasyMock.expect(navigationProperty.getMapping())
+ .andStubReturn(edmMapping);
+ EasyMock.replay(navigationProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ navigationPropertyList.add(navigationProperty);
+ try {
+ HashMap<String, Object> result = resultParser.parse2EdmNavigationValueMap(jpaEntity, navigationPropertyList);
+ assertEquals(relatedEntity, result.get("RelatedEntities"));
+
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testparse2EdmPropertyListMapWithVirtualAccess() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Map<String, Object> edmEntity = new HashMap<String, Object>();
+ edmEntity.put("SoId", 1);
+ DemoRelatedEntity relatedEntity = new DemoRelatedEntity("NewOrder");
+ demoItem jpaEntity = new demoItem("laptop", 1);
+ jpaEntity.setRelatedEntity(relatedEntity);
+ List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
+ // Mocking a navigation property and its mapping object
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ try {
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("relatedEntity");
+ EasyMock.expect(edmMapping.isVirtualAccess())
+ .andStubReturn(true);
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(navigationProperty.getName())
+ .andStubReturn("RelatedEntities");
+ EasyMock.expect(navigationProperty.getMapping())
+ .andStubReturn(edmMapping);
+ EasyMock.replay(navigationProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ navigationPropertyList.add(navigationProperty);
+ try {
+ HashMap<String, Object> result = resultParser.parse2EdmNavigationValueMap(jpaEntity, navigationPropertyList);
+ assertEquals(relatedEntity, result.get("RelatedEntities"));
+
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ // This unit tests when there is a complex type in the select list
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testparse2EdmPropertyValueMapFromListComplex() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ demoItem jpaEntity = new demoItem("laptop", 1);
+ DemoRelatedEntity relatedEntity = new DemoRelatedEntity("DemoOrder");
+ jpaEntity.setRelatedEntity(relatedEntity);
+ List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
+ // Mocking EdmProperties
+ EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
+ EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
+ EdmProperty edmComplexProperty = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType1 = EasyMock.createMock(EdmType.class);
+ EdmStructuralType edmType2 = EasyMock.createMock(EdmStructuralType.class);
+ EdmType edmComplexType = EasyMock.createMock(EdmType.class);
+ JPAEdmMappingImpl mapping1 = EasyMock.createMock(JPAEdmMappingImpl.class);
+ JPAEdmMappingImpl mapping2 = EasyMock.createMock(JPAEdmMappingImpl.class);
+ JPAEdmMappingImpl complexMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ try {
+ EasyMock.expect(edmType1.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType1);
+ EasyMock.expect(mapping1.getInternalName())
+ .andStubReturn("id");
+ EasyMock.expect(mapping1.isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(mapping1);
+ EasyMock.expect(edmProperty1.getName())
+ .andStubReturn("Id");
+ EasyMock.expect(edmProperty1.getMapping())
+ .andStubReturn(mapping1);
+ EasyMock.expect(edmProperty1.getType())
+ .andStubReturn(edmType1);
+ EasyMock.replay(edmProperty1);
+ // Mocking the complex properties
+ EasyMock.expect(edmComplexType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmComplexType);
+ EasyMock.expect(complexMapping.getInternalName())
+ .andStubReturn("order");
+ EasyMock.expect(complexMapping.isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(complexMapping);
+ EasyMock.expect(edmComplexProperty.getName())
+ .andStubReturn("OrderName");
+ EasyMock.expect(edmComplexProperty.getMapping())
+ .andStubReturn(complexMapping);
+ EasyMock.expect(edmComplexProperty.getType())
+ .andStubReturn(edmComplexType);
+ EasyMock.replay(edmComplexProperty);
+ EasyMock.expect(edmType2.getKind())
+ .andStubReturn(EdmTypeKind.COMPLEX);
+ EasyMock.expect(edmType2.getProperty("OrderName"))
+ .andStubReturn(edmComplexProperty);
+ List<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("OrderName");
+ EasyMock.expect(edmType2.getPropertyNames())
+ .andStubReturn(propertyNames);
+ EasyMock.replay(edmType2);
+ EasyMock.expect(mapping2.getInternalName())
+ .andStubReturn("relatedEntity");
+ EasyMock.expect(mapping2.isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(mapping2);
+ EasyMock.expect(edmProperty2.getName())
+ .andStubReturn("Order");
+ EasyMock.expect(edmProperty2.getMapping())
+ .andStubReturn(mapping2);
+ EasyMock.expect(edmProperty2.getType())
+ .andStubReturn(edmType2);
+ EasyMock.replay(edmProperty2);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ selectPropertyList.add(edmProperty1);
+ selectPropertyList.add(edmProperty2);
+ try {
+ Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, selectPropertyList);
+ assertEquals(1, ((HashMap<String, Object>) result.get("Order")).size());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ /*
+ * TestCase - getGetterName is a private method in JPAResultParser. The method is uses reflection to
+ * derive the property access methods from EdmProperty
+ */
+ @Test
+ public void testGetGettersWithOutMapping() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ try {
+
+ /*
+ * Case 1 - Property having No mapping
+ */
+ Class<?>[] pars = {String.class, EdmMapping.class, String.class};
+ Object[] params = {"Field1", null, "get"};
+ Method getGetterName = resultParser.getClass()
+ .getDeclaredMethod("getAccessModifierName", pars);
+ getGetterName.setAccessible(true);
+ String name = (String) getGetterName.invoke(resultParser, params);
+
+ assertEquals("getField1", name);
+
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ @Test
+ public void testGetGettersWithNullPropname() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ try {
+
+ /*
+ * Case 1 - Property having No mapping and no name
+ */
+ Class<?>[] pars = {String.class, EdmMapping.class, String.class};
+ Object[] params = {null, null, null};
+ Method getGetterName = resultParser.getClass()
+ .getDeclaredMethod("getAccessModifierName", pars);
+ getGetterName.setAccessible(true);
+
+ String name = (String) getGetterName.invoke(resultParser, params);
+ assertNull(name);
+
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ /*
+ * TestCase - getGetterName is a private method in JPAResultParser. The method is uses reflection to
+ * derive the property access methods from EdmProperty
+ *
+ * EdmProperty name could have been modified. Then mapping object of EdmProperty should be used for
+ * deriving the name
+ */
+ @Test
+ public void testGetGettersWithMapping() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("field1");
+ EasyMock.replay(edmMapping);
+ try {
+
+ Class<?>[] pars = {String.class, EdmMapping.class, String.class};
+ Object[] params = {"myField", edmMapping, "get"};
+ Method getGetterName = resultParser.getClass()
+ .getDeclaredMethod("getAccessModifierName", pars);
+ getGetterName.setAccessible(true);
+
+ String name = (String) getGetterName.invoke(resultParser, params);
+ assertEquals("getField1", name);
+
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ @Test
+ public void testGetGettersNoSuchMethodException() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ try {
+
+ Method getGetterName = resultParser.getClass()
+ .getDeclaredMethod("getGetterName1", EdmProperty.class);
+ getGetterName.setAccessible(true);
+
+ } catch (NoSuchMethodException e) {
+ assertEquals("org.apache.olingo.odata2.jpa.processor.core.access.data.JPAEntityParser.getGetterName1"
+ + "(org.apache.olingo.odata2.api.edm.EdmProperty)", e.getMessage());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ @Test
+ public void testParse2EdmPropertyValueMap() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new DemoItem2("abc");
+ try {
+ resultParser.parse2EdmPropertyValueMap(jpaEntity, getEdmPropertyList());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testParse2EdmPropertyValueMapWithVirtualAccess() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new DemoItem2("abc");
+ try {
+ resultParser.parse2EdmPropertyValueMap(jpaEntity, getEdmPropertyListWithVirtualAccess());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetGetterEdmException() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new demoItem("abc", 10);
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ try {
+ EasyMock.expect(structuralType.getPropertyNames())
+ .andStubThrow(new EdmException(null));
+ EasyMock.replay(structuralType);
+ Method getGetters = resultParser.getClass()
+ .getDeclaredMethod("getGetters", Object.class, EdmStructuralType.class);
+ getGetters.setAccessible(true);
+ try {
+ getGetters.invoke(resultParser, jpaEntity, structuralType);
+ } catch (IllegalAccessException | IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ assertTrue(true);
+ }
+ } catch (NoSuchMethodException e) {
+ assertEquals("org.apache.olingo.odata2.jpa.processor.core.access.data.JPAEntityParser.getGetters(java.lang.Object,"
+ + "org.apache.olingo.odata2.api.edm.EdmStructuralType)", e.getMessage());
+ } catch (SecurityException | EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testForNullJPAEntity() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ Object map;
+ try {
+ map = resultParser.parse2EdmPropertyValueMap(null, structuralType);
+ assertNull(map);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ class demoItem {
+ private String id;
+ private int value;
+ private DemoRelatedEntity relatedEntity;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ public DemoRelatedEntity getRelatedEntity() {
+ return relatedEntity;
+ }
+
+ public void setRelatedEntity(final DemoRelatedEntity relatedEntity) {
+ this.relatedEntity = relatedEntity;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void set(String property, Object value)
+ throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ this.getClass()
+ .getDeclaredField(property)
+ .set(this, value);
+ }
+
+ public Object get(String property)
+ throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ return this.getClass()
+ .getDeclaredField(property)
+ .get(this);
+ }
+
+ public void setValue(final int value) {
+ this.value = value;
+ }
+
+ demoItem(final String id, final int value) {
+ this.id = id;
+ this.value = value;
+ }
+
+ }
+
+ class DemoRelatedEntity {
+ String order;
+
+ public String getOrder() {
+ return order;
+ }
+
+ public void setOrder(final String order) {
+ this.order = order;
+ }
+
+ public DemoRelatedEntity(final String order) {
+ this.order = order;
+ }
+
+ }
+
+ private List<EdmProperty> getEdmPropertyList() {
+ List<EdmProperty> properties = new ArrayList<EdmProperty>();
+ properties.add(getEdmProperty());
+ return properties;
+ }
+
+ private List<EdmProperty> getEdmPropertyListWithVirtualAccess() {
+ List<EdmProperty> properties = new ArrayList<EdmProperty>();
+ properties.add(getEdmPropertyWithVirtualAccess());
+ return properties;
+ }
+
+ class DemoItem2 {
+ private String field1;
+
+ public String getField1() {
+ return field1;
+ }
- try {
- Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
- assertEquals(2, result.size());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
+ public void setField1(final String field) {
+ field1 = field;
+ }
+
+ // Getter for Dynamic Entity
+ public String get(String fieldName) {
+ return field1;
+ }
- }
-
- @Test
- public void testparse2EdmPropertyValueMapEdmExcep() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new demoItem("abc", 10);
- EdmStructuralType structuralType = EasyMock
- .createMock(EdmStructuralType.class);
- EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
- EdmType edmType01 = EasyMock.createMock(EdmType.class);
- EdmMapping edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- EdmMapping edmMapping01 = EasyMock.createMock(JPAEdmMappingImpl.class);
-
- try {
- EasyMock.expect(edmType.getKind())
- .andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmType.getName()).andReturn("identifier");
- EasyMock.replay(edmType);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
- EasyMock.expect(((JPAEdmMappingImpl)edmMapping).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(edmMapping);
- EasyMock.expect(edmTyped.getType()).andStubThrow(
- new EdmException(null));
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmTyped.getName()).andReturn("identifier").anyTimes();
- EasyMock.replay(edmTyped);
- EasyMock.expect(structuralType.getProperty("identifier"))
- .andStubReturn(edmTyped);
-
- EasyMock.expect(edmType01.getKind()).andStubReturn(
- EdmTypeKind.SIMPLE);
- EasyMock.expect(edmType01.getName()).andStubReturn("value");
- EasyMock.replay(edmType01);
- EasyMock.expect(edmMapping01.getInternalName()).andStubReturn(
- "value");
- EasyMock.expect(((JPAEdmMappingImpl)edmMapping01).isVirtualAccess())
- .andStubReturn(false);
- EasyMock.replay(edmMapping01);
- EasyMock.expect(edmTyped01.getName()).andReturn("value").anyTimes();
- EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
- EasyMock.expect(edmTyped01.getMapping())
- .andStubReturn(edmMapping01);
- EasyMock.replay(edmTyped01);
- EasyMock.expect(structuralType.getProperty("value")).andStubReturn(
- edmTyped01);
-
- List<String> propNames = new ArrayList<String>();
- propNames.add("identifier");
- propNames.add("value");
- EasyMock.expect(structuralType.getPropertyNames()).andReturn(
- propNames);
- EasyMock.replay(structuralType);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2); // assertTrue(false);
- }
+ // Setter for Dynamic Entity
+ public void set(final String fieldName, Object fieldValue) {
+ field1 = (String) fieldValue;
+ }
- try {
- resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
+ public DemoItem2(final String field) {
+ field1 = field;
+ }
- }
-
- @Test
- public void testparse2EdmPropertyListMap() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Map<String, Object> edmEntity = new HashMap<String, Object>();
- edmEntity.put("SoId", 1);
- DemoRelatedEntity relatedEntity = new DemoRelatedEntity("NewOrder");
- demoItem jpaEntity = new demoItem("laptop", 1);
- jpaEntity.setRelatedEntity(relatedEntity);
- List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
- // Mocking a navigation property and its mapping object
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- try {
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("relatedEntity");
- EasyMock.expect(((JPAEdmMappingImpl)edmMapping).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(edmMapping);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("RelatedEntities");
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(navigationProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- navigationPropertyList.add(navigationProperty);
- try {
- HashMap<String, Object> result = resultParser.parse2EdmNavigationValueMap(jpaEntity, navigationPropertyList);
- assertEquals(relatedEntity, result.get("RelatedEntities"));
-
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testparse2EdmPropertyListMapWithVirtualAccess() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Map<String, Object> edmEntity = new HashMap<String, Object>();
- edmEntity.put("SoId", 1);
- DemoRelatedEntity relatedEntity = new DemoRelatedEntity("NewOrder");
- demoItem jpaEntity = new demoItem("laptop", 1);
- jpaEntity.setRelatedEntity(relatedEntity);
- List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
- // Mocking a navigation property and its mapping object
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- try {
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("relatedEntity");
- EasyMock.expect(((JPAEdmMappingImpl)edmMapping).isVirtualAccess()).andStubReturn(true);
- EasyMock.replay(edmMapping);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("RelatedEntities");
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(navigationProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
}
- navigationPropertyList.add(navigationProperty);
- try {
- HashMap<String, Object> result = resultParser.parse2EdmNavigationValueMap(jpaEntity, navigationPropertyList);
- assertEquals(relatedEntity, result.get("RelatedEntities"));
+ private EdmProperty getEdmProperty() {
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- // This unit tests when there is a complex type in the select list
- @SuppressWarnings("unchecked")
- @Test
- public void testparse2EdmPropertyValueMapFromListComplex() {
- JPAEntityParser resultParser = new JPAEntityParser();
- demoItem jpaEntity = new demoItem("laptop", 1);
- DemoRelatedEntity relatedEntity = new DemoRelatedEntity("DemoOrder");
- jpaEntity.setRelatedEntity(relatedEntity);
- List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
- // Mocking EdmProperties
- EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
- EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
- EdmProperty edmComplexProperty = EasyMock.createMock(EdmProperty.class);
- EdmType edmType1 = EasyMock.createMock(EdmType.class);
- EdmStructuralType edmType2 = EasyMock.createMock(EdmStructuralType.class);
- EdmType edmComplexType = EasyMock.createMock(EdmType.class);
- JPAEdmMappingImpl mapping1 = EasyMock.createMock(JPAEdmMappingImpl.class);
- JPAEdmMappingImpl mapping2 = EasyMock.createMock(JPAEdmMappingImpl.class);
- JPAEdmMappingImpl complexMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
- try {
- EasyMock.expect(edmType1.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType1);
- EasyMock.expect(mapping1.getInternalName()).andStubReturn("id");
- EasyMock.expect(((JPAEdmMappingImpl) mapping1).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(mapping1);
- EasyMock.expect(edmProperty1.getName()).andStubReturn("Id");
- EasyMock.expect(edmProperty1.getMapping()).andStubReturn(mapping1);
- EasyMock.expect(edmProperty1.getType()).andStubReturn(edmType1);
- EasyMock.replay(edmProperty1);
- // Mocking the complex properties
- EasyMock.expect(edmComplexType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmComplexType);
- EasyMock.expect(complexMapping.getInternalName()).andStubReturn("order");
- EasyMock.expect(((JPAEdmMappingImpl) complexMapping).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(complexMapping);
- EasyMock.expect(edmComplexProperty.getName()).andStubReturn("OrderName");
- EasyMock.expect(edmComplexProperty.getMapping()).andStubReturn(complexMapping);
- EasyMock.expect(edmComplexProperty.getType()).andStubReturn(edmComplexType);
- EasyMock.replay(edmComplexProperty);
- EasyMock.expect(edmType2.getKind()).andStubReturn(EdmTypeKind.COMPLEX);
- EasyMock.expect(edmType2.getProperty("OrderName")).andStubReturn(edmComplexProperty);
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("OrderName");
- EasyMock.expect(edmType2.getPropertyNames()).andStubReturn(propertyNames);
- EasyMock.replay(edmType2);
- EasyMock.expect(mapping2.getInternalName()).andStubReturn("relatedEntity");
- EasyMock.expect(((JPAEdmMappingImpl) mapping2).isVirtualAccess()).andStubReturn(false);
- EasyMock.replay(mapping2);
- EasyMock.expect(edmProperty2.getName()).andStubReturn("Order");
- EasyMock.expect(edmProperty2.getMapping()).andStubReturn(mapping2);
- EasyMock.expect(edmProperty2.getType()).andStubReturn(edmType2);
- EasyMock.replay(edmProperty2);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- selectPropertyList.add(edmProperty1);
- selectPropertyList.add(edmProperty2);
- try {
- Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, selectPropertyList);
- assertEquals(1, ((HashMap<String, Object>) result.get("Order")).size());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
+ JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("Field1");
+ EasyMock.expect(edmMapping.isVirtualAccess())
+ .andStubReturn(false);
+ EasyMock.replay(edmMapping);
- }
-
- /*
- * TestCase - getGetterName is a private method in JPAResultParser. The
- * method is uses reflection to derive the property access methods from
- * EdmProperty
- */
- @Test
- public void testGetGettersWithOutMapping() {
- JPAEntityParser resultParser = new JPAEntityParser();
- try {
-
- /*
- * Case 1 - Property having No mapping
- */
- Class<?>[] pars = { String.class, EdmMapping.class, String.class };
- Object[] params = { "Field1", null, "get" };
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
- getGetterName.setAccessible(true);
- String name = (String) getGetterName.invoke(resultParser, params);
-
- assertEquals("getField1", name);
-
- } catch (IllegalAccessException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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);
+ EdmType edmType = EasyMock.createMock(EdmType.class);
- }
- }
-
- @Test
- public void testGetGettersWithNullPropname() {
- JPAEntityParser resultParser = new JPAEntityParser();
- try {
-
- /*
- * Case 1 - Property having No mapping and no name
- */
- Class<?>[] pars = { String.class, EdmMapping.class, String.class };
- Object[] params = { null, null, null };
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
- getGetterName.setAccessible(true);
-
- String name = (String) getGetterName.invoke(resultParser, params);
- assertNull(name);
-
- } catch (IllegalAccessException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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);
+ try {
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmType.getName())
+ .andStubReturn("identifier");
+ EasyMock.expect(edmTyped.getName())
+ .andStubReturn("SalesOrderHeader");
+ EasyMock.expect(edmTyped.getMapping())
+ .andStubReturn(edmMapping);
- }
- }
-
- /*
- * TestCase - getGetterName is a private method in JPAResultParser. The
- * method is uses reflection to derive the property access methods from
- * EdmProperty
- *
- * EdmProperty name could have been modified. Then mapping object of
- * EdmProperty should be used for deriving the name
- */
- @Test
- public void testGetGettersWithMapping() {
- JPAEntityParser resultParser = new JPAEntityParser();
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("field1");
- EasyMock.replay(edmMapping);
- try {
-
- Class<?>[] pars = { String.class, EdmMapping.class, String.class };
- Object[] params = { "myField", edmMapping, "get" };
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
- getGetterName.setAccessible(true);
-
- String name = (String) getGetterName.invoke(resultParser, params);
- assertEquals("getField1", name);
-
- } catch (IllegalAccessException 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 (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException 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);
+ EasyMock.expect(edmTyped.getType())
+ .andStubReturn(edmType);
+ EasyMock.expect(edmTyped.getMapping())
+ .andStubReturn(edmMapping);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmType);
+ EasyMock.replay(edmTyped);
+ return edmTyped;
}
- }
- @Test
- public void testGetGettersNoSuchMethodException() {
- JPAEntityParser resultParser = new JPAEntityParser();
- try {
+ private EdmProperty getEdmPropertyWithVirtualAccess() {
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getGetterName1", EdmProperty.class);
- getGetterName.setAccessible(true);
+ JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
+ EasyMock.expect(edmMapping.getInternalName())
+ .andStubReturn("Field1");
+ EasyMock.expect(edmMapping.isVirtualAccess())
+ .andStubReturn(true);
+ EasyMock.replay(edmMapping);
- } catch (NoSuchMethodException e) {
- assertEquals(
- "org.apache.olingo.odata2.jpa.processor.core.access.data.JPAEntityParser.getGetterName1" +
- "(org.apache.olingo.odata2.api.edm.EdmProperty)",
- e.getMessage());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- }
- }
-
- @Test
- public void testParse2EdmPropertyValueMap() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new DemoItem2("abc");
- try {
- resultParser.parse2EdmPropertyValueMap(jpaEntity, getEdmPropertyList());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testParse2EdmPropertyValueMapWithVirtualAccess() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new DemoItem2("abc");
- try {
- resultParser.parse2EdmPropertyValueMap(jpaEntity, getEdmPropertyListWithVirtualAccess());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetGetterEdmException() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new demoItem("abc", 10);
... 25577 lines suppressed ...