Skip to content

Commit

Permalink
HHH-17019 Move tests to bytecode folder
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Aug 3, 2023
1 parent c971b16 commit 1b1ed23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.jpa.callbacks;

import static org.assertj.core.api.Assertions.assertThat;
package org.hibernate.orm.test.bytecode.enhancement.callbacks;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -26,6 +24,8 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.PostLoad;

import static org.assertj.core.api.Assertions.assertThat;

@JiraKey("HHH-17019")
@RunWith(BytecodeEnhancerRunner.class)
public class PostLoadLazyListenerTest extends BaseCoreFunctionalTestCase {
Expand All @@ -38,15 +38,16 @@ protected Class<?>[] getAnnotatedClasses() {
@After
public void tearDown() {
inTransaction( session -> {
session.createQuery( "delete from Tag" ).executeUpdate();
session.createQuery( "delete from Person" ).executeUpdate();
}
session.createQuery( "delete from Tag" ).executeUpdate();
session.createQuery( "delete from Person" ).executeUpdate();
}
);
}

@Test
public void smoke() {
inTransaction( session -> {
inTransaction(
session -> {
Person person = new Person( 1, "name" );
Tag tag = new Tag( 100, person );
person.tags.add( tag );
Expand All @@ -56,10 +57,14 @@ public void smoke() {
}
);

inTransaction( session -> {
inTransaction(
session -> {
Tag tag = session.find( Tag.class, 100 );
assertThat( tag )
.isNotNull();
assertThat( TagListener.WAS_CALLED ).isTrue();
assertThat( PersonListener.WAS_CALLED ).isFalse();

assertThat( tag.person.name ).isEqualTo( "name" );
assertThat( PersonListener.WAS_CALLED ).isTrue();
}
Expand Down Expand Up @@ -87,6 +92,7 @@ public Person(int id, String name) {
}

@Entity(name = "Tag")
@EntityListeners(TagListener.class)
public static class Tag {

@Id
Expand All @@ -112,4 +118,13 @@ void onPreUpdate(Object o) {
WAS_CALLED = true;
}
}

public static class TagListener {
static boolean WAS_CALLED = false;

@PostLoad
void onPreUpdate(Object o) {
WAS_CALLED = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.jpa.callbacks;
package org.hibernate.orm.test.bytecode.enhancement.callbacks;

import java.time.Instant;
import java.util.List;
Expand All @@ -22,16 +22,16 @@
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;

import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.orm.junit.JiraKey;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

@TestForIssue(jiraKey = "HHH-12718")
@JiraKey("HHH-12718")
@RunWith(BytecodeEnhancerRunner.class)
public class PreUpdateBytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase {

Expand Down

0 comments on commit 1b1ed23

Please sign in to comment.