CollectionListeners listeners = new CollectionListeners( getSessions() ); ParentWithCollection parent = createParentWithNoChildren( "parent" ); assertEquals( 0, parent.getChildren().size() ); int index = 0; checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ ); checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ ); checkNumberOfResults( listeners, index ); listeners.clear(); Session s = openSession(); Transaction tx = s.beginTransaction(); parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() ); tx.commit(); s.close(); assertNotNull( parent.getChildren() ); checkNumberOfResults( listeners, 0 );
CollectionListeners listeners = new CollectionListeners( getSessions() ); ParentWithCollection parent = createParentWithNullChildren( "parent" ); assertNull( parent.getChildren() ); int index = 0; // pre- and post- collection recreate events should be created when creating an entity with a "null" collection checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ ); checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ ); checkNumberOfResults( listeners, index ); listeners.clear(); Session s = openSession(); Transaction tx = s.beginTransaction(); parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() ); tx.commit(); s.close(); assertNotNull( parent.getChildren() ); checkNumberOfResults( listeners, 0 );
Clone fragments detected by clone detection tool
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
		checkNumberOfResults( listeners, 0 );
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are in different classes having the same super class
Number of node comparisons151
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    CollectionListeners listeners = new CollectionListeners(getSessions());
    1
    CollectionListeners listeners = new CollectionListeners(getSessions());
    2
    ParentWithCollection parent = createParentWithNoChildren("parent");
    2
    ParentWithCollection parent = createParentWithNoChildren("parent");
    2
    ParentWithCollection parent = createParentWithNullChildren("parent");
    Differences
    Expression1Expression2Difference
    createParentWithNoChildrencreateParentWithNullChildrenMETHOD_INVOCATION_NAME_MISMATCH
    2
    ParentWithCollection parent = createParentWithNullChildren("parent");
    3
    assertEquals(0, parent.getChildren().size());
    3
    assertEquals(0, parent.getChildren().size());
    3
    assertNull(parent.getChildren());
    Differences
    Expression1Expression2Difference
    assertEqualsassertNullMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(0,parent.getChildren().size())assertNull(parent.getChildren())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized
    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);
    Precondition Violations (8)
    Row Violation
    1Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    4Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized
    5Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    8Expression assertNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized