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 testUpdateParentNoneToOneChild()
|
Method name: void testUpdateParentOneToTwoChildren()
|
|||
Number of AST nodes: 19 | Number of AST nodes: 19 | |||
1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | 1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | |
2 | ParentWithCollection parent = createParentWithNoChildren( "parent" );↵ | 2 | ParentWithCollection parent = createParentWithOneChild( "parent"↵ | |
3 | listeners.clear();↵ | 3 | , "child" );↵ | |
4 | assertEquals( 0, parent.getChildren().size() );↵ | 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 | Child newChild = parent.addChild( "new" );↵ | 9 | Child newChild = parent.addChild( "new2" );↵ | |
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.4 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 148 |
Number of mapped statements | 19 |
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) | 7.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | 1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | ||||||||||||||
2 | ParentWithCollection parent = createParentWithNoChildren("parent"); |
| 2 | ParentWithCollection parent = createParentWithOneChild("parent", "child"); | |||||||||||||
3 | listeners.clear(); | 4 | listeners.clear(); | ||||||||||||||
4 | assertEquals(0, parent.getChildren().size()); |
| 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 | Child newChild = parent.addChild("new"); |
| 8 | Child newChild = parent.addChild("new2"); | |||||||||||||
9 | tx.commit(); | 9 | tx.commit(); | ||||||||||||||
10 | s.close(); | 10 | s.close(); | ||||||||||||||
11 | int index = 0; | 11 | int index = 0; | ||||||||||||||
12 | if (((PersistentCollection)parent.getChildren()).wasInitialized()) | 12 | if (((PersistentCollection)parent.getChildren()).wasInitialized()) | ||||||||||||||
13 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | 13 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | ||||||||||||||
14 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); | 14 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); | ||||||||||||||
15 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); | 15 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); | ||||||||||||||
16 | if (newChild instanceof ChildWithBidirectionalManyToMany) | 16 | if (newChild instanceof ChildWithBidirectionalManyToMany) | ||||||||||||||
17 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | 17 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | ||||||||||||||
18 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | 18 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | ||||||||||||||
19 | checkNumberOfResults(listeners, index); | 19 | checkNumberOfResults(listeners, index); |
Row | Violation |
---|