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 testUpdateParentNullToOneChild()
|
Method name: void testUpdateParentOneToTwoChildren()
|
|||
Number of AST nodes: 20 | Number of AST nodes: 19 | |||
1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | 1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | |
2 | ParentWithCollection parent = createParentWithNullChildren( "parent" );↵ | 2 | ParentWithCollection parent = createParentWithOneChild( "parent"↵ | |
3 | listeners.clear();↵ | |||
4 | assertNull( parent.getChildren() ↵ | 3 | , "child" );↵ | |
4 | assertEquals( 1, parent.getChildren().size() );↵ | |||
5 | );↵ | 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 | assertNotNull( parent.getChildren() );↵ | 9 | ↵ | |
10 | Child newChild = parent.addChild( "new" );↵ | 10 | Child newChild = parent.addChild( "new2" );↵ | |
11 | tx.commit();↵ | 11 | tx.commit();↵ | |
12 | s.close();↵ | 12 | s.close();↵ | |
13 | int index = 0;↵ | 13 | int index = 0;↵ | |
14 | if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {↵ | 14 | if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {↵ | |
15 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | 15 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | |
16 | }↵ | 16 | }↵ | |
17 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | 17 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | |
18 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | 18 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | |
19 | if ( newChild instanceof ChildWithBidirectionalManyToMany ) {↵ | 19 | if ( newChild instanceof ChildWithBidirectionalManyToMany ) {↵ | |
20 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | 20 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | |
21 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | 21 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | |
22 | }↵ | 22 | }↵ | |
23 | checkNumberOfResults( listeners, index ); | 23 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 159 |
Number of mapped statements | 19 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 134.7 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | 1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | ||||||||||||||||||||||
2 | ParentWithCollection parent = createParentWithNullChildren("parent"); |
| 2 | ParentWithCollection parent = createParentWithOneChild("parent", "child"); | |||||||||||||||||||||
3 | listeners.clear(); | 4 | listeners.clear(); | ||||||||||||||||||||||
4 | assertNull(parent.getChildren()); |
| 3 | assertEquals(1, parent.getChildren().size()); | |||||||||||||||||||||
5 | Session s = openSession(); | 5 | Session s = openSession(); | ||||||||||||||||||||||
6 | Transaction tx = s.beginTransaction(); | 6 | Transaction tx = s.beginTransaction(); | ||||||||||||||||||||||
7 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | 7 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | ||||||||||||||||||||||
8 | assertNotNull(parent.getChildren()); |
| | ||||||||||||||||||||||
9 | Child newChild = parent.addChild("new"); |
| 8 | Child newChild = parent.addChild("new2"); | |||||||||||||||||||||
10 | tx.commit(); | 9 | tx.commit(); | ||||||||||||||||||||||
11 | s.close(); | 10 | s.close(); | ||||||||||||||||||||||
12 | int index = 0; | 11 | int index = 0; | ||||||||||||||||||||||
13 | if (((PersistentCollection)parent.getChildren()).wasInitialized()) | 12 | if (((PersistentCollection)parent.getChildren()).wasInitialized()) | ||||||||||||||||||||||
14 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | 13 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | ||||||||||||||||||||||
15 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); | 14 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); | ||||||||||||||||||||||
16 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); | 15 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); | ||||||||||||||||||||||
17 | if (newChild instanceof ChildWithBidirectionalManyToMany) | 16 | if (newChild instanceof ChildWithBidirectionalManyToMany) | ||||||||||||||||||||||
18 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | 17 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | ||||||||||||||||||||||
19 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | 18 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | ||||||||||||||||||||||
20 | checkNumberOfResults(listeners, index); | 19 | checkNumberOfResults(listeners, index); |
Row | Violation |
---|---|
1 | Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression assertEquals(1,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized |
4 | Expression assertEquals(1,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized |
5 | Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression assertEquals(1,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized |
8 | Expression assertEquals(1,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized |
9 | Unmatched statement assertNotNull(parent.getChildren()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |