File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/AbstractCollectionEventTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/AbstractCollectionEventTest.java | |||
Method name: void testUpdateParentOneChildToNoneByRemove()
|
Method name: void testUpdateParentOneChildToNoneByClear()
|
|||
Number of AST nodes: 26 | Number of AST nodes: 26 | |||
1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | 1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | |
2 | ParentWithCollection parent = createParentWithOneChild( "parent", "child" );↵ | 2 | ParentWithCollection parent = createParentWithOneChild( "parent", "child" );↵ | |
3 | assertEquals( 1, parent.getChildren().size() );↵ | 3 | assertEquals( 1, parent.getChildren().size() );↵ | |
4 | Child child = ( Child ) parent.getChildren().iterator().next();↵ | 4 | Child child = ( Child ) parent.getChildren().iterator().next();↵ | |
5 | listeners.clear();↵ | 5 | listeners.clear();↵ | |
6 | Session s = openSession();↵ | 6 | Session s = openSession();↵ | |
7 | Transaction tx = s.beginTransaction();↵ | 7 | Transaction tx = s.beginTransaction();↵ | |
8 | parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );↵ | 8 | parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );↵ | |
9 | if ( child instanceof Entity ) {↵ | 9 | if ( child instanceof Entity ) {↵ | |
10 | child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );↵ | 10 | child = ( Child ) s.get( child.getClass(), ( ( Entity ) child ).getId() );↵ | |
11 | }↵ | 11 | }↵ | |
12 | parent.removeChild( child );↵ | 12 | parent.clearChildren();↵ | |
13 | tx.commit();↵ | 13 | tx.commit();↵ | |
14 | s.close();↵ | 14 | s.close();↵ | |
15 | int index = 0;↵ | 15 | int index = 0;↵ | |
16 | if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {↵ | 16 | if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {↵ | |
17 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | 17 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | |
18 | }↵ | 18 | }↵ | |
19 | if ( child instanceof ChildWithBidirectionalManyToMany ) {↵ | 19 | if ( child instanceof ChildWithBidirectionalManyToMany ) {↵ | |
20 | ChildWithBidirectionalManyToMany childWithManyToMany = ( ChildWithBidirectionalManyToMany ) child;↵ | 20 | ChildWithBidirectionalManyToMany childWithManyToMany = ( ChildWithBidirectionalManyToMany ) child;↵ | |
21 | if ( ( ( PersistentCollection ) childWithManyToMany.getParents( ) ).wasInitialized() ) {↵ | 21 | if ( ( ( PersistentCollection ) childWithManyToMany.getParents() ).wasInitialized() ) {↵ | |
22 | checkResult( listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++ );↵ | 22 | checkResult( listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++ );↵ | |
23 | }↵ | 23 | }↵ | |
24 | }↵ | 24 | }↵ | |
25 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | 25 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | |
26 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | 26 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | |
27 | if ( child instanceof ChildWithBidirectionalManyToMany ) {↵ | 27 | if ( child instanceof ChildWithBidirectionalManyToMany ) {↵ | |
28 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );↵ | 28 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );↵ | |
29 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );↵ | 29 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), ( ChildWithBidirectionalManyToMany ) child, index++ );↵ | |
30 | }↵ | 30 | }↵ | |
31 | checkNumberOfResults( listeners, index ); | 31 |
| |
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.7 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 195 |
Number of mapped statements | 26 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 9.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | 1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | ||||||||||||||||||||||
2 | ParentWithCollection parent = createParentWithOneChild("parent", "child"); | 2 | ParentWithCollection parent = createParentWithOneChild("parent", "child"); | ||||||||||||||||||||||
3 | assertEquals(1, parent.getChildren().size()); | 3 | assertEquals(1, parent.getChildren().size()); | ||||||||||||||||||||||
4 | Child child = (Child)parent.getChildren().iterator().next(); | 4 | Child child = (Child)parent.getChildren().iterator().next(); | ||||||||||||||||||||||
5 | listeners.clear(); | 5 | listeners.clear(); | ||||||||||||||||||||||
6 | Session s = openSession(); | 6 | Session s = openSession(); | ||||||||||||||||||||||
7 | Transaction tx = s.beginTransaction(); | 7 | Transaction tx = s.beginTransaction(); | ||||||||||||||||||||||
8 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | 8 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | ||||||||||||||||||||||
9 | if (child instanceof Entity) | 9 | if (child instanceof Entity) | ||||||||||||||||||||||
10 | child = (Child)s.get(child.getClass(), ((Entity)child).getId()); | 10 | child = (Child)s.get(child.getClass(), ((Entity)child).getId()); | ||||||||||||||||||||||
11 | parent.removeChild(child); |
| 11 | parent.clearChildren(); | |||||||||||||||||||||
12 | tx.commit(); | 12 | tx.commit(); | ||||||||||||||||||||||
13 | s.close(); | 13 | s.close(); | ||||||||||||||||||||||
14 | int index = 0; | 14 | int index = 0; | ||||||||||||||||||||||
15 | if (((PersistentCollection)parent.getChildren()).wasInitialized()) | 15 | if (((PersistentCollection)parent.getChildren()).wasInitialized()) | ||||||||||||||||||||||
16 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | 16 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | ||||||||||||||||||||||
17 | if (child instanceof ChildWithBidirectionalManyToMany) | 17 | if (child instanceof ChildWithBidirectionalManyToMany) | ||||||||||||||||||||||
18 | ChildWithBidirectionalManyToMany childWithManyToMany = (ChildWithBidirectionalManyToMany)child; | 18 | ChildWithBidirectionalManyToMany childWithManyToMany = (ChildWithBidirectionalManyToMany)child; | ||||||||||||||||||||||
19 | if (((PersistentCollection)childWithManyToMany.getParents()).wasInitialized()) | 19 | if (((PersistentCollection)childWithManyToMany.getParents()).wasInitialized()) | ||||||||||||||||||||||
20 | checkResult(listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++); | 20 | checkResult(listeners, listeners.getInitializeCollectionListener(), childWithManyToMany, index++); | ||||||||||||||||||||||
21 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); | 21 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); | ||||||||||||||||||||||
22 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); | 22 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); | ||||||||||||||||||||||
23 | if (child instanceof ChildWithBidirectionalManyToMany) | 23 | if (child instanceof ChildWithBidirectionalManyToMany) | ||||||||||||||||||||||
24 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), (ChildWithBidirectionalManyToMany)child, index++); | 24 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), (ChildWithBidirectionalManyToMany)child, index++); | ||||||||||||||||||||||
25 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), (ChildWithBidirectionalManyToMany)child, index++); | 25 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), (ChildWithBidirectionalManyToMany)child, index++); | ||||||||||||||||||||||
26 | checkNumberOfResults(listeners, index); | 26 | checkNumberOfResults(listeners, index); |
Row | Violation |
---|---|
1 | Expression parent.removeChild(child) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression parent.clearChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression parent.removeChild(child) is a void method call, and thus it cannot be parameterized |
4 | Expression parent.clearChildren() is a void method call, and thus it cannot be parameterized |
5 | Expression parent.removeChild(child) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression parent.clearChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression parent.removeChild(child) is a void method call, and thus it cannot be parameterized |
8 | Expression parent.clearChildren() is a void method call, and thus it cannot be parameterized |