File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/set/PersistentSetTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/set/PersistentSetTest.java | |||
Method name: void testWriteMethodDirtying()
|
Method name: void testCompositeElementWriteMethodDirtying()
|
|||
Number of AST nodes: 36 | Number of AST nodes: 34 | |||
1 | Parent parent = new Parent( "p1" );↵ | |||
2 | Child child = new Child( "c1" );↵ | |||
3 | parent.getChildren↵ | 1 | Container container = new Container( "p1" );↵ | |
2 | Container.Content c1 = new Container.Content( "c1" );↵ | |||
4 | ().add( child );↵ | 3 | container.getContents().add( c1 );↵ | |
5 | child.setParent( parent );↵ | 4 | ↵ | |
6 | Child otherChild = new Child( "c2" );↵ | 5 | Container.Content c2 = new Container.Content( "c2" );↵ | |
7 | Session session = openSession();↵ | 6 | Session session = openSession();↵ | |
8 | session.beginTransaction();↵ | 7 | session.beginTransaction();↵ | |
9 | session.save( parent );↵ | 8 | session.save( container );↵ | |
10 | session.flush();↵ | 9 | session.flush();↵ | |
11 | // at this point, the set on parent has now been replaced with a PersistentSet...↵ | 10 | // at this point, the set on container has now been replaced with a PersistentSet...↵ | |
12 | PersistentSet children = ( PersistentSet ) parent.getChildren();↵ | 11 | PersistentSet children = ( PersistentSet ) container.getContents();↵ | |
13 | assertFalse( children.add( child ) );↵ | 12 | assertFalse( children.add( c1 ) );↵ | |
14 | assertFalse( children.isDirty() );↵ | 13 | assertFalse( children.isDirty() );↵ | |
15 | assertFalse( children.remove( otherChild ) );↵ | 14 | assertFalse( children.remove( c2 ) );↵ | |
16 | assertFalse( children.isDirty() );↵ | 15 | assertFalse( children.isDirty() );↵ | |
17 | HashSet otherSet = new HashSet();↵ | 16 | HashSet otherSet = new HashSet();↵ | |
18 | otherSet.add( child );↵ | 17 | otherSet.add( c1 );↵ | |
19 | assertFalse( children.addAll( otherSet ) );↵ | 18 | assertFalse( children.addAll( otherSet ) );↵ | |
20 | assertFalse( children.isDirty() );↵ | 19 | assertFalse( children.isDirty() );↵ | |
21 | assertFalse( children.retainAll( otherSet ) );↵ | 20 | assertFalse( children.retainAll( otherSet ) );↵ | |
22 | assertFalse( children.isDirty() );↵ | 21 | assertFalse( children.isDirty() );↵ | |
23 | otherSet = new HashSet();↵ | 22 | otherSet = new HashSet();↵ | |
24 | otherSet.add( otherChild );↵ | 23 | otherSet.add( c2 );↵ | |
25 | assertFalse( children.removeAll( otherSet ) );↵ | 24 | assertFalse( children.removeAll( otherSet ) );↵ | |
26 | assertFalse( children.isDirty() );↵ | 25 | assertFalse( children.isDirty() );↵ | |
27 | assertTrue( children.retainAll( otherSet ));↵ | 26 | assertTrue( children.retainAll( otherSet ));↵ | |
28 | assertTrue( children.isDirty() );↵ | 27 | assertTrue( children.isDirty() );↵ | |
29 | assertTrue( children.isEmpty() );↵ | 28 | assertTrue( children.isEmpty() );↵ | |
30 | children.clear();↵ | 29 | children.clear();↵ | |
31 | session.delete( child );↵ | 30 | ↵ | |
32 | assertTrue( children.isDirty() );↵ | 31 | assertTrue( children.isDirty() );↵ | |
33 | session.flush();↵ | 32 | session.flush();↵ | |
34 | children.clear();↵ | 33 | children.clear();↵ | |
35 | assertFalse( children.isDirty() );↵ | 34 | assertFalse( children.isDirty() );↵ | |
36 | session.delete( parent );↵ | 35 | session.delete( container );↵ | |
37 | session.getTransaction().commit();↵ | 36 | session.getTransaction().commit();↵ | |
38 | session.close(); | 37 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 506 |
Number of mapped statements | 29 |
Number of unmapped statements in the first code fragment | 7 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | Container container = new Container("p1"); | |||||||||||||||
1 | Parent parent = new Parent("p1"); |
| | |||||||||||||||
|
| 2 | Container.Content c1 = new Container.Content("c1"); | |||||||||||||||
2 | Child child = new Child("c1"); |
| | |||||||||||||||
| 3 | container.getContents().add(c1); | ||||||||||||||||
3 | parent.getChildren().add(child); | | ||||||||||||||||
|
| 4 | Container.Content c2 = new Container.Content("c2"); | |||||||||||||||
4 | child.setParent(parent); |
| | |||||||||||||||
5 | Child otherChild = new Child("c2"); |
| | |||||||||||||||
6 | Session session = openSession(); | 5 | Session session = openSession(); | |||||||||||||||
7 | session.beginTransaction(); | 6 | session.beginTransaction(); | |||||||||||||||
8 | session.save(parent); |
| 7 | session.save(container); | ||||||||||||||
9 | session.flush(); | 8 | session.flush(); | |||||||||||||||
| 9 | PersistentSet children = (PersistentSet)container.getContents(); | ||||||||||||||||
10 | PersistentSet children = (PersistentSet)parent.getChildren(); | | ||||||||||||||||
11 | assertFalse(children.add(child)); |
| 10 | assertFalse(children.add(c1)); | ||||||||||||||
12 | assertFalse(children.isDirty()); | 11 | assertFalse(children.isDirty()); | |||||||||||||||
13 | assertFalse(children.remove(otherChild)); |
| 12 | assertFalse(children.remove(c2)); | ||||||||||||||
14 | assertFalse(children.isDirty()); | 13 | assertFalse(children.isDirty()); | |||||||||||||||
15 | HashSet otherSet = new HashSet(); | 14 | HashSet otherSet = new HashSet(); | |||||||||||||||
16 | otherSet.add(child); |
| 15 | otherSet.add(c1); | ||||||||||||||
17 | assertFalse(children.addAll(otherSet)); | 16 | assertFalse(children.addAll(otherSet)); | |||||||||||||||
18 | assertFalse(children.isDirty()); | 17 | assertFalse(children.isDirty()); | |||||||||||||||
19 | assertFalse(children.retainAll(otherSet)); | 18 | assertFalse(children.retainAll(otherSet)); | |||||||||||||||
20 | assertFalse(children.isDirty()); | 19 | assertFalse(children.isDirty()); | |||||||||||||||
21 | otherSet = new HashSet(); | 20 | otherSet = new HashSet(); | |||||||||||||||
22 | otherSet.add(otherChild); |
| 21 | otherSet.add(c2); | ||||||||||||||
23 | assertFalse(children.removeAll(otherSet)); | 22 | assertFalse(children.removeAll(otherSet)); | |||||||||||||||
24 | assertFalse(children.isDirty()); | 23 | assertFalse(children.isDirty()); | |||||||||||||||
25 | assertTrue(children.retainAll(otherSet)); | 24 | assertTrue(children.retainAll(otherSet)); | |||||||||||||||
26 | assertTrue(children.isDirty()); | 25 | assertTrue(children.isDirty()); | |||||||||||||||
27 | assertTrue(children.isEmpty()); | 26 | assertTrue(children.isEmpty()); | |||||||||||||||
28 | children.clear(); | 27 | children.clear(); | |||||||||||||||
29 | session.delete(child); |
| | |||||||||||||||
30 | assertTrue(children.isDirty()); | 28 | assertTrue(children.isDirty()); | |||||||||||||||
31 | session.flush(); | 29 | session.flush(); | |||||||||||||||
32 | children.clear(); | 30 | children.clear(); | |||||||||||||||
33 | assertFalse(children.isDirty()); | 31 | assertFalse(children.isDirty()); | |||||||||||||||
34 | session.delete(parent); |
| 32 | session.delete(container); | ||||||||||||||
35 | session.getTransaction().commit(); | 33 | session.getTransaction().commit(); | |||||||||||||||
36 | session.close(); | 34 | session.close(); |
Row | Violation |
---|---|
1 | Unmatched statement Container container=new Container("p1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement Parent parent=new Parent("p1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement Container.Content c1=new Container.Content("c1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement Child child=new Child("c1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement Container.Content c2=new Container.Content("c2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement child.setParent(parent); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Unmatched statement Child otherChild=new Child("c2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
8 | Type org.hibernate.test.collection.set.Parent of variable parent does not match with type org.hibernate.test.collection.set.Container of variable container |
9 | Type org.hibernate.test.collection.set.Child of variable child does not match with type org.hibernate.test.collection.set.Container.Content of variable c1 |
10 | Type org.hibernate.test.collection.set.Child of variable otherChild does not match with type org.hibernate.test.collection.set.Container.Content of variable c2 |
11 | Type org.hibernate.test.collection.set.Child of variable child does not match with type org.hibernate.test.collection.set.Container.Content of variable c1 |
12 | Type org.hibernate.test.collection.set.Child of variable otherChild does not match with type org.hibernate.test.collection.set.Container.Content of variable c2 |
13 | Unmatched statement session.delete(child); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Type org.hibernate.test.collection.set.Parent of variable parent does not match with type org.hibernate.test.collection.set.Container of variable container |
15 | Clone fragment #1 returns variables session , while Clone fragment #2 returns variables |