Session s = openSession( new CollectionInterceptor() ); Transaction t = s.beginTransaction(); User u = new User("Gavin", "nivag"); s.persist(u); u.setPassword("vagni"); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "Gavin"); assertEquals( 2, u.getActions().size() ); s.delete(u); t.commit(); s.close();
Session s = openSession( new PropertyInterceptor() ); Transaction t = s.beginTransaction(); User u = new User("Gavin", "nivag"); s.persist(u); u.setPassword("vagni"); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); u = (User) s.get(User.class, "Gavin"); assertNotNull( u.getCreated() ); assertNotNull( u.getLastUpdated() ); s.delete(u); t.commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java
Method name: void testCollectionIntercept() Method name: void testPropertyIntercept()
Number of AST nodes: 14 Number of AST nodes: 15
1
Session s = openSession( new CollectionInterceptor() );
1
Session s = openSession( new PropertyInterceptor() );
2
		Transaction t = s.beginTransaction();
2
		Transaction t = s.beginTransaction();
3
		User u = new User("Gavin", "nivag");
3
		User u = new User("Gavin", "nivag");
4
		s.persist(u);
4
		s.persist(u);
5
		u.setPassword("vagni");
5
		u.setPassword("vagni");
6
		t.commit();
6
		t.commit();
7
		s.close();
7
		s.close();
8
		s = openSession();
8
		s = openSession();
9
		t = s.beginTransaction();
9
		t = s.beginTransaction();
10
		u = (User) s.get(User.class, "Gavin");
10
		u = (User) s.get(User.class, "Gavin");
11
		assertEquals( 2, u.getActions().size
11
		assertNotNull( u.getCreated() );
12
() );
12
		assertNotNull( u.getLastUpdated() );
13
		s.delete(u);
13
		s.delete(u);
14
		t.commit();
14
		t.commit();
15
		s.close();
15
		s.close();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones locationClones are declared in the same class
Number of node comparisons79
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession(new CollectionInterceptor());
    1
    Session s = openSession(new CollectionInterceptor());
    1
    Session s = openSession(new PropertyInterceptor());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.interceptor.CollectionInterceptororg.hibernate.test.interceptor.PropertyInterceptorSUBCLASS_TYPE_MISMATCH
    1
    Session s = openSession(new PropertyInterceptor());
    2
    Transaction t = s.beginTransaction();
    2
    Transaction t = s.beginTransaction();
    3
    User u = new User("Gavin", "nivag");
    3
    User u = new User("Gavin", "nivag");
    4
    s.persist(u);
    4
    s.persist(u);
    5
    u.setPassword("vagni");
    5
    u.setPassword("vagni");
    6
    t.commit();
    6
    t.commit();
    7
    s.close();
    7
    s.close();
    8
    s = openSession();
    8
    s = openSession();
    9
    t = s.beginTransaction();
    9
    t = s.beginTransaction();
    10
    u = (User)s.get(User.class, "Gavin");
    10
    u = (User)s.get(User.class, "Gavin");
    11
    assertEquals(2, u.getActions().size());
    11
    assertEquals(2, u.getActions().size());
    11
    assertNotNull(u.getCreated());
    Differences
    Expression1Expression2Difference
    assertEqualsassertNotNullMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(2,u.getActions().size())assertNotNull(u.getCreated())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    11
    assertNotNull(u.getCreated());
                                                                                
    12
    assertNotNull(u.getLastUpdated());
    Preondition Violations
    Unmatched statement assertNotNull(u.getLastUpdated()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    assertNotNull(u.getLastUpdated());
    12
    s.delete(u);
    13
    s.delete(u);
    13
    t.commit();
    14
    t.commit();
    14
    s.close();
    15
    s.close();
    Precondition Violations (9)
    Row Violation
    1Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    4Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    5Expression assertEquals(2,u.getActions().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertNotNull(u.getCreated()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertEquals(2,u.getActions().size()) is a void method call, and thus it cannot be parameterized
    8Expression assertNotNull(u.getCreated()) is a void method call, and thus it cannot be parameterized
    9Unmatched statement assertNotNull(u.getLastUpdated()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted