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 testSaveParentEmptyChildren()
|
Method name: void testDeleteParentWithNullChildren()
|
|||
Number of AST nodes: 15 | Number of AST nodes: 14 | |||
1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | 1 | CollectionListeners listeners = new CollectionListeners( getSessions() );↵ | |
2 | ParentWithCollection parent = createParentWithNoChildren( "parent" );↵ | 2 | ParentWithCollection parent = createParentWithNullChildren( "parent" );↵ | |
3 | assertEquals( 0, parent.getChildren().size() ↵ | 3 | listeners.clear();↵ | |
4 | Session s = openSession();↵ | |||
5 | Transaction tx = s.beginTransaction();↵ | |||
6 | parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );↵ | |||
7 | s.delete( parent );↵ | |||
8 | tx.commit();↵ | |||
4 | );↵ | 9 | s.close();↵ | |
5 | int index = 0;↵ | 10 | int index = 0;↵ | |
6 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );↵ | 11 | checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );↵ | |
7 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );↵ | 12 | checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, index++ );↵ | |
8 | checkNumberOfResults( listeners, index );↵ | 13 | checkResult( listeners, ↵ | |
9 | listeners.clear();↵ | |||
10 | Session s = openSession();↵ | |||
11 | Transaction tx = s.beginTransaction();↵ | |||
12 | parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );↵ | |||
13 | tx.commit();↵ | |||
14 | s.close();↵ | |||
15 | assertNotNull( parent.getChildren() );↵ | 14 | listeners.getPostCollectionRemoveListener(), parent, index++ );↵ | |
16 | checkNumberOfResults( listeners, 0 ); | 15 | checkNumberOfResults( listeners, index ); | |
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.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 139 |
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | 1 | CollectionListeners listeners = new CollectionListeners(getSessions()); | ||||||||||||||||||||||
2 | ParentWithCollection parent = createParentWithNoChildren("parent"); |
| 2 | ParentWithCollection parent = createParentWithNullChildren("parent"); | |||||||||||||||||||||
3 | assertEquals(0, parent.getChildren().size()); |
| | ||||||||||||||||||||||
4 | int index = 0; | 10 | int index = 0; | ||||||||||||||||||||||
5 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++); |
| 11 | checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++); | |||||||||||||||||||||
6 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++); |
| 12 | checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, index++); | |||||||||||||||||||||
7 | checkNumberOfResults(listeners, index); |
| 13 | checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, index++); | |||||||||||||||||||||
8 | listeners.clear(); | 3 | listeners.clear(); | ||||||||||||||||||||||
9 | Session s = openSession(); | 4 | Session s = openSession(); | ||||||||||||||||||||||
10 | Transaction tx = s.beginTransaction(); | 5 | Transaction tx = s.beginTransaction(); | ||||||||||||||||||||||
11 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | 6 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | ||||||||||||||||||||||
|
| 7 | s.delete(parent); | ||||||||||||||||||||||
12 | tx.commit(); | 8 | tx.commit(); | ||||||||||||||||||||||
13 | s.close(); | 9 | s.close(); | ||||||||||||||||||||||
14 | assertNotNull(parent.getChildren()); |
| | ||||||||||||||||||||||
15 | checkNumberOfResults(listeners, 0); |
| 14 | checkNumberOfResults(listeners, index); |
Row | Violation |
---|---|
1 | Unmatched statement assertEquals(0,parent.getChildren().size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Expression listeners.getPreCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression listeners.getInitializeCollectionListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression listeners.getPostCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression listeners.getPreCollectionRemoveListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized |
9 | Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized |
10 | Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized |
13 | Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized |
14 | Unmatched statement s.delete(parent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | 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 |
16 | Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted |