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 testUpdateParentNoneToOneChild()
|
|||
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 = createParentWithNoChildren( "parent" );↵ | |
3 | listeners.clear();↵ | 3 | listeners.clear();↵ | |
4 | assertNull( parent.getChildren() );↵ | 4 | assertEquals( 0, 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() );↵ | 8 | ↵ | |
9 | Child newChild = parent.addChild( "new" );↵ | 9 | Child newChild = parent.addChild( "new" );↵ | |
10 | tx.commit();↵ | 10 | tx.commit();↵ | |
11 | s.close();↵ | 11 | s.close();↵ | |
12 | int index = 0;↵ | 12 | int index = 0;↵ | |
13 | if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {↵ | 13 | if ( ( ( PersistentCollection ) parent.getChildren() ).wasInitialized() ) {↵ | |
14 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | 14 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | |
15 | }↵ | 15 | }↵ | |
16 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | 16 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | |
17 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | 17 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | |
18 | if ( newChild instanceof ChildWithBidirectionalManyToMany ) {↵ | 18 | if ( newChild instanceof ChildWithBidirectionalManyToMany ) {↵ | |
19 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | 19 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | |
20 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | 20 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | |
21 | }↵ | 21 | }↵ | |
22 | checkNumberOfResults( listeners, index ); | 22 |
| |
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) | 30.0 |
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 = createParentWithNoChildren("parent"); | |||||||||||||||||||||
3 | listeners.clear(); | 3 | listeners.clear(); | ||||||||||||||||||||||
4 | assertNull(parent.getChildren()); |
| 4 | assertEquals(0, 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("new"); | ||||||||||||||||||||||
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(0,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(0,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(0,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(0,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 |