diff --git a/entity-view/testsuite/pom.xml b/entity-view/testsuite/pom.xml index 081f819966..74643f2c5d 100644 --- a/entity-view/testsuite/pom.xml +++ b/entity-view/testsuite/pom.xml @@ -41,19 +41,17 @@ ${project.groupId} blaze-persistence-core-api - test ${project.groupId} blaze-persistence-core-impl - test ${project.groupId} blaze-persistence-core-testsuite ${project.version} - + * * @@ -63,28 +61,24 @@ ${project.groupId} blaze-persistence-entity-view-api - test ${project.groupId} blaze-persistence-entity-view-impl - test ${project.groupId} blaze-common-utils - test junit junit - test + compile com.googlecode.catch-exception catch-exception - test org.mockito @@ -457,12 +451,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-4.2 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -543,6 +535,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -562,12 +566,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-4.3 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -648,6 +650,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -667,12 +681,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-5 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -753,6 +765,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -772,12 +796,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-5 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -858,6 +880,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -880,12 +914,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-5.2 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -966,6 +998,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -985,12 +1029,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-5.3 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -1071,6 +1113,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -1100,12 +1154,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-5.4 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -1186,6 +1238,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -1212,12 +1276,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-6.0 - test ${project.groupId} blaze-persistence-testsuite-base-hibernate - test @@ -1298,6 +1360,18 @@ + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + @@ -1317,7 +1391,6 @@ ${project.groupId} blaze-persistence-testsuite-base-eclipselink - test @@ -1454,7 +1527,6 @@ ${project.groupId} blaze-persistence-testsuite-base-datanucleus - test ${project.groupId} @@ -1615,7 +1687,6 @@ ${project.groupId} blaze-persistence-testsuite-base-datanucleus - test ${project.groupId} @@ -1883,7 +1954,6 @@ ${project.groupId} blaze-persistence-testsuite-base-openjpa - test diff --git a/entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/AbstractEntityViewTest.java b/entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/AbstractEntityViewTest.java similarity index 100% rename from entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/AbstractEntityViewTest.java rename to entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/AbstractEntityViewTest.java diff --git a/entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateDocumentTest.java b/entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateDocumentTest.java similarity index 100% rename from entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateDocumentTest.java rename to entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateDocumentTest.java diff --git a/entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateTest.java b/entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateTest.java similarity index 96% rename from entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateTest.java rename to entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateTest.java index f409b3840d..b385e74c1d 100644 --- a/entity-view/testsuite/src/test/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateTest.java +++ b/entity-view/testsuite/src/main/java/com/blazebit/persistence/view/testsuite/update/AbstractEntityViewUpdateTest.java @@ -162,15 +162,15 @@ public final void tearDown() { protected void assertNullCollection(Collection collection) { // Currently, setting a collection to null will result in an empty recording collection after update // assertNull(collection); - assertTrue(collection instanceof RecordingCollection); - assertEquals(0, collection.size()); + Assert.assertTrue(collection instanceof RecordingCollection); + Assert.assertEquals(0, collection.size()); } protected void assertNullMap(Map map) { // Currently, setting a collection to null will result in an empty recording collection after update // assertNull(map); - assertTrue(map instanceof RecordingMap); - assertEquals(0, map.size()); + Assert.assertTrue(map instanceof RecordingMap); + Assert.assertEquals(0, map.size()); } protected void registerViewTypes(EntityViewConfiguration cfg) { @@ -240,12 +240,12 @@ protected AssertStatementBuilder assertQueriesAfterUpdate(T docView) { protected void assertVersionDiff(long oldVersion, long currentVersion, long diff, long fullDiff) { if (version) { if (isFullMode()) { - assertEquals(oldVersion + fullDiff, currentVersion); + Assert.assertEquals(oldVersion + fullDiff, currentVersion); } else { - assertEquals(oldVersion + diff, currentVersion); + Assert.assertEquals(oldVersion + diff, currentVersion); } } else { - assertEquals(oldVersion, currentVersion); + Assert.assertEquals(oldVersion, currentVersion); } } diff --git a/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/EntityViewRemoveViewWithUnmappedCollectionAndWhereClauseTest.java b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/EntityViewRemoveViewWithUnmappedCollectionAndWhereClauseTest.java new file mode 100644 index 0000000000..be26b509e1 --- /dev/null +++ b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/EntityViewRemoveViewWithUnmappedCollectionAndWhereClauseTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2014 - 2019 Blazebit. + * + * Licensed 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 com.blazebit.persistence.view.testsuite.removeunmapped; + +import com.blazebit.persistence.testsuite.base.jpa.assertion.AssertStatementBuilder; +import com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus; +import com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink; +import com.blazebit.persistence.testsuite.tx.TxVoidWork; +import com.blazebit.persistence.view.FlushMode; +import com.blazebit.persistence.view.FlushStrategy; +import com.blazebit.persistence.view.testsuite.removeunmapped.model.FileLink; +import com.blazebit.persistence.view.testsuite.removeunmapped.model.Template; +import com.blazebit.persistence.view.testsuite.removeunmapped.model.TemplateView; +import com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import javax.persistence.EntityManager; + + +/** + * + * @author Harald Eibensteiner + * @since 1.4.0 + */ +@RunWith(Parameterized.class) +// NOTE: No Datanucleus support yet +@Category({ NoDatanucleus.class, NoEclipselink.class}) +public class EntityViewRemoveViewWithUnmappedCollectionAndWhereClauseTest extends AbstractEntityViewUpdateTest { + + public EntityViewRemoveViewWithUnmappedCollectionAndWhereClauseTest(FlushMode mode, FlushStrategy strategy, boolean version) { + super(mode, strategy, version, TemplateView.class); + } + + @Parameterized.Parameters(name = "{0} - {1} - VERSIONED={2}") + public static Object[][] combinations() { + return MODE_STRATEGY_VERSION_COMBINATIONS; + } + + @Override + protected Class[] getEntityClasses() { + return new Class[]{ + Template.class, + FileLink.class + }; + } + + @Test + public void testSimpleRemove() { + // Given + transactional(new TxVoidWork() { + @Override + public void work(EntityManager em) { + Template t = new Template(1L); + em.persist(t); + } + }); + // When + remove(TemplateView.class, 1L); + + // Then + } + + @Override + protected void reload() { + + } + + @Override + protected AssertStatementBuilder fullFetch(AssertStatementBuilder builder) { + return null; + } + + @Override + protected AssertStatementBuilder versionUpdate(AssertStatementBuilder builder) { + return null; + } +} diff --git a/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/FileLink.java b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/FileLink.java new file mode 100644 index 0000000000..3f68763337 --- /dev/null +++ b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/FileLink.java @@ -0,0 +1,74 @@ +/* + * Copyright 2014 - 2019 Blazebit. + * + * Licensed 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 com.blazebit.persistence.view.testsuite.removeunmapped.model; + +import org.hibernate.annotations.Where; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import java.util.Set; + +/** + * + * @author Harald Eibensteiner + * @since 1.4.0 + */ +@Entity +public class FileLink { + + @Id + Long id; + @Column(name = "type") + Integer type; + @Column(name = "id1") + Long id1; + String content; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Long getId1() { + return id1; + } + + public void setId1(Long id1) { + this.id1 = id1; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/Template.java b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/Template.java new file mode 100644 index 0000000000..d382ee9df5 --- /dev/null +++ b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/Template.java @@ -0,0 +1,62 @@ +/* + * Copyright 2014 - 2019 Blazebit. + * + * Licensed 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 com.blazebit.persistence.view.testsuite.removeunmapped.model; + +import org.hibernate.annotations.Where; + +import javax.persistence.*; +import java.util.Set; + +/** + * + * @author Harald Eibensteiner + * @since 1.4.0 + */ +@Entity +public class Template { + + @Id + @Column(name = "template_id") + Long id; + @OneToMany + @JoinColumn(name = "id1", referencedColumnName = "template_id") + @Where(clause = "type = 1") + Set fileLinks; + + public Template() { + } + + public Template(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Set getFileLinks() { + return fileLinks; + } + + public void setFileLinks(Set fileLinks) { + this.fileLinks = fileLinks; + } +} diff --git a/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/TemplateView.java b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/TemplateView.java new file mode 100644 index 0000000000..cf023c10f7 --- /dev/null +++ b/entity-view/testsuite/src/test/hibernate/com/blazebit/persistence/view/testsuite/removeunmapped/model/TemplateView.java @@ -0,0 +1,31 @@ +/* + * Copyright 2014 - 2019 Blazebit. + * + * Licensed 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 com.blazebit.persistence.view.testsuite.removeunmapped.model; + +import com.blazebit.persistence.testsuite.entity.Person; +import com.blazebit.persistence.view.EntityView; +import com.blazebit.persistence.view.testsuite.basic.model.IdHolderView; + +/** + * + * @author Harald Eibensteiner + * @since 1.4.0 + */ +@EntityView(Template.class) +public interface TemplateView extends IdHolderView { + +}