HHH-14329 Amend existing DirtyTrackingTest

This commit is contained in:
Sanne Grinovero 2020-11-17 14:46:31 +00:00 committed by Christian Beikov
parent e891a0296c
commit 6b55f8ea09
1 changed files with 21 additions and 5 deletions

View File

@ -63,11 +63,20 @@ public class DirtyTrackingTest {
EnhancerTestUtils.checkDirtyTracking( entity, "someStrings" );
EnhancerTestUtils.clearDirtyTracking( entity );
// Association: this should not set the entity to dirty
Set<Integer> intSet = new HashSet<>();
intSet.add( 42 );
entity.someInts = intSet;
// Association, 1: creating the association will mark it dirty
Set<OtherEntity> associatedSet = new HashSet<>();
OtherEntity o = new OtherEntity();
o.id = 1l;
o.name = "other";
associatedSet.add( o );
entity.someAssociation = associatedSet;
EnhancerTestUtils.checkDirtyTracking( entity, "someAssociation" );
EnhancerTestUtils.clearDirtyTracking( entity );
// Association, 2: modifying a related entity should not
o.name = "newName";
EnhancerTestUtils.checkDirtyTracking( entity );
EnhancerTestUtils.checkDirtyTracking( o, "name" );
// testing composite object
Address address = new Address();
@ -125,7 +134,7 @@ public class DirtyTrackingTest {
List<String> someStrings;
@OneToMany
Set<Integer> someInts;
Set<OtherEntity> someAssociation;
@Embedded
Address address;
@ -141,4 +150,11 @@ public class DirtyTrackingTest {
this.someNumber = someNumber;
}
}
@Entity
private static class OtherEntity {
@Id
Long id;
String name;
}
}