Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F14C22009F9 for ; Mon, 23 May 2016 22:42:02 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EFCA4160A0E; Mon, 23 May 2016 20:42:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EBABE160A05 for ; Mon, 23 May 2016 22:42:01 +0200 (CEST) Received: (qmail 30445 invoked by uid 500); 23 May 2016 20:42:01 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 30435 invoked by uid 99); 23 May 2016 20:42:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 May 2016 20:42:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D154BDFDD0; Mon, 23 May 2016 20:42:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tandraschko@apache.org To: commits@deltaspike.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: deltaspike git commit: DELTASPIKE-1154 remove "unused" verifier API for now Date: Mon, 23 May 2016 20:42:00 +0000 (UTC) archived-at: Mon, 23 May 2016 20:42:03 -0000 Repository: deltaspike Updated Branches: refs/heads/master 243426f22 -> 0bb287f56 DELTASPIKE-1154 remove "unused" verifier API for now Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/0bb287f5 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/0bb287f5 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/0bb287f5 Branch: refs/heads/master Commit: 0bb287f56a3e4d2afc9f731ce56fc03102a7dd08 Parents: 243426f Author: Thomas Andraschko Authored: Mon May 23 22:41:53 2016 +0200 Committer: Thomas Andraschko Committed: Mon May 23 22:41:53 2016 +0200 ---------------------------------------------------------------------- .../extractor/AnnotationMetadataExtractor.java | 3 +- .../data/impl/meta/verifier/EntityVerifier.java | 35 ----------- .../data/impl/meta/verifier/Verifier.java | 26 -------- .../deltaspike/data/impl/util/EntityUtils.java | 4 +- .../impl/meta/verifier/EntityVerifierTest.java | 62 -------------------- .../data/impl/util/EntityUtilsTest.java | 30 +++++++++- 6 files changed, 32 insertions(+), 128 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0bb287f5/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/extractor/AnnotationMetadataExtractor.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/extractor/AnnotationMetadataExtractor.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/extractor/AnnotationMetadataExtractor.java index 0801ea9..46bedc8 100644 --- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/extractor/AnnotationMetadataExtractor.java +++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/extractor/AnnotationMetadataExtractor.java @@ -20,7 +20,6 @@ package org.apache.deltaspike.data.impl.meta.extractor; import org.apache.deltaspike.data.api.Repository; import org.apache.deltaspike.data.impl.meta.RepositoryEntity; -import org.apache.deltaspike.data.impl.meta.verifier.EntityVerifier; import org.apache.deltaspike.data.impl.util.EntityUtils; public class AnnotationMetadataExtractor implements MetadataExtractor @@ -31,7 +30,7 @@ public class AnnotationMetadataExtractor implements MetadataExtractor { Repository repo = repoClass.getAnnotation(Repository.class); Class repoEntity = repo.forEntity(); - boolean isEntityClass = !Object.class.equals(repoEntity) && EntityVerifier.INSTANCE.verify(repoEntity); + boolean isEntityClass = !Object.class.equals(repoEntity) && EntityUtils.isEntityClass(repoEntity); if (isEntityClass) { return new RepositoryEntity(repoEntity, EntityUtils.primaryKeyClass(repoEntity)); http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0bb287f5/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifier.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifier.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifier.java deleted file mode 100644 index 5ef310a..0000000 --- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.data.impl.meta.verifier; - -import javax.persistence.Entity; -import org.apache.deltaspike.jpa.spi.descriptor.xml.PersistenceUnitDescriptorProvider; - -public class EntityVerifier implements Verifier> -{ - public static final EntityVerifier INSTANCE = new EntityVerifier(); - - @Override - public boolean verify(Class entity) - { - return entity.isAnnotationPresent(Entity.class) - || PersistenceUnitDescriptorProvider.getInstance().isEntity(entity); - } - -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0bb287f5/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/Verifier.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/Verifier.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/Verifier.java deleted file mode 100644 index 62fe3ab..0000000 --- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/verifier/Verifier.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.data.impl.meta.verifier; - -public interface Verifier -{ - - boolean verify(T t); - -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0bb287f5/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/EntityUtils.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/EntityUtils.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/EntityUtils.java index 54444b6..cfe2606 100755 --- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/EntityUtils.java +++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/EntityUtils.java @@ -32,7 +32,6 @@ import javax.persistence.Version; import javax.persistence.metamodel.EntityType; import org.apache.deltaspike.core.util.StringUtils; -import org.apache.deltaspike.data.impl.meta.verifier.EntityVerifier; import org.apache.deltaspike.data.impl.property.Property; import org.apache.deltaspike.data.impl.property.query.AnnotatedPropertyCriteria; import org.apache.deltaspike.data.impl.property.query.NamedPropertyCriteria; @@ -109,7 +108,8 @@ public final class EntityUtils public static boolean isEntityClass(Class entityClass) { - return EntityVerifier.INSTANCE.verify(entityClass); + return entityClass.isAnnotationPresent(Entity.class) + || PersistenceUnitDescriptorProvider.getInstance().isEntity(entityClass); } public static Property primaryKeyProperty(Class entityClass) http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0bb287f5/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifierTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifierTest.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifierTest.java deleted file mode 100644 index e190022..0000000 --- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/meta/verifier/EntityVerifierTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.data.impl.meta.verifier; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.apache.deltaspike.data.impl.meta.verifier.EntityVerifier; -import org.apache.deltaspike.data.test.domain.Simple; -import org.junit.Test; - -public class EntityVerifierTest -{ - - @Test - public void should_accept_entity_class() - { - // given - EntityVerifier entityVerifier = new EntityVerifier(); - - // when - boolean isValid = entityVerifier.verify(Simple.class); - - // then - assertTrue(isValid); - } - - @Test - public void should_not_accept_class_without_entity_annotation() - { - // given - EntityVerifier entityVerifier = new EntityVerifier(); - - // when - boolean isValid = entityVerifier.verify(EntityWithoutId.class); - - // then - assertFalse(isValid); - - } - - private static class EntityWithoutId - { - } - -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0bb287f5/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java index cde1590..fa8bd81 100755 --- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java +++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java @@ -20,7 +20,7 @@ package org.apache.deltaspike.data.impl.util; import java.io.Serializable; -import org.apache.deltaspike.data.impl.util.EntityUtils; +import org.apache.deltaspike.data.test.domain.Simple; import org.apache.deltaspike.data.test.domain.Tee; import org.apache.deltaspike.data.test.domain.Tee2; import org.apache.deltaspike.data.test.domain.TeeId; @@ -53,4 +53,32 @@ public class EntityUtilsTest // then Assert.assertEquals(TeeId.class, pkClass); } + + @Test + public void should_accept_entity_class() + { + // given + + // when + boolean isValid = EntityUtils.isEntityClass(Simple.class); + + // then + Assert.assertTrue(isValid); + } + + @Test + public void should_not_accept_class_without_entity_annotation() + { + // given + + // when + boolean isValid = EntityUtils.isEntityClass(EntityWithoutId.class); + + // then + Assert.assertFalse(isValid); + } + + private static class EntityWithoutId + { + } }