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 testUpdateParentNullToOneChildDiffCollection()
|
Method name: void testUpdateParentNoneToOneChildDiffCollection()
|
|||
Number of AST nodes: 23 | Number of AST nodes: 23 | |||
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 | Collection collectionOrig = parent.getChildren();↵ | 8 | Collection oldCollection = parent.getChildren();↵ | |
9 | parent.newChildren( createCollection() );↵ | 9 | parent.newChildren( createCollection() );↵ | |
10 | Child newChild = parent.addChild( "new" );↵ | 10 | Child newChild = parent.addChild( "new" );↵ | |
11 | tx.commit();↵ | 11 | tx.commit();↵ | |
12 | s.close();↵ | 12 | s.close();↵ | |
13 | int index = 0;↵ | 13 | int index = 0;↵ | |
14 | if ( ( ( PersistentCollection ) collectionOrig ).wasInitialized() ) {↵ | 14 | if ( ( ( PersistentCollection ) oldCollection ).wasInitialized() ) {↵ | |
15 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, collectionOrig, index++ );↵ | 15 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++ );↵ | |
16 | }↵ | 16 | }↵ | |
17 | checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, collectionOrig, index++ );↵ | 17 | checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );↵ | |
18 | checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, collectionOrig, index++ );↵ | 18 | checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, 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 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );↵ | 23 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );↵ | |
24 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );↵ | 24 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );↵ | |
25 | checkNumberOfResults( listeners, index ); | 25 |
| |
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.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 206 |
Number of mapped statements | 23 |
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) | 8.8 |
Clone type | Type 2 |
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 | Collection collectionOrig = parent.getChildren(); |
| 8 | Collection oldCollection = parent.getChildren(); | |||||||||||||||||||||
9 | parent.newChildren(createCollection()); | 9 | parent.newChildren(createCollection()); | ||||||||||||||||||||||
10 | Child newChild = parent.addChild("new"); | 10 | Child newChild = parent.addChild("new"); | ||||||||||||||||||||||
11 | tx.commit(); | 11 | tx.commit(); | ||||||||||||||||||||||
12 | s.close(); | 12 | s.close(); | ||||||||||||||||||||||
13 | int index = 0; | 13 | int index = 0; | ||||||||||||||||||||||
14 | if (((PersistentCollection)collectionOrig).wasInitialized()) |
| 14 | if (((PersistentCollection)oldCollection).wasInitialized()) | |||||||||||||||||||||
15 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, collectionOrig, index++); |
| 15 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++); | |||||||||||||||||||||
16 | checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, collectionOrig, index++); |
| 16 | checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++); | |||||||||||||||||||||
17 | checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, collectionOrig, index++); |
| 17 | checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, 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 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++); | 21 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++); | ||||||||||||||||||||||
22 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++); | 22 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++); | ||||||||||||||||||||||
23 | checkNumberOfResults(listeners, index); | 23 | 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 |