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 testSaveParentEmptyChildren()
|
Method name: void testSaveParentNullChildrenFailureExpected()
|
|||
Number of AST nodes: 15 | Number of AST nodes: 15 | |||
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 | assertNull( parent.getChildren() );↵ | |
4 | int index = 0;↵ | 4 | int index = 0;↵ | |
5 | ↵ | 5 | // pre- and post- collection recreate events should be created when creating an entity with a "null" collection↵ | |
6 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );↵ | 6 | checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );↵ | |
7 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );↵ | 7 | checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );↵ | |
8 | checkNumberOfResults( listeners, index );↵ | 8 | checkNumberOfResults( listeners, index );↵ | |
9 | listeners.clear();↵ | 9 | listeners.clear();↵ | |
10 | Session s = openSession();↵ | 10 | Session s = openSession();↵ | |
11 | Transaction tx = s.beginTransaction();↵ | 11 | Transaction tx = s.beginTransaction();↵ | |
12 | parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );↵ | 12 | parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );↵ | |
13 | tx.commit();↵ | 13 | tx.commit();↵ | |
14 | s.close();↵ | 14 | s.close();↵ | |
15 | assertNotNull( parent.getChildren() );↵ | 15 | assertNotNull( parent.getChildren() );↵ | |
16 | checkNumberOfResults( listeners, 0 ); | 16 |
| |
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.0 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 151 |
Number of mapped statements | 15 |
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) | 0.0 |
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 = createParentWithNullChildren("parent"); | |||||||||||||||||||||
3 | assertEquals(0, parent.getChildren().size()); |
| 3 | assertNull(parent.getChildren()); | |||||||||||||||||||||
4 | int index = 0; | 4 | int index = 0; | ||||||||||||||||||||||
5 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++); | 5 | checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++); | ||||||||||||||||||||||
6 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++); | 6 | checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++); | ||||||||||||||||||||||
7 | checkNumberOfResults(listeners, index); | 7 | checkNumberOfResults(listeners, index); | ||||||||||||||||||||||
8 | listeners.clear(); | 8 | listeners.clear(); | ||||||||||||||||||||||
9 | Session s = openSession(); | 9 | Session s = openSession(); | ||||||||||||||||||||||
10 | Transaction tx = s.beginTransaction(); | 10 | Transaction tx = s.beginTransaction(); | ||||||||||||||||||||||
11 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | 11 | parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId()); | ||||||||||||||||||||||
12 | tx.commit(); | 12 | tx.commit(); | ||||||||||||||||||||||
13 | s.close(); | 13 | s.close(); | ||||||||||||||||||||||
14 | assertNotNull(parent.getChildren()); | 14 | assertNotNull(parent.getChildren()); | ||||||||||||||||||||||
15 | checkNumberOfResults(listeners, 0); | 15 | checkNumberOfResults(listeners, 0); |
Row | Violation |
---|---|
1 | Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized |
4 | Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized |
5 | Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized |
8 | Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized |