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/BrokenCollectionEventTest.java | |||
Method name: void testUpdateParentNullToOneChild()
|
Method name: void testUpdateParentNoChildrenToNullFailureExpected()
|
|||
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 | Collection oldCollection = parent.getChildren();↵ | |
9 | Child newChild = parent.addChild( "new" );↵ | 9 | parent.newChildren( null );↵ | |
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 ) oldCollection ).wasInitialized() ) {↵ | |
14 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | 14 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++ );↵ | |
15 | }↵ | 15 | }↵ | |
16 | checkResult( listeners, listeners.getPreCollectionUpdateListener(), parent, index++ );↵ | 16 | checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++ );↵ | |
17 | checkResult( listeners, listeners.getPostCollectionUpdateListener(), parent, index++ );↵ | 17 | checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, ↵ | |
18 | if ( newChild instanceof ChildWithBidirectionalManyToMany ) {↵ | |||
19 | ↵ | 18 | oldCollection, index++ );↵ | |
19 | // pre- and post- collection recreate events should be created when updating an entity with a "null" collection↵ | |||
20 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | 20 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );↵ | |
21 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), ( ChildWithBidirectionalManyToMany ) newChild, index++ );↵ | 21 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, 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 | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 186 |
Number of mapped statements | 16 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 102.9 |
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 | Collection oldCollection = parent.getChildren(); | ||||||||||||||||||||||
|
| 9 | parent.newChildren(null); | ||||||||||||||||||||||
8 | assertNotNull(parent.getChildren()); |
| 15 | checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, oldCollection, index++); | |||||||||||||||||||||
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)oldCollection).wasInitialized()) | |||||||||||||||||||||
14 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); |
| 14 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, oldCollection, index++); | |||||||||||||||||||||
|
| 16 | checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, oldCollection, index++); | ||||||||||||||||||||||
15 | checkResult(listeners, listeners.getPreCollectionUpdateListener(), parent, index++); |
| 17 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++); | |||||||||||||||||||||
16 | checkResult(listeners, listeners.getPostCollectionUpdateListener(), parent, index++); |
| 18 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++); | |||||||||||||||||||||
17 | if (newChild instanceof ChildWithBidirectionalManyToMany) | | |||||||||||||||||||||||
18 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), (ChildWithBidirectionalManyToMany)newChild, index++); | | |||||||||||||||||||||||
19 | 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 Collection oldCollection=parent.getChildren(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Unmatched statement parent.newChildren(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
11 | Expression assertNotNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression checkResult(listeners,listeners.getPreCollectionRemoveListener(),parent,oldCollection,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression assertNotNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized |
14 | Expression checkResult(listeners,listeners.getPreCollectionRemoveListener(),parent,oldCollection,index++) is a void method call, and thus it cannot be parameterized |
15 | Expression assertNotNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression checkResult(listeners,listeners.getPreCollectionRemoveListener(),parent,oldCollection,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression assertNotNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized |
18 | Expression checkResult(listeners,listeners.getPreCollectionRemoveListener(),parent,oldCollection,index++) is a void method call, and thus it cannot be parameterized |
19 | Expression parent.getChildren() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression checkResult(listeners,listeners.getInitializeCollectionListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression checkResult(listeners,listeners.getInitializeCollectionListener(),parent,oldCollection,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression checkResult(listeners,listeners.getInitializeCollectionListener(),parent,index++) is a void method call, and thus it cannot be parameterized |
23 | Expression checkResult(listeners,listeners.getInitializeCollectionListener(),parent,oldCollection,index++) is a void method call, and thus it cannot be parameterized |
24 | Unmatched statement checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,oldCollection,index++); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Expression listeners.getPreCollectionUpdateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
26 | Expression listeners.getPreCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
27 | Expression listeners.getPostCollectionUpdateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
28 | Expression listeners.getPostCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
29 | Unmatched statement checkResult(listeners,listeners.getPostCollectionRecreateListener(),(ChildWithBidirectionalManyToMany)newChild,index++); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
30 | Clone fragment #1 returns variables parent, listeners, index , while Clone fragment #2 returns variables parent, listeners, index |