File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.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: 34 | Number of AST nodes: 34 | |||
1 | Parent parent = new Parent( "p1" );↵ | |||
2 | Child child = new Child( "c1" );↵ | |||
3 | parent.getChildren().put( child.getName(), child );↵ | |||
4 | child.setParent( parent );↵ | |||
5 | Child otherChild = new Child↵ | 1 | Container container = new Container( "p1" );↵ | |
2 | Container.Content c1 = new Container.Content( "c1" );↵ | |||
3 | container.getContents().add( c1 );↵ | |||
6 | ( "c2" );↵ | 4 | Container.Content c2 = new Container.Content( "c2" );↵ | |
7 | Session session = openSession();↵ | 5 | Session session = openSession();↵ | |
8 | session.beginTransaction();↵ | 6 | session.beginTransaction();↵ | |
9 | session.save( parent );↵ | 7 | session.save( container );↵ | |
10 | session.flush();↵ | 8 | session.flush();↵ | |
11 | // at this point, the set on parent has now been replaced with a PersistentSet...↵ | 9 | // at this point, the set on container has now been replaced with a PersistentSet...↵ | |
12 | PersistentMap children = ( PersistentMap ) parent.getChildren();↵ | 10 | PersistentSet children = ( Persistent↵ | |
13 | Object old = children.put( child.getName(), child );↵ | |||
14 | assertTrue( old == child↵ | 11 | Set ) container.getContents();↵ | |
15 | );↵ | 12 | assertFalse( children.add( c1 ) );↵ | |
16 | assertFalse( children.isDirty() );↵ | 13 | assertFalse( children.isDirty() );↵ | |
17 | old = children.remove( otherChild.getName() );↵ | 14 | assertFalse( children.remove( ↵ | |
18 | assertNull( old );↵ | 15 | c2 ) );↵ | |
19 | assertFalse( children.isDirty() );↵ | 16 | assertFalse( children.isDirty() );↵ | |
20 | HashMap otherMap = new HashMap();↵ | 17 | HashSet otherSet = new HashSet();↵ | |
21 | otherMap.put( child.getName(), child↵ | 18 | otherSet.add( c1 );↵ | |
19 | assertFalse( children.addAll( otherSet ) );↵ | |||
22 | );↵ | 20 | assertFalse( children.isDirty() );↵ | |
23 | children.putAll( otherMap );↵ | 21 | assertFalse( children.retainAll( otherSet ) );↵ | |
24 | assertFalse( children.isDirty() );↵ | 22 | assertFalse( children.isDirty() );↵ | |
25 | otherMap = new HashMap();↵ | 23 | otherSet = new HashSet();↵ | |
26 | otherMap.put( otherChild.getName(), otherChild );↵ | 24 | other↵ | |
27 | ↵ | 25 | Set.add( c2 );↵ | |
28 | children.putAll( otherMap );↵ | 26 | assertFalse( children.removeAll( otherSet ) );↵ | |
29 | assertTrue( children.isDirty() );↵ | 27 | assertFalse( children.isDirty() );↵ | |
30 | children.clear↵ | 28 | assertTrue( children.retainAll( otherSet ));↵ | |
31 | Dirty();↵ | 29 | assertTrue( children.isDirty() );↵ | |
32 | session.delete( child );↵ | 30 | assertTrue( children.isEmpty() );↵ | |
33 | children.clear();↵ | 31 | children.clear();↵ | |
34 | assertTrue( children.isDirty() );↵ | 32 | assertTrue( children.isDirty() );↵ | |
35 | session.flush();↵ | 33 | session.flush();↵ | |
36 | children.clear();↵ | 34 | children.clear();↵ | |
37 | assertFalse( children.isDirty() );↵ | 35 | assertFalse( children.isDirty() );↵ | |
38 | session.delete( parent );↵ | 36 | session.delete( container );↵ | |
39 | session.getTransaction().commit();↵ | 37 | session.getTransaction().commit();↵ | |
40 | session.close(); | 38 |
| |
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 in different classes having the same super class |
Number of node comparisons | 612 |
Number of mapped statements | 17 |
Number of unmapped statements in the first code fragment | 17 |
Number of unmapped statements in the second code fragment | 17 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 2 |
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().put(child.getName(), 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 | assertFalse(children.add(c1)); | ||||||||||||||||||
10 | PersistentMap children = (PersistentMap)parent.getChildren(); | | ||||||||||||||||||
| 11 | assertFalse(children.isDirty()); | ||||||||||||||||||
11 | Object old = children.put(child.getName(), child); | | ||||||||||||||||||
| 12 | assertFalse(children.remove(c2)); | ||||||||||||||||||
12 | assertTrue(old == child); |
| 26 | assertTrue(children.isEmpty()); | ||||||||||||||||
13 | assertFalse(children.isDirty()); |
| 13 | assertFalse(children.isDirty()); | ||||||||||||||||
| 14 | HashSet otherSet = new HashSet(); | ||||||||||||||||||
14 | old = children.remove(otherChild.getName()); |
| | |||||||||||||||||
| 15 | otherSet.add(c1); | ||||||||||||||||||
15 | assertNull(old); | | ||||||||||||||||||
| 16 | assertFalse(children.addAll(otherSet)); | ||||||||||||||||||
16 | assertFalse(children.isDirty()); |
| 17 | assertFalse(children.isDirty()); | ||||||||||||||||
17 | HashMap otherMap = new HashMap(); | | ||||||||||||||||||
| 18 | assertFalse(children.retainAll(otherSet)); | ||||||||||||||||||
18 | otherMap.put(child.getName(), child); | | ||||||||||||||||||
19 | children.putAll(otherMap); | | ||||||||||||||||||
20 | assertFalse(children.isDirty()); |
| 19 | assertFalse(children.isDirty()); | ||||||||||||||||
| 20 | otherSet = new HashSet(); | ||||||||||||||||||
| 21 | otherSet.add(c2); | ||||||||||||||||||
21 | otherMap = new HashMap(); | | ||||||||||||||||||
| 22 | assertFalse(children.removeAll(otherSet)); | ||||||||||||||||||
22 | otherMap.put(otherChild.getName(), otherChild); | | ||||||||||||||||||
| 23 | assertFalse(children.isDirty()); | ||||||||||||||||||
23 | children.putAll(otherMap); | | ||||||||||||||||||
| 24 | assertTrue(children.retainAll(otherSet)); | ||||||||||||||||||
24 | assertTrue(children.isDirty()); |
| 25 | assertTrue(children.isDirty()); | ||||||||||||||||
25 | children.clearDirty(); |
| | |||||||||||||||||
26 | session.delete(child); |
| 32 | session.delete(container); | ||||||||||||||||
27 | children.clear(); |
| 27 | children.clear(); | ||||||||||||||||
28 | assertTrue(children.isDirty()); |
| 28 | assertTrue(children.isDirty()); | ||||||||||||||||
29 | session.flush(); | 29 | session.flush(); | |||||||||||||||||
30 | children.clear(); |
| 30 | children.clear(); | ||||||||||||||||
31 | assertFalse(children.isDirty()); |
| 31 | assertFalse(children.isDirty()); | ||||||||||||||||
32 | session.delete(parent); |
| | |||||||||||||||||
33 | session.getTransaction().commit(); | 33 | session.getTransaction().commit(); | |||||||||||||||||
34 | 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 | Expression parent cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression container cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Type org.hibernate.test.collection.map.Parent of variable parent does not match with type org.hibernate.test.collection.set.Container of variable container |
11 | Expression old == child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression children.isEmpty() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Unmatched statement old=children.remove(otherChild.getName()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement children.clearDirty(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Expression child cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression container cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Type org.hibernate.test.collection.map.Child of variable child does not match with type org.hibernate.test.collection.set.Container of variable container |
18 | Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public void clear() |
19 | Expression children cannot be unified with expression children , because common superclass org.hibernate.collection.AbstractPersistentCollection does not declare member(s) public void clear() |
20 | Unmatched statement session.delete(parent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
21 | Clone fragment #1 returns variables session , while Clone fragment #2 returns variables |